NModbus / NModbus

NModbus is a C# implementation of the Modbus protocol.
MIT License
819 stars 262 forks source link

Support for broadcast messaging #120

Open cdrose opened 1 year ago

cdrose commented 1 year ago

Is there a way to implement broadcast messaging in NModbus?

A broadcast message is sent to node 0 and has no response from the slave devices. As far as I can see writes to node 0 are handled the same as any other message and wait for a response. I have tried to work around it by setting the the read timeout to 1, retries to zero and then catching the TimeoutException but the performance is not great. Is there a better approach?

rquackenbush commented 1 year ago

I haven’t looked into this closely in the current implementation. I suspect that you’ve found the best workaround.

I’m working on the next version of NModbus and am providing first class support for broadcast requests.

cdrose commented 1 year ago

My new approach is to build the message manually, add the CRC calculation from NModbus.Utility, and then send it directly using the serial port. So far seems to be behaving as expected :)

MondoKevin commented 1 year ago

I haven’t looked into this closely in the current implementation. I suspect that you’ve found the best workaround.

I’m working on the next version of NModbus and am providing first class support for broadcast requests.

Hi @rquackenbush. I am also looking at using the broadcast functionality. I was wondering if the new version with broadcast support would be available soon?

rquackenbush commented 1 year ago

@MondoKevin - unfortunately it's still in progress. I'm actually looking for someone to sponsor some serial adapters for me to develop with. Any chance you're interested? I'm looking for 3 FTDI RS-485 adapters.

rquackenbush commented 1 year ago

I've ordered FTDI cables and will attempt to incorporate broadcast messaging into the 3.x version of NModbus.

MondoKevin commented 1 year ago

I've ordered FTDI cables and will attempt to incorporate broadcast messaging into the 3.x version of NModbus.

That's great! Thanks @rquackenbush. I look forward to seeing how it turns out.