Open realselvatico opened 6 years ago
I see the same problem. It is quite more evident when at the end of each group of several read F03 I do a disconnect. .
the misalligned can be see if one response return "BUSY" 01 83 xx xx xx , the next packet is misalligned of 5 bytes; for workaround the problem i changed the ticksWait in DataReceivedHandler from const long ticksWait = TimeSpan.TicksPerMillisecond 2000: to const long ticksWait = TimeSpan.TicksPerMillisecond 100;
but i believe it is not the "best" solution
this is the log from a monitor:
[25/03/2018 09:13:15] - Open port COM8
[25/03/2018 09:13:15] Written data (COM8)
01 03 01 2c 00 6e 04 13 ...,.n..
[25/03/2018 09:13:15] Read data (COM8)
01 03 dc 30 32 34 31 33 30 38 30 32 31 30 33 38 ..Ü0241308021038
36 30 30 33 32 37 32 00 0c 1d b3 00 18 2c b4 55 6003272...³..,´U
4b 00 00 32 32 62 62 63 63 64 64 65 65 66 66 67 K..22bbccddeeffg
67 68 68 69 69 6c 6c ff ff ff ff ff ff ff ff ff ghhiillÿÿÿÿÿÿÿÿÿ
ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 ÿÿÿÿÿÿÿÿÿÿÿ.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 ...............2
31 34 33 36 35 38 37 20 20 20 20 20 20 20 20 20 1436587
20 20 20 00 63 00 00 00 00 00 00 00 00 00 00 00 .c...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1f ................
21 !
[25/03/2018 09:13:15] Written data (COM8)
01 03 01 f4 00 03 45 c5 ...ô..EÅ
[25/03/2018 09:13:15] Read data (COM8)
01 03 06 00 00 00 00 00 00 21 75 .........!u
[25/03/2018 09:13:15] Written data (COM8)
01 03 00 c8 00 10 c5 f8 ...È..Åø
[25/03/2018 09:13:15] Read data (COM8)
01 03 20 00 00 00 00 00 00 00 00 00 00 00 00 00 .. .............
00 00 00 00 00 37 32 00 0c 1d b3 00 18 2c b4 55 .....72...³..,´U
4b 00 00 22 5a K.."Z
[25/03/2018 09:13:16] Written data (COM8)
01 03 03 e8 00 05 05 b9 ...è...¹
[25/03/2018 09:13:16] Read data (COM8)
01 03 0a 07 d0 00 00 00 00 00 00 00 00 08 a9 ....Ð.........©
[25/03/2018 09:13:16] Written data (COM8)
01 03 04 4c 00 19 44 e7 ...L..Dç
[25/03/2018 09:13:16] Read data (COM8)
01 03 32 00 02 00 00 00 00 02 30 02 8a 01 68 00 ..2.......0.Š.h.
00 00 00 00 00 00 00 00 00 00 00 00 13 00 0f 00 ................
00 00 32 00 04 00 00 13 88 00 41 00 00 00 00 00 ..2.....ˆ.A.....
05 00 01 02 30 80 46 ....0€F
[25/03/2018 09:13:16] Written data (COM8)
01 03 04 b0 00 3a c5 0e ...°.:Å.
[25/03/2018 09:13:16] Read data (COM8)
01 03 74 00 08 00 00 00 00 00 02 00 00 00 08 00 ..t.............
03 fe 4c fe 4c 00 00 01 40 00 00 00 00 00 64 00 .þLþL...@.....d.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 9c da .......œÚ
[25/03/2018 09:13:16] Written data (COM8)
01 03 05 14 00 1f 44 ca ......DÊ
[25/03/2018 09:13:16] Read data (COM8)
01 03 3e 00 00 00 00 00 00 00 00 00 00 00 08 00 ..>.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 24 00 07 10 d9 00 00 00 00 00 ......$...Ù.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 52 dc .RÜ
[25/03/2018 09:13:17] Written data (COM8)
01 03 05 14 00 1f 44 ca ......DÊ
[25/03/2018 09:13:17] Read data (COM8)
01 03 3e 00 00 00 00 00 00 00 00 00 00 00 08 00 ..>.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 24 00 07 10 d9 00 00 00 00 00 ......$...Ù.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 52 dc .RÜ
[25/03/2018 09:13:17] Written data (COM8)
01 03 02 bc 00 18 85 9c ...¼..…œ
[25/03/2018 09:13:17] Read data (COM8)
01 03 30 00 00 00 00 00 00 00 00 00 00 00 00 00 ..0.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 c0 bc ...À¼
[25/03/2018 09:13:17] Written data (COM8)
01 03 05 dc 00 03 c4 fd ...Ü..Äý
[25/03/2018 09:13:17] Read data (COM8)
01 03 06 00 00 00 00 01 50 20 d9 ........P Ù
[25/03/2018 09:13:17] Written data (COM8)
01 03 06 40 00 20 45 4e ...@. EN
[25/03/2018 09:13:17] Read data (COM8)
01 03 40 00 09 00 00 00 00 00 01 00 00 00 00 00 ..@.............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 bf a9 ...¿©
[25/03/2018 09:13:17] - Close port COM8
while this is the log from EasyModbsTCP.net callback:
2018-03-25 09:13:15.718->>>> Scan: group1 - Expected : 30 secs, Elapesed Time: 6.9 secs 2018-03-25 09:13:15.744-COM8 Tx: 01 03 01 2C 00 6E 04 13 2018-03-25 09:13:15.895-COM8 Rx: 01 03 DC 30 32 34 31 33 30 38 30 32 31 30 33 38 36 30 30 33 32 37 32 00 0C 1D B3 00 18 2C B4 55 4B 00 00 32 32 62 62 63 63 64 64 65 65 66 66 67 67 68 68 69 69 6C 6C FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 31 34 33 36 35 38 37 20 20 20 20 20 20 20 20 20 20 20 20 00 63 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1F 21 2018-03-25 09:13:15.903->>>> Scan: group2 - Expected : 2 secs, Elapesed Time: 7.0 secs 2018-03-25 09:13:15.914-COM8 Tx: 01 03 01 F4 00 03 45 C5 2018-03-25 09:13:15.938-COM8 Rx: 01 03 06 00 00 00 00 00 00 21 75 2018-03-25 09:13:15.945->>>> Scan: group3 - Expected : 30 secs, Elapesed Time: 6.9 secs 2018-03-25 09:13:15.956-COM8 Tx: 01 03 00 C8 00 10 C5 F8 2018-03-25 09:13:16.009-COM8 Rx: 01 03 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 32 00 0C 1D B3 00 18 2C B4 55 4B 00 00 22 5A 2018-03-25 09:13:16.014->>>> Scan: group4 - Expected : 30 secs, Elapesed Time: 7.0 secs 2018-03-25 09:13:16.027-COM8 Tx: 01 03 03 E8 00 05 05 B9 2018-03-25 09:13:16.050-COM8 Rx: 01 03 0A 07 D0 00 00 00 00 00 00 00 00 08 A9 2018-03-25 09:13:16.058->>>> Scan: group5 - Expected : 30 secs, Elapesed Time: 6.9 secs 2018-03-25 09:13:16.071-COM8 Tx: 01 03 04 4C 00 19 44 E7 2018-03-25 09:13:16.131-COM8 Rx: 01 03 32 00 02 00 00 00 00 02 30 02 8A 01 68 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 0F 00 00 00 32 00 04 00 00 13 88 00 41 00 00 00 00 00 05 00 01 02 30 80 46 2018-03-25 09:13:16.139->>>> Scan: group6 - Expected : 5 secs, Elapesed Time: 6.9 secs 2018-03-25 09:13:16.151-COM8 Tx: 01 03 04 B0 00 3A C5 0E 2018-03-25 09:13:16.245-COM8 Rx: 01 03 74 00 08 00 00 00 00 00 02 00 00 00 08 00 03 FE 4C FE 4C 00 00 01 40 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 9C DA 2018-03-25 09:13:16.268->>>> Scan: group7 - Expected : 30 secs, Elapesed Time: 5.9 secs 2018-03-25 09:13:16.298-COM8 Tx: 01 03 05 14 00 1F 44 CA 2018-03-25 09:13:16.357-COM8 Rx: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 07 10 D9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 DC 2018-03-25 09:13:17.339-COM8 Tx: 01 03 05 14 00 1F 44 CA 2018-03-25 09:13:17.396-COM8 Rx: 01 03 3E 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 07 10 D9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 DC 2018-03-25 09:13:17.406->>>> Scan: group8 - Expected : 30 secs, Elapesed Time: 7.0 secs 2018-03-25 09:13:17.421-COM8 Tx: 01 03 02 BC 00 18 85 9C 2018-03-25 09:13:17.474-COM8 Rx: 01 03 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C0 BC 2018-03-25 09:13:17.484->>>> Scan: group9 - Expected : 30 secs, Elapesed Time: 7.0 secs 2018-03-25 09:13:17.499-COM8 Tx: 01 03 05 DC 00 03 C4 FD 2018-03-25 09:13:17.521-COM8 Rx: 01 03 06 00 00 00 00 01 50 20 D9 2018-03-25 09:13:17.529->>>> Scan: group10 - Expected : 30 secs, Elapesed Time: 6.9 secs 2018-03-25 09:13:17.542-COM8 Tx: 01 03 06 40 00 20 45 4E 2018-03-25 09:13:17.603-COM8 Rx: 01 03 40 00 09 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BF A9
as you can see the response to "01 03 05 14 00 1F 44 CA" is read badly, the first part of the response if fillexd with "00"
I hope that you can have time for looking this problem because make the RTU quite instable.
thanks in advaced William
Fix the problem by disabling the receiving event and handle the recepion dldirecly into each function
Good morning, during some tests, I found a fairly rare situation but it can happen. In particular, using ModBusClient, it may happen that a disalinneability occurs between the request to read some memory areas and its response. It can happen when several readings of different areas are made, in one of these readings a communication error or other happens, in the subsequent answers the data are out of phase of a reading.
I assume there may be a problem when the stream.Read is done that the previous stream is downloaded.
I apologize in advance if I have not been clear enough, but it is a particular condition but quite annoying.