Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is my read event callback called by libevent
- static void cmd_read(int fd, short evtype, void *arg) {
- if (!(evtype & EV_READ)) {
- log(LOG_ERR, "Unknown event type in read callback: 0x%hx", evtype);
- return;
- }
- char buf[16] = { 0 };
- //This method does a standard read until a \n is found which is my
- //end of the message from the arduino
- serialport_read_until(fd, buf, '\n');
- //The message must start with 'XA' characters
- if (buf[0] != 'X' && buf[1] != 'A')
- return;
- //TODO parse the command and data here
- //Print the entire message to the screen
- log(LOG_INFO, "Str: %s", buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement