Merge
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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]);
|
||||||
|
|||||||
Reference in New Issue
Block a user