8 years, 1 month ago.

Change RTU settings at runtime (after init)

Hi,

I have a question about this nice modbus implementation. I would like to be able to change RTU settings of the modbus serial connection at runtime after initialization: baudrate, parity, number of stopbits.

I can't find the necessary functions to execute these changes.

Could you give me an indication where to look and/or how to proceed?

Thank you in advance!

Christopher

Question relating to:

Port of the FreeModbus Libary for mbed Modbus

Haven't really got an answer to the port configuration issue but I'm interested in discussing modbus issues as I looked at freemodbus a while back but couldn't really understand the documentation and variable naming conventions. I'm working on my own RTU-only handler.

posted by Oliver Broad 18 Mar 2016

1 Answer

8 years, 1 month ago.

G'day Christopher,

I don't think it is intended to be able to change baud rate and parity on-the-fly. The modbus protocol uses timers that are based on the baud rate, so changing baud rate after initialisation is not a good idea. You might just have to call "eMBClose" followed by "eMBInit" with your new baud rate and parity as parameters of that function.

Regards

Cam

Accepted Answer

Hello Cam,

Thank you for your answer and for the pointer in a solution direction. I'll give that solution a try and will let you know how it works out.

Fact is that I am designing a device that will be a modbus slave. The RTU config it will be used in will be different for every device, but I would like to have one biinary, and have the RTU config done at the moment of the installation of the device.

posted by Christopher Peirs 21 Mar 2016

Hi Cam,

Yes that did the trick, thanks!

posted by Christopher Peirs 22 Mar 2016