Modbus Operator Class. More...
#include <modbus.hpp>
Public Member Functions | |
modbus (const std::string &host, uint16_t port) | |
modbus (const std::string &host) | |
~modbus () | |
bool | modbus_connect () |
void | modbus_close () |
void | modbus_set_slave_id (int id) |
void | modbus_read_coils (int address, int amount, bool *buffer) |
void | modbus_read_input_bits (int address, int amount, bool *buffer) |
void | modbus_read_holding_registers (int address, int amount, uint16_t *buffer) |
void | modbus_read_input_registers (int address, int amount, uint16_t *buffer) |
void | modbus_write_coil (int address, bool to_write) |
void | modbus_write_register (int address, uint16_t value) |
void | modbus_write_coils (int address, int amount, bool *value) |
void | modbus_write_registers (int address, int amount, uint16_t *value) |
Private Member Functions | |
void | modbus_build_request (uint8_t *to_send, int address, int func) |
void | modbus_read (int address, int amount, int func) |
void | modbus_write (int address, int amount, int func, uint16_t *value) |
ssize_t | modbus_send (uint8_t *to_send, int length) |
ssize_t | modbus_receive (uint8_t *buffer) |
void | modbus_error_handle (uint8_t *msg, int func) |
Private Attributes | |
bool | _connected {false} |
uint16_t | PORT {502} |
int | _socket {0} |
int | _msg_id {1} |
int | _slaveid {1} |
std::string | HOST |
struct sockaddr_in | _server |
Modbus Operator Class.
Modbus Operator Class Providing networking support and mobus operation support.
Definition at line 63 of file modbus.hpp.
modbus::modbus | ( | const std::string & | host, |
uint16_t | port | ||
) |
Definition at line 6 of file modbus.cpp.
|
explicit |
Definition at line 10 of file modbus.cpp.
modbus::~modbus | ( | void | ) |
Definition at line 12 of file modbus.cpp.
|
private |
Definition at line 54 of file modbus.cpp.
Referenced by modbus_read(), and modbus_write().
void modbus::modbus_close | ( | ) |
Definition at line 49 of file modbus.cpp.
Referenced by MagAOX::app::xt1121Ctrl::appShutdown().
bool modbus::modbus_connect | ( | ) |
Definition at line 19 of file modbus.cpp.
Referenced by MagAOX::app::xt1121Ctrl::appLogic().
|
private |
Definition at line 281 of file modbus.cpp.
Referenced by modbus_read_coils(), modbus_read_holding_registers(), modbus_read_input_bits(), modbus_read_input_registers(), modbus_write_coil(), modbus_write_coils(), modbus_write_register(), and modbus_write_registers().
|
private |
Definition at line 100 of file modbus.cpp.
Referenced by modbus_read_coils(), modbus_read_holding_registers(), modbus_read_input_bits(), and modbus_read_input_registers().
void modbus::modbus_read_coils | ( | int | address, |
int | amount, | ||
bool * | buffer | ||
) |
Definition at line 153 of file modbus.cpp.
void modbus::modbus_read_holding_registers | ( | int | address, |
int | amount, | ||
uint16_t * | buffer | ||
) |
Definition at line 109 of file modbus.cpp.
void modbus::modbus_read_input_bits | ( | int | address, |
int | amount, | ||
bool * | buffer | ||
) |
Definition at line 174 of file modbus.cpp.
void modbus::modbus_read_input_registers | ( | int | address, |
int | amount, | ||
uint16_t * | buffer | ||
) |
Definition at line 131 of file modbus.cpp.
Referenced by MagAOX::app::xt1121Ctrl::getState().
|
private |
Definition at line 277 of file modbus.cpp.
Referenced by modbus_read_coils(), modbus_read_holding_registers(), modbus_read_input_bits(), modbus_read_input_registers(), modbus_write_coil(), modbus_write_coils(), modbus_write_register(), and modbus_write_registers().
|
private |
Definition at line 272 of file modbus.cpp.
Referenced by modbus_read(), and modbus_write().
void modbus::modbus_set_slave_id | ( | int | id | ) |
Definition at line 15 of file modbus.cpp.
Referenced by MagAOX::app::xt1121Ctrl::appLogic().
|
private |
Definition at line 66 of file modbus.cpp.
Referenced by modbus_write_coil(), modbus_write_coils(), modbus_write_register(), and modbus_write_registers().
void modbus::modbus_write_coil | ( | int | address, |
bool | to_write | ||
) |
Definition at line 195 of file modbus.cpp.
void modbus::modbus_write_coils | ( | int | address, |
int | amount, | ||
bool * | value | ||
) |
Definition at line 232 of file modbus.cpp.
void modbus::modbus_write_register | ( | int | address, |
uint16_t | value | ||
) |
Definition at line 214 of file modbus.cpp.
void modbus::modbus_write_registers | ( | int | address, |
int | amount, | ||
uint16_t * | value | ||
) |
Definition at line 254 of file modbus.cpp.
Referenced by MagAOX::app::xt1121Ctrl::channelSetCallback().
|
private |
Definition at line 65 of file modbus.hpp.
Referenced by modbus_connect(), modbus_read_coils(), modbus_read_holding_registers(), modbus_read_input_bits(), modbus_read_input_registers(), modbus_write_coil(), modbus_write_coils(), modbus_write_register(), and modbus_write_registers().
|
private |
Definition at line 68 of file modbus.hpp.
Referenced by modbus_build_request(), and modbus_send().
|
private |
Definition at line 70 of file modbus.hpp.
Referenced by modbus_connect().
|
private |
Definition at line 69 of file modbus.hpp.
Referenced by modbus_build_request(), and modbus_set_slave_id().
|
private |
Definition at line 67 of file modbus.hpp.
Referenced by modbus_close(), modbus_connect(), modbus_receive(), and modbus_send().
|
private |
Definition at line 70 of file modbus.hpp.
Referenced by modbus_connect().
|
private |
Definition at line 66 of file modbus.hpp.
Referenced by modbus_connect().