Close

Working on the Logging Program

A project log for Geiger Counter

A simple Geiger counter with serial output and local display.

bharbourBharbour 10/06/2019 at 00:010 Comments

The primary intent of this counter is to sit in the corner and collect data for a long time. The approach that I am taking to that, is to use a very simple fixed format, space delimited protocol coming out of the serial port on the counter, and log the resulting data on a Linux box, where storage is cheap.

A logging program will capture the data from the serial port and store it to the disk, in files containing 24 hours of data each. Data is stored on 1 minute intervals, along with a time stamp from the counter's RTC. After each file is closed at midninght, it gets gzipped to reduce storage requirements. The disk files use Comma Separated Variable format because it is really easy to parse for post processing or just read into a spreadsheet program. A log file of text and debuggish information is also stored and compressed nightly.

Just after midnight, the counter RTC is checked against the host PC RTC which is GPS disciplined. If the counter RTC skews more than a few seconds from the PC clock, it will be corrected.

The logging program is going to be started from the init process when Linux boots. A consequence of this is that the program starts with root permissions, which is not a good plan for a secure system. Getting the process permissions and such to be reasonably secure in this situation has been pretty much of a slog. The last time I wrote "daemon code" was back in engineering school, a long time ago. Current Linux is not that different conceptually from the DEC Ultrix that we used for the systems programming classes in 1988, but enough time has passed and details have changed to require a lot of reading. My favorite reference book on Linux system programming is "The Linux Programming Interface" by Michael Kerrisk. It is an EXCELLENT reference book, well written with good explanations and good example code.

At this point, I have one more corner case to handle in the process ownership / configuration code. Once this is done, it is time to move on to another project.

Discussions