tool/SdoCommand.cpp
changeset 1184 75cd6681eb08
child 1327 4d179b06dd3c
equal deleted inserted replaced
1183:d77f634ab0b5 1184:75cd6681eb08
       
     1 /*****************************************************************************
       
     2  *
       
     3  * $Id$
       
     4  *
       
     5  ****************************************************************************/
       
     6 
       
     7 #include "SdoCommand.h"
       
     8 
       
     9 /*****************************************************************************/
       
    10 
       
    11 SdoCommand::SdoCommand(const string &name, const string &briefDesc):
       
    12     Command(name, briefDesc)
       
    13 {
       
    14 }
       
    15 
       
    16 /****************************************************************************/
       
    17 
       
    18 const SdoCommand::DataType *SdoCommand::findDataType(const string &str)
       
    19 {
       
    20     const DataType *d;
       
    21     
       
    22     for (d = dataTypes; d->name; d++)
       
    23         if (str == d->name)
       
    24             return d;
       
    25 
       
    26     return NULL;
       
    27 }
       
    28 
       
    29 /****************************************************************************/
       
    30 
       
    31 const SdoCommand::DataType *SdoCommand::findDataType(uint16_t code)
       
    32 {
       
    33     const DataType *d;
       
    34     
       
    35     for (d = dataTypes; d->name; d++)
       
    36         if (code == d->coeCode)
       
    37             return d;
       
    38 
       
    39     return NULL;
       
    40 }
       
    41 
       
    42 /****************************************************************************/
       
    43 
       
    44 const char *SdoCommand::abortText(uint32_t abortCode)
       
    45 {
       
    46     const AbortMessage *abortMsg;
       
    47 
       
    48     for (abortMsg = abortMessages; abortMsg->code; abortMsg++) {
       
    49         if (abortMsg->code == abortCode) {
       
    50             return abortMsg->message;
       
    51         }
       
    52     }
       
    53 
       
    54     return "???";
       
    55 }
       
    56 
       
    57 /****************************************************************************/
       
    58 
       
    59 const SdoCommand::DataType SdoCommand::dataTypes[] = {
       
    60     {"int8",   0x0002, 1},
       
    61     {"int16",  0x0003, 2},
       
    62     {"int32",  0x0004, 4},
       
    63     {"uint8",  0x0005, 1},
       
    64     {"uint16", 0x0006, 2},
       
    65     {"uint32", 0x0007, 4},
       
    66     {"string", 0x0009, 0},
       
    67     {"raw",    0xffff, 0},
       
    68     {}
       
    69 };
       
    70 
       
    71 /*****************************************************************************/
       
    72 
       
    73 /** Sdo abort messages.
       
    74  *
       
    75  * The "Abort Sdo transfer request" supplies an abort code, which can be
       
    76  * translated to clear text. This table does the mapping of the codes and
       
    77  * messages.
       
    78  */
       
    79 const SdoCommand::AbortMessage SdoCommand::abortMessages[] = {
       
    80     {0x05030000, "Toggle bit not changed"},
       
    81     {0x05040000, "Sdo protocol timeout"},
       
    82     {0x05040001, "Client/Server command specifier not valid or unknown"},
       
    83     {0x05040005, "Out of memory"},
       
    84     {0x06010000, "Unsupported access to an object"},
       
    85     {0x06010001, "Attempt to read a write-only object"},
       
    86     {0x06010002, "Attempt to write a read-only object"},
       
    87     {0x06020000, "This object does not exist in the object directory"},
       
    88     {0x06040041, "The object cannot be mapped into the Pdo"},
       
    89     {0x06040042, "The number and length of the objects to be mapped would"
       
    90      " exceed the Pdo length"},
       
    91     {0x06040043, "General parameter incompatibility reason"},
       
    92     {0x06040047, "Gerneral internal incompatibility in device"},
       
    93     {0x06060000, "Access failure due to a hardware error"},
       
    94     {0x06070010, "Data type does not match, length of service parameter does"
       
    95      " not match"},
       
    96     {0x06070012, "Data type does not match, length of service parameter too"
       
    97      " high"},
       
    98     {0x06070013, "Data type does not match, length of service parameter too"
       
    99      " low"},
       
   100     {0x06090011, "Subindex does not exist"},
       
   101     {0x06090030, "Value range of parameter exceeded"},
       
   102     {0x06090031, "Value of parameter written too high"},
       
   103     {0x06090032, "Value of parameter written too low"},
       
   104     {0x06090036, "Maximum value is less than minimum value"},
       
   105     {0x08000000, "General error"},
       
   106     {0x08000020, "Data cannot be transferred or stored to the application"},
       
   107     {0x08000021, "Data cannot be transferred or stored to the application"
       
   108      " because of local control"},
       
   109     {0x08000022, "Data cannot be transferred or stored to the application"
       
   110      " because of the present device state"},
       
   111     {0x08000023, "Object dictionary dynamic generation fails or no object"
       
   112      " dictionary is present"},
       
   113     {}
       
   114 };
       
   115 
       
   116 /****************************************************************************/