Skip to content

Commit c9f9349

Browse files
authored
Merge pull request #2 from bobzomer/add-error-description
Add error description
2 parents f031c6f + 6f6e9ad commit c9f9349

File tree

2 files changed

+95
-4
lines changed

2 files changed

+95
-4
lines changed

mc.omron.v1.00/FINSCommands/IFinsCommand.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23

34
namespace mcOMRON
45
{
@@ -47,6 +48,95 @@ enum FinsCommands
4748
ControllerDataRead,
4849
};
4950

51+
class FinsErrorCodes
52+
{
53+
public static IDictionary<byte, string> ErrorCodes { get; } = new Dictionary<byte, string> {
54+
{ 0x0, "No Error" },
55+
{ 0x1, "Invalid Memory Address Parameter" },
56+
{ 0x2, "Invalid or Illegal Command Param" },
57+
{ 0x3, "Response SID did not match" },
58+
{ 0x4, "NSB did not respond to send req" },
59+
{ 0x5, "Timed Out - No Response" },
60+
{ 0x6, "Timed Out Waiting For Response" },
61+
{ 0x7, "Bad Received CRC" },
62+
{ 0x8, "Unmatched Message IDs" },
63+
{ 0x9, "Unmatched Command/Response" },
64+
{ 0xa, "Unknown Error" },
65+
{ 0xb, "Network Address Out Of Range" },
66+
{ 0xc, "Node Address Out Of Range" },
67+
{ 0xd, "Unit Address Out Of Range" },
68+
{ 0xe, "Invalid Address Parameter" },
69+
{ 0xf, "Timed Out waiting for echo" },
70+
{ 0x10, "Bad Received FCS" },
71+
{ 0x11, "Response from different Host Link Unit" },
72+
{ 0x12, "No Valid Response Code" },
73+
{ 0x13, "No FINS Response Packet" },
74+
{ 0x14, "Unknown Error Code" },
75+
{ 0x15, "Local Node not part of Network" },
76+
{ 0x16, "Token Timeout, Node # too High" },
77+
{ 0x17, "Number of Transmit Retries Exceeded" },
78+
{ 0x18, "Max # of Frames Exceeded" },
79+
{ 0x19, "Node # Setting Error" },
80+
{ 0x1a, "Node # Duplication Error" },
81+
{ 0x1b, "Dest Node not part of Network" },
82+
{ 0x1c, "No Node with Node # Specified" },
83+
{ 0x1d, "Third Node not part of Network" },
84+
{ 0x1e, "Busy Error, Dest Node Busy" },
85+
{ 0x1f, "Response Timeout, Noise or Watchdog" },
86+
{ 0x20, "Error in Comm Controller" },
87+
{ 0x21, "PLC Error in Dest Node" },
88+
{ 0x23, "Undefined Command Used" },
89+
{ 0x24, "Cannot Process Command" },
90+
{ 0x25, "Routing Error" },
91+
{ 0x26, "Command is too Long" },
92+
{ 0x27, "Command is too Short" },
93+
{ 0x28, "Specified Data Items != Actual" },
94+
{ 0x29, "Incorrect Command Format" },
95+
{ 0x2a, "Incorrect Header" },
96+
{ 0x2b, "Memory Area Code Error" },
97+
{ 0x2c, "Access Size Specified is Wrong" },
98+
{ 0x2d, "First Address is Inaccessible" },
99+
{ 0x2e, "Address Range Exceeded" },
100+
{ 0x2f, "Unknown Error Code" },
101+
{ 0x30, "Non-existent Program # Specified" },
102+
{ 0x31, "Unknown Error Code" },
103+
{ 0x32, "Unknown Error Code" },
104+
{ 0x33, "Data Size in Command is Wrong" },
105+
{ 0x34, "Unknown Error Code" },
106+
{ 0x35, "Response Block too Long" },
107+
{ 0x36, "Incorrect Parameter Code" },
108+
{ 0x37, "Program Area Protected" },
109+
{ 0x38, "Registered Table Error" },
110+
{ 0x39, "Area Read-Only or Write Protected" },
111+
{ 0x3b, "Mode is Wrong" },
112+
{ 0x3c, "Mode is Wrong (Running)" },
113+
{ 0x3d, "PLC is in Program Mode" },
114+
{ 0x3e, "PLC is in Debug Mode" },
115+
{ 0x3f, "PLC is in Monitor Mode" },
116+
{ 0x40, "PLC is in Run Mode" },
117+
{ 0x41, "Specified Node is not Control Node" },
118+
{ 0x42, "Specified Memory does not Exist" },
119+
{ 0x43, "No Clock Exists" },
120+
{ 0x44, "Data Link Table Error" },
121+
{ 0x45, "Unit Error" },
122+
{ 0x46, "Command Error" },
123+
{ 0x47, "Destination Address Setting Error" },
124+
{ 0x48, "No Routing Tables" },
125+
{ 0x49, "Routing Table Error" },
126+
{ 0x4a, "Too Many Relays" },
127+
{ 0x4b, "The Header is not FINS" },
128+
{ 0x4c, "The Data Length is too Long" },
129+
{ 0x4d, "The Command is not Supported" },
130+
{ 0x50, "Timed Out waiting for Port Semaphore" },
131+
{ 0x5e, "All Connections are in Use" },
132+
{ 0x5f, "The Specified Node is Already Connected" },
133+
{ 0x60, "Attempt to Access Protected Node from Unspecified IP" },
134+
{ 0x61, "The Client FINS Node Address is OOR" },
135+
{ 0x62, "Same FINS Node Address is being used by Client and Server" },
136+
{ 0x63, "No Node Addresses are Available to Allocate" },
137+
};
138+
}
139+
50140
#endregion
51141

52142

mc.omron.v1.00/FINSCommands/tcpFinsCommand.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,10 @@ public bool NodeAddressDataSend()
489489

490490
// checks response error
491491
//
492-
if (respNADS[15] != 0)
493-
{
494-
this._lastError = "NASD command error: " + respNADS[15];
492+
if (respNADS[15] != 0) {
493+
if (!FinsErrorCodes.ErrorCodes.TryGetValue(respNADS[15], out string errorDescription))
494+
errorDescription = "Unknown error";
495+
this._lastError = "NADS command error: " + respNADS[15] + "(" + errorDescription + ")";
495496

496497
// no more actions
497498
//
@@ -759,4 +760,4 @@ public string LastDialog(string Caption)
759760
#endregion
760761
}
761762
}
762-
763+

0 commit comments

Comments
 (0)