From e7485ac5b04d2b68b63816336c1a8b2104cf9282 Mon Sep 17 00:00:00 2001 From: Candy Date: Wed, 7 Apr 2021 22:05:02 +0800 Subject: [PATCH] =?UTF-8?q?Modbus=20=E4=B8=B2=E5=8F=A3=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Run/Driver/Cdy.Spider.ModbusDriver/ModbusSeriseDriver.cs | 2 +- .../Cdy.Spider.SerisePortClient/SerisePortClientChannel.cs | 7 ++++++- Spider.sln | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Run/Driver/Cdy.Spider.ModbusDriver/ModbusSeriseDriver.cs b/Run/Driver/Cdy.Spider.ModbusDriver/ModbusSeriseDriver.cs index e20a6db7..c76a4f4a 100644 --- a/Run/Driver/Cdy.Spider.ModbusDriver/ModbusSeriseDriver.cs +++ b/Run/Driver/Cdy.Spider.ModbusDriver/ModbusSeriseDriver.cs @@ -64,7 +64,7 @@ public class ModbusSeriseDriver:TimerDriverRunner /// /// /// - public override DriverData Data => base.Data; + public override DriverData Data => mData; #endregion ...Properties... diff --git a/Run/Driver/Cdy.Spider.SerisePortClient/SerisePortClientChannel.cs b/Run/Driver/Cdy.Spider.SerisePortClient/SerisePortClientChannel.cs index 11407ba0..e75300db 100644 --- a/Run/Driver/Cdy.Spider.SerisePortClient/SerisePortClientChannel.cs +++ b/Run/Driver/Cdy.Spider.SerisePortClient/SerisePortClientChannel.cs @@ -62,6 +62,11 @@ public class SerisePortClientChannel : ChannelBase #region ... Methods ... + public void TestOpen() + { + mClient = new System.IO.Ports.SerialPort("Com2", 9600); + } + /// /// /// @@ -145,7 +150,7 @@ private void ThreadPro() { while (!mIsClosed) { - if (mClient != null && mClient.BytesToRead > 0 && !mIsTransparentRead) + if (mClient.IsOpen && mClient != null && mClient.BytesToRead > 0 && !mIsTransparentRead) { var vdlen = mClient.BytesToRead; diff --git a/Spider.sln b/Spider.sln index d617abeb..ac4f2f41 100644 --- a/Spider.sln +++ b/Spider.sln @@ -67,7 +67,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cdy.Spider.UdpClient.Develo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cdy.Spider.SerisePortClient.Develop", "Cdy.Spider.SerisePortClient.Develop\Cdy.Spider.SerisePortClient.Develop.csproj", "{CD41D8D2-741C-4CE2-A5BD-75A37E18A500}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cdy.Spider.ModbusDriver.Develop", "Develop\Drivers\Cdy.Spider.ModbusDriver.Develop\Cdy.Spider.ModbusDriver.Develop.csproj", "{C8842128-A394-4478-B823-5CBCB324F567}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cdy.Spider.ModbusDriver.Develop", "Develop\Drivers\Cdy.Spider.ModbusDriver.Develop\Cdy.Spider.ModbusDriver.Develop.csproj", "{C8842128-A394-4478-B823-5CBCB324F567}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution