.. _program_listing_file__tmp_ws_src_kobuki_core_include_kobuki_core_packet_handler_packet_finder.hpp: Program Listing for File packet_finder.hpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/kobuki_core/include/kobuki_core/packet_handler/packet_finder.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef PACKET_FINDER_HPP_ #define PACKET_FINDER_HPP_ /***************************************************************************** ** Includes *****************************************************************************/ #include #include #include #include "../macros.hpp" /***************************************************************************** ** Namespaces *****************************************************************************/ namespace kobuki { /***************************************************************************** ** Using *****************************************************************************/ /***************************************************************************** ** Interface *****************************************************************************/ class kobuki_PUBLIC PacketFinderBase { public: typedef ecl::PushAndPop BufferType; enum packetFinderState { clearBuffer = 0, waitingForStx, waitingForPayloadSize, waitingForPayloadToEtx, waitingForEtx, }; enum packetFinderState state; protected: unsigned int size_stx; unsigned int size_etx; unsigned int size_length_field; bool variable_size_payload; unsigned int size_max_payload; unsigned int size_payload; unsigned int size_checksum_field; BufferType STX; BufferType ETX; BufferType buffer; bool verbose; ecl::Signal sig_warn, sig_error; public: PacketFinderBase(); virtual ~PacketFinderBase() {}; void configure(const std::string &sigslots_namespace, const BufferType & putStx, const BufferType & putEtx, unsigned int sizeLengthField, unsigned int sizeMaxPayload, unsigned int sizeChecksumField, bool variableSizePayload); void clear(); void enableVerbose(); virtual bool update(const unsigned char * incoming, unsigned int numberOfIncoming); virtual bool checkSum(); unsigned int numberOfDataToRead(); void getBuffer(BufferType & bufferRef); void getPayload(BufferType & bufferRef); protected: bool WaitForStx(const unsigned char datum); bool waitForPayloadSize(const unsigned char * incoming, unsigned int numberOfIncoming); bool waitForEtx(const unsigned char incoming, bool & foundPacket); bool waitForPayloadAndEtx(const unsigned char * incoming, unsigned int numberOfIncoming, bool & foundPacket); }; } // namespace kobuki #endif /* PACKET_FINDER_HPP_ */