UniSet 2.32.1
ComPort485F.h
1#ifndef DISABLE_COMPORT_485F
2/*
3 * Copyright (c) 2015 Pavel Vainerman.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation, version 2.1.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Lesser Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17// --------------------------------------------------------------------------
18#ifndef COMPORT_485F_H_
19#define COMPORT_485F_H_
20// --------------------------------------------------------------------------
21#include <queue>
22#include "ComPort.h"
23#include "PassiveTimer.h"
24// --------------------------------------------------------------------------
25namespace uniset
26{
39 public ComPort
40 {
41 public:
42
43 ComPort485F( const std::string& comDevice, char gpio_num, bool tmit_ctrl = false );
44
45 virtual void sendByte( unsigned char x ) override;
46 virtual void setTimeout( timeout_t timeout ) override;
47 virtual ssize_t sendBlock( unsigned char* msg, size_t len ) override;
48
49 virtual void cleanupChannel() override;
50 virtual void reopen() override;
51
52 protected:
53
54 virtual unsigned char m_receiveByte( bool wait ) override;
55 void save2queue( unsigned char* msg, size_t len, size_t bnum );
56 bool remove_echo( unsigned char tb[], ssize_t len );
57 void m_read( timeout_t tmsec );
58
60 unsigned char tbuf[ComPort::BufSize];
61
62 std::queue<unsigned char> wq;
63 std::queue<unsigned char> rq;
65 char gpio_num;
66 bool tmit_ctrl_on;
67 PassiveTimer ptRecv;
68 timeout_t tout_msec = { 2000 };
69 };
70 // -------------------------------------------------------------------------
71} // end of uniset namespace
72// --------------------------------------------------------------------------
73#endif // COMPORT_485F_H_
74// --------------------------------------------------------------------------
75#endif // #ifndef DISABLE_COMPORT_485F
Definition ComPort485F.h:40
std::queue< unsigned char > rq
Definition ComPort485F.h:63
unsigned char tbuf[ComPort::BufSize]
Definition ComPort485F.h:60
std::queue< unsigned char > wq
Definition ComPort485F.h:62
Definition ComPort.h:30
Пассивный таймер
Definition PassiveTimer.h:94
Definition Calibration.h:27