libmodbus_client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Pilz GmbH & Co. KG
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General 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 LIBMODBUS_CLIENT_H
19 #define LIBMODBUS_CLIENT_H
20 
21 #include <modbus/modbus.h>
22 
23 #include <vector>
24 
26 
27 namespace prbt_hardware_support
28 {
29 
36 {
37 public:
38 
40  virtual ~LibModbusClient() override;
41 
43  bool init(const char* ip, unsigned int port) override;
44 
46  void setResponseTimeoutInMs(unsigned long timeout_ms) override;
47 
49  unsigned long getResponseTimeoutInMs() override;
50 
52  RegCont readHoldingRegister(int addr, int nb) override;
53 
55  RegCont writeReadHoldingRegister(const int write_addr,
56  const RegCont &write_reg,
57  const int read_addr, const int read_nb) override;
58 
62  void close();
63 
64 private:
65  modbus_t *modbus_connection_ {nullptr};
66 };
67 
68 } // namespace prbt_hardware_support
69 
70 #endif // LIBMODBUS_CLIENT_H
virtual ~LibModbusClient() override
See base class.
RegCont readHoldingRegister(int addr, int nb) override
See base class.
std::vector< uint16_t > RegCont
Convenience data type defining the data type for a collection of registers.
void close()
Close connection with server.
bool init(const char *ip, unsigned int port) override
See base class.
RegCont writeReadHoldingRegister(const int write_addr, const RegCont &write_reg, const int read_addr, const int read_nb) override
See base class.
void setResponseTimeoutInMs(unsigned long timeout_ms) override
See base class.
unsigned long getResponseTimeoutInMs() override
See base class.
Wrapper around libmodbus, see https://libmodbus.org/.


prbt_hardware_support
Author(s):
autogenerated on Tue Feb 2 2021 03:50:17