OutOfRange in some array, write doesn't work
This commit is contained in:
1
Main.cs
1
Main.cs
@@ -474,6 +474,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
switch ((FunctionCode)functionCode)
|
||||
{
|
||||
case (FunctionCode.WriteCoil):
|
||||
Console.WriteLine("Trying to force single coil");
|
||||
if (valueLower == "true" || valueLower == "1")
|
||||
await Modbus.WriteSingleAsync(port, (FunctionCode)functionCode, (byte)UpDown_ModbusID.Value, (ushort)address, 0xFF_00);
|
||||
else if (valueLower == "false" || valueLower == "0")
|
||||
|
||||
@@ -55,6 +55,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
GetCRC(_message, ref CRC);
|
||||
_message[6] = CRC[0];
|
||||
_message[7] = CRC[1];
|
||||
Console.WriteLine("Message: " + ByteArrayToString(_message));
|
||||
return _message;
|
||||
}
|
||||
else return new byte[1] { 0xFF };
|
||||
@@ -129,6 +130,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
try
|
||||
{
|
||||
port.Write(message, 0, message.Length);
|
||||
Console.WriteLine("Write message sent successfully");
|
||||
return true;
|
||||
}
|
||||
catch (Exception err)
|
||||
|
||||
Reference in New Issue
Block a user