3 Commits

Author SHA1 Message Date
nikzori
3d4a97b4e9 fixed and optimized port data processing 2025-03-27 12:57:40 +03:00
nikzori
3a3fd60a00 fixed and optimized port data processing 2025-03-27 12:53:14 +03:00
nikzori
5c2a9973f0 fixed and optimized port data processing 2025-03-27 12:52:24 +03:00
5 changed files with 16 additions and 24 deletions

View File

@@ -6,7 +6,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{47A399D3-30C1-4EF4-9E94-F3518919A59C}</ProjectGuid> <ProjectGuid>{47A399D3-30C1-4EF4-9E94-F3518919A59C}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>Gidrolock_Modbus_Configurator</RootNamespace> <RootNamespace>Gidrolock_Modbus_Scanner</RootNamespace>
<AssemblyName>Gidrolock Modbus Configurator</AssemblyName> <AssemblyName>Gidrolock Modbus Configurator</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>

View File

@@ -277,6 +277,9 @@ namespace Gidrolock_Modbus_Scanner
static void PortDataReceived(object sender, EventArgs e) static void PortDataReceived(object sender, EventArgs e)
{ {
//reset values on every event call;
buffer = new byte[255];
offset = 0;
try try
{ {
stopwatch.Restart(); stopwatch.Restart();
@@ -291,22 +294,12 @@ namespace Gidrolock_Modbus_Scanner
} }
} }
// assume that the message ended // assume that the message ended
offset = 0;
List<byte> message = new List<byte>(); List<byte> message = new List<byte>();
int endOfMessage = buffer.Length - 1; for (int i = 0; i < offset; i++)
for (int i = buffer.Length-1; i >= 0; i--)
{
if (buffer[i] != 0x00)
{
endOfMessage = i;
break;
}
}
for (int i = 0; i < endOfMessage + 1; i++)
{ {
message.Add(buffer[i]); message.Add(buffer[i]);
} }
if (message.Count == 0) if (message.Count == 0)
return; return;
@@ -345,7 +338,6 @@ namespace Gidrolock_Modbus_Scanner
} }
} }
public class ModbusResponseEventArgs : EventArgs public class ModbusResponseEventArgs : EventArgs
{ {
public byte[] Message { get; set; } public byte[] Message { get; set; }

View File

@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.9.3.0")] [assembly: AssemblyVersion("0.9.4.0")]
[assembly: AssemblyFileVersion("0.9.3.0")] [assembly: AssemblyFileVersion("0.9.4.0")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]

View File

@@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Gidrolock_Modbus_Configurator.Properties { namespace Gidrolock_Modbus_Scanner.Properties {
using System; using System;
@@ -39,7 +39,7 @@ namespace Gidrolock_Modbus_Configurator.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gidrolock_Modbus_Configurator.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gidrolock_Modbus_Scanner.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace Gidrolock_Modbus_Configurator.Properties { namespace Gidrolock_Modbus_Scanner.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]