31 #include <gtest/gtest.h> 39 #if defined(__linux__) 69 TEST(MotorSerialNoFixtureTests, badPortnameException) {
82 uint8_t
test[] = {0x7E, 0x3B, 0x07, 0x00, 0x00, 0x01, 0x2C, 0x90};
97 uint8_t
test[] = {0x00, 0x7E, 0x3B, 0x07, 0x00, 0x00, 0x01, 0x2C, 0x90};
112 uint8_t
test[] = {0x01, 0x2C, 0x0E, 0x7E, 0x3B, 0x07,
113 0x00, 0x00, 0x01, 0x2C, 0x90};
115 ASSERT_NE(-1, write(
master_fd, test, 11));
128 uint8_t
test[] = {0x7E, 0x3D, 0x07, 0x00, 0x00, 0x00, 0x00, 0xBB};
130 ASSERT_NE(-1, write(
master_fd, test, 8));
141 uint8_t
test[] = {0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
143 ASSERT_NE(-1, write(
master_fd, test, 9));
163 uint8_t
test[] = {0x00, 0x7d, 0x3B, 0x07, 0x00, 0x00, 0x01, 0x2C, 0x90};
165 ASSERT_NE(-1, write(
master_fd, test, 9));
185 uint8_t
test[] = {0x7E, 0x3B, 0x00};
187 ASSERT_NE(-1, write(
master_fd, test, 3));
207 uint8_t
test[] = {0x0f, 0x7E, 0x3B, 0x00};
209 ASSERT_NE(-1, write(
master_fd, test, 4));
229 uint8_t
test[] = {0x7E, 0xFB, 0x07, 0x00, 0x00, 0x00, 0x00, 0xFB};
231 ASSERT_NE(-1, write(
master_fd, test, 8));
251 uint8_t
test[] = {0x7E, 0x2E, 0x07, 0x00, 0x00, 0x00, 0x00, 0xCA};
253 ASSERT_NE(-1, write(
master_fd, test, 8));
286 EXPECT_EQ(input.size(), read(
master_fd, input.c_array(), input.size()));
292 std::vector<MotorMessage> commands;
298 commands.push_back(left_odom);
304 commands.push_back(right_odom);
310 commands.push_back(left_vel);
316 commands.push_back(right_vel);
323 struct timeval timeout = { 10, 0 };
330 int ret = select(
master_fd+1, &fds, NULL, NULL, &timeout);
338 EXPECT_EQ(avail, read(
master_fd, arr+count, avail));
342 ASSERT_EQ(32, count);
344 std::vector<uint8_t> input(arr, arr +
sizeof(arr) /
sizeof(uint8_t));
346 std::vector<uint8_t> expected(0);
347 for (std::vector<MotorMessage>::iterator i = commands.begin();
348 i != commands.end(); ++i) {
350 expected.insert(expected.end(), serialized.begin(), serialized.end());
353 ASSERT_EQ(expected, input);
356 int main(
int argc,
char **argv) {
357 testing::InitGoogleTest(&argc, argv);
358 return RUN_ALL_TESTS();
MotorMessage::MessageTypes getType() const
int main(int argc, char **argv)
void setData(int32_t data)
int transmitCommand(MotorMessage command)
MotorMessage::Registers getRegister() const
boost::array< uint8_t, 8 > RawMotorMessage
int transmitCommands(const std::vector< MotorMessage > &commands)
TEST(MotorSerialNoFixtureTests, badPortnameException)
RawMotorMessage serialize() const
boost::thread serial_thread
void setRegister(MotorMessage::Registers reg)
void setType(MotorMessage::MessageTypes type)
MotorMessage receiveCommand()
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
TEST_F(MotorSerialTests, serialClosedOnInterupt)