|
12345678910111213141516171819202122232425262728293031 |
- #include "ModbusRtu.h"
- #include <sstream>
-
- inline std::string ModbusRTU::getSettingsString() const
- {
- return std::to_string(baud) + pairity + std::to_string(stopBit);
- }
-
- ModbusRTU::~ModbusRTU()
- {
- //if(my_slave != nullptr){
- // delete my_slave;
- //}
- //if(my_modbus != nullptr){
- // my_modbus->close();
- // delete my_modbus;
- //}
- }
-
- ModbusRTU::ModbusRTU(const u_int id, const std::string _device, const unsigned int _baud, const char _pairity, const unsigned int _stopBit)
- : ModbusInterface(id, _device), baud(_baud), pairity(_pairity), stopBit(_stopBit)
- {
-
- }
-
- void ModbusRTU::modbus_init() {
- if(my_modbus == nullptr){
- my_modbus = new Modbus::Master(Modbus::Rtu, device, getSettingsString());
- assignSlave();
- }
- }
|