Skip to content

Commit

Permalink
Update to V5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gusmanb committed May 5, 2024
1 parent c13c6fc commit 5838d03
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions Software/LogicAnalyzer/SharedDriver/LogicAnalyzerDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,10 @@ private void InitSerialPort(string SerialPort, int Bauds)
baseStream.ReadTimeout = 10000;
DeviceVersion = readResponse.ReadLine();

var verMatch = regVersion.Match(DeviceVersion ?? "");

if (verMatch == null || !verMatch.Success || !verMatch.Groups[2].Success)
{
Dispose();
throw new DeviceConnectionException($"Invalid device version V{ (string.IsNullOrWhiteSpace(verMatch?.Value) ? "(unknown)" : verMatch?.Value) }, minimum supported version: V{MAJOR_VERSION}_{MINOR_VERSION}");
}

int majorVer = int.Parse(verMatch.Groups[2].Value);
int minorVer = int.Parse(verMatch.Groups[3].Value);

if (majorVer < MAJOR_VERSION)
if (!ValidateVersion())
{
Dispose();
throw new DeviceConnectionException($"Invalid device version V{verMatch.Value}, minimum supported version: V{MAJOR_VERSION}_{MINOR_VERSION}");
}

if (majorVer == MAJOR_VERSION && minorVer < MINOR_VERSION)
{
Dispose();
throw new DeviceConnectionException($"Invalid device version V{verMatch.Value}, minimum supported version: V{MAJOR_VERSION}_{MINOR_VERSION}");
throw new DeviceConnectionException($"Invalid device version {DeviceVersion}, minimum supported version: V{MAJOR_VERSION}_{MINOR_VERSION}");
}

baseStream.ReadTimeout = Timeout.Infinite;
Expand Down Expand Up @@ -139,10 +122,38 @@ private void InitNetwork(string AddressPort)

baseStream.ReadTimeout = 10000;
DeviceVersion = readResponse.ReadLine();

if (!ValidateVersion())
{
Dispose();
throw new DeviceConnectionException($"Invalid device version {DeviceVersion}, minimum supported version: V{MAJOR_VERSION}_{MINOR_VERSION}");
}

baseStream.ReadTimeout = Timeout.Infinite;

isNetwork = true;
}

private bool ValidateVersion()
{
var verMatch = regVersion.Match(DeviceVersion ?? "");

if (verMatch == null || !verMatch.Success || !verMatch.Groups[2].Success)
return false;

int majorVer = int.Parse(verMatch.Groups[2].Value);
int minorVer = int.Parse(verMatch.Groups[3].Value);

if (majorVer < MAJOR_VERSION)
return false;

if (majorVer == MAJOR_VERSION && minorVer < MINOR_VERSION)
return false;

return true;

}

public unsafe bool SendNetworkConfig(string AccesPointName, string Password, string IPAddress, ushort Port)
{
if(isNetwork)
Expand Down Expand Up @@ -525,7 +536,6 @@ public void Dispose()
readData = null;
readData = null;

DeviceVersion = null;
CaptureCompleted = null;
}

Expand Down

0 comments on commit 5838d03

Please sign in to comment.