Hardware Reference
In-Depth Information
170 main(int argc,char
argv) {
∗∗
171 char buf[1024];
172 int rc;
173 pthread_t tid;
174
175 if ( argc > 1 )
176 host_name = argv[1];
177 sprintf(service_sensor_pub,"tcp://%s:9999",host_name);
178 sprintf(service_sensor_pull,"tcp://%s:9998",host_name);
179
180 mutex_init();
181 context = zmq_ctx_new();
182 assert(context);
183
184 subscriber = zmq_socket(context,ZMQ_SUB);
185 assert(subscriber);
186
187 rc = zmq_connect(subscriber,service_sensor_pub);
188 if (rc == −1) perror("zmq_connect\n");
189 assert(rc!=−1);
190
191 rc = zmq_setsockopt(subscriber,ZMQ_SUBSCRIBE,"sw1:", 4);
192 assert(rc!=−1);
193 rc = zmq_setsockopt(subscriber,ZMQ_SUBSCRIBE,"led:", 4);
194 assert(rc!=−1);
195 rc = zmq_setsockopt(subscriber,ZMQ_SUBSCRIBE, "off:",4);
196 assert(rc!=−1);
197
198 console = zmq_socket(context,ZMQ_PUSH);
199 assert(console);
200
201 rc = zmq_connect(console, service_sensor_pull);
202 assert(!rc);
203
204 initscr();
205 cbreak();
206 noecho();
207 nonl();
208
209 clear();
210 box(stdscr,0,0);
211 move(1,2);
212 printw("Receiving sensor at: %s",service_sensor_pub);
213
214 attrset(A_UNDERLINE);
215 mvaddstr(7,2,"Commands:");
216 attrset(A_NORMAL);
Search WWH ::




Custom Search