UniSet  2.2.1
ComPort485F.h
00001 #ifndef COMPORT_485F_H_
00002 #define COMPORT_485F_H_
00003 // --------------------------------------------------------------------------
00004 #include <queue>
00005 #include "ComPort.h"
00006 #include "PassiveTimer.h"
00007 // --------------------------------------------------------------------------
00019 class ComPort485F:
00020     public ComPort
00021 {
00022     public:
00023 
00024         ComPort485F( const std::string& comDevice, int gpio_num, bool tmit_ctrl = false );
00025 
00026         virtual void sendByte( unsigned char x ) override;
00027         virtual void setTimeout( timeout_t timeout ) override;
00028         virtual size_t sendBlock( unsigned char* msg, size_t len ) override;
00029 
00030         virtual void cleanupChannel() override;
00031         virtual void reopen() override;
00032 
00033     protected:
00034 
00035         virtual unsigned char m_receiveByte( bool wait ) override;
00036         void save2queue( unsigned char* msg, int len, int bnum );
00037         bool remove_echo( unsigned char tb[], int len );
00038         void m_read( int tmsec );
00039 
00041         unsigned char tbuf[ComPort::BufSize];
00042 
00043         std::queue<unsigned char> wq; 
00044         std::queue<unsigned char> rq; 
00046         int gpio_num;
00047         bool tmit_ctrl_on;
00048         PassiveTimer ptRecv;
00049         timeout_t tout_msec = { 2000 };
00050 };
00051 // --------------------------------------------------------------------------
00052 #endif // COMPORT_485F_H_
00053 // --------------------------------------------------------------------------