more auto-detection stuff done
This commit is contained in:
@@ -139,7 +139,7 @@ namespace Gidrolock_Modbus_Scanner
|
||||
Array.Reverse(e.Data);
|
||||
DGV_Device.Rows[activeEntryIndex].Cells[2].Value = BitConverter.ToUInt32(e.Data, 0);
|
||||
break;
|
||||
case ("utf8"):
|
||||
case ("string"):
|
||||
List<byte> bytes = new List<byte>();
|
||||
for (int i = 0; i < e.Data.Length; i++)
|
||||
{
|
||||
|
||||
10
Main.cs
10
Main.cs
@@ -361,27 +361,29 @@ namespace Gidrolock_Modbus_Scanner
|
||||
|
||||
if (ce.dataType == "string")
|
||||
{
|
||||
|
||||
List<byte> bytes = new List<byte>();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (data[i] != 0) // clean empty bytes from 16-bit registers
|
||||
bytes.Add(data[i]);
|
||||
}
|
||||
string value = Encoding.UTF8.GetString(bytes.ToArray());
|
||||
string value = Encoding.UTF8.GetString(bytes.ToArray());
|
||||
foreach (Device dev in juju[ce])
|
||||
{
|
||||
{
|
||||
if (dev.checkEntry.expectedValue == value)
|
||||
{
|
||||
Console.WriteLine("It's a match!");
|
||||
device = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ce.dataType == "bool")
|
||||
else if (ce.dataType == "bool")
|
||||
{
|
||||
// why would you even do that lmao
|
||||
}
|
||||
if (ce.dataType == "uint16" || ce.dataType == "uint32")
|
||||
else if (ce.dataType == "uint16" || ce.dataType == "uint32")
|
||||
{
|
||||
byte[] _data = data;
|
||||
Array.Reverse(_data);
|
||||
|
||||
@@ -44,7 +44,7 @@ Modbus TCP
|
||||
"length": 1,
|
||||
|
||||
// <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>: bool, uint16, uint32, utf8
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>: bool, uint16, uint32, string
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: uint16
|
||||
"dataType": "uint16",
|
||||
|
||||
@@ -62,7 +62,7 @@ Modbus TCP
|
||||
"dataType": "string",
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
"expectedValue": "SWT485"
|
||||
"expectedValue": "STW485"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ Config fields and possible values:
|
||||
"length": 1,
|
||||
|
||||
// data type for parsing
|
||||
// supported data types: bool, uint16, uint32, utf8
|
||||
// supported data types: bool, uint16, uint32, string
|
||||
// default value: uint16
|
||||
"dataType": "uint16",
|
||||
|
||||
@@ -63,7 +63,7 @@ Config fields and possible values:
|
||||
"dataType": "string",
|
||||
|
||||
// value after parsing
|
||||
"expectedValue": "SWT485"
|
||||
"expectedValue": "STW485"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user