arduino-libraries / ArduinoModbus

244 stars 116 forks source link

don't wait for confirmation response if the write is a broadcast message #118

Open bobemoe opened 11 months ago

bobemoe commented 11 months ago

Fixes #117

I added a condition ctx->slave!=0 so that a response is not expected if its a broadcast message. This allows the endTransmission to return asap without blocking waiting for a response that will never come and eventually timing out.

I added this to modbus_write_bits and modbus_write_registers which are the only 2 functions called by endTransmission

This has fixed issue #117 for me.

Not sure if this may need to be added in any other places?

CLAassistant commented 11 months ago

CLA assistant check
All committers have signed the CLA.

github-actions[bot] commented 11 months ago

Memory usage change @ df2ffbeb7c09208cd34db1210a2f4e7e0f509f48

Board flash % RAM for global variables %
arduino:mbed_nano:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:megaavr:uno2018:mode=off :small_red_triangle: 0 - +24 0.0 - +0.05 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 :small_red_triangle: 0 - +16 0.0 - +0.01 0 - 0 0.0 - 0.0
Click for full report table Board|`examples/RTU/ModbusRTUClientKitchenSink`
flash|%|`examples/RTU/ModbusRTUClientKitchenSink`
RAM for global variables|%|`examples/RTU/ModbusRTUClientParameters`
flash|%|`examples/RTU/ModbusRTUClientParameters`
RAM for global variables|%|`examples/RTU/ModbusRTUClientToggle`
flash|%|`examples/RTU/ModbusRTUClientToggle`
RAM for global variables|%|`examples/RTU/ModbusRTUServerKitchenSink`
flash|%|`examples/RTU/ModbusRTUServerKitchenSink`
RAM for global variables|%|`examples/RTU/ModbusRTUServerLED`
flash|%|`examples/RTU/ModbusRTUServerLED`
RAM for global variables|%|`examples/RTU/ModbusRTUTemperatureSensor`
flash|%|`examples/RTU/ModbusRTUTemperatureSensor`
RAM for global variables|%|`examples/TCP/EthernetModbusClientToggle`
flash|%|`examples/TCP/EthernetModbusClientToggle`
RAM for global variables|%|`examples/TCP/EthernetModbusServerLED`
flash|%|`examples/TCP/EthernetModbusServerLED`
RAM for global variables|%|`examples/TCP/WiFiModbusClientToggle`
flash|%|`examples/TCP/WiFiModbusClientToggle`
RAM for global variables|%|`examples/TCP/WiFiModbusServerLED`
flash|%|`examples/TCP/WiFiModbusServerLED`
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- `arduino:mbed_nano:nano33ble`|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 `arduino:mbed_opta:opta`|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 `arduino:mbed_portenta:envie_m7`|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|||||||| `arduino:megaavr:uno2018:mode=off`|24|0.05|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 `arduino:samd:mkrwifi1010`|16|0.01|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/RTU/ModbusRTUClientKitchenSink
flash,%,examples/RTU/ModbusRTUClientKitchenSink
RAM for global variables,%,examples/RTU/ModbusRTUClientParameters
flash,%,examples/RTU/ModbusRTUClientParameters
RAM for global variables,%,examples/RTU/ModbusRTUClientToggle
flash,%,examples/RTU/ModbusRTUClientToggle
RAM for global variables,%,examples/RTU/ModbusRTUServerKitchenSink
flash,%,examples/RTU/ModbusRTUServerKitchenSink
RAM for global variables,%,examples/RTU/ModbusRTUServerLED
flash,%,examples/RTU/ModbusRTUServerLED
RAM for global variables,%,examples/RTU/ModbusRTUTemperatureSensor
flash,%,examples/RTU/ModbusRTUTemperatureSensor
RAM for global variables,%,examples/TCP/EthernetModbusClientToggle
flash,%,examples/TCP/EthernetModbusClientToggle
RAM for global variables,%,examples/TCP/EthernetModbusServerLED
flash,%,examples/TCP/EthernetModbusServerLED
RAM for global variables,%,examples/TCP/WiFiModbusClientToggle
flash,%,examples/TCP/WiFiModbusClientToggle
RAM for global variables,%,examples/TCP/WiFiModbusServerLED
flash,%,examples/TCP/WiFiModbusServerLED
RAM for global variables,% arduino:mbed_nano:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_opta:opta,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,,,,,,,, arduino:megaavr:uno2018:mode=off,24,0.05,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrwifi1010,16,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 ```
bobemoe commented 11 months ago

I've just found this issue upstream and PR https://github.com/stephane/libmodbus/pull/467

PanzerFowst commented 6 months ago

If that is the case, then shouldn't this PR be closed?

bobemoe commented 6 months ago

Yeah I guess, though I'm still having to use this as a patch as its not actually been merged in upstream.

PanzerFowst commented 6 months ago

Gotcha, makes sense. I suppose that also assumes that the libmodbus would also need to be updated in this two too.

On Wed, Jan 3, 2024 at 04:46 bobemoe @.***> wrote:

Yeah I guess, though I'm still having to use this as a patch as its not actually been merged in upstream.

— Reply to this email directly, view it on GitHub https://github.com/arduino-libraries/ArduinoModbus/pull/118#issuecomment-1875169547, or unsubscribe https://github.com/notifications/unsubscribe-auth/AISWKL7P3CEC5G3NX2XTU3LYMUZINAVCNFSM6AAAAAA24YKYI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVGE3DSNJUG4 . You are receiving this because you commented.Message ID: @.***>

-- PanzerFowst™

​ "When life gives you lemons, BLOW 'EM UP!!" --Natsu Dragneel