26 #include <sys/socket.h> 27 #include <netinet/in.h> 28 #include <netinet/tcp.h> 29 #include <gtest/gtest.h> 32 #include "nmea_msgs/Sentence.h" 52 tx = n->
advertise<nmea_msgs::Sentence>(
"nmea_sentence_out", 5);
58 *sockfd = socket(AF_INET, SOCK_STREAM, 0);
60 struct sockaddr_in serv_addr;
61 memset(&serv_addr,
'0',
sizeof(serv_addr));
62 serv_addr.sin_addr.s_addr = 0x0100007F;
63 serv_addr.sin_family = AF_INET;
64 serv_addr.sin_port = htons(29500);
66 ASSERT_EQ(0, ::
connect(*sockfd, (
struct sockaddr *)&serv_addr,
sizeof(serv_addr)));
97 EXPECT_EQ(len, write(dev, buffer, len));
112 const int num_devs = 5;
113 const int msgs_per_dev = 10;
114 int devs[num_devs], i;
116 for (i = 0; i < num_devs; i++) {
123 for (
int m = 0; m < msgs_per_dev; m++) {
124 for (i = 0; i < num_devs; i++) {
126 int len = sprintf(buffer,
"$MSG,blah,%d,%d*00%s", i, m,
"\r\n");
127 ROS_INFO(
"Sending msg #%d on dev #%d: [%s]", m, i, buffer);
128 EXPECT_EQ(len, write(devs[i], buffer, len));
142 for (i = 0; i < num_devs; i++) {
156 nmea_msgs::Sentence msg;
170 int main(
int argc,
char **argv)
172 testing::InitGoogleTest(&argc, argv);
175 return RUN_ALL_TESTS();
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
boost::shared_ptr< nmea_msgs::Sentence const > last_received
const char * mock_sentence
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void _rx_callback(const nmea_msgs::SentenceConstPtr &msg)
void disconnect(int *sockfd)
TEST_F(NMEASocketTest, basic_rx_test)
int main(int argc, char **argv)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void connect(int *sockfd)
#define ROS_INFO_STREAM(args)
ROSCPP_DECL void spinOnce()