cwalter-at / freemodbus

BSD licensed MODBUS RTU/ASCII and TCP slave
720 stars 379 forks source link

support variable stop bits #9

Open karlp opened 4 years ago

karlp commented 4 years ago

The commonly required settings are not just baud and parity, but also sometimes stop bits. Add as an extra parameter to mbascii and mbrtu.

Signed-off-by: Karl Palsson karlp@etactica.com

DipSwitch commented 3 years ago

Nice addition but to be modbus compliant you should only use 2 bits when no parity is used. So it's always MB_PAR_EVEN, MB_PAR_ODD or MB_PAR_NONE. Where MB_PAR_EVEN and MB_PAR_ODD have 1 stop bit and MB_PAR_NONE should have 2 stop bits.

So if you want to be modbus compliant you de number of stop bits can be deducted from the chosen parity.

karlp commented 3 years ago

I would love to live in this beautiful standards compliant world of yours :) By all means, it can be automatically selected based on parity by default, but the options are still required if you actually want to use it.