You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
601 B
C++
35 lines
601 B
C++
#include "p_serial_bus.h"
|
|
#include <iostream>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <zmq.hpp>
|
|
|
|
#define SERIAL_DEV ("/dev/ttyAMA1")
|
|
#define ZMQ_IPC_ADDR ("ipc:///penguinator/pubsub")
|
|
|
|
void sigint_handler(int param)
|
|
{
|
|
std::cout << "Exiting..." << std::endl;
|
|
exit(1);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
signal(SIGINT, sigint_handler);
|
|
ps_bus sbus(SERIAL_DEV);
|
|
zmq::context_t ctx;
|
|
zmq::socket_t sub(ctx, ZMQ_SUB);
|
|
sub.connect(ZMQ_IPC_ADDR);
|
|
sub.setsockopt(ZMQ_SUBSCRIBE, "", 0);
|
|
|
|
for (;;)
|
|
{
|
|
zmq::message_t msg;
|
|
sub.recv(&msg, 0);
|
|
std::cout << msg << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|