Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModbusRtu.cpp 773B

12345678910111213141516171819202122232425262728293031
  1. #include "ModbusRtu.h"
  2. #include <sstream>
  3. inline std::string ModbusRTU::getSettingsString() const
  4. {
  5. return std::to_string(baud) + pairity + std::to_string(stopBit);
  6. }
  7. ModbusRTU::~ModbusRTU()
  8. {
  9. //if(my_slave != nullptr){
  10. // delete my_slave;
  11. //}
  12. //if(my_modbus != nullptr){
  13. // my_modbus->close();
  14. // delete my_modbus;
  15. //}
  16. }
  17. ModbusRTU::ModbusRTU(const u_int id, const std::string _device, const unsigned int _baud, const char _pairity, const unsigned int _stopBit)
  18. : ModbusInterface(id, _device), baud(_baud), pairity(_pairity), stopBit(_stopBit)
  19. {
  20. }
  21. void ModbusRTU::modbus_init() {
  22. if(my_modbus == nullptr){
  23. my_modbus = new Modbus::Master(Modbus::Rtu, device, getSettingsString());
  24. assignSlave();
  25. }
  26. }