rllib  1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
rlCanOpenTypes Class Reference

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. More...
 
int getLength ()
 returns number of bytes used for current type More...
 
void clearBuffer ()
 sets all bytes in databuffer to zero More...
 
void set_DaemonType (rl_types _type)
 alternative setter receives integer typenumber More...
 
void set_DaemonType (int _type)
 alternative setter receives integer typenumber More...
 
int get_DaemonType ()
 returns current of data stored in databuffer More...
 
void set_CanOpenType (int _type)
 recieves an CANopen typenumber and returns appropiate RL-Type More...
 
int get_CanOpenType ()
 returns the current type converted to CANopen typenumber More...
 
void set_int (int _value)
 sets type to RL_INT and stores passed parameter data in databuffer More...
 
int get_int ()
 returns databuffer-content as integer type. More...
 
void set_float (float _value)
 sets type to RL_FLOAT and stores passed parameter data in databuffer More...
 
float get_float ()
 returns databuffer-content as float type. More...
 
void set_double (double _value)
 sets type to RL_DOUBLE and stores passed parameter data in databuffer More...
 
double get_double ()
 returns databuffer-content as double type. More...
 
void set_short (short _value)
 sets type to RL_SHORT and stores passed parameter data in databuffer More...
 
short get_short ()
 returns databuffer-content as short type More...
 
void set_ushort (unsigned short _value)
 sets type to RL_USHORT and stores passed parameter data in databuffer More...
 
unsigned short get_ushort ()
 returns databuffer-content as short type More...
 
void set_longlong (long int _value)
 sets type to RL_LONGLONG and stores passed parameter data in databuffer More...
 
long int get_longlong ()
 returns databuffer-content as long long type More...
 
void set_string (const char *_value)
 
char * get_string ()
 creates string filled with databuffer-content and returns a pointer More...
 
void set_buffer (int _index, unsigned char _databyte)
 transfer raw data into the databuffer More...
 
unsigned char get_buffer (int _index)
 returns 1 byte from databuffer More...
 
void set_uchar (unsigned char _value)
 sets type to RL_UCHAR and stores passed parameter data in databuffer More...
 
unsigned char get_uchar ()
 returns databuffer-content as uchar type More...
 
void set_bool (bool _value)
 sets type to RL_BOOL and stores passed parameter data in databuffer More...
 
bool get_bool ()
 returns databuffer-content as bool type More...
 
void set_long (long _value)
 sets type to RL_LONG and stores passed parameter data in databuffer More...
 
long get_long ()
 returns databuffer-content as long type More...
 
void set_ulong (unsigned long _value)
 sets type to RL_ULONG and stores passed parameter data in databuffer More...
 
unsigned long get_ulong ()
 returns databuffer-content as unsigned long type More...
 
void set_ulonglong (unsigned long int _value)
 sets type to RL_ULONGLONG and stores passed parameter data in databuffer More...
 
unsigned long int get_ulonglong ()
 returns databuffer-content as unsigned long long type More...
 
void set_rlmsgerr (long _errnr)
 sets the errornumber. refer private varibale rlmsgerr for details More...
 
long get_rlmsgerr ()
 returns current errnumber More...
 
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. More...
 
bool get_nodestateFlags (bool &_bNodeNoResponse, bool &_bEmcyBuffOverflow, bool &_bPrmFault, bool &_bGuardActive, bool &_bDeactivated)
 
bool get_nodestateFlag_NoResponse ()
 read particular nodestade with the following functions More...
 
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. More...
 
unsigned char get_nodestate ()
 returns the nodestate. refer code numbers above More...
 
void set_nodeerror (unsigned char _nodeerror)
 
unsigned char get_nodeerror ()
 returns actual node error More...
 
void buf2pdobuf ()
 exchange bytes 0-7 from databuffer to pdobuffer More...
 
void pdobuf2buf ()
 exchange bytes 0-7 from pdobuffer to databuffer More...
 
rlCanOpenTypesoperator= (rlCanOpenTypes &cp)
 copies all data from right object into left object More...
 
IPCMSGSTRUCT createIpcMsg ()
 returns a IPCMSGSTRUCT filled with current object data More...
 
