Skip to content

Commit 5e9cdaf

Browse files
committed
串口通讯功能改造。
1 parent c231517 commit 5e9cdaf

File tree

5 files changed

+7
-19
lines changed

5 files changed

+7
-19
lines changed

QpTestClient/QuickConnectForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Quick.Protocol.SerialPort/QpSerialPortClient.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ protected override async Task<Stream> InnerConnectAsync()
3939
if (LogUtils.LogConnection)
4040
LogUtils.Log($"SerialPort[{options.PortName}] open success.");
4141
serialPort.WriteTimeout = options.TransportTimeout;
42-
serialPort.WriteLine(QpConsts.QuickProtocolNameAndVersion);
4342
return serialPort.BaseStream;
4443
}
4544

Quick.Protocol.SerialPort/QpSerialPortClientOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override void LoadFromQueryString(string key, string value)
7373

7474
protected override void LoadFromUri(Uri uri)
7575
{
76-
PortName = uri.Host;
76+
PortName = uri.AbsolutePath.Replace("/", string.Empty);
7777
if (!OperatingSystem.IsWindows())
7878
{
7979
if (!PortName.StartsWith(unixPortNamePrefix))
@@ -85,13 +85,13 @@ protected override void LoadFromUri(Uri uri)
8585
protected override string ToUriBasic(HashSet<string> ignorePropertyNames)
8686
{
8787
ignorePropertyNames.Add(nameof(PortName));
88-
var host = PortName;
88+
var portName = PortName;
8989
if (!OperatingSystem.IsWindows())
9090
{
91-
if (host.StartsWith(unixPortNamePrefix))
92-
host = host.Substring(unixPortNamePrefix.Length);
91+
if (portName.StartsWith(unixPortNamePrefix))
92+
portName = portName.Substring(unixPortNamePrefix.Length);
9393
}
94-
return $"{URI_SCHEMA}://{host}";
94+
return $"{URI_SCHEMA}://./{portName}";
9595
}
9696

9797
public static void RegisterUriSchema()

Quick.Protocol.SerialPort/QpSerialPortServer.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
using Quick.Protocol.Utils;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.IO;
5-
using System.Text;
62
using System.Threading;
73
using System.Threading.Tasks;
84

@@ -58,17 +54,11 @@ protected override Task InnerAcceptAsync(CancellationToken token)
5854
if (isAccepted)
5955
return Task.Delay(1000, token);
6056
isAccepted = true;
61-
57+
6258
return Task.Run(() =>
6359
{
6460
if (!serialPort.IsOpen)
6561
serialPort.Open();
66-
var line = serialPort.ReadLine();
67-
if (QpConsts.QuickProtocolNameAndVersion != line)
68-
{
69-
isAccepted = false;
70-
throw new IOException("Protocol not match.");
71-
}
7262
}, token)
7363
.ContinueWith(task =>
7464
{

Quick.Protocol/QpConsts.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ public class QpConsts
88
{
99
public const string QUICK_PROTOCOL_NAME = "Quick.Protocol";
1010
public const string QUICK_PROTOCOL_VERSION = "2.0";
11-
public static readonly string QuickProtocolNameAndVersion = $"{QUICK_PROTOCOL_NAME}_{QUICK_PROTOCOL_VERSION}";
1211
}
1312
}

0 commit comments

Comments
 (0)