mirror of
https://github.com/JasonYANG170/logicanalyzer.git
synced 2024-11-23 12:06:27 +00:00
Corrected driver to work properly under Linux
This commit is contained in:
parent
ab32e4f324
commit
bba03c69eb
|
@ -6,6 +6,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ApplicationIcon>window.ico</ApplicationIcon>
|
<ApplicationIcon>window.ico</ApplicationIcon>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -186,6 +186,9 @@ async Task<int> Capture(CLCaptureOptions opts)
|
||||||
case CaptureError.HardwareError:
|
case CaptureError.HardwareError:
|
||||||
Console.WriteLine("Device reported error starting capture. Restart the device and try again.");
|
Console.WriteLine("Device reported error starting capture. Restart the device and try again.");
|
||||||
return -1;
|
return -1;
|
||||||
|
case CaptureError.UnexpectedError:
|
||||||
|
Console.WriteLine("Unexpected error. Restart the device and try again.");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +226,9 @@ async Task<int> Capture(CLCaptureOptions opts)
|
||||||
case CaptureError.HardwareError:
|
case CaptureError.HardwareError:
|
||||||
Console.WriteLine("Device reported error starting capture. Restart the device and try again.");
|
Console.WriteLine("Device reported error starting capture. Restart the device and try again.");
|
||||||
return -1;
|
return -1;
|
||||||
|
case CaptureError.UnexpectedError:
|
||||||
|
Console.WriteLine("Unexpected error. Restart the device and try again.");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationIcon>Assets\window.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\window.ico</ApplicationIcon>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove=".gitignore" />
|
<None Remove=".gitignore" />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_LastSelectedProfileId>C:\Users\geniw\source\repos\LogicAnalyzer\LogicAnalyzer\Properties\PublishProfiles\Windows-Arm64.pubxml</_LastSelectedProfileId>
|
<_LastSelectedProfileId>C:\Users\geniw\source\repos\LogicAnalyzer\LogicAnalyzer\Properties\PublishProfiles\Linux-Arm.pubxml</_LastSelectedProfileId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -561,6 +561,9 @@ namespace LogicAnalyzer
|
||||||
case CaptureError.HardwareError:
|
case CaptureError.HardwareError:
|
||||||
await ShowError("Error", "Device reported error starting capture. Restart the device and try again.");
|
await ShowError("Error", "Device reported error starting capture. Restart the device and try again.");
|
||||||
return;
|
return;
|
||||||
|
case CaptureError.UnexpectedError:
|
||||||
|
await ShowError("Error", "Unexpected error, restart the application and the device and try again.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -15,6 +16,8 @@ namespace SharedDriver
|
||||||
Stream baseStream;
|
Stream baseStream;
|
||||||
SerialPort sp;
|
SerialPort sp;
|
||||||
TcpClient tcpClient;
|
TcpClient tcpClient;
|
||||||
|
string devAddr;
|
||||||
|
ushort devPort;
|
||||||
|
|
||||||
public string? DeviceVersion { get; set; }
|
public string? DeviceVersion { get; set; }
|
||||||
public event EventHandler<CaptureEventArgs>? CaptureCompleted;
|
public event EventHandler<CaptureEventArgs>? CaptureCompleted;
|
||||||
|
@ -59,17 +62,15 @@ namespace SharedDriver
|
||||||
if (match == null || !match.Success)
|
if (match == null || !match.Success)
|
||||||
throw new ArgumentException("Specified address/port is invalid");
|
throw new ArgumentException("Specified address/port is invalid");
|
||||||
|
|
||||||
string addr = match.Groups[1].Value;
|
devAddr = match.Groups[1].Value;
|
||||||
string port = match.Groups[2].Value;
|
string port = match.Groups[2].Value;
|
||||||
|
|
||||||
ushort uport;
|
if(!ushort.TryParse(port, out devPort))
|
||||||
|
|
||||||
if(!ushort.TryParse(port, out uport))
|
|
||||||
throw new ArgumentException("Specified address/port is invalid");
|
throw new ArgumentException("Specified address/port is invalid");
|
||||||
|
|
||||||
tcpClient = new TcpClient();
|
tcpClient = new TcpClient();
|
||||||
|
|
||||||
tcpClient.Connect(addr, uport);
|
tcpClient.Connect(devAddr, devPort);
|
||||||
baseStream = tcpClient.GetStream();
|
baseStream = tcpClient.GetStream();
|
||||||
|
|
||||||
readResponse = new StreamReader(baseStream);
|
readResponse = new StreamReader(baseStream);
|
||||||
|
@ -127,137 +128,144 @@ namespace SharedDriver
|
||||||
if (Channels == null || Channels.Length == 0 || PreSamples < 2 || PostSamples < 512 || Frequency < 3100 || Frequency > 100000000)
|
if (Channels == null || Channels.Length == 0 || PreSamples < 2 || PostSamples < 512 || Frequency < 3100 || Frequency > 100000000)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
|
|
||||||
switch (CaptureMode)
|
try
|
||||||
{
|
{
|
||||||
case 0:
|
switch (CaptureMode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
|
||||||
if (PreSamples > 98303 || PostSamples > 131069 || PreSamples + PostSamples > 131071)
|
if (PreSamples > 98303 || PostSamples > 131069 || PreSamples + PostSamples > 131071)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
if (PreSamples > 49151 || PostSamples > 65533 || PreSamples + PostSamples > 65535)
|
if (PreSamples > 49151 || PostSamples > 65533 || PreSamples + PostSamples > 65535)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
if (PreSamples > 24576 || PostSamples > 32765 || PreSamples + PostSamples > 32767)
|
if (PreSamples > 24576 || PostSamples > 32765 || PreSamples + PostSamples > 32767)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
channelCount = Channels.Length;
|
||||||
|
triggerChannel = Array.IndexOf(Channels, TriggerChannel);
|
||||||
|
preSamples = PreSamples;
|
||||||
|
currentCaptureHandler = CaptureCompletedHandler;
|
||||||
|
|
||||||
|
CaptureRequest request = new CaptureRequest
|
||||||
|
{
|
||||||
|
triggerType = 0,
|
||||||
|
trigger = (byte)TriggerChannel,
|
||||||
|
invertedOrCount = TriggerInverted ? (byte)1 : (byte)0,
|
||||||
|
channels = new byte[32],
|
||||||
|
channelCount = (byte)Channels.Length,
|
||||||
|
frequency = (uint)Frequency,
|
||||||
|
preSamples = (uint)PreSamples,
|
||||||
|
postSamples = (uint)PostSamples,
|
||||||
|
captureMode = CaptureMode
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int buc = 0; buc < Channels.Length; buc++)
|
||||||
|
request.channels[buc] = (byte)Channels[buc];
|
||||||
|
|
||||||
|
OutputPacket pack = new OutputPacket();
|
||||||
|
pack.AddByte(1);
|
||||||
|
pack.AddStruct(request);
|
||||||
|
|
||||||
|
baseStream.Write(pack.Serialize());
|
||||||
|
baseStream.Flush();
|
||||||
|
|
||||||
|
baseStream.ReadTimeout = 10000;
|
||||||
|
var result = readResponse.ReadLine();
|
||||||
|
baseStream.ReadTimeout = Timeout.Infinite;
|
||||||
|
|
||||||
|
if (result == "CAPTURE_STARTED")
|
||||||
|
{
|
||||||
|
capturing = true;
|
||||||
|
Task.Run(() => ReadCapture(PreSamples + PostSamples, CaptureMode));
|
||||||
|
return CaptureError.None;
|
||||||
|
}
|
||||||
|
return CaptureError.HardwareError;
|
||||||
}
|
}
|
||||||
|
catch { return CaptureError.UnexpectedError; }
|
||||||
channelCount = Channels.Length;
|
|
||||||
triggerChannel = Array.IndexOf(Channels, TriggerChannel);
|
|
||||||
preSamples = PreSamples;
|
|
||||||
currentCaptureHandler = CaptureCompletedHandler;
|
|
||||||
|
|
||||||
CaptureRequest request = new CaptureRequest
|
|
||||||
{
|
|
||||||
triggerType = 0,
|
|
||||||
trigger = (byte)TriggerChannel,
|
|
||||||
invertedOrCount = TriggerInverted ? (byte)1 : (byte)0,
|
|
||||||
channels = new byte[32],
|
|
||||||
channelCount = (byte)Channels.Length,
|
|
||||||
frequency = (uint)Frequency,
|
|
||||||
preSamples = (uint)PreSamples,
|
|
||||||
postSamples = (uint)PostSamples,
|
|
||||||
captureMode = CaptureMode
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int buc = 0; buc < Channels.Length; buc++)
|
|
||||||
request.channels[buc] = (byte)Channels[buc];
|
|
||||||
|
|
||||||
OutputPacket pack = new OutputPacket();
|
|
||||||
pack.AddByte(1);
|
|
||||||
pack.AddStruct(request);
|
|
||||||
|
|
||||||
baseStream.Write(pack.Serialize());
|
|
||||||
baseStream.Flush();
|
|
||||||
|
|
||||||
baseStream.ReadTimeout = 10000;
|
|
||||||
var result = readResponse.ReadLine();
|
|
||||||
baseStream.ReadTimeout = Timeout.Infinite;
|
|
||||||
|
|
||||||
if (result == "CAPTURE_STARTED")
|
|
||||||
{
|
|
||||||
capturing = true;
|
|
||||||
Task.Run(() => ReadCapture(PreSamples + PostSamples, CaptureMode));
|
|
||||||
return CaptureError.None;
|
|
||||||
}
|
|
||||||
return CaptureError.HardwareError;
|
|
||||||
}
|
}
|
||||||
public CaptureError StartPatternCapture(int Frequency, int PreSamples, int PostSamples, int[] Channels, int TriggerChannel, int TriggerBitCount, UInt16 TriggerPattern, bool Fast, byte CaptureMode, Action<CaptureEventArgs>? CaptureCompletedHandler = null)
|
public CaptureError StartPatternCapture(int Frequency, int PreSamples, int PostSamples, int[] Channels, int TriggerChannel, int TriggerBitCount, UInt16 TriggerPattern, bool Fast, byte CaptureMode, Action<CaptureEventArgs>? CaptureCompletedHandler = null)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
if (capturing)
|
|
||||||
return CaptureError.Busy;
|
|
||||||
|
|
||||||
if (Channels == null || Channels.Length == 0 || PreSamples < 2 || PostSamples < 512 || Frequency < 3100 || Frequency > 100000000)
|
|
||||||
return CaptureError.BadParams;
|
|
||||||
|
|
||||||
switch (CaptureMode)
|
|
||||||
{
|
{
|
||||||
case 0:
|
if (capturing)
|
||||||
|
return CaptureError.Busy;
|
||||||
|
|
||||||
if (PreSamples > 98303 || PostSamples > 131069 || PreSamples + PostSamples > 131071)
|
if (Channels == null || Channels.Length == 0 || PreSamples < 2 || PostSamples < 512 || Frequency < 3100 || Frequency > 100000000)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
switch (CaptureMode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
|
||||||
if (PreSamples > 49151 || PostSamples > 65533 || PreSamples + PostSamples > 65535)
|
if (PreSamples > 98303 || PostSamples > 131069 || PreSamples + PostSamples > 131071)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 1:
|
||||||
|
|
||||||
if (PreSamples > 24576 || PostSamples > 32765 || PreSamples + PostSamples > 32767)
|
if (PreSamples > 49151 || PostSamples > 65533 || PreSamples + PostSamples > 65535)
|
||||||
return CaptureError.BadParams;
|
return CaptureError.BadParams;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
|
||||||
|
if (PreSamples > 24576 || PostSamples > 32765 || PreSamples + PostSamples > 32767)
|
||||||
|
return CaptureError.BadParams;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
channelCount = Channels.Length;
|
||||||
|
triggerChannel = Array.IndexOf(Channels, TriggerChannel);
|
||||||
|
preSamples = PreSamples;
|
||||||
|
currentCaptureHandler = CaptureCompletedHandler;
|
||||||
|
|
||||||
|
CaptureRequest request = new CaptureRequest
|
||||||
|
{
|
||||||
|
triggerType = (byte)(Fast ? 2 : 1),
|
||||||
|
trigger = (byte)TriggerChannel,
|
||||||
|
invertedOrCount = (byte)TriggerBitCount,
|
||||||
|
triggerValue = (UInt16)TriggerPattern,
|
||||||
|
channels = new byte[32],
|
||||||
|
channelCount = (byte)Channels.Length,
|
||||||
|
frequency = (uint)Frequency,
|
||||||
|
preSamples = (uint)PreSamples,
|
||||||
|
postSamples = (uint)PostSamples,
|
||||||
|
captureMode = CaptureMode
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int buc = 0; buc < Channels.Length; buc++)
|
||||||
|
request.channels[buc] = (byte)Channels[buc];
|
||||||
|
|
||||||
|
OutputPacket pack = new OutputPacket();
|
||||||
|
pack.AddByte(1);
|
||||||
|
pack.AddStruct(request);
|
||||||
|
|
||||||
|
baseStream.Write(pack.Serialize());
|
||||||
|
baseStream.Flush();
|
||||||
|
|
||||||
|
baseStream.ReadTimeout = 10000;
|
||||||
|
var result = readResponse.ReadLine();
|
||||||
|
baseStream.ReadTimeout = Timeout.Infinite;
|
||||||
|
|
||||||
|
if (result == "CAPTURE_STARTED")
|
||||||
|
{
|
||||||
|
capturing = true;
|
||||||
|
Task.Run(() => ReadCapture(PreSamples + PostSamples, CaptureMode));
|
||||||
|
return CaptureError.None;
|
||||||
|
}
|
||||||
|
return CaptureError.HardwareError;
|
||||||
}
|
}
|
||||||
|
catch { return CaptureError.UnexpectedError; }
|
||||||
channelCount = Channels.Length;
|
|
||||||
triggerChannel = Array.IndexOf(Channels, TriggerChannel);
|
|
||||||
preSamples = PreSamples;
|
|
||||||
currentCaptureHandler = CaptureCompletedHandler;
|
|
||||||
|
|
||||||
CaptureRequest request = new CaptureRequest
|
|
||||||
{
|
|
||||||
triggerType = (byte)(Fast ? 2 : 1),
|
|
||||||
trigger = (byte)TriggerChannel,
|
|
||||||
invertedOrCount = (byte)TriggerBitCount,
|
|
||||||
triggerValue = (UInt16)TriggerPattern,
|
|
||||||
channels = new byte[32],
|
|
||||||
channelCount = (byte)Channels.Length,
|
|
||||||
frequency = (uint)Frequency,
|
|
||||||
preSamples = (uint)PreSamples,
|
|
||||||
postSamples = (uint)PostSamples,
|
|
||||||
captureMode = CaptureMode
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int buc = 0; buc < Channels.Length; buc++)
|
|
||||||
request.channels[buc] = (byte)Channels[buc];
|
|
||||||
|
|
||||||
OutputPacket pack = new OutputPacket();
|
|
||||||
pack.AddByte(1);
|
|
||||||
pack.AddStruct(request);
|
|
||||||
|
|
||||||
baseStream.Write(pack.Serialize());
|
|
||||||
baseStream.Flush();
|
|
||||||
|
|
||||||
baseStream.ReadTimeout = 10000;
|
|
||||||
var result = readResponse.ReadLine();
|
|
||||||
baseStream.ReadTimeout = Timeout.Infinite;
|
|
||||||
|
|
||||||
if (result == "CAPTURE_STARTED")
|
|
||||||
{
|
|
||||||
capturing = true;
|
|
||||||
Task.Run(() => ReadCapture(PreSamples + PostSamples, CaptureMode));
|
|
||||||
return CaptureError.None;
|
|
||||||
}
|
|
||||||
return CaptureError.HardwareError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StopCapture()
|
public bool StopCapture()
|
||||||
|
@ -267,15 +275,32 @@ namespace SharedDriver
|
||||||
|
|
||||||
capturing = false;
|
capturing = false;
|
||||||
|
|
||||||
sp.Write(new byte[] { 0xFF }, 0, 1);
|
if (IsNetwork)
|
||||||
sp.BaseStream.Flush();
|
{
|
||||||
Thread.Sleep(1);
|
baseStream.WriteByte(0xff);
|
||||||
sp.Close();
|
baseStream.Flush();
|
||||||
Thread.Sleep(1);
|
Thread.Sleep(1);
|
||||||
sp.Open();
|
tcpClient.Close();
|
||||||
baseStream = sp.BaseStream;
|
Thread.Sleep(1);
|
||||||
readResponse = new StreamReader(baseStream);
|
tcpClient = new TcpClient();
|
||||||
readData = new BinaryReader(baseStream);
|
tcpClient.Connect(devAddr, devPort);
|
||||||
|
baseStream = tcpClient.GetStream();
|
||||||
|
readResponse = new StreamReader(baseStream);
|
||||||
|
readData = new BinaryReader(baseStream);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
sp.Write(new byte[] { 0xFF }, 0, 1);
|
||||||
|
sp.BaseStream.Flush();
|
||||||
|
Thread.Sleep(1);
|
||||||
|
sp.Close();
|
||||||
|
Thread.Sleep(1);
|
||||||
|
sp.Open();
|
||||||
|
baseStream = sp.BaseStream;
|
||||||
|
readResponse = new StreamReader(baseStream);
|
||||||
|
readData = new BinaryReader(baseStream);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -333,19 +358,39 @@ namespace SharedDriver
|
||||||
uint length = readData.ReadUInt32();
|
uint length = readData.ReadUInt32();
|
||||||
uint[] samples = new uint[length];
|
uint[] samples = new uint[length];
|
||||||
|
|
||||||
|
BinaryReader rdData;
|
||||||
|
|
||||||
|
if (IsNetwork)
|
||||||
|
rdData = readData;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] readBuffer = new byte[Samples * (Mode == 0 ? 1 : (Mode == 1 ? 2 : 4))];
|
||||||
|
int left = readBuffer.Length;
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
while (left > 0 && sp.IsOpen)
|
||||||
|
{
|
||||||
|
pos += sp.Read(readBuffer, pos, left);
|
||||||
|
left = readBuffer.Length - pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryStream ms = new MemoryStream(readBuffer);
|
||||||
|
rdData = new BinaryReader(ms);
|
||||||
|
}
|
||||||
|
|
||||||
switch(Mode)
|
switch(Mode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
for (int buc = 0; buc < length; buc++)
|
for (int buc = 0; buc < length; buc++)
|
||||||
samples[buc] = readData.ReadByte();
|
samples[buc] = rdData.ReadByte();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
for (int buc = 0; buc < length; buc++)
|
for (int buc = 0; buc < length; buc++)
|
||||||
samples[buc] = readData.ReadUInt16();
|
samples[buc] = rdData.ReadUInt16();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
for (int buc = 0; buc < length; buc++)
|
for (int buc = 0; buc < length; buc++)
|
||||||
samples[buc] = readData.ReadUInt32();
|
samples[buc] = rdData.ReadUInt32();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +399,22 @@ namespace SharedDriver
|
||||||
else if (CaptureCompleted != null)
|
else if (CaptureCompleted != null)
|
||||||
CaptureCompleted(this, new CaptureEventArgs { Samples = samples, ChannelCount = channelCount, TriggerChannel = triggerChannel, PreSamples = preSamples });
|
CaptureCompleted(this, new CaptureEventArgs { Samples = samples, ChannelCount = channelCount, TriggerChannel = triggerChannel, PreSamples = preSamples });
|
||||||
|
|
||||||
|
if (!IsNetwork)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rdData.BaseStream.Close();
|
||||||
|
rdData.BaseStream.Dispose();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rdData.Close();
|
||||||
|
rdData.Dispose();
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
capturing = false;
|
capturing = false;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
|
@ -453,7 +514,8 @@ namespace SharedDriver
|
||||||
None,
|
None,
|
||||||
Busy,
|
Busy,
|
||||||
BadParams,
|
BadParams,
|
||||||
HardwareError
|
HardwareError,
|
||||||
|
UnexpectedError
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CaptureEventArgs : EventArgs
|
public class CaptureEventArgs : EventArgs
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<Version>3.5.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user