Hardware Reference
In-Depth Information
295
led:n change state of LED
296
stop: shutdown the sensor
297
/
298 for (;;) {
299 rc = zmq_recv(console,buf,sizeof buf −1,0);
300 if ( rc > 0 ) {
301 buf[rc] = 0;
302 if ( !strncmp(buf,"led:",4) ) {
303 /
LED command from console
/
304 buf[rc] = 0;
305 sscanf(buf,"led:%d",&LED);
306 gpio_write(fd_LED,LED);
307 publish_LED();
308 }
309 if ( !strncmp(buf,"stop:",5) ) {
310 stop = 1;
311 break;
312 }
313 }
314 }
315
316 mutex_lock();
317 zmq_close(console);
318 console = 0;
319
320 rc = zmq_send(publisher,"off: " 4,0);
321 assert(rc !=−1);
322 sleep(3);
323 zmq_close(publisher);
324 publisher = 0;
325
326 gpio_close(gp_SW1);
327 gpio_close(gp_LED);
328 mutex_unlock();
329
330 return 0;
331 }
332
333 /
End sensor.c
/
Console Source Code
The console program is an ncurses-based program. It provides the user with a full-screen
display without the complexity of programming a GUI program (an exercise left to the
interested reader).
 
Search WWH ::




Custom Search