mirror of
https://github.com/JasonYANG170/logicanalyzer.git
synced 2024-11-23 12:06:27 +00:00
Updated driver and CLCapture to avoid port blockage under Linux
This commit is contained in:
parent
fc05977ad4
commit
21de831ccf
46
Software/LogicAnalyzer/AppConfig.json
Normal file
46
Software/LogicAnalyzer/AppConfig.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"AppName": "Avalonia.Designer.HostApp, Version=0.10.16.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b",
|
||||
"WindowSettings": {
|
||||
"LogicAnalyzer.Dialogs.CreateSamplesDialog": {
|
||||
"Width": 800.0,
|
||||
"Height": 600.0,
|
||||
"Position": {
|
||||
"$type": "Avalonia.PixelPoint, Avalonia.Visuals",
|
||||
"X": 0,
|
||||
"Y": 0
|
||||
},
|
||||
"WindowState": 0
|
||||
},
|
||||
"LogicAnalyzer.MainWindow": {
|
||||
"Width": 1024.0,
|
||||
"Height": 800.0,
|
||||
"Position": {
|
||||
"$type": "Avalonia.PixelPoint, Avalonia.Visuals",
|
||||
"X": 0,
|
||||
"Y": 0
|
||||
},
|
||||
"WindowState": 0
|
||||
},
|
||||
"LogicAnalyzer.Dialogs.SignalComposerDialog": {
|
||||
"EditorFontSize": 14.0,
|
||||
"Width": 640.0,
|
||||
"Height": 480.0,
|
||||
"Position": {
|
||||
"$type": "Avalonia.PixelPoint, Avalonia.Visuals",
|
||||
"X": 0,
|
||||
"Y": 0
|
||||
},
|
||||
"WindowState": 0
|
||||
},
|
||||
"LogicAnalyzer.Dialogs.MeasureDialog": {
|
||||
"Width": 400.0,
|
||||
"Height": 450.0,
|
||||
"Position": {
|
||||
"$type": "Avalonia.PixelPoint, Avalonia.Visuals",
|
||||
"X": 0,
|
||||
"Y": 0
|
||||
},
|
||||
"WindowState": 0
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,9 +9,12 @@ using System.Text.RegularExpressions;
|
|||
|
||||
Regex regAddressPort = new Regex("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\:[0-9]+");
|
||||
Regex regAddress = new Regex("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
|
||||
LogicAnalyzerDriver? driver = null;
|
||||
|
||||
TaskCompletionSource<CaptureEventArgs> captureCompletedTask;
|
||||
|
||||
Console.CancelKeyPress += Console_CancelKeyPress;
|
||||
|
||||
return await Parser.Default.ParseArguments<CLCaptureOptions, CLNetworkOptions>(args)
|
||||
.MapResult(
|
||||
async (CLCaptureOptions opts) => await Capture(opts),
|
||||
|
@ -144,8 +147,6 @@ async Task<int> Capture(CLCaptureOptions opts)
|
|||
break;
|
||||
}
|
||||
|
||||
LogicAnalyzerDriver driver;
|
||||
|
||||
Console.WriteLine($"Opening logic analyzer in {opts.AddressPort}...");
|
||||
|
||||
try
|
||||
|
@ -234,6 +235,12 @@ async Task<int> Capture(CLCaptureOptions opts)
|
|||
|
||||
var result = await captureCompletedTask.Task;
|
||||
|
||||
if (result.Samples == null)
|
||||
{
|
||||
Console.WriteLine("Capture aborted.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Console.WriteLine("Capture complete, writting output file...");
|
||||
|
||||
var file = File.Create(opts.OutputFile);
|
||||
|
@ -302,7 +309,7 @@ int Configure(CLNetworkOptions opts)
|
|||
return -1;
|
||||
}
|
||||
|
||||
LogicAnalyzerDriver driver;
|
||||
|
||||
|
||||
Console.WriteLine($"Opening logic analyzer in port {opts.SerialPort}...");
|
||||
|
||||
|
@ -343,4 +350,18 @@ int Configure(CLNetworkOptions opts)
|
|||
void CaptureFinished(CaptureEventArgs e)
|
||||
{
|
||||
captureCompletedTask.SetResult(e);
|
||||
}
|
||||
}
|
||||
|
||||
void Console_CancelKeyPress(object? sender, ConsoleCancelEventArgs e)
|
||||
{
|
||||
if (driver != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
driver.StopCapture();
|
||||
driver.Dispose();
|
||||
}
|
||||
catch { }
|
||||
driver = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"profiles": {
|
||||
"CLCapture": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "netconfig"
|
||||
"commandLineArgs": "capture COM3 1000000 1,2,3,4,5,6,7,8 20 20000 TriggerType:Edge,Channel:1,Value:1 ../test.csv"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_LastSelectedProfileId>C:\Users\geniw\source\repos\LogicAnalyzer\LogicAnalyzer\Properties\PublishProfiles\Linux-Arm64.pubxml</_LastSelectedProfileId>
|
||||
<_LastSelectedProfileId>C:\Users\geniw\source\repos\LogicAnalyzer\LogicAnalyzer\Properties\PublishProfiles\Windows-Arm64.pubxml</_LastSelectedProfileId>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -549,6 +549,9 @@ namespace LogicAnalyzer
|
|||
|
||||
private void Driver_CaptureCompleted(object? sender, CaptureEventArgs e)
|
||||
{
|
||||
if (e.Samples == null)
|
||||
return;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
sampleViewer.BeginUpdate();
|
||||
|
|
|
@ -375,7 +375,13 @@ namespace SharedDriver
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + " - " + ex.StackTrace);
|
||||
//if(ex.GetType() != typeof(OperationCanceledException))
|
||||
// Console.WriteLine(ex.Message + " - " + ex.StackTrace);
|
||||
|
||||
if (currentCaptureHandler != null)
|
||||
currentCaptureHandler(new CaptureEventArgs { SourceType = isNetwork ? AnalyzerDriverType.Network : AnalyzerDriverType.Serial, Samples = null, ChannelCount = channelCount, TriggerChannel = triggerChannel, PreSamples = preSamples });
|
||||
else if (CaptureCompleted != null)
|
||||
CaptureCompleted(this, new CaptureEventArgs { SourceType = isNetwork ? AnalyzerDriverType.Network : AnalyzerDriverType.Serial, Samples = null, ChannelCount = channelCount, TriggerChannel = triggerChannel, PreSamples = preSamples });
|
||||
}
|
||||
}
|
||||
public bool StopCapture()
|
||||
|
@ -389,7 +395,7 @@ namespace SharedDriver
|
|||
{
|
||||
baseStream.WriteByte(0xff);
|
||||
baseStream.Flush();
|
||||
Thread.Sleep(1);
|
||||
Thread.Sleep(2000);
|
||||
tcpClient.Close();
|
||||
Thread.Sleep(1);
|
||||
tcpClient = new TcpClient();
|
||||
|
@ -403,7 +409,7 @@ namespace SharedDriver
|
|||
|
||||
sp.Write(new byte[] { 0xFF }, 0, 1);
|
||||
sp.BaseStream.Flush();
|
||||
Thread.Sleep(1);
|
||||
Thread.Sleep(2000);
|
||||
sp.Close();
|
||||
Thread.Sleep(1);
|
||||
sp.Open();
|
||||
|
|
Loading…
Reference in New Issue
Block a user