Skip to content

Commit 31ef2ac

Browse files
committed
v2.48
- Fix issue FC01 in RTU mode causes "Internal Error" - Fix timeout FC02 RTU - Fix timeout and CRC error warning FC06 RTU - Added right click template datagrids - Improved check response FC05/FC15/FC06/FC16
1 parent 0dba0e0 commit 31ef2ac

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

ModBus_Client/ModBus_Chicco.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ public UInt16[] readInputStatus_02(byte slave_add, uint start_add, uint no_of_in
914914
if (response.Length == 0)
915915
{
916916
Console_print(" Timed out", null, 0);
917-
return null;
917+
throw new ModbusException("Timed out");
918918
}
919919

920920
RX_set = true; // pictureBox gialla
@@ -1855,7 +1855,7 @@ public UInt16[] readInputRegister_04(byte slave_add, uint start_add, uint no_of_
18551855
if (response.Length == 0)
18561856
{
18571857
Console_print(" Timed out", null, 0);
1858-
return null;
1858+
throw new ModbusException("Timed out");
18591859
}
18601860

18611861
RX_set = true; // pictureBox gialla
@@ -1864,7 +1864,7 @@ public UInt16[] readInputRegister_04(byte slave_add, uint start_add, uint no_of_
18641864
Console_print(" Rx <- ", response, response.Length);
18651865

18661866
// Check CRC
1867-
if(!Check_CRC(response, response.Length))
1867+
if (!Check_CRC(response, response.Length))
18681868
{
18691869
throw new ModbusException("CRC Error");
18701870
}
@@ -2100,7 +2100,11 @@ public String diagnostics_08(byte slave_add, uint sub_func, uint data, int readT
21002100
Console.WriteLine("Timeout lettura porta seriale");
21012101
}
21022102

2103-
Check_CRC(response, Length);
2103+
// Check CRC
2104+
if (!Check_CRC(response, Length))
2105+
{
2106+
throw new ModbusException("CRC Error");
2107+
}
21042108

21052109
// Timeout
21062110
if (Length == 0)
@@ -2713,9 +2717,10 @@ public UInt16[] presetMultipleRegisters_16(byte slave_add, uint start_add, UInt1
27132717
Console_printByte("Rx: ", response, response.Length);
27142718
Console_print(" Rx <- ", response, response.Length);
27152719

2716-
if(!Check_CRC(response, response.Length))
2720+
// Check CRC
2721+
if (!Check_CRC(response, response.Length))
27172722
{
2718-
return new UInt16[0] { };
2723+
throw new ModbusException("CRC Error");
27192724
}
27202725

27212726
// Modbus Error Code

ModBus_Client/ModBus_Client.xaml.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,10 +2542,20 @@ public void writeMultipleCoils()
25422542
{
25432543
SetTableCrcError(list_coilsTable, true);
25442544
}
2545+
2546+
this.Dispatcher.Invoke((Action)delegate
2547+
{
2548+
buttonWriteCoils15.IsEnabled = true;
2549+
});
25452550
}
25462551
else
25472552
{
25482553
SetTableInternalError(list_coilsTable, true);
2554+
2555+
this.Dispatcher.Invoke((Action)delegate
2556+
{
2557+
buttonWriteCoils15.IsEnabled = true;
2558+
});
25492559
}
25502560

25512561
this.Dispatcher.Invoke((Action)delegate
@@ -2692,6 +2702,8 @@ public void readInputs()
26922702
}
26932703
else
26942704
{
2705+
SetTableInternalError(list_inputsTable, true);
2706+
26952707
this.Dispatcher.Invoke((Action)delegate
26962708
{
26972709
buttonReadInput02.IsEnabled = true;
@@ -3573,8 +3585,12 @@ public void writeMultipleRegisters()
35733585
else
35743586
{
35753587
MessageBox.Show(lang.languageTemplate["strings"]["errSetReg"], "Alert");
3576-
list_holdingRegistersTable[(int)(address_start)].Foreground = ForeGroundLight.ToString();
3577-
list_holdingRegistersTable[(int)(address_start)].Background = Brushes.Red.ToString();
3588+
3589+
this.Dispatcher.Invoke((Action)delegate
3590+
{
3591+
list_holdingRegistersTable[(int)(address_start)].Foreground = ForeGroundLight.ToString();
3592+
list_holdingRegistersTable[(int)(address_start)].Background = Brushes.Red.ToString();
3593+
});
35783594
}
35793595
}
35803596
}
@@ -3613,8 +3629,12 @@ public void writeMultipleRegisters()
36133629
else
36143630
{
36153631
MessageBox.Show(lang.languageTemplate["strings"]["errSetReg"], "Alert");
3616-
list_holdingRegistersTable[(int)(address_start)].Foreground = ForeGroundLight.ToString();
3617-
list_holdingRegistersTable[(int)(address_start)].Background = Brushes.Red.ToString();
3632+
3633+
this.Dispatcher.Invoke((Action)delegate
3634+
{
3635+
list_holdingRegistersTable[(int)(address_start)].Foreground = ForeGroundLight.ToString();
3636+
list_holdingRegistersTable[(int)(address_start)].Background = Brushes.Red.ToString();
3637+
});
36183638
}
36193639
}
36203640
}

ModBus_Client/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2.47.*")]
54+
[assembly: AssemblyVersion("2.48.*")]
5555
[assembly: AssemblyFileVersion("1.0.0.0")]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Client ModBus TCP/RTU written in C# useful for Modbus read and write operations
33

44
## Release
55

6-
### v2.47 New Version
7-
[ModBus_Client_v2.47 - Portable Zip](https://github.com/fedeturco/ModBus_Client/releases/download/2.47/ModBus_Client_v2.47.zip)
6+
### v2.48 New Version
7+
[ModBus_Client_v2.48 - Portable Zip](https://github.com/fedeturco/ModBus_Client/releases/download/2.48/ModBus_Client_v2.48.zip)
88

9-
### v2.46 Stable
10-
[ModBus_Client_v2.46 - Portable Zip](https://github.com/fedeturco/ModBus_Client/releases/download/2.46/ModBus_Client_v2.46.zip)
9+
### v2.47 Stable
10+
[ModBus_Client_v2.47 - Portable Zip](https://github.com/fedeturco/ModBus_Client/releases/download/2.47/ModBus_Client_v2.47.zip)
1111

1212
### Manual
1313
[Manual EN](https://github.com/fedeturco/ModBus_Client/blob/master/ModBus_Client/Manuals/ModBus_Client_EN.pdf)

0 commit comments

Comments
 (0)