2017-10-21 Update 1 Emergency Fix Siemens Error Throw Fix.

This commit is contained in:
parallelbgls
2017-10-21 09:37:27 +08:00
parent 0fd8871ee4
commit ee9415f0e6
4 changed files with 18 additions and 3 deletions

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.Siemens.Core</AssemblyName> <AssemblyName>Modbus.Net.Siemens.Core</AssemblyName>
<RootNamespace>Modbus.Net.Siemens</RootNamespace> <RootNamespace>Modbus.Net.Siemens</RootNamespace>
<PackageId>Modbus.Net.Siemens.Core</PackageId> <PackageId>Modbus.Net.Siemens.Core</PackageId>
<Version>1.3.10</Version> <Version>1.3.10.2</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
<Description>Modbus.Net Siemens Profinet Implementation</Description> <Description>Modbus.Net Siemens Profinet Implementation</Description>

View File

@@ -5,7 +5,7 @@
<AssemblyName>Modbus.Net.Siemens</AssemblyName> <AssemblyName>Modbus.Net.Siemens</AssemblyName>
<RootNamespace>Modbus.Net.Siemens</RootNamespace> <RootNamespace>Modbus.Net.Siemens</RootNamespace>
<PackageId>Modbus.Net.Siemens</PackageId> <PackageId>Modbus.Net.Siemens</PackageId>
<Version>1.3.10</Version> <Version>1.3.10.2</Version>
<Authors>Chris L.(Luo Sheng)</Authors> <Authors>Chris L.(Luo Sheng)</Authors>
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company> <Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
<Description>Modbus.Net Siemens Profinet Implementation</Description> <Description>Modbus.Net Siemens Profinet Implementation</Description>

View File

@@ -860,13 +860,26 @@ namespace Modbus.Net.Siemens
{0xEF, "Layer 2 specific error"} {0xEF, "Layer 2 specific error"}
}; };
private static readonly Dictionary<int, string> ProtocalErrorDetailDictionary = new Dictionary<int, string>
{
{0x8304, "Resource not available,\r\n there are no more resources available for application associations to be established" },
{0x8104, "Context is not supported:\r\n -Error in PDU structure\r\n -Unknown service" },
{0x8404, "Fatal error detected.\r\n Service or function aborted" },
{0x8500, "PDU size error"}
};
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="errCls">错误分类</param> /// <param name="errCls">错误分类</param>
/// <param name="errCod">错误码</param> /// <param name="errCod">错误码</param>
public SiemensProtocalErrorException(int errCls, int errCod) public SiemensProtocalErrorException(int errCls, int errCod)
: base(ProtocalErrorDictionary[errCls] + " : " + errCod) : base((ProtocalErrorDictionary.ContainsKey(errCls)
? ProtocalErrorDictionary[errCls]
: "Unknown error") + " \r\n " +
(ProtocalErrorDetailDictionary.ContainsKey(errCls * 256 + errCod)
? ProtocalErrorDetailDictionary[errCls * 256 + errCod]
: "Unknown error detail"))
{ {
ErrorClass = errCls; ErrorClass = errCls;
ErrorCode = errCod; ErrorCode = errCod;

View File

@@ -43,6 +43,8 @@ namespace Modbus.Net.Siemens
case 0xf0: case 0xf0:
switch (content[8]) switch (content[8])
{ {
case 0x01:
case 0x02:
case 0x03: case 0x03:
if (content[17] == 0x00 && content[18] == 0x00) return true; if (content[17] == 0x00 && content[18] == 0x00) return true;
throw new SiemensProtocalErrorException(content[17], content[18]); throw new SiemensProtocalErrorException(content[17], content[18]);