Skip to content

Commit d4c1035

Browse files
authored
[ModbusClient] Fix for startup marker in the response (#1106)
1 parent 22052b1 commit d4c1035

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

devices/Modbus/Client/ModbusClient.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,14 @@ private Response SendRequest(Request request)
457457
try
458458
{
459459
// read dummy byte (from specs: 3.5 chars time start marker, will never ever be read in a understandible manner)
460-
_ = DataRead();
460+
// Some Modbus Server do not use the start marker, so we need to read the first byte and see if it is the device ID we expect and if not assume its the startup marker.
461+
id = DataRead();
461462

462463
// read device ID
463-
id = DataRead();
464+
if (id != request.DeviceId)
465+
{
466+
id = DataRead();
467+
}
464468

465469
// Function number
466470
var fn = DataRead();

0 commit comments

Comments
 (0)