serial_stream.h
Go to the documentation of this file.
00001 
00032 // Based on example from:
00033 //   https://github.com/labust/labust-ros-pkg/wiki/Create-a-Serial-Port-application
00034 
00035 #ifndef CREATE_SERIAL_STREAM_H
00036 #define CREATE_SERIAL_STREAM_H
00037 
00038 #include <boost/asio.hpp>
00039 #include <boost/thread.hpp>
00040 #include <boost/thread/condition_variable.hpp>
00041 #include <boost/function.hpp>
00042 #include <boost/shared_ptr.hpp>
00043 
00044 #include "create/data.h"
00045 #include "create/types.h"
00046 #include "create/util.h"
00047 #include "create/serial.h"
00048 
00049 namespace create {
00050   class SerialStream : public Serial {
00051     private:
00052       enum ReadState {
00053         READ_HEADER,
00054         READ_NBYTES,
00055         READ_PACKET_ID,
00056         READ_PACKET_BYTES,
00057         READ_CHECKSUM
00058       };
00059 
00060       // State machine variables
00061       ReadState readState;
00062       uint8_t headerByte;
00063       uint8_t packetID;
00064       uint8_t expectedNumBytes;
00065       uint16_t packetBytes;
00066       uint8_t numBytesRead;
00067       uint32_t byteSum;
00068       uint8_t numDataBytesRead;
00069       uint8_t expectedNumDataBytes;
00070 
00071     protected:
00072       bool startSensorStream();
00073       void processByte(uint8_t byteRead);
00074 
00075     public:
00076       SerialStream(boost::shared_ptr<Data> data, const uint8_t& header = create::util::STREAM_HEADER);
00077 
00078   };
00079 }  // namespace create
00080 
00081 #endif // CREATE_SERIAL_H


libcreate
Author(s): Jacob Perron
autogenerated on Thu Jun 6 2019 21:02:06