Skyla-read

Description

The Skyla VB1 blood-analysis machine has two modes of communication: Skyla and ASTM. It's hard to find a good description of the ASTM protocol. It's also hard to find software supporting ASTM (your best bet is probably to use Github search and then download, install and then try these programs one by one). Fortunately, I did manage to find a brief description of the Skyla protocol;
The device sends a SOH and then expects an ACK. After receiving an ACK, it sends name - value pairs terminated by CrLfs. When it's done it sends an EOT and then expects an other ACK;

Protocol

Skyla PC
SOH->
<-ACK
Data->
EOT->
<-ACK

Controls

ASCIIDescriptionCntrlValue
SOHStart Of Heading^A1
EOTEnd Of Transmission^D4
ACKAcknowledge^F6

Software

The device only uses TDX, RXD and GND, so there is no use in using modem control lines or RTS - CTS flow control. The device might support XON - XOFF, but there is no indication that it does.
I wrote some serial port software before, so I just modified what I had to retrieve data from the device;
On reception of a SOH, the software generates a filename containing date and time. The '-n' option can be used to set the filename prefix. Without the prefix the TTY name is used. The time is followed by milliseconds and the filename has the '.txt' extension: Prefix-YYYYMMDD-hhmmss-ms.txt, E.G.: ttyS1-20210714-132727-123.txt. The file is closed on the reception of an EOT.
The files are saved in a directory set with the '-p' option. If it can't open files in this dir and an alternative destination directory is set with the '-a' option, it will save in this directory instead. When this happens, it will send an email to the address set with the '-m' option, provided this option is set.
CrLf pairs are converted to Lfs and trailing white-space is removed.
With the '-s' option, name - value pairs defined in 'skyskip.h' and the date - time send by the device are not saved to file.
Note: You may want to modify 'skyskip.h' to suit your needs!
The program saves a Pid file in the directory set with '-r'. The program can be killed with a SIGTERM; kill -TERM `cat Pid_File`.
'-l' enables logging and sets the log-file name and directory.

Options

Options

Download and install

Source: skyla.tar.gz
Extract with: tar xvfz skyla.tar.gz
Compile with: cc -O2 -Wall -o skyla-read skyla-read.c
Copy skyla-read to /usr/local/bin/
Copy man page to /usr/local/share/man/man1/
gzip man page: gzip skyla-read.1

Systemd

Starting the program from systemd may lead to the program running at 100% CPU. This is caused by systemd closing stdin.
Using the '-i' option (ignore stdin) (new in 2021-07-26) fixes this.

Version

Version: 2021-07-26 19:40:12 GMT
The previous version from 2021-07-16 produced warnings on newer compilers. This was fixed in 2021-07-18.