fedeturco / ModBus_Client

Modbus Client
https://fedeturco.github.io/ModbusClient/
3 stars 0 forks source link

FC01 in RTU mode causes "Internal Error" #1

Closed Cwmwd24 closed 1 month ago

Cwmwd24 commented 3 months ago

Pre-built Version v2.47

I have a trial Modbus server running on an Arduino that I'm experimenting with -- I've set up some coils that are shared with discrete inputs so I expect to get the same data from FC01 and FC02. I can change a coil with FC15 and read their state with FC02 but when I read them with FC01 I get an error and no data.

image

Here's a log portion showing reading the first 8 coils with FC02 and then FC01, as far as I can see the reply received to FC01 is good?

Tx: 01 02 00 00 00 08 79 CC
Rx: 01 02 01 80 A0 28
Tx: 01 01 00 00 00 08 3D CC
Rx: 01 01 01 80 50 28
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at ModBusMaster_Chicco.ModBus_Chicco.readCoilStatus_01(Byte slave_add, UInt32 start_add, UInt32 no_of_coils, Int32 readTimeout) in C:\Users\feder\Desktop\ModBus_Client\ModBus_Client\ModBus_Chicco.cs:line 717
   at ModBus_Client.MainWindow.readColisRange() in C:\Users\feder\Desktop\ModBus_Client\ModBus_Client\ModBus_Client.xaml.cs:line 1959

I've tried the same FC01 command with other software (which is not so nice to use) and I get the data I expect in the GUI.

fedeturco commented 1 month ago

Hi @Cwmwd24 , thanks for the report and sorry for the delay, I have released a new version today (2.48) that fixes the problem. As you wrote the answer to the FC01 request was correct, it was mishandled the table conversion only for the RTU mode. I tested the new version and it seems to be solved, please let me know if it helps you. Best regards

Cwmwd24 commented 1 month ago

Thanks for your effort and time @fedeturco, I've tried your new version with my hardware and FC01 results are shown correctly now on the GUI. Brilliant.

All the very best,