00001 00033 // Based on example from: 00034 // https://github.com/labust/labust-ros-pkg/wiki/Create-a-Serial-Port-application 00035 00036 #ifndef CREATE_SERIAL_QUERY_H 00037 #define CREATE_SERIAL_QUERY_H 00038 00039 #include <boost/asio.hpp> 00040 #include <boost/thread.hpp> 00041 #include <boost/thread/condition_variable.hpp> 00042 #include <boost/function.hpp> 00043 #include <boost/shared_ptr.hpp> 00044 00045 #include "create/data.h" 00046 #include "create/types.h" 00047 #include "create/util.h" 00048 #include "create/serial.h" 00049 00050 namespace create { 00051 class SerialQuery : public Serial { 00052 00053 private: 00054 boost::asio::deadline_timer streamRecoveryTimer; 00055 uint8_t packetID; 00056 int8_t packetByte; 00057 uint16_t packetData; 00058 const uint8_t maxPacketID; 00059 00060 bool started; 00061 00062 void requestSensorData(); 00063 void restartSensorStream(const boost::system::error_code& err); 00064 00065 void flushInput(); 00066 00067 protected: 00068 bool startSensorStream(); 00069 void processByte(uint8_t byteRead); 00070 00071 public: 00072 SerialQuery(boost::shared_ptr<Data> data); 00073 }; 00074 } // namespace create 00075 00076 #endif // CREATE_SERIAL_H