Hardware Reference
In-Depth Information
249 mutex_init();
250
251 /
/
252 fd_LED = gpio_open_output(gp_LED);
253 if ( fd_LED < 0 ) {
254 printf("%s : Opening GPIO %d for output.\n",
255 strerror (errno),gp_LED);
256 return 1;
257 }
258
259 /
Open GPIO for LED
/
260 fd_SW1 = gpio_open_edge(22,"both"); /
Open GPIO for SW1
GPIO input
/
261 if ( fd_SW1 < 0 ) {
262 printf("%s: Opening GPIO %d for input.\n",
263 strerror(errno),gp_SW1);
264 return 1;
265 }
266
267 context = zmq_ctx_new();
268 assert(context);
269
270 /
/
271 publisher = zmq_socket(context,ZMQ_PUB);
272 assert(publisher);
273 rc = zmq_bind(publisher,service_sensor_pub);
274 assert(!rc);
275
276 /
Create a ZMQ publishing socket
/
277 console = zmq_socket(context, ZMQ_PULL);
278 assert(console);
279 rc = zmq_bind(console,service_sensor_pull);
280 assert(rc != −1);
281
282 SW1 = 0;
283 publish_SW1();
284 publish_LED();
285
286 rc = pthread_create(&tid,0,SW1_monitor_thread,0);
287 assert(!rc);
288
289 rc = pthread_create(&tid,0,console_thread,0);
290 assert(!rc);
291
292 /
Create a console PULL socket
293
In this thread, we "pull" console commands :
294
Search WWH ::




Custom Search