void getIpcMsg (IPCMSGSTRUCT _myIpcMsg)
 overwrites all data with IPCMSGSTRUCT data More...
 
void rlMsgErrOut ()
 prints MsgErrStr to StdOut More...
 
char * rlMsgErrStr ()
 
char * type2str (int _typenr)
 returns a pointer to a new 12 character string containing the name of the type More...
 
bool translate_CanOpenType (int _canopentype)
 
int get_CanOpenTypeLength (int _canopentype)
 

Static Public Member Functions

static int canOpenType2DeamonType (int _canopentype)
 Function for typenumber conversion. More...
 
static int deamonType2CanOpenType (int _deamontype)
 Function for typenumber conversion. More...
 

Public Attributes

unsigned char pdobuffer [8]
 external buffer for pdotransfer More...
 
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)
 produce an invalid-type-warning to stdout. used by nearly all getter functions More...
 

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
 
}; 
 

Detailed Description

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.

Member Enumeration Documentation

◆ canopen_types

Enumerator
c_BOOLEAN 
INTEGER8_t 
INTEGER16_t 
INTEGER32_t 
UNSIGNED8_t 
UNSIGNED16_t 
UNSIGNED32_t 
REAL32_t 
VISIBLE_STRING 
OCTET_STRING_t 
UNICODE_STRING 
TIME_OF_DAY_t 
TIME_DIFFERENC 
BIT_STRING_t 
DOMAIN_t 
INTEGER24_t 
REAL64_t 
INTEGER40_t 
INTEGER48_t 
INTEGER56_t 
INTEGER64_t 
UNSIGNED24_t 
RESERVED1_t 
UNSIGNED40_t 
UNSIGNED48_t 
UNSIGNED56_t 
UNSIGNED64_t 

Definition at line 60 of file rlcanopentypes.h.

60  {
61 
62  c_BOOLEAN = 0x0001,
63  INTEGER8_t = 0x0002,
64  INTEGER16_t = 0x0003,
65  INTEGER32_t = 0x0004,
66  UNSIGNED8_t = 0x0005,
67  UNSIGNED16_t = 0x0006,
68  UNSIGNED32_t = 0x0007,
69  REAL32_t = 0x0008,
70  VISIBLE_STRING = 0x0009,
71  OCTET_STRING_t = 0x000A,
72  UNICODE_STRING = 0x000B,
73  TIME_OF_DAY_t = 0x000C,
74  TIME_DIFFERENC = 0x000D,
75  BIT_STRING_t = 0x000E,
76  DOMAIN_t = 0x000F,
77  INTEGER24_t = 0x0010,
78  REAL64_t = 0x0011,
79  INTEGER40_t = 0x0012,
80  INTEGER48_t = 0x0013,
81  INTEGER56_t = 0x0014,
82  INTEGER64_t = 0x0015,
83  UNSIGNED24_t = 0x0016,
84  RESERVED1_t = 0x0017,
85  UNSIGNED40_t = 0x0018,
86  UNSIGNED48_t = 0x0019,
87  UNSIGNED56_t = 0x001A,
88  UNSIGNED64_t = 0x001B
89 };

◆ rl_types

Enumerator
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.

Constructor & Destructor Documentation

◆ rlCanOpenTypes()

rlCanOpenTypes::rlCanOpenTypes ( )

Constructor initializes with RL_NOTYPE.

Definition at line 24 of file rlcanopentypes.cpp.

24  {
26  rlmsgerr = 0;
27  clearBuffer();
28 }
void clearBuffer()
sets all bytes in databuffer to zero

Member Function Documentation

◆ buf2pdobuf()

void rlCanOpenTypes::buf2pdobuf ( )

exchange bytes 0-7 from databuffer to pdobuffer

Definition at line 434 of file rlcanopentypes.cpp.

434  {
435  for (int i=0; i<8; i++){
436  pdobuffer[i]=t_databytes[i];
437  }
438  typenumber = RL_PDO;
439 }
unsigned char t_databytes[247]
unsigned char pdobuffer[8]
external buffer for pdotransfer

◆ canOpenType2DeamonType()

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.

