As of today, most of the code has been written and tested on Freya with a mostly functional big PIC! Error handling and notification was first, and so far mostly involves try-except statements everywhere. There are three levels of email alerts and logging (debug, info, error) which can be configured easily. The actual sending of emails works like a charm; each cycle’s worth of error messages are saved and sent as a digest. This system is satisfactorily robust to power loss and internet loss. Commands work in a similar way: they are queued for a cycle and then sent all at once. This logic is written and partially tested.
Setup code is also written: it initializes and configures logging, connects to the serial port, and initializes various files. Eventually it ought also to do things like confirm correct time, reset toggles, and so on. More excitingly, the main scheduled loop is written and running successfully. Over the course of 20 seconds, it calls functions that do the relevant things. The schedule right now is:
- Write a Q to the PIC, wait 2s.
- Send pending emails, wait 8s.
- Write an S to the PIC, wait 1s.
- Read/process/save data, wait 5s.
- Send all pending commands, wait 4s.
Other things now written but in need of more testing: logic to format 2Unix data (I ended up using string.Template), logic to read data, and logic to pass data to the objects that will handle it. The code right now also wants organization and comments, which I’ll get to tomorrow.
On the hardware side, the next challenge may be mounting the backup USB. pmount is uncooperative on Vor, and regular old mount require root privileges. I’ll have to run some tests (ie on boot do previously mounted devices stay mounted?) to see if anything more than a manual mount is necessary. The current board requires manual mount, and there’s probably not much the program could do about some failure causing the drive to unmount…
The list of features to be added:
- Daily actions, including:
- resetting error flags
- checking space and RAM usage
- Configuring toggle files for 2Unix and end script
- Configuring saving of data
- Ending at the appropriate point in a cycle if remotely turned off
- Startup bash script
- Some unified way of range-checking and responding to data (to be implemented in ConvertData.py)
— Soren