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 {
35 {
36 public:
38  virtual ~LibModbusClient() override;
39 
41  bool init(const char* ip, unsigned int port) override;
42 
44  void setResponseTimeoutInMs(unsigned long timeout_ms) override;
45 
47  unsigned long getResponseTimeoutInMs() override;
48 
50  RegCont readHoldingRegister(int addr, int nb) override;
51 
53  RegCont writeReadHoldingRegister(const int write_addr, const RegCont& write_reg, const int read_addr,
54  const int read_nb) override;
55 
59  void close();
60 
61 private:
62  modbus_t* modbus_connection_{ nullptr };
63 };
64 
65 } // namespace prbt_hardware_support
66 
67 #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 Wed Oct 28 2020 03:12:06