4 #include <gtest/gtest.h> 18 ASSERT_NE(-1,
master_fd = posix_openpt( O_RDWR | O_NOCTTY | O_NDELAY ));
24 ASSERT_TRUE(
ser.
isOpen()) <<
"Couldn't open Serial connection to pseudoterminal.";
29 write(
master_fd, msg.c_str(), msg.length());
75 msg[msg.length() - 1]++;
80 EXPECT_EQ(-1, sensor.
receive(®isters)) <<
"Didn't properly ignore bad checksum message.";
87 msg =
"ssssssnsnsns" + msg;
96 std::string msg(
"snp\x12\x45");
99 EXPECT_EQ(-1, sensor.
receive(NULL)) <<
"Didn't properly time out in the face of a partial message.";
102 int main(
int argc,
char **argv)
104 testing::InitGoogleTest(&argc, argv);
105 return RUN_ALL_TESTS();
void write_serial(const std::string &msg)
Provides the Registers class, which initializes with a suite of accessors suitable for reading and wr...
const Accessor< int16_t > accel_raw
static std::string message(uint8_t address, std::string data)
const Accessor< int16_t > mag_raw
TEST_F(FakeSerial, basic_message_rx)
int16_t receive(Registers *r)
void setPort(const std::string &port)
Comms class definition. Does not manage the serial connection itself, but takes care of reading and w...
int main(int argc, char **argv)
RegT get(uint8_t field) const
#define UM6_COMMUNICATION