Skip to content

Commit 5c4481b

Browse files
committed
fix bugs in shortgroup
1 parent 5c8c046 commit 5c4481b

File tree

12 files changed

+10
-7
lines changed

12 files changed

+10
-7
lines changed

SCADA/Example/BatchCoreTest.exe

0 Bytes
Binary file not shown.

SCADA/Example/ClientDriver.dll

0 Bytes
Binary file not shown.

SCADA/Example/DataService.dll

0 Bytes
Binary file not shown.
87 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

SCADA/Program/DataService/PLCGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ protected override unsafe void Poll()
983983
{
984984
for (int i = 0; i < addr.DataSize / 2; i++)
985985
{
986-
prcv[iShort1] = IPAddress.HostToNetworkOrder(prcv[iShort1]);
986+
prcv[iShort1 + i] = IPAddress.HostToNetworkOrder(prcv[iShort1 + i]);
987987
}
988988
}
989989
if (addr.DataSize <= 2)

SCADA/Program/ModbusDriver/ModbusRTUDriver.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,20 +478,23 @@ public byte[] ReadBytes(DeviceAddress address, ushort size)
478478
CreateReadHeader(address.Area, address.Start, size, func);
479479
lock (_async)
480480
{
481-
byte[] frameBytes = new byte[size * 2 + 3];//size * 2 +
481+
byte[] frameBytes = new byte[size * 2 + 5];//size * 2 +
482482
byte[] data = new byte[size * 2];
483483
_serialPort.Write(header, 0, header.Length);
484484
int numBytesRead = 0;
485485
while (numBytesRead < 2)
486486
numBytesRead += _serialPort.Read(frameBytes, numBytesRead, 2 - numBytesRead);
487487
if (frameBytes[1] == address.DBNumber)
488488
{
489-
numBytesRead = 0;
490-
while (numBytesRead != frameBytes.Length)
489+
while (numBytesRead < frameBytes.Length)
491490
numBytesRead += _serialPort.Read(frameBytes, numBytesRead, frameBytes.Length - numBytesRead);
492-
Array.Copy(frameBytes, 1, data, 0, data.Length);
493-
Thread.Sleep(20);
494-
return data;
491+
if (Utility.CheckSumCRC(frameBytes))
492+
{
493+
Array.Copy(frameBytes, 3, data, 0, data.Length);
494+
Thread.Sleep(20);
495+
return data;
496+
}
497+
else Thread.Sleep(10);
495498
}
496499
else
497500
{

SCADA/dll/DataService.dll

0 Bytes
Binary file not shown.

SCADA/dll/ModbusDriver.dll

0 Bytes
Binary file not shown.

SCADA/dll/OPCDriver.dll

0 Bytes
Binary file not shown.

SCADA/dll/SiemensPLCDriver.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)