20 #include <boost/crc.hpp> 21 #include <boost/cstdint.hpp> 22 #include <boost/integer.hpp> 36 const char init_data[] = { 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd };
37 int init_len =
sizeof(init_data) /
sizeof(init_data[0]);
38 const char startup_data[] = { 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
39 int startup_len =
sizeof(startup_data) /
sizeof(startup_data[0]);
50 }
while(bytes_recv <= 0);
52 unsigned short int crc =
getChecksum(startup_data, startup_len);
54 memcpy(&init_buf, init_data, init_len);
55 memcpy(&init_buf[init_len], startup_data, startup_len);
56 init_buf[init_len+startup_len] = ((
char*)&crc)[1];
57 init_buf[init_len+startup_len+1] = ((
char*)&crc)[0];
66 boost::crc_16_type checksum_agent;
67 checksum_agent.process_bytes(data, len);
68 return checksum_agent.checksum();
78 ROS_WARN(
"Can not write to serial port. Port closed!");
80 ROS_DEBUG(
"Wrote [%s] with %i bytes from %lu bytes", data, bytes_wrote, len);
101 color.
r = fabs(color.
r * 255);
102 color.
g = fabs(color.
g * 255);
103 color.
b = fabs(color.
b * 255);
110 buffer[7] = ((
char*)&crc)[1];
111 buffer[8] = ((
char*)&crc)[0];
116 ROS_ERROR(
"Could not write to serial port");
void setColor(color::rgba color)
char buffer[PACKAGE_SIZE]
unsigned short int getChecksum(const char *data, size_t len)
static const int PACKAGE_SIZE
void setColorMulti(std::vector< color::rgba > &colors)
int sendData(std::string value)
boost::signals2::signal< void(color::rgba color)> m_sigColorSet
int sendData(const char *data, size_t len)
int readData(std::string &value, size_t nBytes)