class to handle CANopen types More...
#include <rlcanopentypes.h>
Public Types | |
| enum | rl_types { RL_BOOL = 0, RL_UCHAR, RL_SHORT, RL_USHORT, RL_INT, RL_LONG, RL_FLOAT, RL_DOUBLE, RL_LONGLONG, RL_STRING, RL_BUFFER, RL_ULONG, RL_ULONGLONG, RL_PDO = 13, RL_NODESTATE, RL_NOTYPE = 0xFF } |
| enum | canopen_types { c_BOOLEAN = 0x0001, INTEGER8_t = 0x0002, INTEGER16_t = 0x0003, INTEGER32_t = 0x0004, UNSIGNED8_t = 0x0005, UNSIGNED16_t = 0x0006, UNSIGNED32_t = 0x0007, REAL32_t = 0x0008, VISIBLE_STRING = 0x0009, OCTET_STRING_t = 0x000A, UNICODE_STRING = 0x000B, TIME_OF_DAY_t = 0x000C, TIME_DIFFERENC = 0x000D, BIT_STRING_t = 0x000E, DOMAIN_t = 0x000F, INTEGER24_t = 0x0010, REAL64_t = 0x0011, INTEGER40_t = 0x0012, INTEGER48_t = 0x0013, INTEGER56_t = 0x0014, INTEGER64_t = 0x0015, UNSIGNED24_t = 0x0016, RESERVED1_t = 0x0017, UNSIGNED40_t = 0x0018, UNSIGNED48_t = 0x0019, UNSIGNED56_t = 0x001A, UNSIGNED64_t = 0x001B } |
Public Member Functions | |
| rlCanOpenTypes () | |
| Constructor initializes with RL_NOTYPE. | |
| int | getLength () |
| returns number of bytes used for current type | |
| void | clearBuffer () |
| sets all bytes in databuffer to zero | |
| void | set_DaemonType (rl_types _type) |
| alternative setter receives integer typenumber | |
| void | set_DaemonType (int _type) |
| alternative setter receives integer typenumber | |
| int | get_DaemonType () |
| returns current of data stored in databuffer | |
| void | set_CanOpenType (int _type) |
| recieves an CANopen typenumber and returns appropiate RL-Type | |
| int | get_CanOpenType () |
| returns the current type converted to CANopen typenumber | |
| void | set_int (int _value) |
| sets type to RL_INT and stores passed parameter data in databuffer | |
| int | get_int () |
| returns databuffer-content as integer type. | |
| void | set_float (float _value) |
| sets type to RL_FLOAT and stores passed parameter data in databuffer | |
| float | get_float () |
| returns databuffer-content as float type. | |
| void | set_double (double _value) |
| sets type to RL_DOUBLE and stores passed parameter data in databuffer | |
| double | get_double () |
| returns databuffer-content as double type. | |
| void | set_short (short _value) |
| sets type to RL_SHORT and stores passed parameter data in databuffer | |
| short | get_short () |
| returns databuffer-content as short type | |
| void | set_ushort (unsigned short _value) |
| sets type to RL_USHORT and stores passed parameter data in databuffer | |
| unsigned short | get_ushort () |
| returns databuffer-content as short type | |
| void | set_longlong (long int _value) |
| sets type to RL_LONGLONG and stores passed parameter data in databuffer | |
| long int | get_longlong () |
| returns databuffer-content as long long type | |
| void | set_string (const char *_value) |
| char * | get_string () |
| creates string filled with databuffer-content and returns a pointer | |
| void | set_buffer (int _index, unsigned char _databyte) |
| transfer raw data into the databuffer | |
| unsigned char | get_buffer (int _index) |
| returns 1 byte from databuffer | |
| void | set_uchar (unsigned char _value) |
| sets type to RL_UCHAR and stores passed parameter data in databuffer | |
| unsigned char | get_uchar () |
| returns databuffer-content as uchar type | |
| void | set_bool (bool _value) |
| sets type to RL_BOOL and stores passed parameter data in databuffer | |
| bool | get_bool () |
| returns databuffer-content as bool type | |
| void | set_long (long _value) |
| sets type to RL_LONG and stores passed parameter data in databuffer | |
| long | get_long () |
| returns databuffer-content as long type | |
| void | set_ulong (unsigned long _value) |
| sets type to RL_ULONG and stores passed parameter data in databuffer | |
| unsigned long | get_ulong () |
| returns databuffer-content as unsigned long type | |
| void | set_ulonglong (unsigned long int _value) |
| sets type to RL_ULONGLONG and stores passed parameter data in databuffer | |
| unsigned long int | get_ulonglong () |
| returns databuffer-content as unsigned long long type | |
| void | set_rlmsgerr (long _errnr) |
| sets the errornumber. refer private varibale rlmsgerr for details | |
| long | get_rlmsgerr () |
| returns current errnumber | |
| void | set_nodestateFlags (unsigned char _bNodeNoResponse, unsigned char _bEmcyBuffOverflow, unsigned char _bPrmFault, unsigned char _bGuardActive, unsigned char _bDeactivated) |
| sets type to RL_NODESTATE. Stores flag-data received from the device. | |
| bool | get_nodestateFlags (bool &_bNodeNoResponse, bool &_bEmcyBuffOverflow, bool &_bPrmFault, bool &_bGuardActive, bool &_bDeactivated) |
| bool | get_nodestateFlag_NoResponse () |
| read particular nodestade with the following functions | |
| bool | get_nodestateFlag_EmcyBuffOverflow () |
| bool | get_nodestateFlag_PrmFault () |
| bool | get_nodestateFlag_GuardActive () |
| bool | get_nodestateFlag_Deactivated () |
| void | set_nodestate (unsigned char _nodestate) |
| sets current state of node. | |
| unsigned char | get_nodestate () |
| returns the nodestate. refer code numbers above | |
| void | set_nodeerror (unsigned char _nodeerror) |
| unsigned char | get_nodeerror () |
| returns actual node error | |
| void | buf2pdobuf () |
| exchange bytes 0-7 from databuffer to pdobuffer | |
| void | pdobuf2buf () |
| exchange bytes 0-7 from pdobuffer to databuffer | |
| rlCanOpenTypes & | operator= (rlCanOpenTypes &cp) |
| copies all data from right object into left object | |
| IPCMSGSTRUCT | createIpcMsg () |
| returns a IPCMSGSTRUCT filled with current object data | |
| void | getIpcMsg (IPCMSGSTRUCT _myIpcMsg) |
| overwrites all data with IPCMSGSTRUCT data | |
| void | rlMsgErrOut () |
| prints MsgErrStr to StdOut | |
| char * | rlMsgErrStr () |
| * returns a pointer to a new 22 character string containing name of error in rlmsgerr | |
| char * | type2str (int _typenr) |
| returns a pointer to a new 12 character string containing the name of the type | |
| bool | translate_CanOpenType (int _canopentype) |
| int | get_CanOpenTypeLength (int _canopentype) |
Static Public Member Functions | |
| static int | canOpenType2DeamonType (int _canopentype) |
| Function for typenumber conversion. | |
| static int | deamonType2CanOpenType (int _deamontype) |
| Function for typenumber conversion. | |
Public Attributes | |
| unsigned char | pdobuffer [8] |
| external buffer for pdotransfer | |
| int | t_int |
| float | t_float |
| double | t_double |
| short | t_short |
| unsigned short | t_ushort |
| long int | t_longlong |
| char | t_string [247] |
| unsigned char | t_databytes [247] |
| unsigned char | t_databyte |
| bool | t_bool |
| long | t_long |
| unsigned long | t_ulong |
| unsigned long int | t_ulonglong |
| unsigned char | bNodeNoResponse: 1 |
| unsigned char | bEmcyBuffOverflow: 1 |
| unsigned char | bPrmFault: 1 |
| unsigned char | bGuardActive: 1 |
| unsigned char | bDeactivated: 1 |
| unsigned char | bNodeState |
| unsigned char | bActualError |
| struct { | |
| unsigned char bNodeNoResponse: 1 | |
| unsigned char bEmcyBuffOverflow: 1 | |
| unsigned char bPrmFault: 1 | |
| unsigned char bGuardActive: 1 | |
| unsigned char bDeactivated: 1 | |
| unsigned char bNodeState | |
| unsigned char bActualError | |
| } | bNodeFlagState |
Private Member Functions | |
| void | invalidTypeError (int _typenr) |
Private Attributes | |
| int | typenumber |
| long | rlmsgerr |
| union { | |
| int t_int | |
| float t_float | |
| double t_double | |
| short t_short | |
| unsigned short t_ushort | |
| long int t_longlong | |
| char t_string [247] | |
| unsigned char t_databytes [247] | |
| unsigned char t_databyte | |
| bool t_bool | |
| long t_long | |
| unsigned long t_ulong | |
| unsigned long int t_ulonglong | |
| struct { | |
| unsigned char bNodeNoResponse: 1 | |
| unsigned char bEmcyBuffOverflow: 1 | |
| unsigned char bPrmFault: 1 | |
| unsigned char bGuardActive: 1 | |
| unsigned char bDeactivated: 1 | |
| unsigned char bNodeState | |
| unsigned char bActualError | |
| } bNodeFlagState | |
| }; | |
class to handle CANopen types
Can nodes contain data objects of any type. It is necessary to convert type secure data into type insecure rawdata to transfer it over the canbus. Therefore this class helps to convert raw canbus data easily. To prevent users from reading out raw data with a wrong type (e.g. performing get_int() when a float number is stored in this class), a type number indicates the currently stored datatype. Everytime such a type violation occurs, a warning is written to stdout.
Definition at line 38 of file rlcanopentypes.h.
Definition at line 60 of file rlcanopentypes.h.
00060 { 00061 00062 c_BOOLEAN = 0x0001, 00063 INTEGER8_t = 0x0002, 00064 INTEGER16_t = 0x0003, 00065 INTEGER32_t = 0x0004, 00066 UNSIGNED8_t = 0x0005, 00067 UNSIGNED16_t = 0x0006, 00068 UNSIGNED32_t = 0x0007, 00069 REAL32_t = 0x0008, 00070 VISIBLE_STRING = 0x0009, 00071 OCTET_STRING_t = 0x000A, 00072 UNICODE_STRING = 0x000B, 00073 TIME_OF_DAY_t = 0x000C, 00074 TIME_DIFFERENC = 0x000D, 00075 BIT_STRING_t = 0x000E, 00076 DOMAIN_t = 0x000F, 00077 INTEGER24_t = 0x0010, 00078 REAL64_t = 0x0011, 00079 INTEGER40_t = 0x0012, 00080 INTEGER48_t = 0x0013, 00081 INTEGER56_t = 0x0014, 00082 INTEGER64_t = 0x0015, 00083 UNSIGNED24_t = 0x0016, 00084 RESERVED1_t = 0x0017, 00085 UNSIGNED40_t = 0x0018, 00086 UNSIGNED48_t = 0x0019, 00087 UNSIGNED56_t = 0x001A, 00088 UNSIGNED64_t = 0x001B 00089 };
| RL_BOOL | |
| RL_UCHAR | |
| RL_SHORT | |
| RL_USHORT | |
| RL_INT | |
| RL_LONG | |
| RL_FLOAT | |
| RL_DOUBLE | |
| RL_LONGLONG | |
| RL_STRING | |
| RL_BUFFER | |
| RL_ULONG | |
| RL_ULONGLONG | |
| RL_PDO | |
| RL_NODESTATE | |
| RL_NOTYPE |
Definition at line 40 of file rlcanopentypes.h.
| rlCanOpenTypes::rlCanOpenTypes | ( | ) |
Constructor initializes with RL_NOTYPE.
Definition at line 24 of file rlcanopentypes.cpp.
00024 { 00025 typenumber = RL_NOTYPE; 00026 rlmsgerr = 0; 00027 clearBuffer(); 00028 }
| void rlCanOpenTypes::buf2pdobuf | ( | ) |
exchange bytes 0-7 from databuffer to pdobuffer
Definition at line 434 of file rlcanopentypes.cpp.
00434 { 00435 for (int i=0; i<8; i++){ 00436 pdobuffer[i]=t_databytes[i]; 00437 } 00438 typenumber = RL_PDO; 00439 }
| int rlCanOpenTypes::canOpenType2DeamonType | ( | int | _canopentype | ) | [static] |
Function for typenumber conversion.
Function for typenumber conversion. CANopen-Type differs between 27 primitive data types while DaemonType only consists of 13 ANSI C data types an two more daemon specific tyes: RL_PDO and RL_NOTYPE which indicates that no type is defined for raw data placed in this classes databuffer.
Definition at line 86 of file rlcanopentypes.cpp.
00087 { 00088 // refer table Data Types on page 11 in CiA CANopen Specification 00089 00090 switch(_canopentype) { 00091 case 0x0001:return RL_BOOL; // c_BOOLEAN 00092 case 0x0002:return RL_SHORT; // INTEGER8_t 00093 case 0x0003:return RL_SHORT; // INTEGER16_t 00094 case 0x0004:return RL_LONG; // INTEGER32_t 00095 case 0x0005:return RL_UCHAR; // UNSIGNED8_t 00096 case 0x0006:return RL_USHORT; // UNSIGNED16_t 00097 case 0x0007:return RL_ULONG; // UNSIGNED32_t 00098 case 0x0008:return RL_FLOAT; // REAL32_t 00099 case 0x0009:return RL_STRING; // VISIBLE_STRING 00100 case 0x000A:return RL_STRING; // OCTET_STRING_t 00101 case 0x000B:return RL_STRING; // UNICODE_STRING 00102 case 0x000C:return RL_ULONGLONG; // TIME_OF_DAY_t 00103 case 0x000D:return RL_ULONGLONG; // TIME_DIFFERENC 00104 case 0x000E:return RL_BUFFER; // BIT_STRING_t 00105 case 0x000F:return RL_BUFFER; // DOMAIN_t 00106 case 0x0010:return RL_ULONG; // INTEGER24_t 00107 case 0x0011:return RL_DOUBLE; // REAL64_t 00108 case 0x0012:return RL_LONGLONG; // INTEGER40_t 00109 case 0x0013:return RL_LONGLONG; // INTEGER48_t 00110 case 0x0014:return RL_LONGLONG; // INTEGER56_t 00111 case 0x0015:return RL_LONGLONG; // INTEGER64_t 00112 case 0x0016:return RL_ULONG; // UNSIGNED24_t 00113 case 0x0017:return RL_BUFFER; // RESERVED1_t 00114 case 0x0018:return RL_ULONGLONG; // UNSIGNED40_t 00115 case 0x0019:return RL_ULONGLONG; // UNSIGNED48_t 00116 case 0x001A:return RL_ULONGLONG; // UNSIGNED56_t 00117 case 0x001B:return RL_ULONGLONG; // UNSIGNED64_t 00118 default :return RL_NOTYPE; // ERROR 00119 } 00120 }
| void rlCanOpenTypes::clearBuffer | ( | ) |
sets all bytes in databuffer to zero
Definition at line 54 of file rlcanopentypes.cpp.
00054 { 00055 for (int i=0; i<247; i++){ 00056 t_databytes[i] = 0; 00057 } 00058 }
| IPCMSGSTRUCT rlCanOpenTypes::createIpcMsg | ( | ) |
returns a IPCMSGSTRUCT filled with current object data
Definition at line 451 of file rlcanopentypes.cpp.
00451 { 00452 IPCMSGSTRUCT istruct; 00453 for (int i=0; i<247; i++){ 00454 istruct.mtext[i] = t_string[i]; 00455 } 00456 istruct.typenumber = typenumber; 00457 istruct.msgtype = -1; 00458 istruct.transfertype= -1; 00459 istruct.processid = -1; 00460 istruct.boardid = -1; 00461 istruct.nodeid = -1; 00462 istruct.objectindex = -1; 00463 istruct.subindex = -1; 00464 istruct.pdoid = -1; 00465 istruct.mappingid = -1; 00466 istruct.rlmsgerr = rlmsgerr; 00467 return istruct; 00468 }
| int rlCanOpenTypes::deamonType2CanOpenType | ( | int | _deamontype | ) | [static] |
Function for typenumber conversion.
Definition at line 124 of file rlcanopentypes.cpp.
00125 { 00126 00127 switch(_deamontype) { 00128 case RL_INT:return 0x0007; 00129 case RL_FLOAT:return 0x0008; 00130 case RL_DOUBLE:return 0x0011; 00131 case RL_SHORT:return 0x0003; 00132 case RL_USHORT:return 0x0006; 00133 case RL_LONGLONG:return 0x0015; 00134 case RL_STRING:return 0x0009; 00135 case RL_BUFFER:return 0x000A; 00136 case RL_UCHAR:return 0x0005;//??? 00137 case RL_BOOL:return 0x0001; 00138 case RL_LONG:return 0x0004; 00139 case RL_ULONG:return 0x0007; 00140 case RL_ULONGLONG:return 0x001B; 00141 case RL_PDO:return 0x000E; 00142 case RL_NOTYPE:return 0x0; 00143 default:return 0x0; 00144 } 00145 }
| bool rlCanOpenTypes::get_bool | ( | ) |
returns databuffer-content as bool type
returns databuffer-content as bool type. When type is not RL_BOOL this will produce an invalid-type-warning to stdout
Definition at line 303 of file rlcanopentypes.cpp.
00303 { 00304 if (typenumber != RL_BOOL){ 00305 invalidTypeError(RL_BOOL); 00306 } 00307 return t_bool; 00308 }
| unsigned char rlCanOpenTypes::get_buffer | ( | int | _index | ) |
returns 1 byte from databuffer
Definition at line 271 of file rlcanopentypes.cpp.
00271 { 00272 if (_index<247){ 00273 return t_databytes[_index]; 00274 } 00275 else 00276 { 00277 fprintf(stderr, "ERROR! get_buffer: INDEX OUT OF RANGE!\n"); 00278 return 0; 00279 } 00280 }
| int rlCanOpenTypes::get_CanOpenType | ( | ) |
returns the current type converted to CANopen typenumber
Definition at line 81 of file rlcanopentypes.cpp.
00081 { 00082 return deamonType2CanOpenType(typenumber); 00083 }
| int rlCanOpenTypes::get_CanOpenTypeLength | ( | int | _canopentype | ) |
Definition at line 648 of file rlcanopentypes.cpp.
00649 { 00650 switch (_canopentype){ 00651 case rlCanOpenTypes::INTEGER24_t :return 3; 00652 case rlCanOpenTypes::INTEGER40_t :return 5; 00653 case rlCanOpenTypes::INTEGER48_t :return 6; 00654 case rlCanOpenTypes::INTEGER56_t :return 7; 00655 case rlCanOpenTypes::UNSIGNED24_t:return 3; 00656 case rlCanOpenTypes::UNSIGNED40_t:return 5; 00657 case rlCanOpenTypes::UNSIGNED48_t:return 6; 00658 case rlCanOpenTypes::UNSIGNED56_t:return 7; 00659 default :return false; 00660 }; 00661 }
| int rlCanOpenTypes::get_DaemonType | ( | ) |
returns current of data stored in databuffer
Definition at line 71 of file rlcanopentypes.cpp.
00071 { 00072 return typenumber; 00073 }
| double rlCanOpenTypes::get_double | ( | ) |
returns databuffer-content as double type.
returns databuffer-content as double type. When type is not RL_DOUBLE this will produce an invalid-type-warning to stdout
Definition at line 183 of file rlcanopentypes.cpp.
00183 { 00184 if (typenumber != RL_DOUBLE){ 00185 invalidTypeError(RL_DOUBLE); 00186 } 00187 return t_double; 00188 }
| float rlCanOpenTypes::get_float | ( | ) |
returns databuffer-content as float type.
returns databuffer-content as float type. When type is not RL_FLOAT this will produce an invalid-type-warning to stdout
Definition at line 169 of file rlcanopentypes.cpp.
00169 { 00170 if (typenumber != RL_FLOAT){ 00171 invalidTypeError(RL_FLOAT); 00172 } 00173 return t_float; 00174 }
| int rlCanOpenTypes::get_int | ( | ) |
returns databuffer-content as integer type.
returns databuffer-content as integer type. When type is not RL_INT this will produce an invalid-type-warning to stdout
Definition at line 154 of file rlcanopentypes.cpp.
00154 { 00155 if (typenumber != RL_INT){ 00156 invalidTypeError(RL_INT); 00157 00158 } 00159 return t_int; 00160 }
| long rlCanOpenTypes::get_long | ( | ) |
returns databuffer-content as long type
returns databuffer-content as long type. When type is not RL_LONG this will produce an invalid-type-warning to stdout
Definition at line 316 of file rlcanopentypes.cpp.
00316 { 00317 if (typenumber != RL_LONG){ 00318 invalidTypeError(RL_LONG); 00319 } 00320 return t_long; 00321 }
| long int rlCanOpenTypes::get_longlong | ( | ) |
returns databuffer-content as long long type
returns databuffer-content as long long type. When type is not RL_LONGLONG this will produce an invalid-type-warning to stdout
Definition at line 226 of file rlcanopentypes.cpp.
00226 { 00227 if (typenumber != RL_LONGLONG){ 00228 invalidTypeError(RL_LONGLONG); 00229 } 00230 return t_longlong; 00231 }
| unsigned char rlCanOpenTypes::get_nodeerror | ( | ) |
returns actual node error
Definition at line 539 of file rlcanopentypes.cpp.
00540 { 00541 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00542 return bNodeFlagState.bActualError; 00543 }
| unsigned char rlCanOpenTypes::get_nodestate | ( | ) |
returns the nodestate. refer code numbers above
returns the current nodestate code number
Definition at line 532 of file rlcanopentypes.cpp.
00533 { 00534 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00535 return bNodeFlagState.bNodeState; 00536 }
| bool rlCanOpenTypes::get_nodestateFlag_Deactivated | ( | ) |
Definition at line 566 of file rlcanopentypes.cpp.
00567 { 00568 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00569 return bNodeFlagState.bDeactivated; 00570 }
| bool rlCanOpenTypes::get_nodestateFlag_EmcyBuffOverflow | ( | ) |
Definition at line 551 of file rlcanopentypes.cpp.
00552 { 00553 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00554 return bNodeFlagState.bEmcyBuffOverflow; 00555 }
| bool rlCanOpenTypes::get_nodestateFlag_GuardActive | ( | ) |
Definition at line 561 of file rlcanopentypes.cpp.
00562 { 00563 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00564 return bNodeFlagState.bGuardActive; 00565 }
| bool rlCanOpenTypes::get_nodestateFlag_NoResponse | ( | ) |
read particular nodestade with the following functions
read particular nodestade
Definition at line 546 of file rlcanopentypes.cpp.
00547 { 00548 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00549 return bNodeFlagState.bNodeNoResponse; 00550 }
| bool rlCanOpenTypes::get_nodestateFlag_PrmFault | ( | ) |
Definition at line 556 of file rlcanopentypes.cpp.
00557 { 00558 if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 00559 return bNodeFlagState.bPrmFault; 00560 }
| bool rlCanOpenTypes::get_nodestateFlags | ( | bool & | _bNodeNoResponse, | |
| bool & | _bEmcyBuffOverflow, | |||
| bool & | _bPrmFault, | |||
| bool & | _bGuardActive, | |||
| bool & | _bDeactivated | |||
| ) |
returns false when typenumber is not RL_NODESTATE. if true states are stored in parameter variables
Definition at line 510 of file rlcanopentypes.cpp.
00515 { 00516 if (typenumber == RL_NODESTATE){ 00517 _bNodeNoResponse = bNodeFlagState.bNodeNoResponse; 00518 _bEmcyBuffOverflow = bNodeFlagState.bEmcyBuffOverflow; 00519 _bPrmFault = bNodeFlagState.bPrmFault; 00520 _bGuardActive = bNodeFlagState.bGuardActive; 00521 _bDeactivated = bNodeFlagState.bDeactivated; 00522 return true; 00523 } 00524 else 00525 { 00526 invalidTypeError(RL_NODESTATE); 00527 return false; 00528 } 00529 }
| long rlCanOpenTypes::get_rlmsgerr | ( | ) |
returns current errnumber
Definition at line 357 of file rlcanopentypes.cpp.
00357 { 00358 return rlmsgerr; 00359 }
| short rlCanOpenTypes::get_short | ( | ) |
returns databuffer-content as short type
returns databuffer-content as short type. When type is not RL_SHORT this will produce an invalid-type-warning to stdout
Definition at line 197 of file rlcanopentypes.cpp.
00197 { 00198 if (typenumber != RL_SHORT){ 00199 invalidTypeError(RL_SHORT); 00200 } 00201 return t_short; 00202 }
| char * rlCanOpenTypes::get_string | ( | ) |
creates string filled with databuffer-content and returns a pointer
creates a new 246 bytes string filled with databuffer-content and returns a pointer. this pointer must be stored and memory must be freed with delete, when the string is not longer needed, to prevent programm from producing memory leak.
Definition at line 245 of file rlcanopentypes.cpp.
00245 { 00246 if (typenumber != RL_STRING){ 00247 invalidTypeError(RL_STRING); 00248 } 00249 char* outstring = new char[247]; 00250 int i=0; 00251 while ((t_string[i] != '\0')&&(i<247)){ 00252 outstring[i] = t_string[i]; 00253 i++; 00254 } 00255 return outstring; 00256 }
| unsigned char rlCanOpenTypes::get_uchar | ( | ) |
returns databuffer-content as uchar type
returns databuffer-content as uchar type. When type is not RL_UCHAR this will produce an invalid-type-warning to stdout
Definition at line 289 of file rlcanopentypes.cpp.
00289 { 00290 if (typenumber != RL_UCHAR){ 00291 invalidTypeError(RL_UCHAR); 00292 } 00293 return t_databyte; 00294 }
| unsigned long rlCanOpenTypes::get_ulong | ( | ) |
returns databuffer-content as unsigned long type
returns databuffer-content as ulong type. When type is not RL_ULONG this will produce an invalid-type-warning to stdout
Definition at line 344 of file rlcanopentypes.cpp.
00344 { 00345 if (typenumber != RL_ULONG){ 00346 invalidTypeError(RL_ULONG); 00347 } 00348 return t_ulong; 00349 }
| unsigned long int rlCanOpenTypes::get_ulonglong | ( | ) |
returns databuffer-content as unsigned long long type
Definition at line 329 of file rlcanopentypes.cpp.
00329 { 00330 if (typenumber != RL_ULONGLONG) 00331 { 00332 invalidTypeError(RL_ULONGLONG); 00333 } 00334 return t_ulonglong; 00335 }
| unsigned short rlCanOpenTypes::get_ushort | ( | ) |
returns databuffer-content as short type
returns databuffer-content as short type. When type is not RL_USHORT this will produce an invalid-type-warning to stdout
Definition at line 211 of file rlcanopentypes.cpp.
00211 { 00212 if (typenumber != RL_USHORT){ 00213 invalidTypeError(RL_USHORT); 00214 } 00215 return t_ushort; 00216 }
| void rlCanOpenTypes::getIpcMsg | ( | IPCMSGSTRUCT | _myIpcMsg | ) |
overwrites all data with IPCMSGSTRUCT data
Definition at line 471 of file rlcanopentypes.cpp.
00471 { 00472 for (int i=0; i<247; i++){ 00473 t_string[i] = _myIpcMsg.mtext[i]; 00474 } 00475 typenumber = _myIpcMsg.typenumber; 00476 rlmsgerr = _myIpcMsg.rlmsgerr; 00477 }
| int rlCanOpenTypes::getLength | ( | ) |
returns number of bytes used for current type
Definition at line 31 of file rlcanopentypes.cpp.
00032 { 00033 switch(typenumber) { 00034 case RL_INT: return 4; 00035 case RL_FLOAT: return 4; 00036 case RL_DOUBLE: return 8; 00037 case RL_SHORT: return 2; 00038 case RL_USHORT: return 2; 00039 case RL_LONGLONG: return 8; 00040 case RL_STRING: return 246; 00041 case RL_BUFFER: return 246; 00042 case RL_UCHAR: return 1; 00043 case RL_BOOL: return 1; 00044 case RL_LONG: return 4; 00045 case RL_ULONG: return 4; 00046 case RL_ULONGLONG: return 8; 00047 case RL_PDO: return 8; 00048 case RL_NOTYPE: return 0; 00049 default: return 0; 00050 } 00051 }
| void rlCanOpenTypes::invalidTypeError | ( | int | _typenr | ) | [private] |
produce an invalid-type-warning to stdout. used by nearly all getter functions
Definition at line 373 of file rlcanopentypes.cpp.
00373 { 00374 char* curTypeStr; 00375 char* usrTypeStr; 00376 curTypeStr = type2str(typenumber); 00377 usrTypeStr = type2str(_typenr); 00378 rlDebugPrintf("Warning! %s invalid type! current data type is: %s \n" 00379 , usrTypeStr, curTypeStr); 00380 delete curTypeStr; 00381 delete usrTypeStr; 00382 }
| rlCanOpenTypes & rlCanOpenTypes::operator= | ( | rlCanOpenTypes & | cp | ) |
copies all data from right object into left object
Definition at line 363 of file rlcanopentypes.cpp.
00363 { 00364 typenumber = cp.typenumber; 00365 rlmsgerr = cp.rlmsgerr; 00366 for (int i=0; i<246; i++){ 00367 t_databytes[i]=cp.t_databytes[i]; 00368 } 00369 return *this; 00370 }
| void rlCanOpenTypes::pdobuf2buf | ( | ) |
exchange bytes 0-7 from pdobuffer to databuffer
Definition at line 442 of file rlcanopentypes.cpp.
00442 { 00443 for (int i=0; i<8; i++){ 00444 t_databytes[i]=pdobuffer[i]; 00445 } 00446 typenumber = RL_PDO; 00447 }
| void rlCanOpenTypes::rlMsgErrOut | ( | ) |
prints MsgErrStr to StdOut
prints error message to StdOut
Definition at line 410 of file rlcanopentypes.cpp.
00410 { 00411 char* errOut = rlMsgErrStr(); 00412 rlDebugPrintf("ERROR: \"%s\" \n", errOut); 00413 delete errOut; 00414 }
| char * rlCanOpenTypes::rlMsgErrStr | ( | ) |
* returns a pointer to a new 22 character string containing name of error in rlmsgerr
returns a pointer to a new 22 character string containing the name of the error in rlmsgerr. This pointer must be stored and memory must be freed with delete, when the string is not longer needed, to prevent programm from producing memory leak.
Definition at line 416 of file rlcanopentypes.cpp.
00416 { 00417 char* errstr = new char[25]; 00418 switch(rlmsgerr) { 00419 case 0: strncpy(errstr, "ERRCODE_NOERROR ", 25); break; 00420 case -1: strncpy(errstr, " ", 25); break; 00421 case -2: strncpy(errstr, "ERRCODE_INVALID_NODEID", 25); break; 00422 case -3: strncpy(errstr, "ERRCODE_INVALID_PDOID ", 25); break; 00423 case -4: strncpy(errstr, "ERRCODE_PDOSND_FAIL ", 25); break; 00424 case -5: strncpy(errstr, "ERRCODE_INVALID_MAPID ", 25); break; 00425 case -6: strncpy(errstr, "ERRCODE_INVALID_RLTYPE", 25); break; 00426 case -7: strncpy(errstr, "ERRCODE_PDORCV_FAIL ", 25); break; 00427 default: strncpy(errstr, "ERRCODE_MSGF ", 25); break; 00428 } 00429 return errstr; 00430 }
| void rlCanOpenTypes::set_bool | ( | bool | _value | ) |
sets type to RL_BOOL and stores passed parameter data in databuffer
Definition at line 297 of file rlcanopentypes.cpp.
00297 { 00298 t_bool = _value; 00299 typenumber = RL_BOOL; 00300 }
| void rlCanOpenTypes::set_buffer | ( | int | _index, | |
| unsigned char | _databyte | |||
| ) |
transfer raw data into the databuffer
This setter does not modify the current type. it is intended to transfer raw data recieved from canbus into the databuffer and afterwards set the approbiate daemontype with set_daemontype. _index must be within range of 246 bytes databuffer size.
Definition at line 259 of file rlcanopentypes.cpp.
00259 { 00260 if (_index<247){ 00261 t_databytes[_index] = _databyte; 00262 } 00263 else 00264 { 00265 fprintf(stderr, "ERROR! set_buffer: INDEX OUT OF RANGE!\n"); 00266 } 00267 }
| void rlCanOpenTypes::set_CanOpenType | ( | int | _type | ) |
recieves an CANopen typenumber and returns appropiate RL-Type
recieves an CANopen typenumber as defined in CiA DS-301 specification. This type is converted to the appropiate RL-type. Therefore type-numbers may be extracted directly from EDS file without external conversion.
Definition at line 76 of file rlcanopentypes.cpp.
00076 { 00077 typenumber = canOpenType2DeamonType(_type); 00078 }
| void rlCanOpenTypes::set_DaemonType | ( | int | _type | ) |
alternative setter receives integer typenumber
sets the type of data stored in databuffer.
Definition at line 61 of file rlcanopentypes.cpp.
00061 { 00062 typenumber = _type; 00063 }
| void rlCanOpenTypes::set_DaemonType | ( | rl_types | _type | ) |
alternative setter receives integer typenumber
sets the type of data stored in databuffer. All getter-functions forced to return a type different from this will produce an invalid-type-warning to stdout
Definition at line 66 of file rlcanopentypes.cpp.
00066 { 00067 typenumber = _type; 00068 }
| void rlCanOpenTypes::set_double | ( | double | _value | ) |
sets type to RL_DOUBLE and stores passed parameter data in databuffer
Definition at line 177 of file rlcanopentypes.cpp.
00177 { 00178 t_double = _value; 00179 typenumber = RL_DOUBLE; 00180 }
| void rlCanOpenTypes::set_float | ( | float | _value | ) |
sets type to RL_FLOAT and stores passed parameter data in databuffer
Definition at line 163 of file rlcanopentypes.cpp.
00163 { 00164 t_float = _value; 00165 typenumber = RL_FLOAT; 00166 }
| void rlCanOpenTypes::set_int | ( | int | _value | ) |
sets type to RL_INT and stores passed parameter data in databuffer
Definition at line 148 of file rlcanopentypes.cpp.
00148 { 00149 t_int = _value; 00150 typenumber = RL_INT; 00151 }
| void rlCanOpenTypes::set_long | ( | long | _value | ) |
sets type to RL_LONG and stores passed parameter data in databuffer
Definition at line 310 of file rlcanopentypes.cpp.
00310 { 00311 t_long = _value; 00312 typenumber = RL_LONG; 00313 }
| void rlCanOpenTypes::set_longlong | ( | long int | _value | ) |
sets type to RL_LONGLONG and stores passed parameter data in databuffer
Definition at line 220 of file rlcanopentypes.cpp.
00220 { 00221 t_longlong = _value; 00222 typenumber = RL_LONGLONG; 00223 }
| void rlCanOpenTypes::set_nodeerror | ( | unsigned char | _nodeerror | ) |
sets the actual node error. refer com_pie.pdf page 15 for detailed error code description
Definition at line 503 of file rlcanopentypes.cpp.
00504 { 00505 bNodeFlagState.bActualError = _nodeerror; 00506 }
| void rlCanOpenTypes::set_nodestate | ( | unsigned char | _nodestate | ) |
sets current state of node.
sets current state of node. this is a code number the following meaning: alias nr DISCONNECTED 1 CONNECTING 2 PREPARING 3 PREPARED 4 OPERATIONAL 5 PRE_OPERATIONAL 127
Definition at line 495 of file rlcanopentypes.cpp.
00496 { 00497 bNodeFlagState.bNodeState = _nodestate; 00498 typenumber = RL_NODESTATE; 00499 }
| void rlCanOpenTypes::set_nodestateFlags | ( | unsigned char | _bNodeNoResponse, | |
| unsigned char | _bEmcyBuffOverflow, | |||
| unsigned char | _bPrmFault, | |||
| unsigned char | _bGuardActive, | |||
| unsigned char | _bDeactivated | |||
| ) |
sets type to RL_NODESTATE. Stores flag-data received from the device.
sets type to RL_NODESTATE. This is function is intended to store flag-data received from the device.
Definition at line 480 of file rlcanopentypes.cpp.
00485 { 00486 bNodeFlagState.bNodeNoResponse = _bNodeNoResponse; 00487 bNodeFlagState.bEmcyBuffOverflow = _bEmcyBuffOverflow; 00488 bNodeFlagState.bPrmFault = _bPrmFault; 00489 bNodeFlagState.bGuardActive = _bGuardActive; 00490 bNodeFlagState.bDeactivated = _bDeactivated; 00491 typenumber = RL_NODESTATE; 00492 }
| void rlCanOpenTypes::set_rlmsgerr | ( | long | _errnr | ) |
sets the errornumber. refer private varibale rlmsgerr for details
Definition at line 352 of file rlcanopentypes.cpp.
00352 { 00353 rlmsgerr = _errnr; 00354 }
| void rlCanOpenTypes::set_short | ( | short | _value | ) |
sets type to RL_SHORT and stores passed parameter data in databuffer
Definition at line 191 of file rlcanopentypes.cpp.
00191 { 00192 t_short = _value; 00193 typenumber = RL_SHORT; 00194 }
| void rlCanOpenTypes::set_string | ( | const char * | _value | ) |
sets type to RL_STRING. the passed string-constant is copied byte-wise to databuffer
Definition at line 235 of file rlcanopentypes.cpp.
00235 { 00236 int i=0; 00237 while ((_value[i] != '\0')&&(i<247)){ 00238 t_string[i] = _value[i]; 00239 i++; 00240 } 00241 typenumber = RL_STRING; 00242 }
| void rlCanOpenTypes::set_uchar | ( | unsigned char | _value | ) |
sets type to RL_UCHAR and stores passed parameter data in databuffer
Definition at line 283 of file rlcanopentypes.cpp.
00283 { 00284 t_databyte = _value; 00285 typenumber = RL_UCHAR; 00286 }
| void rlCanOpenTypes::set_ulong | ( | unsigned long | _value | ) |
sets type to RL_ULONG and stores passed parameter data in databuffer
Definition at line 338 of file rlcanopentypes.cpp.
00338 { 00339 t_ulong = _value; 00340 typenumber = RL_ULONG; 00341 }
| void rlCanOpenTypes::set_ulonglong | ( | unsigned long int | _value | ) |
sets type to RL_ULONGLONG and stores passed parameter data in databuffer
Definition at line 323 of file rlcanopentypes.cpp.
00323 { 00324 t_ulonglong = _value; 00325 typenumber = RL_ULONGLONG; 00326 }
| void rlCanOpenTypes::set_ushort | ( | unsigned short | _value | ) |
sets type to RL_USHORT and stores passed parameter data in databuffer
| bool rlCanOpenTypes::translate_CanOpenType | ( | int | _canopentype | ) |
Definition at line 573 of file rlcanopentypes.cpp.
00574 { 00575 switch (_canopentype){ 00576 case rlCanOpenTypes::INTEGER24_t : 00577 if (t_int<0) { 00578 t_int = t_int * -1; 00579 t_databytes[3] = 00; 00580 t_int = t_int * -1; 00581 } 00582 else{ 00583 t_databytes[3] = 00; 00584 } 00585 break; 00586 00587 case rlCanOpenTypes::INTEGER40_t : 00588 if (t_longlong<0) { 00589 t_longlong = t_longlong * -1; 00590 t_databytes[5] = 00; 00591 t_databytes[6] = 00; 00592 t_databytes[7] = 00; 00593 t_longlong = t_longlong * -1; 00594 } 00595 else{ 00596 t_databytes[5] = 00; 00597 t_databytes[6] = 00; 00598 t_databytes[7] = 00; 00599 } 00600 break; 00601 00602 case rlCanOpenTypes::INTEGER48_t :return true; 00603 if (t_longlong<0) { 00604 t_longlong = t_longlong * -1; 00605 t_databytes[6] = 00; 00606 t_databytes[7] = 00; 00607 t_longlong = t_longlong * -1; 00608 } 00609 else{ 00610 t_databytes[6] = 00; 00611 t_databytes[7] = 00; 00612 } 00613 break; 00614 00615 00616 case rlCanOpenTypes::INTEGER56_t :return true; 00617 if (t_longlong<0) { 00618 t_longlong = t_longlong * -1; 00619 t_databytes[7] = 00; 00620 t_longlong = t_longlong * -1; 00621 } 00622 else{ 00623 t_databytes[7] = 00; 00624 } 00625 break; 00626 00627 case rlCanOpenTypes::UNSIGNED24_t: 00628 t_databytes[3] = 00; 00629 break; 00630 case rlCanOpenTypes::UNSIGNED40_t: 00631 t_databytes[5] = 00; 00632 t_databytes[6] = 00; 00633 t_databytes[7] = 00; 00634 break; 00635 case rlCanOpenTypes::UNSIGNED48_t: 00636 t_databytes[6] = 00; 00637 t_databytes[7] = 00; 00638 break; 00639 case rlCanOpenTypes::UNSIGNED56_t: 00640 t_databytes[7] = 00; 00641 break; 00642 default :return false; 00643 }; 00644 00645 return false; 00646 }
| char * rlCanOpenTypes::type2str | ( | int | _typenr | ) |
returns a pointer to a new 12 character string containing the name of the type
returns a pointer to a new 12 character string containing the name of the type passed by _typnr. This pointer must be stored and memory must be freed with delete, when the string is not longer needed, to prevent programm from producing memory leak.
Definition at line 385 of file rlcanopentypes.cpp.
00385 { 00386 char* typestr = new char[12]; 00387 switch(_typenr) { 00388 case RL_INT: strncpy(typestr, "RL_INT ", 12); break; 00389 case RL_FLOAT: strncpy(typestr, "RL_FLOAT ", 12); break; 00390 case RL_DOUBLE: strncpy(typestr, "RL_DOUBLE ", 12); break; 00391 case RL_SHORT: strncpy(typestr, "RL_SHORT ", 12); break; 00392 case RL_USHORT: strncpy(typestr, "RL_USHORT ", 12); break; 00393 case RL_LONGLONG: strncpy(typestr, "RL_LONGLONG ", 12); break; 00394 case RL_STRING: strncpy(typestr, "RL_STRING ", 12); break; 00395 case RL_BUFFER: strncpy(typestr, "RL_BUFFER ", 12); break; 00396 case RL_UCHAR: strncpy(typestr, "RL_UCHAR ", 12); break; 00397 case RL_BOOL: strncpy(typestr, "RL_BOOL ", 12); break; 00398 case RL_LONG: strncpy(typestr, "RL_LONG ", 12); break; 00399 case RL_ULONG: strncpy(typestr, "RL_ULONG ", 12); break; 00400 case RL_ULONGLONG: strncpy(typestr, "RL_ULONGLONG", 12); break; 00401 case RL_PDO: strncpy(typestr, "RL_PDO ", 12); break; 00402 case RL_NODESTATE: strncpy(typestr, "RL_NODESTATE", 12); break; 00403 case RL_NOTYPE: strncpy(typestr, "RL_NOTYPE ", 12); break; 00404 default: strncpy(typestr, "UNDEFINED ", 12); 00405 } 00406 return typestr; 00407 }
union { ... } [private] |
| unsigned char rlCanOpenTypes::bActualError |
Definition at line 365 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::bDeactivated |
Definition at line 357 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::bEmcyBuffOverflow |
Definition at line 354 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::bGuardActive |
Definition at line 356 of file rlcanopentypes.h.
| struct { ... } rlCanOpenTypes::bNodeFlagState |
| unsigned char rlCanOpenTypes::bNodeNoResponse |
Definition at line 353 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::bNodeState |
Definition at line 358 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::bPrmFault |
Definition at line 355 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::pdobuffer[8] |
external buffer for pdotransfer
Definition at line 274 of file rlcanopentypes.h.
long rlCanOpenTypes::rlmsgerr [private] |
errnumber // alias // description rlmsgerr = 0 // ERRCODE_NOERROR // no error rlmsgerr > 0 // // msg.f error code. Refer com_pie.pdf page 44 for details. rlmsgerr = -1 // // msg.a or msg.nr inconsistency rlmsgerr = -2 // ERRCODE_INVALID_NODEID // nodeid does not exist rlmsgerr = -3 // ERRCODE_INVALID_PDOID // pdoid does not exist rlmsgerr = -4 // ERRCODE_PDOSND_FAIL // transmit pdo failed rlmsgerr = -5 // ERRCODE_INVALID_MAPID // mappingid does not exist rlmsgerr = -6 // ERRCODE_INVALID_RLTYPE // type does not fit during pdo transmit rlmsgerr = -7 // ERRCODE_PDORCV_FAIL // pdo receive failed
Definition at line 332 of file rlcanopentypes.h.
Definition at line 346 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::t_databyte |
Definition at line 345 of file rlcanopentypes.h.
| unsigned char rlCanOpenTypes::t_databytes[247] |
Definition at line 344 of file rlcanopentypes.h.
| double rlCanOpenTypes::t_double |
Definition at line 339 of file rlcanopentypes.h.
| float rlCanOpenTypes::t_float |
Definition at line 338 of file rlcanopentypes.h.
Definition at line 337 of file rlcanopentypes.h.
Definition at line 347 of file rlcanopentypes.h.
| long int rlCanOpenTypes::t_longlong |
Definition at line 342 of file rlcanopentypes.h.
| short rlCanOpenTypes::t_short |
Definition at line 340 of file rlcanopentypes.h.
| char rlCanOpenTypes::t_string[247] |
Definition at line 343 of file rlcanopentypes.h.
| unsigned long rlCanOpenTypes::t_ulong |
Definition at line 348 of file rlcanopentypes.h.
| unsigned long int rlCanOpenTypes::t_ulonglong |
Definition at line 349 of file rlcanopentypes.h.
| unsigned short rlCanOpenTypes::t_ushort |
Definition at line 341 of file rlcanopentypes.h.
int rlCanOpenTypes::typenumber [private] |
variable that stores the current datatype. only rl_types enum values are indented to be stored here
Definition at line 320 of file rlcanopentypes.h.
1.6.3