diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 index 0c0f44d..2a9d283 100644 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/IoTGateway/v16/.suo b/.vs/IoTGateway/v16/.suo index de2fcc3..6163207 100644 Binary files a/.vs/IoTGateway/v16/.suo and b/.vs/IoTGateway/v16/.suo differ diff --git a/IoTGateway/IoTGateway.csproj b/IoTGateway/IoTGateway.csproj index f9281df..e7baa97 100644 --- a/IoTGateway/IoTGateway.csproj +++ b/IoTGateway/IoTGateway.csproj @@ -20,6 +20,7 @@ + diff --git a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj index 8579554..cec66fb 100644 --- a/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj +++ b/Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj @@ -7,7 +7,11 @@ - + + + + + diff --git a/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs b/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs index fb1b49d..440ae77 100644 --- a/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs +++ b/Plugins/Drivers/DriverModbusMaster/ModbusMaster.cs @@ -74,7 +74,22 @@ namespace DriverModbusMaster { get { - return clientTcp != null && master != null && clientTcp.Connected; + switch (Master_TYPE) + { + case Master_TYPE.Tcp: + case Master_TYPE.RtuOnTcp: + case Master_TYPE.AsciiOnTcp: + return clientTcp != null && master != null && clientTcp.Connected; + case Master_TYPE.Udp: + case Master_TYPE.RtuOnUdp: + case Master_TYPE.AsciiOnUdp: + return clientUdp != null && master != null && clientUdp.Client.Connected ; + case Master_TYPE.Rtu: + case Master_TYPE.Ascii: + return port != null && master != null && port.IsOpen; + default: + return false; + } } } @@ -124,7 +139,7 @@ namespace DriverModbusMaster break; } } - catch (Exception) + catch (Exception ex) { return false; } @@ -225,7 +240,7 @@ namespace DriverModbusMaster private DriverReturnValueModel ReadRegistersBuffers(byte FunCode, DriverAddressIoArgModel ioarg) { DriverReturnValueModel ret = new() { StatusType = VaribaleStatusTypeEnum.Good }; - if (!clientTcp.Connected) + if (!IsConnected) ret.StatusType = VaribaleStatusTypeEnum.Bad; else { diff --git a/Plugins/Drivers/DriverModbusMaster/System.IO.Ports.dll b/Plugins/Drivers/DriverModbusMaster/System.IO.Ports.dll deleted file mode 100644 index bd5d3fb..0000000 Binary files a/Plugins/Drivers/DriverModbusMaster/System.IO.Ports.dll and /dev/null differ