87 {
88  // refer table Data Types on page 11 in CiA CANopen Specification
89 
90  switch(_canopentype) {
91  case 0x0001:return RL_BOOL; // c_BOOLEAN
92  case 0x0002:return RL_SHORT; // INTEGER8_t
93  case 0x0003:return RL_SHORT; // INTEGER16_t
94  case 0x0004:return RL_LONG; // INTEGER32_t
95  case 0x0005:return RL_UCHAR; // UNSIGNED8_t
96  case 0x0006:return RL_USHORT; // UNSIGNED16_t
97  case 0x0007:return RL_ULONG; // UNSIGNED32_t
98  case 0x0008:return RL_FLOAT; // REAL32_t
99  case 0x0009:return RL_STRING; // VISIBLE_STRING
100  case 0x000A:return RL_STRING; // OCTET_STRING_t
101  case 0x000B:return RL_STRING; // UNICODE_STRING
102  case 0x000C:return RL_ULONGLONG; // TIME_OF_DAY_t
103  case 0x000D:return RL_ULONGLONG; // TIME_DIFFERENC
104  case 0x000E:return RL_BUFFER; // BIT_STRING_t
105  case 0x000F:return RL_BUFFER; // DOMAIN_t
106  case 0x0010:return RL_ULONG; // INTEGER24_t
107  case 0x0011:return RL_DOUBLE; // REAL64_t
108  case 0x0012:return RL_LONGLONG; // INTEGER40_t
109  case 0x0013:return RL_LONGLONG; // INTEGER48_t
110  case 0x0014:return RL_LONGLONG; // INTEGER56_t
111  case 0x0015:return RL_LONGLONG; // INTEGER64_t
112  case 0x0016:return RL_ULONG; // UNSIGNED24_t
113  case 0x0017:return RL_BUFFER; // RESERVED1_t
114  case 0x0018:return RL_ULONGLONG; // UNSIGNED40_t
115  case 0x0019:return RL_ULONGLONG; // UNSIGNED48_t
116  case 0x001A:return RL_ULONGLONG; // UNSIGNED56_t
117  case 0x001B:return RL_ULONGLONG; // UNSIGNED64_t
118  default :return RL_NOTYPE; // ERROR
119  }
120 }

◆ clearBuffer()

void rlCanOpenTypes::clearBuffer ( )

sets all bytes in databuffer to zero

Definition at line 54 of file rlcanopentypes.cpp.

54  {
55  for (int i=0; i<247; i++){
56  t_databytes[i] = 0;
57  }
58 }
unsigned char t_databytes[247]

◆ createIpcMsg()

IPCMSGSTRUCT rlCanOpenTypes::createIpcMsg ( )

returns a IPCMSGSTRUCT filled with current object data

Definition at line 451 of file rlcanopentypes.cpp.

451  {
452  IPCMSGSTRUCT istruct;
453  for (int i=0; i<247; i++){
454  istruct.mtext[i] = t_string[i];
455  }
456  istruct.typenumber = typenumber;
457  istruct.msgtype = -1;
458  istruct.transfertype= -1;
459  istruct.processid = -1;
460  istruct.boardid = -1;
461  istruct.nodeid = -1;
462  istruct.objectindex = -1;
463  istruct.subindex = -1;
464  istruct.pdoid = -1;
465  istruct.mappingid = -1;
466  istruct.rlmsgerr = rlmsgerr;
467  return istruct;
468 }
the IPCMSGSTRUCT is the transfer buffer which is send trough TCP sockets
char mtext[247]
char t_string[247]

◆ deamonType2CanOpenType()

int rlCanOpenTypes::deamonType2CanOpenType ( int  _deamontype)
static

Function for typenumber conversion.

Definition at line 124 of file rlcanopentypes.cpp.

