cadcf24a
Peter M. Groen
Setting up workin...
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*!
* \brief ModbusConnect
* \param conncfg
*/
void ModbusConnect( const ConnectionConfig &conncfg );
/*!
* \brief ModbusDisconnect
*/
void ModbusDisconnect();
/*!
* \brief ModbusReadData
* \param slaveId
* \param startAddress
* \param noOfItems
*/
modbusData ModbusReadData( int slaveId, int functionCode, int startAddress, int noOfItems );
/*!
* \brief ModbusReadHoldReg
* \param slaveId
* \param startAddress
* \param noOfItems
* \return
*/
modbusData ModbusReadHoldReg( int slaveId, int startAddress, int noOfItems );
/*!
* \brief ModBusWriteData
* \param slaveId
* \param funtionCode
* \param startAddress
* \param noOfItems
* \param values
*/
void ModBusWriteData( int slaveId, int functionCode, int startAddress, int noOfItems, std::vector<int>values );
/*!
* \brief isConnected
* \return
*/
bool isConnected() const;
/*!
* \brief ErrorString
* \param errnum
* \return
*/
std::string ErrorString( int errnum );
private: // Methods
void ModbusConnectRTU( const std::string &serialport, int baud, char parity, int dataBits, int stopBits, int RTS, int timeOut );
void ModbusConnectTCP( const std::string &ip, int port, int timeOut = -1 );
void InitBuffers();
void ClearBuffers();
private: // Members
ConnectionType m_connType { ConnectionType::CT_UNKNOWN }; ///> The type of connection this instance provides. Needed for administration
bool m_connected { false }; ///> Shows if the connection is still active.
modbus_t *m_modbus; ///> The actual low-level modbus instance as a raw-pointer. ( unique_pointer gives an error on this struct )
// Return value Buffers ( Room for improvement )
uint8_t *m_dest;
uint16_t *m_dest16;
|