Hardware Reference
In-Depth Information
You'll need the ncurses development library installed, in addition to ØMQ:
# apt-get install libncurses5-dev
To run the console program, simply launch it with the optional hostname as the first
command-line argument (the default is localhost ):
$ ./console 192.145.200.14 # Raspberry Pi by IP no.
Mac users will use the following:
$ ./mac_console myrasp # Raspberry Pi by hostname
Figure 8-4 shows the appearance of the console when it first starts up. The ???
show that the console does not yet know the status of the switch or LED. Beside the
command-line input, it also shows Online? , indicating that it does not yet know whether
the sensor is online. As soon as one message is received, that changes to ONLINE .
Figure 8-4. Console at startup
Console Commands
The console commands are all single-character commands and are displayed on the
screen. Typing 0 turns off the LED on the sensor, and typing 1 turns it on. Typing q or Q
quits the console.
Typing x or X terminates the sensor program. (It would not be good to have this
option on a real jail cell control).
Sensor Source Code
Every attempt was made to keep these listings short. But despite these attempts, the
code is a bit “winded” for this simple-minded task. The important thing here is the basic
concept and how to leverage it in your own more sophisticated designs.
 
Search WWH ::




Custom Search