Skip to content

Commit

Permalink
Merge pull request #2 from bobzomer/add-error-description
Browse files Browse the repository at this point in the history
Add error description
  • Loading branch information
mcNets authored Jun 9, 2022
2 parents f031c6f + 6f6e9ad commit c9f9349
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 4 deletions.
90 changes: 90 additions & 0 deletions mc.omron.v1.00/FINSCommands/IFinsCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace mcOMRON
{
Expand Down Expand Up @@ -47,6 +48,95 @@ enum FinsCommands
ControllerDataRead,
};

class FinsErrorCodes
{
public static IDictionary<byte, string> ErrorCodes { get; } = new Dictionary<byte, string> {
{ 0x0, "No Error" },
{ 0x1, "Invalid Memory Address Parameter" },
{ 0x2, "Invalid or Illegal Command Param" },
{ 0x3, "Response SID did not match" },
{ 0x4, "NSB did not respond to send req" },
{ 0x5, "Timed Out - No Response" },
{ 0x6, "Timed Out Waiting For Response" },
{ 0x7, "Bad Received CRC" },
{ 0x8, "Unmatched Message IDs" },
{ 0x9, "Unmatched Command/Response" },
{ 0xa, "Unknown Error" },
{ 0xb, "Network Address Out Of Range" },
{ 0xc, "Node Address Out Of Range" },
{ 0xd, "Unit Address Out Of Range" },
{ 0xe, "Invalid Address Parameter" },
{ 0xf, "Timed Out waiting for echo" },
{ 0x10, "Bad Received FCS" },
{ 0x11, "Response from different Host Link Unit" },
{ 0x12, "No Valid Response Code" },
{ 0x13, "No FINS Response Packet" },
{ 0x14, "Unknown Error Code" },
{ 0x15, "Local Node not part of Network" },
{ 0x16, "Token Timeout, Node # too High" },
{ 0x17, "Number of Transmit Retries Exceeded" },
{ 0x18, "Max # of Frames Exceeded" },
{ 0x19, "Node # Setting Error" },
{ 0x1a, "Node # Duplication Error" },
{ 0x1b, "Dest Node not part of Network" },
{ 0x1c, "No Node with Node # Specified" },
{ 0x1d, "Third Node not part of Network" },
{ 0x1e, "Busy Error, Dest Node Busy" },
{ 0x1f, "Response Timeout, Noise or Watchdog" },
{ 0x20, "Error in Comm Controller" },
{ 0x21, "PLC Error in Dest Node" },
{ 0x23, "Undefined Command Used" },
{ 0x24, "Cannot Process Command" },
{ 0x25, "Routing Error" },
{ 0x26, "Command is too Long" },
{ 0x27, "Command is too Short" },
{ 0x28, "Specified Data Items != Actual" },
{ 0x29, "Incorrect Command Format" },
{ 0x2a, "Incorrect Header" },
{ 0x2b, "Memory Area Code Error" },
{ 0x2c, "Access Size Specified is Wrong" },
{ 0x2d, "First Address is Inaccessible" },
{ 0x2e, "Address Range Exceeded" },
{ 0x2f, "Unknown Error Code" },
{ 0x30, "Non-existent Program # Specified" },
{ 0x31, "Unknown Error Code" },
{ 0x32, "Unknown Error Code" },
{ 0x33, "Data Size in Command is Wrong" },
{ 0x34, "Unknown Error Code" },
{ 0x35, "Response Block too Long" },
{ 0x36, "Incorrect Parameter Code" },
{ 0x37, "Program Area Protected" },
{ 0x38, "Registered Table Error" },
{ 0x39, "Area Read-Only or Write Protected" },
{ 0x3b, "Mode is Wrong" },
{ 0x3c, "Mode is Wrong (Running)" },
{ 0x3d, "PLC is in Program Mode" },
{ 0x3e, "PLC is in Debug Mode" },
{ 0x3f, "PLC is in Monitor Mode" },
{ 0x40, "PLC is in Run Mode" },
{ 0x41, "Specified Node is not Control Node" },
{ 0x42, "Specified Memory does not Exist" },
{ 0x43, "No Clock Exists" },
{ 0x44, "Data Link Table Error" },
{ 0x45, "Unit Error" },
{ 0x46, "Command Error" },
{ 0x47, "Destination Address Setting Error" },
{ 0x48, "No Routing Tables" },
{ 0x49, "Routing Table Error" },
{ 0x4a, "Too Many Relays" },
{ 0x4b, "The Header is not FINS" },
{ 0x4c, "The Data Length is too Long" },
{ 0x4d, "The Command is not Supported" },
{ 0x50, "Timed Out waiting for Port Semaphore" },
{ 0x5e, "All Connections are in Use" },
{ 0x5f, "The Specified Node is Already Connected" },
{ 0x60, "Attempt to Access Protected Node from Unspecified IP" },
{ 0x61, "The Client FINS Node Address is OOR" },
{ 0x62, "Same FINS Node Address is being used by Client and Server" },
{ 0x63, "No Node Addresses are Available to Allocate" },
};
}

#endregion


Expand Down
9 changes: 5 additions & 4 deletions mc.omron.v1.00/FINSCommands/tcpFinsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,10 @@ public bool NodeAddressDataSend()

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

// no more actions
//
Expand Down Expand Up @@ -759,4 +760,4 @@ public string LastDialog(string Caption)
#endregion
}
}


0 comments on commit c9f9349

Please sign in to comment.