31 #include <boost/algorithm/string.hpp> 34 #include "nmea_msgs/Sentence.h" 39 static int consecutive_errors = 0;
42 int buffer_length = snprintf(buffer, 256,
"%s\r\n", sentence_msg_ptr->sentence.c_str());
47 const char* buffer_write = buffer;
48 struct pollfd pollfds[] = { { fd, POLLOUT, 0 } };
51 int retval = poll(pollfds, 1, 1000);
53 if (pollfds[0].revents & POLLHUP)
55 ROS_INFO(
"Device hangup occurred on attempted write.");
60 if (pollfds[0].revents & POLLERR)
62 ROS_FATAL(
"Killing node due to device error.");
66 retval = write(fd, buffer_write, buffer_length - (buffer_write - buffer));
69 buffer_write += retval;
73 ROS_WARN(
"Device write error; abandoning message (%s).",
74 sentence_msg_ptr->sentence.c_str());
75 if (++consecutive_errors >= 10)
77 ROS_FATAL(
"Killing node due to %d consecutive write errors.", consecutive_errors);
82 if (buffer_write - buffer >= buffer_length)
84 consecutive_errors = 0;
void tx_msg_callback(const nmea_msgs::SentenceConstPtr sentence_msg_ptr, int fd)
ROSCPP_DECL void shutdown()