Repository navigation
fix(transport): retry a read whose answer has the wrong length - #674
Merged
Merged
Conversation
A meter sent 1 data byte for a 2-register read. It was not treated as a failed request, so it was not retried and the driver decoder threw. Now every register, coil and discrete input read checks the byte count inside the retried function, in createModbusTransport and in SlaveTransport (the path the MQTT bridge uses). Closes #673
@ya-modbus/cli
@ya-modbus/device-profiler
@ya-modbus/driver-dds024mr
@ya-modbus/driver-dds519mr
@ya-modbus/driver-ex9em
@ya-modbus/driver-loader
@ya-modbus/driver-or-we-514
@ya-modbus/driver-or-we-516
@ya-modbus/driver-sdk
@ya-modbus/driver-sdm630
@ya-modbus/driver-types
@ya-modbus/driver-xymd1
@ya-modbus/emulator
@ya-modbus/mqtt-bridge
@ya-modbus/transport
ya-modbus
ya-modbus-bridge
ya-modbus-emulator
ya-modbus-profile
commit: |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A read whose answer has the wrong number of data bytes is now a failed request, so
withRetrysends it again in the same poll, like after a timeout or a CRC error. Before, the short buffer went to the driver, the decoder threw, and the whole poll failed (an OR-WE-514 sent 1 data byte for a 2-register read, 4 times in 23 hours).Changes
checkLength(packages/transport/src/answer-length.ts): register reads expectcount × 2bytes, coil and discrete-input reads expectceil(count / 8)bytes.createModbusTransport(CLI, profiler) andSlaveTransport(the MQTT bridge, throughTransportManager).Wrong answer length: expected 4 data bytes, got 1.withRequestContextappends the port, slave, function, address and count, e.g.(… 9600 8N1, slave 2, FC03 read holding registers, address 0 (0x0000), count 2).Checklist
Closes #673