|
UniSet
2.6.0
|
00001 /* 00002 * Copyright (c) 2015 Pavel Vainerman. 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as 00006 * published by the Free Software Foundation, version 2.1. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Lesser Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 // -------------------------------------------------------------------------- 00017 #ifndef COMPORT_485F_H_ 00018 #define COMPORT_485F_H_ 00019 // -------------------------------------------------------------------------- 00020 #include <queue> 00021 #include "ComPort.h" 00022 #include "PassiveTimer.h" 00023 // -------------------------------------------------------------------------- 00024 namespace uniset 00025 { 00037 class ComPort485F: 00038 public ComPort 00039 { 00040 public: 00041 00042 ComPort485F( const std::string& comDevice, int gpio_num, bool tmit_ctrl = false ); 00043 00044 virtual void sendByte( unsigned char x ) override; 00045 virtual void setTimeout( timeout_t timeout ) override; 00046 virtual size_t sendBlock( unsigned char* msg, size_t len ) override; 00047 00048 virtual void cleanupChannel() override; 00049 virtual void reopen() override; 00050 00051 protected: 00052 00053 virtual unsigned char m_receiveByte( bool wait ) override; 00054 void save2queue(unsigned char* msg, size_t len, size_t bnum ); 00055 bool remove_echo( unsigned char tb[], size_t len ); 00056 void m_read( timeout_t tmsec ); 00057 00059 unsigned char tbuf[ComPort::BufSize]; 00060 00061 std::queue<unsigned char> wq; 00062 std::queue<unsigned char> rq; 00064 int gpio_num; 00065 bool tmit_ctrl_on; 00066 PassiveTimer ptRecv; 00067 timeout_t tout_msec = { 2000 }; 00068 }; 00069 // ------------------------------------------------------------------------- 00070 } // end of uniset namespace 00071 // -------------------------------------------------------------------------- 00072 #endif // COMPORT_485F_H_ 00073 // --------------------------------------------------------------------------
1.7.6.1