epsilonrt / libmodbuspp

Much more than a C++ wrapper for libmodbus
https://epsilonrt.fr/modbuspp
GNU Lesser General Public License v3.0
73 stars 44 forks source link

Bug report #10

Closed Northpower closed 3 years ago

Northpower commented 3 years ago

Hi I will first thank you for your work on this library. I have used it on Tcp at this works perfectly. My problem is in Rtu that is not possible to set parity to 'N' none. I look through your files and found that you are not looking to see if the parity is 'N'.

An easy fix will set p='N' instead of 'E'.

  char RtuLayer::parity (const std::string & settings) {
    char p = 'E';
    size_t s = settings.length();

    if (s >= 2) {
      char c = settings[s - 2];
      if ( (c == 'E') || (c == 'O')) {
        return c;
      }
    }
    return p;
  }

https://github.com/epsilonrt/libmodbuspp/blob/f46453b3de2499d3f1bf79ad0e93f43ba05fe955/src/rtulayer.cpp#L249-L260

I have made a pull request with the little change. Thanks again for your work on this Modbus library. Have a great day