15 #include "../../include/kobuki_driver/packet_handler/packet_finder.hpp" 28 state(waitingForStx), verbose(false)
39 unsigned int sizeMaxPayload,
unsigned int sizeChecksumField,
bool variableSizePayload)
53 sig_warn.connect(sigslots_namespace + std::string(
"/ros_warn"));
54 sig_error.connect(sigslots_namespace + std::string(
"/ros_error"));
105 printf(
"[state(%d):%02d]",
state, num);
120 bufferRef.push_back(
buffer[i]);
135 if (!(numberOfIncoming > 0))
138 bool found_packet(
false);
194 if ( found_packet ) {
206 bool found_stx(
true);
212 for (
unsigned int i = 0; i <
buffer.size() && i <
STX.size(); i++)
222 return (found_stx &&
buffer.size() ==
STX.size());
228 unsigned char first_byte;
229 for (
unsigned int i = 0; i < numberOfIncoming; i++) {
230 first_byte = incoming[i];
231 buffer.push_back(incoming[i]);
236 for (
unsigned int i = 0; i <
buffer.size(); i++)
237 printf(
"%02x ",
buffer[i]);
281 buffer.push_back(incoming);
291 unsigned int number_of_match(0);
292 for (
unsigned int i = 0; i <
ETX.size(); i++)
300 if (number_of_match ==
ETX.size())
316 for (
unsigned int i = 0; i < numberOfIncoming; i++)
318 buffer.push_back(incoming[i]);
325 std::ostringstream ostream;
328 ostream << std::setfill(
'0') << std::uppercase;
340 ostream <<
", buffer: [" << std::setw(2) <<
buffer.size() <<
"][";
341 for (
unsigned int i = 0; i <
buffer.size(); ++i ) {
342 ostream << std::setw(2) << std::hex << static_cast<int>(
buffer[i]) <<
" " << std::dec;
357 std::cout <<
"Start check etx " << std::endl;
358 for (
unsigned int i = 0; i < numberOfIncoming; ++i ) {
359 std::cout << std::hex << static_cast<int>(*(incoming+i)) <<
" ";
361 std::cout << std::dec << std::endl;
374 std::cout <<
"End of checking etx " << std::endl;
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
ecl::Signal< const std::string & > sig_error
ecl::PushAndPop< unsigned char > BufferType
unsigned int size_max_payload
void getBuffer(BufferType &bufferRef)
bool waitForPayloadAndEtx(const unsigned char *incoming, unsigned int numberOfIncoming, bool &foundPacket)
bool waitForEtx(const unsigned char incoming, bool &foundPacket)
bool waitForPayloadSize(const unsigned char *incoming, unsigned int numberOfIncoming)
ecl::Signal< const std::string & > sig_warn
unsigned int size_checksum_field
unsigned int numberOfDataToRead()
unsigned int size_length_field
void getPayload(BufferType &bufferRef)
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
bool variable_size_payload
enum packetFinderState state
bool WaitForStx(const unsigned char datum)
unsigned int size_payload