autopolling mostly done

This commit is contained in:
nikzori
2024-12-16 15:52:01 +03:00
parent f13922491d
commit f76094cab4
3 changed files with 12 additions and 16 deletions

View File

@@ -186,8 +186,6 @@ namespace Gidrolock_Modbus_Scanner
static void PortDataReceived(object sender, EventArgs e)
{
Console.WriteLine("Data receieved on Serial Port");
try
{
byte[] message = new byte[port.BytesToRead];
@@ -197,15 +195,13 @@ namespace Gidrolock_Modbus_Scanner
{
port.Read(message, i + 3, 1);
}
Console.WriteLine("Raw data from port: " + BitConverter.ToString(message));
byte[] data = new byte[length];
for (int i = 0; i < length; i++)
{
data[i] = message[i + 3];
}
string dataCleaned = ByteArrayToString(message);
Console.WriteLine("Received response: " + dataCleaned);
Console.WriteLine("UTF8: " + Encoding.UTF8.GetString(data));
port.DiscardInBuffer();