Python, Linux, and Lionel trains
Controlling a miniature train empire with concurrent Linux processes.
Two hobbies are prevalent in my house: Lionel trains and Linux computers. The train layout isn’t a permanent fixture; it gets set up a couple of times a year – usually around Christmas – but it’s been known to appear during the summer as well. The last time it appeared, I added a Linux computer to control the setup. Although I still run the trains with traditional throttles, I let the computer play with the rest.
Rather than write one massive control program, I decided to split the design into single-purpose modules that run independently (Figure 1). Each module performs a single task in either the input, output, or control categories. Any given input or output module corresponds directly to a specific piece of hardware. Control modules don’t have hardware equivalents but instead provide the logic that links the inputs and outputs. Any number of modules can be run simultaneously.
The modules are written in Python and use mmap to communicate among themselves. The files inputs.txt, which represents the current state of the railroad’s sensors, and outputs.txt, which has the requested state for the relays or LEDs that activate working accessories, are memory-mapped files. They are both initialized to a single line of 100 zeros.
Buy this article as PDF
Carnegie Mellon researchers say 3 million pages could fall down the phishing hole in the next year.
The US government rolls new best-practice rules for protecting SSH.
Klaus Knopper announces the latest version of his iconic Live Linux system.
All websites that use these popular CMS tools could be vulnerable to denial of service attacks if users don't install the updates.
According to a report, many potential victims of the Heartbleed attack have patched their systems, but few have cleaned up the crime scene to protect themselves from the effects of a previous intrusion.
DARPA and NICTA release the code for the ultra-secure microkernel system used in aerial drones.
Should you trust an online service to store your online passwords?
New B+ board lets you build cool things without the complication of a powered USB hub.
Redmond rushes in to root out alleged malware haven.
New initiative will bring futuristic virtual reality effects to the web surfing experience.