125 {
126 
127  switch(_deamontype) {
128  case RL_INT:return 0x0007;
129  case RL_FLOAT:return 0x0008;
130  case RL_DOUBLE:return 0x0011;
131  case RL_SHORT:return 0x0003;
132  case RL_USHORT:return 0x0006;
133  case RL_LONGLONG:return 0x0015;
134  case RL_STRING:return 0x0009;
135  case RL_BUFFER:return 0x000A;
136  case RL_UCHAR:return 0x0005;//???
137  case RL_BOOL:return 0x0001;
138  case RL_LONG:return 0x0004;
139  case RL_ULONG:return 0x0007;
140  case RL_ULONGLONG:return 0x001B;
141  case RL_PDO:return 0x000E;
142  case RL_NOTYPE:return 0x0;
143  default:return 0x0;
144  }
145 }

◆ get_bool()

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.

303  {
304  if (typenumber != RL_BOOL){
306  }
307  return t_bool;
308 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_buffer()

unsigned char rlCanOpenTypes::get_buffer ( int  _index)

returns 1 byte from databuffer

Definition at line 271 of file rlcanopentypes.cpp.

271  {
272  if (_index<247){
273  return t_databytes[_index];
274  }
275  else
276  {
277  fprintf(stderr, "ERROR! get_buffer: INDEX OUT OF RANGE!\n");
278  return 0;
279  }
280 }
unsigned char t_databytes[247]

◆ get_CanOpenType()

int rlCanOpenTypes::get_CanOpenType ( )

returns the current type converted to CANopen typenumber

Definition at line 81 of file rlcanopentypes.cpp.

81  {
83 }
static int deamonType2CanOpenType(int _deamontype)
Function for typenumber conversion.

◆ get_CanOpenTypeLength()

int rlCanOpenTypes::get_CanOpenTypeLength ( int  _canopentype)

◆ get_DaemonType()

int rlCanOpenTypes::get_DaemonType ( )

returns current of data stored in databuffer

Definition at line 71 of file rlcanopentypes.cpp.

71  {
72  return typenumber;
73 }

◆ get_double()

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.

183  {
184  if (typenumber != RL_DOUBLE){
186  }
187  return t_double;
188 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_float()

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.

169  {
170  if (typenumber != RL_FLOAT){
172  }
173  return t_float;
174 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_int()

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.

154  {
155  if (typenumber != RL_INT){
157 
158  }
159  return t_int;
160 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_long()

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.

316  {
317  if (typenumber != RL_LONG){
319  }
320  return t_long;
321 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_longlong()

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.

226  {
227  if (typenumber != RL_LONGLONG){
229  }
230  return t_longlong;
231 }
long int t_longlong
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodeerror()

unsigned char rlCanOpenTypes::get_nodeerror ( )

returns actual node error

Definition at line 539 of file rlcanopentypes.cpp.

540 {
542  return bNodeFlagState.bActualError;
543 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestate()

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.

533 {
535  return bNodeFlagState.bNodeState;
536 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlag_Deactivated()

bool rlCanOpenTypes::get_nodestateFlag_Deactivated ( )

Definition at line 566 of file rlcanopentypes.cpp.

567 {
569  return bNodeFlagState.bDeactivated;
570 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlag_EmcyBuffOverflow()

bool rlCanOpenTypes::get_nodestateFlag_EmcyBuffOverflow ( )

Definition at line 551 of file rlcanopentypes.cpp.

552 {
554  return bNodeFlagState.bEmcyBuffOverflow;
555 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlag_GuardActive()

bool rlCanOpenTypes::get_nodestateFlag_GuardActive ( )

Definition at line 561 of file rlcanopentypes.cpp.

562 {
564  return bNodeFlagState.bGuardActive;
565 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlag_NoResponse()

bool rlCanOpenTypes::get_nodestateFlag_NoResponse ( )

read particular nodestade with the following functions

read particular nodestade

Definition at line 546 of file rlcanopentypes.cpp.

547 {
549  return bNodeFlagState.bNodeNoResponse;
550 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlag_PrmFault()

bool rlCanOpenTypes::get_nodestateFlag_PrmFault ( )

Definition at line 556 of file rlcanopentypes.cpp.

557 {
559  return bNodeFlagState.bPrmFault;
560 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_nodestateFlags()

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.

515 {
516  if (typenumber == RL_NODESTATE){
517  _bNodeNoResponse = bNodeFlagState.bNodeNoResponse;
518  _bEmcyBuffOverflow = bNodeFlagState.bEmcyBuffOverflow;
519  _bPrmFault = bNodeFlagState.bPrmFault;
520  _bGuardActive = bNodeFlagState.bGuardActive;
521  _bDeactivated = bNodeFlagState.bDeactivated;
522  return true;
523  }
524  else
525  {
527  return false;
528  }
529 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_rlmsgerr()

long rlCanOpenTypes::get_rlmsgerr ( )

returns current errnumber

Definition at line 357 of file rlcanopentypes.cpp.

357  {
358  return rlmsgerr;
359 }

◆ get_short()

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.

197  {
198  if (typenumber != RL_SHORT){
200  }
201  return t_short;
202 }
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_string()

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.

245  {
246  if (typenumber != RL_STRING){
248  }
249  char* outstring = new char[247];
250  int i=0;
251  while ((t_string[i] != '\0')&&(i<247)){
252  outstring[i] = t_string[i];
253  i++;
254  }
255  return outstring;
256 }
char t_string[247]
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_uchar()

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.

289  {
290  if (typenumber != RL_UCHAR){
292  }
293  return t_databyte;
294 }
unsigned char t_databyte
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_ulong()

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.

344  {
345  if (typenumber != RL_ULONG){
347  }
348  return t_ulong;
349 }
unsigned long t_ulong
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_ulonglong()

unsigned long int rlCanOpenTypes::get_ulonglong ( )

returns databuffer-content as unsigned long long type

Definition at line 329 of file rlcanopentypes.cpp.

329  {
330  if (typenumber != RL_ULONGLONG)
331  {
333  }
334  return t_ulonglong;
335 }
unsigned long int t_ulonglong
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ get_ushort()

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.

211  {
212  if (typenumber != RL_USHORT){
214  }
215  return t_ushort;
216 }
unsigned short t_ushort
void invalidTypeError(int _typenr)
produce an invalid-type-warning to stdout. used by nearly all getter functions

◆ getIpcMsg()

void rlCanOpenTypes::getIpcMsg ( IPCMSGSTRUCT  _myIpcMsg)

overwrites all data with IPCMSGSTRUCT data

Definition at line 471 of file rlcanopentypes.cpp.

471  {
472  for (int i=0; i<247; i++){
473  t_string[i] = _myIpcMsg.mtext[i];
474  }
475  typenumber = _myIpcMsg.typenumber;
476  rlmsgerr = _myIpcMsg.rlmsgerr;
477 }
char mtext[247]
char t_string[247]

◆ getLength()

int rlCanOpenTypes::getLength ( )

returns number of bytes used for current type

Definition at line 31 of file rlcanopentypes.cpp.

32 {
33  switch(typenumber) {
34  case RL_INT: return 4;
35  case RL_FLOAT: return 4;
36  case RL_DOUBLE: return 8;
37  case RL_SHORT: return 2;
38  case RL_USHORT: return 2;
39  case RL_LONGLONG: return 8;
40  case RL_STRING: return 246;
41  case RL_BUFFER: return 246;
42  case RL_UCHAR: return 1;
43  case RL_BOOL: return 1;
44  case RL_LONG: return 4;
45  case RL_ULONG: return 4;
46  case RL_ULONGLONG: return 8;
47  case RL_PDO: return 8;
48  case RL_NOTYPE: return 0;
49  default: return 0;
50  }
51 }

◆ invalidTypeError()

void rlCanOpenTypes::invalidTypeError ( int  _typenr)
private

produce an invalid-type-warning to stdout. used by nearly all getter functions

produce an invalid-type-warning to stdout. used by nearly all getter functions

Definition at line 373 of file rlcanopentypes.cpp.

373  {
374  char* curTypeStr;
375  char* usrTypeStr;
376  curTypeStr = type2str(typenumber);
377  usrTypeStr = type2str(_typenr);
378  rlDebugPrintf("Warning! %s invalid type! current data type is: %s \n"
379  , usrTypeStr, curTypeStr);
380  delete curTypeStr;
381  delete usrTypeStr;
382 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61
char * type2str(int _typenr)
returns a pointer to a new 12 character string containing the name of the type

◆ operator=()

rlCanOpenTypes & rlCanOpenTypes::operator= ( rlCanOpenTypes cp)

copies all data from right object into left object

Definition at line 363 of file rlcanopentypes.cpp.

363  {
364  typenumber = cp.typenumber;
365  rlmsgerr = cp.rlmsgerr;
366  for (int i=0; i<246; i++){
367  t_databytes[i]=cp.t_databytes[i];
368  }
369  return *this;
370 }
unsigned char t_databytes[247]

◆ pdobuf2buf()

void rlCanOpenTypes::pdobuf2buf ( )

exchange bytes 0-7 from pdobuffer to databuffer

Definition at line 442 of file rlcanopentypes.cpp.

442  {
443  for (int i=0; i<8; i++){
444  t_databytes[i]=pdobuffer[i];
445  }
446  typenumber = RL_PDO;
447 }
unsigned char t_databytes[247]
unsigned char pdobuffer[8]
external buffer for pdotransfer

◆ rlMsgErrOut()

void rlCanOpenTypes::rlMsgErrOut ( )

prints MsgErrStr to StdOut

prints error message to StdOut

Definition at line 410 of file rlcanopentypes.cpp.

410  {
411  char* errOut = rlMsgErrStr();
412  rlDebugPrintf("ERROR: \"%s\" \n", errOut);
413  delete errOut;
414 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61

◆ rlMsgErrStr()

char * rlCanOpenTypes::rlMsgErrStr ( )

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.

  • returns a pointer to a new 22 character string containing name of error in rlmsgerr

Definition at line 416 of file rlcanopentypes.cpp.

416  {
417  char* errstr = new char[25];
418  switch(rlmsgerr) {
419  case 0: strncpy(errstr, "ERRCODE_NOERROR ", 25); break;
420  case -1: strncpy(errstr, " ", 25); break;
421  case -2: strncpy(errstr, "ERRCODE_INVALID_NODEID", 25); break;
422  case -3: strncpy(errstr, "ERRCODE_INVALID_PDOID ", 25); break;
423  case -4: strncpy(errstr, "ERRCODE_PDOSND_FAIL ", 25); break;
424  case -5: strncpy(errstr, "ERRCODE_INVALID_MAPID ", 25); break;
425  case -6: strncpy(errstr, "ERRCODE_INVALID_RLTYPE", 25); break;
426  case -7: strncpy(errstr, "ERRCODE_PDORCV_FAIL ", 25); break;
427  default: strncpy(errstr, "ERRCODE_MSGF ", 25); break;
428  }
429  return errstr;
430 }

◆ set_bool()

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.

297  {
298  t_bool = _value;
300 }

◆ set_buffer()

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.

259  {
260  if (_index<247){
261  t_databytes[_index] = _databyte;
262  }
263  else
264  {
265  fprintf(stderr, "ERROR! set_buffer: INDEX OUT OF RANGE!\n");
266  }
267 }
unsigned char t_databytes[247]

◆ set_CanOpenType()

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.

76  {
78 }
static int canOpenType2DeamonType(int _canopentype)
Function for typenumber conversion.

◆ set_DaemonType() [1/2]

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.

66  {
67  typenumber = _type;
68 }

◆ set_DaemonType() [2/2]

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.

61  {
62  typenumber = _type;
63 }

◆ set_double()

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.

177  {
178  t_double = _value;
180 }

◆ set_float()

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.

163  {
164  t_float = _value;
166 }

◆ set_int()

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.

148  {
149  t_int = _value;
150  typenumber = RL_INT;
151 }

◆ set_long()

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.

310  {
311  t_long = _value;
313 }

◆ set_longlong()

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.

220  {
221  t_longlong = _value;
223 }
long int t_longlong

◆ set_nodeerror()

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.

504 {
505  bNodeFlagState.bActualError = _nodeerror;
506 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState

◆ set_nodestate()

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.

496 {
497  bNodeFlagState.bNodeState = _nodestate;
499 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState

◆ set_nodestateFlags()

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.

485 {
486  bNodeFlagState.bNodeNoResponse = _bNodeNoResponse;
487  bNodeFlagState.bEmcyBuffOverflow = _bEmcyBuffOverflow;
488  bNodeFlagState.bPrmFault = _bPrmFault;
489  bNodeFlagState.bGuardActive = _bGuardActive;
490  bNodeFlagState.bDeactivated = _bDeactivated;
492 }
struct rlCanOpenTypes::@0::@2 bNodeFlagState

◆ set_rlmsgerr()

void rlCanOpenTypes::set_rlmsgerr ( long  _errnr)

sets the errornumber. refer private varibale rlmsgerr for details

Definition at line 352 of file rlcanopentypes.cpp.

352  {
353  rlmsgerr = _errnr;
354 }

◆ set_short()

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.

191  {
192  t_short = _value;
194 }

◆ set_string()

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.

235  {
236  int i=0;
237  while ((_value[i] != '\0')&&(i<247)){
238  t_string[i] = _value[i];
239  i++;
240  }
242 }
char t_string[247]

◆ set_uchar()

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.

283  {
284  t_databyte = _value;
286 }
unsigned char t_databyte

◆ set_ulong()

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.

338  {
339  t_ulong = _value;
341 }
unsigned long t_ulong

◆ set_ulonglong()

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.

323  {
324  t_ulonglong = _value;
326 }
unsigned long int t_ulonglong

◆ set_ushort()

void rlCanOpenTypes::set_ushort ( unsigned short  _value)

sets type to RL_USHORT and stores passed parameter data in databuffer

Definition at line 205 of file rlcanopentypes.cpp.

205  {
206  t_ushort = _value;
208 }
unsigned short t_ushort

◆ translate_CanOpenType()

bool rlCanOpenTypes::translate_CanOpenType ( int  _canopentype)

Definition at line 573 of file rlcanopentypes.cpp.

574 {
575  switch (_canopentype){
577  if (t_int<0) {
578  t_int = t_int * -1;
579  t_databytes[3] = 00;
580  t_int = t_int * -1;
581  }
582  else{
583  t_databytes[3] = 00;
584  }
585  break;
586 
588  if (t_longlong<0) {
589  t_longlong = t_longlong * -1;
590  t_databytes[5] = 00;
591  t_databytes[6] = 00;
592  t_databytes[7] = 00;
593  t_longlong = t_longlong * -1;
594  }
595  else{
596  t_databytes[5] = 00;
597  t_databytes[6] = 00;
598  t_databytes[7] = 00;
599  }
600  break;
601 
602  case rlCanOpenTypes::INTEGER48_t :return true;
603  if (t_longlong<0) {
604  t_longlong = t_longlong * -1;
605  t_databytes[6] = 00;
606  t_databytes[7] = 00;
607  t_longlong = t_longlong * -1;
608  }
609  else{
610  t_databytes[6] = 00;
611  t_databytes[7] = 00;
612  }
613  break;
614 
615 
616  case rlCanOpenTypes::INTEGER56_t :return true;
617  if (t_longlong<0) {
618  t_longlong = t_longlong * -1;
619  t_databytes[7] = 00;
620  t_longlong = t_longlong * -1;
621  }
622  else{
623  t_databytes[7] = 00;
624  }
625  break;
626 
628  t_databytes[3] = 00;
629  break;
631  t_databytes[5] = 00;
632  t_databytes[6] = 00;
633  t_databytes[7] = 00;
634  break;
636  t_databytes[6] = 00;
637  t_databytes[7] = 00;
638  break;
640  t_databytes[7] = 00;
641  break;
642  default :return false;
643  };
644 
645  return false;
646 }
long int t_longlong
unsigned char t_databytes[247]

◆ type2str()

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.

385  {
386  char* typestr = new char[12];
387  switch(_typenr) {
388  case RL_INT: strncpy(typestr, "RL_INT ", 12); break;
389  case RL_FLOAT: strncpy(typestr, "RL_FLOAT ", 12); break;
390  case RL_DOUBLE: strncpy(typestr, "RL_DOUBLE ", 12); break;
391  case RL_SHORT: strncpy(typestr, "RL_SHORT ", 12); break;
392  case RL_USHORT: strncpy(typestr, "RL_USHORT ", 12); break;
393  case RL_LONGLONG: strncpy(typestr, "RL_LONGLONG ", 12); break;
394  case RL_STRING: strncpy(typestr, "RL_STRING ", 12); break;
395  case RL_BUFFER: strncpy(typestr, "RL_BUFFER ", 12); break;
396  case RL_UCHAR: strncpy(typestr, "RL_UCHAR ", 12); break;
397  case RL_BOOL: strncpy(typestr, "RL_BOOL ", 12); break;
398  case RL_LONG: strncpy(typestr, "RL_LONG ", 12); break;
399  case RL_ULONG: strncpy(typestr, "RL_ULONG ", 12); break;
400  case RL_ULONGLONG: strncpy(typestr, "RL_ULONGLONG", 12); break;
401  case RL_PDO: strncpy(typestr, "RL_PDO ", 12); break;
402  case RL_NODESTATE: strncpy(typestr, "RL_NODESTATE", 12); break;
403  case RL_NOTYPE: strncpy(typestr, "RL_NOTYPE ", 12); break;
404  default: strncpy(typestr, "UNDEFINED ", 12);
405  }
406  return typestr;
407 }

Member Data Documentation

◆ @1

union { ... }

◆ bActualError

unsigned char rlCanOpenTypes::bActualError

Definition at line 365 of file rlcanopentypes.h.

◆ bDeactivated

unsigned char rlCanOpenTypes::bDeactivated

Definition at line 357 of file rlcanopentypes.h.

◆ bEmcyBuffOverflow

unsigned char rlCanOpenTypes::bEmcyBuffOverflow

Definition at line 354 of file rlcanopentypes.h.

◆ bGuardActive

unsigned char rlCanOpenTypes::bGuardActive

Definition at line 356 of file rlcanopentypes.h.

◆ bNodeFlagState

struct { ... } rlCanOpenTypes::bNodeFlagState

◆ bNodeNoResponse

unsigned char rlCanOpenTypes::bNodeNoResponse

Definition at line 353 of file rlcanopentypes.h.

◆ bNodeState

unsigned char rlCanOpenTypes::bNodeState

Definition at line 358 of file rlcanopentypes.h.

◆ bPrmFault

unsigned char rlCanOpenTypes::bPrmFault

Definition at line 355 of file rlcanopentypes.h.

◆ pdobuffer

unsigned char rlCanOpenTypes::pdobuffer[8]

external buffer for pdotransfer

Definition at line 274 of file rlcanopentypes.h.

◆ rlmsgerr

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.

◆ t_bool

bool rlCanOpenTypes::t_bool

Definition at line 346 of file rlcanopentypes.h.

◆ t_databyte

unsigned char rlCanOpenTypes::t_databyte

Definition at line 345 of file rlcanopentypes.h.

◆ t_databytes

unsigned char rlCanOpenTypes::t_databytes[247]

Definition at line 344 of file rlcanopentypes.h.

◆ t_double

double rlCanOpenTypes::t_double

Definition at line 339 of file rlcanopentypes.h.

◆ t_float

float rlCanOpenTypes::t_float

Definition at line 338 of file rlcanopentypes.h.

◆ t_int

int rlCanOpenTypes::t_int

Definition at line 337 of file rlcanopentypes.h.

◆ t_long

long rlCanOpenTypes::t_long

Definition at line 347 of file rlcanopentypes.h.

◆ t_longlong

long int rlCanOpenTypes::t_longlong

Definition at line 342 of file rlcanopentypes.h.

◆ t_short

short rlCanOpenTypes::t_short

Definition at line 340 of file rlcanopentypes.h.

◆ t_string

char rlCanOpenTypes::t_string[247]

Definition at line 343 of file rlcanopentypes.h.

◆ t_ulong

unsigned long rlCanOpenTypes::t_ulong

Definition at line 348 of file rlcanopentypes.h.

◆ t_ulonglong

unsigned long int rlCanOpenTypes::t_ulonglong

Definition at line 349 of file rlcanopentypes.h.

◆ t_ushort

unsigned short rlCanOpenTypes::t_ushort

Definition at line 341 of file rlcanopentypes.h.

◆ typenumber

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.


The documentation for this class was generated from the following files: