16 #include "../../include/xbot_driver/packet_handler/packet_finder.hpp" 28 PacketFinderBase::PacketFinderBase() :
29 state(waitingForStx), verbose(false)
40 unsigned int sizeMaxPayload,
unsigned int sizeChecksumField,
bool variableSizePayload)
106 printf(
"[state(%d):%02d]",
state, num);
144 if (!(numberOfIncoming > 0))
147 bool found_packet(
false);
203 if ( found_packet ) {
215 bool found_stx(
true);
237 unsigned char first_byte;
238 for (
unsigned int i = 0; i < numberOfIncoming; i++) {
239 first_byte = incoming[i];
245 for (
unsigned int i = 0; i <
buffer.
size(); i++)
246 printf(
"%02x ",
buffer[i]);
300 unsigned int number_of_match(0);
301 for (
unsigned int i = 0; i <
ETX.
size(); i++)
309 if (number_of_match ==
ETX.
size())
325 for (
unsigned int i = 0; i < numberOfIncoming; i++)
334 std::ostringstream ostream;
337 ostream << std::setfill(
'0') << std::uppercase;
349 ostream <<
", buffer: [" << std::setw(2) <<
buffer.
size() <<
"][";
350 for (
unsigned int i = 0; i <
buffer.
size(); ++i ) {
351 ostream << std::setw(2) << std::hex << static_cast<int>(
buffer[i]) <<
" " << std::dec;
366 std::cout <<
"Start check etx " <<
std::endl;
367 for (
unsigned int i = 0; i < numberOfIncoming; ++i ) {
368 std::cout << std::hex << static_cast<int>(*(incoming+i)) <<
" ";
383 std::cout <<
"End of checking etx " <<
std::endl;
bool WaitForStx(const unsigned char datum)
enum packetFinderState state
unsigned int size() const
unsigned int size_payload
bool waitForPayloadAndEtx(const unsigned char *incoming, unsigned int numberOfIncoming, bool &foundPacket)
ecl::Signal< const std::string & > sig_error
bool variable_size_payload
unsigned int size_checksum_field
void push_back(const Type &datum)
void configure(const std::string &sigslots_namespace, const BufferType &putStx, const BufferType &putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload)
bool waitForEtx(const unsigned char incoming, bool &foundPacket)
ecl::PushAndPop< unsigned char > BufferType
ecl::Signal< const std::string & > sig_warn
virtual bool update(const unsigned char *incoming, unsigned int numberOfIncoming)
unsigned int size_length_field
void getBuffer(BufferType &bufferRef)
unsigned int size_max_payload
void connect(const std::string &topic)
void getPayload(BufferType &bufferRef)
unsigned int numberOfDataToRead()
bool waitForPayloadSize(const unsigned char *incoming, unsigned int numberOfIncoming)