Hardware Reference
In-Depth Information
217 mvaddstr(9,2,"0 − Turn remote LED off.");
218 mvaddstr(10,2,"1 − Turn remote LED on.");
219 mvaddstr(11,2,"X − Shutdown sensor node.");
220 mvaddstr(12,2,"Q − Quit the console.");
221 mvprintw(7,15,"Online ?");
222
223 rc = pthread_create(&tid,0,command_center,0);
224 assert(!rc);
225
226 for(;;) {
227 rc = zmq_recv(subscriber,buf,sizeof buf − 1,0);
228 assert(rc >= 0 && rc < sizeof buf −1);
229 buf[rc] = 0;
230
231 if ( !strncmp(buf,"off:",4) )
232 post_offline();
233
234 if ( !strncmp(buf,"sw1:",4) ) {
235 sscanf(buf,"sw1:%d",&SW1);
236 post_SW1();
237 }
238
239 if ( !strncmp(buf,"led:",4) ) {
240 sscanf(buf,"led:%d",&LED);
241 post_LED();
242 }
243 }
244
245 return 0;
246 }
247
248 /
console.c
/
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
Mutex . c
3
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
4
5 static pthread_mutex_t mutex;
6
7 static void
8 mutex_init(void) {
9 int rc = pthread_mutex_init(&mutex, 0);
10 assert(!rc);
11 }
12
 
Search WWH ::




Custom Search