TransportLayer.h
Go to the documentation of this file.
00001 //
00002 // Created by tom on 05/05/16.
00003 //
00004 
00005 #ifndef ROBOTICAN_HARDWARE_INTERFACE_TRANSPORTLAYER_H
00006 #define ROBOTICAN_HARDWARE_INTERFACE_TRANSPORTLAYER_H
00007 
00008 #include <robotican_hardware_interface/Protocol.h>
00009 #include <boost/asio/serial_port.hpp>
00010 #include <boost/asio.hpp>
00011 
00012 typedef uint16_t crc;
00013 
00014 #define POLYNOMIAL 0xD8  /* 11011 followed by 0's */
00015 #define WIDTH  (8 * sizeof(crc))
00016 #define TOPBIT (1 << (WIDTH - 1))
00017 #define MAX_TABLE 256
00018 
00019 #include <robotican_hardware_interface/ros_utils.h>
00020 
00021 class TransportLayer {
00022 private:
00023     crc _crcTable[MAX_TABLE];
00024     boost::asio::io_service _ioService;
00025     boost::asio::serial_port _serial;
00026     bool read(byte buff[], byte buffLength);
00027 
00028     void crcInit();
00029 
00030 public:
00031     TransportLayer(std::string port, unsigned int baudrate);
00032     ~TransportLayer();
00033 
00034     bool tryToRead(byte *buff, byte buffLength);
00035 
00036     void write(byte buff[], byte buffLength);
00037 
00038     crc calcChecksum(uint8_t const message[], int nBytes);
00039 };
00040 
00041 #endif //ROBOTICAN_HARDWARE_INTERFACE_TRANSPORTLAYER_H


robotican_hardware_interface
Author(s):
autogenerated on Fri Oct 27 2017 03:02:48