legge info da squeow
Find a file
2023-07-02 17:22:15 +02:00
.gitignore readme 2023-07-02 17:04:16 +02:00
decoder.py initial commit 2023-07-01 14:23:33 +02:00
read.py importante cambio di nome 2023-07-02 17:05:15 +02:00
README.md link to squeow 2023-07-02 17:22:15 +02:00
webserver.py monitoring howto 2023-07-02 17:20:40 +02:00

About

Receive monitoring data from a squeow AM transmitter.

read.py will (using decoder.py) connect to a serial port, print values to stdout, and send values to a webserver

webserver.py is such a webserver. It provides an authenticated API for receiving values (most likely by read.py) and an unauthenticated API to get values.

Howto

Dependencies

apt install python3-fastapi python3-serial python3-requests

Run

./read.py -v --baudrate 115200 --wait --device /dev/pts/17 --http-endpoint http://127.0.0.1:8000 --http-auth-file password.txt
uvicorn webserver:app

Serial protocol

Goals

receive-only

if you only want to receive data, you shouldn't need to ask for data. This makes it possible to connect a serial port to multiple receivers!

machine and human-readable

this software will parse messages, but even if you don't have it around, you should be able to read messages just opening minicom.

High level description

Messages are started by the 0x01 ascii character (SOH start of heading) and ended by 0x0A ("\n", NL, new line). A messages needs to be entirely ascii.

There are two types of messages:

  • log messages
  • dump messages

Dump messages

Example: DMP freq=1234567 temp1=78 temp2=50 alm_temp=0 ros=4095 alm_ros=1

DMP is just a prefix to indicate the kind of message. Follows a space-separated sequence of key-values. A value is any string (including numbers, but no spaces). Please only use lowercase letters, numbers, and underscore ([a-z0-9_]). Values can only be integral positive numbers. Booleans don't have any specific form of support.

It is allowed to send dump messages which only inform the receiver about a part of the state, and not all of it. It's the receiver's responsibility to keep track of the whole state, and updating it whenever a new dump message arrives.

Log messages

Examples :

LOG I starting
LOG E overcurrent protection

LOG is just a prefix. Then a space Then a single capital letter indicating the severity of the message. Then a space. Whatever follows is the actual message

This makes it possible for debug messages to be sent.

Monitoring

None of the software provided will include monitoring functionalities. However, it will be easy to integrate with an existing monitoring service:

Nagios

This check will verify whether the alarm for temp1 is off

/usr/lib/nagios/plugins/check_http --regex '^0$' -I 127.0.0.1 -p 8000 --url=/variables/alm_temp1

Prometheus

a /metrics endpoint is exposed with the common metric=value format, which is easily to integrate into your prometheus instance.