rllib  1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
rlCanOpenTypes Class Reference

class to handle CANopen types More...

#include <rlcanopentypes.h>

List of all members.

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
rlCanOpenTypesoperator= (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
}; 

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

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.

                   {
 
 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                                               
};  
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 ( )

Constructor initializes with RL_NOTYPE.

Definition at line 24 of file rlcanopentypes.cpp.


Member Function Documentation

void rlCanOpenTypes::buf2pdobuf ( )

exchange bytes 0-7 from databuffer to pdobuffer

Definition at line 434 of file rlcanopentypes.cpp.

                               {
  for (int i=0; i<8; i++){
    pdobuffer[i]=t_databytes[i];
  }
  typenumber = RL_PDO;
}
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.

{
  // refer table Data Types on page 11 in CiA CANopen Specification
  
  switch(_canopentype)   { 
    case 0x0001:return RL_BOOL;   // c_BOOLEAN         
    case 0x0002:return RL_SHORT;   // INTEGER8_t        
    case 0x0003:return RL_SHORT;   // INTEGER16_t       
    case 0x0004:return RL_LONG;   // INTEGER32_t        
    case 0x0005:return RL_UCHAR;   // UNSIGNED8_t        
    case 0x0006:return RL_USHORT;   // UNSIGNED16_t       
    case 0x0007:return RL_ULONG;   // UNSIGNED32_t       
    case 0x0008:return RL_FLOAT;   // REAL32_t           
    case 0x0009:return RL_STRING;   // VISIBLE_STRING
    case 0x000A:return RL_STRING;   // OCTET_STRING_t     
    case 0x000B:return RL_STRING;   // UNICODE_STRING
    case 0x000C:return RL_ULONGLONG;   // TIME_OF_DAY_t      
    case 0x000D:return RL_ULONGLONG;   // TIME_DIFFERENC
    case 0x000E:return RL_BUFFER;   // BIT_STRING_t       
    case 0x000F:return RL_BUFFER;   // DOMAIN_t           
    case 0x0010:return RL_ULONG;   // INTEGER24_t        
    case 0x0011:return RL_DOUBLE;   // REAL64_t           
    case 0x0012:return RL_LONGLONG;   // INTEGER40_t        
    case 0x0013:return RL_LONGLONG;   // INTEGER48_t        
    case 0x0014:return RL_LONGLONG;   // INTEGER56_t        
    case 0x0015:return RL_LONGLONG;   // INTEGER64_t        
    case 0x0016:return RL_ULONG;   // UNSIGNED24_t       
    case 0x0017:return RL_BUFFER;   // RESERVED1_t        
    case 0x0018:return RL_ULONGLONG;   // UNSIGNED40_t       
    case 0x0019:return RL_ULONGLONG;   // UNSIGNED48_t       
    case 0x001A:return RL_ULONGLONG;   // UNSIGNED56_t       
    case 0x001B:return RL_ULONGLONG;   // UNSIGNED64_t  
    default    :return RL_NOTYPE;   // ERROR
  }
}
void rlCanOpenTypes::clearBuffer ( )

sets all bytes in databuffer to zero

Definition at line 54 of file rlcanopentypes.cpp.

                                {
  for (int i=0; i<247; i++){
    t_databytes[i] = 0;
  }
}
IPCMSGSTRUCT rlCanOpenTypes::createIpcMsg ( )

returns a IPCMSGSTRUCT filled with current object data

Definition at line 451 of file rlcanopentypes.cpp.

                                         {
  IPCMSGSTRUCT istruct;
  for (int i=0; i<247; i++){
    istruct.mtext[i] = t_string[i];
  }
  istruct.typenumber = typenumber;
  istruct.msgtype     = -1;
  istruct.transfertype= -1;
  istruct.processid   = -1;
  istruct.boardid     = -1;
  istruct.nodeid      = -1;
  istruct.objectindex = -1;
  istruct.subindex    = -1;
  istruct.pdoid       = -1;
  istruct.mappingid   = -1;
  istruct.rlmsgerr    = rlmsgerr;
  return istruct;
}
int rlCanOpenTypes::deamonType2CanOpenType ( int  _deamontype) [static]

Function for typenumber conversion.

Definition at line 124 of file rlcanopentypes.cpp.

{

  switch(_deamontype)   {                               
   case RL_INT:return 0x0007;
   case RL_FLOAT:return 0x0008;
   case RL_DOUBLE:return 0x0011;
   case RL_SHORT:return 0x0003;
   case RL_USHORT:return 0x0006;
   case RL_LONGLONG:return 0x0015;
   case RL_STRING:return 0x0009;
   case RL_BUFFER:return 0x000A;
   case RL_UCHAR:return 0x0005;//???
   case RL_BOOL:return 0x0001;
   case RL_LONG:return 0x0004;
   case RL_ULONG:return 0x0007;
   case RL_ULONGLONG:return 0x001B;
   case RL_PDO:return 0x000E;
   case RL_NOTYPE:return 0x0;
   default:return 0x0;
  } 
}         
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.

                             {
  if (typenumber != RL_BOOL){
    invalidTypeError(RL_BOOL);
  }
  return t_bool;
}
unsigned char rlCanOpenTypes::get_buffer ( int  _index)

returns 1 byte from databuffer

Definition at line 271 of file rlcanopentypes.cpp.

                                                  {
  if (_index<247){
    return t_databytes[_index];
  }
  else
  {
    fprintf(stderr, "ERROR! get_buffer: INDEX OUT OF RANGE!\n");  
    return 0;
  }
}
int rlCanOpenTypes::get_CanOpenType ( )

returns the current type converted to CANopen typenumber

Definition at line 81 of file rlcanopentypes.cpp.

int rlCanOpenTypes::get_CanOpenTypeLength ( int  _canopentype)

Definition at line 648 of file rlcanopentypes.cpp.

{
  switch (_canopentype){
    case rlCanOpenTypes::INTEGER24_t :return 3;  
    case rlCanOpenTypes::INTEGER40_t :return 5;  
    case rlCanOpenTypes::INTEGER48_t :return 6;  
    case rlCanOpenTypes::INTEGER56_t :return 7;  
    case rlCanOpenTypes::UNSIGNED24_t:return 3;  
    case rlCanOpenTypes::UNSIGNED40_t:return 5;  
    case rlCanOpenTypes::UNSIGNED48_t:return 6; 
    case rlCanOpenTypes::UNSIGNED56_t:return 7;   
    default                          :return false;
  }; 
}   
int rlCanOpenTypes::get_DaemonType ( )

returns current of data stored in databuffer

Definition at line 71 of file rlcanopentypes.cpp.

                                   {
  return typenumber;
}
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.

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.

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.

                           {
  if (typenumber != RL_INT){
    invalidTypeError(RL_INT);
    
  }
  return t_int;
}
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.

                              {
  if (typenumber != RL_LONG){
    invalidTypeError(RL_LONG);          
  }
  return t_long;
}
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.

unsigned char rlCanOpenTypes::get_nodeerror ( )

returns actual node error

Definition at line 539 of file rlcanopentypes.cpp.

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.

bool rlCanOpenTypes::get_nodestateFlag_Deactivated ( )

Definition at line 566 of file rlcanopentypes.cpp.

bool rlCanOpenTypes::get_nodestateFlag_EmcyBuffOverflow ( )

Definition at line 551 of file rlcanopentypes.cpp.

{
  if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 
  return bNodeFlagState.bEmcyBuffOverflow;
}
bool rlCanOpenTypes::get_nodestateFlag_GuardActive ( )

Definition at line 561 of file rlcanopentypes.cpp.

bool rlCanOpenTypes::get_nodestateFlag_NoResponse ( )

read particular nodestade with the following functions

read particular nodestade

Definition at line 546 of file rlcanopentypes.cpp.

{
  if (typenumber != RL_NODESTATE) invalidTypeError(RL_NODESTATE); 
  return bNodeFlagState.bNodeNoResponse;
}
bool rlCanOpenTypes::get_nodestateFlag_PrmFault ( )

Definition at line 556 of file rlcanopentypes.cpp.

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.

{
  if (typenumber == RL_NODESTATE){
    _bNodeNoResponse    = bNodeFlagState.bNodeNoResponse;
    _bEmcyBuffOverflow  = bNodeFlagState.bEmcyBuffOverflow;
    _bPrmFault          = bNodeFlagState.bPrmFault;
    _bGuardActive       = bNodeFlagState.bGuardActive;
    _bDeactivated       = bNodeFlagState.bDeactivated;
    return true;
  }
  else
  {
    invalidTypeError(RL_NODESTATE);    
    return false;
  }
}                     
long rlCanOpenTypes::get_rlmsgerr ( )

returns current errnumber

Definition at line 357 of file rlcanopentypes.cpp.

                                 {
  return rlmsgerr;
}
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.

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.

                                {
  if (typenumber != RL_STRING){
    invalidTypeError(RL_STRING);
  }
  char* outstring = new char[247];
  int i=0;
  while ((t_string[i] != '\0')&&(i<247)){
    outstring[i] = t_string[i];
    i++;        
  }
  return outstring;
}
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.

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.

unsigned long int rlCanOpenTypes::get_ulonglong ( )

returns databuffer-content as unsigned long long type

Definition at line 329 of file rlcanopentypes.cpp.

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.

void rlCanOpenTypes::getIpcMsg ( IPCMSGSTRUCT  _myIpcMsg)

overwrites all data with IPCMSGSTRUCT data

Definition at line 471 of file rlcanopentypes.cpp.

                                                    {
  for (int i=0; i<247; i++){
    t_string[i] = _myIpcMsg.mtext[i];
  }
  typenumber = _myIpcMsg.typenumber;
  rlmsgerr   = _myIpcMsg.rlmsgerr;
}
int rlCanOpenTypes::getLength ( )

returns number of bytes used for current type

Definition at line 31 of file rlcanopentypes.cpp.

{
  switch(typenumber)   {                               
    case RL_INT:       return 4;
    case RL_FLOAT:     return 4;
    case RL_DOUBLE:    return 8;
    case RL_SHORT:     return 2;
    case RL_USHORT:    return 2;
    case RL_LONGLONG:  return 8;
    case RL_STRING:    return 246;
    case RL_BUFFER:    return 246;
    case RL_UCHAR:     return 1;
    case RL_BOOL:      return 1;
    case RL_LONG:      return 4;
    case RL_ULONG:     return 4;
    case RL_ULONGLONG: return 8;
    case RL_PDO:       return 8;
    case RL_NOTYPE:    return 0;
    default:           return 0;
  } 
}   
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.

                                                 {
  char* curTypeStr; 
  char* usrTypeStr;
  curTypeStr = type2str(typenumber);
  usrTypeStr = type2str(_typenr);
  rlDebugPrintf("Warning! %s invalid type! current data type is: %s \n"
         , usrTypeStr, curTypeStr);
  delete curTypeStr;
  delete usrTypeStr;
}
rlCanOpenTypes & rlCanOpenTypes::operator= ( rlCanOpenTypes cp)

copies all data from right object into left object

Definition at line 363 of file rlcanopentypes.cpp.

                                                             {
  typenumber = cp.typenumber;
  rlmsgerr = cp.rlmsgerr;
  for (int i=0; i<246; i++){
    t_databytes[i]=cp.t_databytes[i];
  }
  return *this;
}
void rlCanOpenTypes::pdobuf2buf ( )

exchange bytes 0-7 from pdobuffer to databuffer

Definition at line 442 of file rlcanopentypes.cpp.

                               {
  for (int i=0; i<8; i++){
    t_databytes[i]=pdobuffer[i];
  }
  typenumber = RL_PDO;
}
void rlCanOpenTypes::rlMsgErrOut ( )

prints MsgErrStr to StdOut

prints error message to StdOut

Definition at line 410 of file rlcanopentypes.cpp.

                                {
  char* errOut = rlMsgErrStr();
  rlDebugPrintf("ERROR: \"%s\" \n", errOut);
  delete errOut;
}
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.

                                 {
  char* errstr = new char[25];
  switch(rlmsgerr)   {                               
   case 0:  strncpy(errstr, "ERRCODE_NOERROR       ", 25); break;
   case -1: strncpy(errstr, "                      ", 25); break;
   case -2: strncpy(errstr, "ERRCODE_INVALID_NODEID", 25); break;
   case -3: strncpy(errstr, "ERRCODE_INVALID_PDOID ", 25); break;
   case -4: strncpy(errstr, "ERRCODE_PDOSND_FAIL   ", 25); break;
   case -5: strncpy(errstr, "ERRCODE_INVALID_MAPID ", 25); break;
   case -6: strncpy(errstr, "ERRCODE_INVALID_RLTYPE", 25); break;
   case -7: strncpy(errstr, "ERRCODE_PDORCV_FAIL   ", 25); break;
   default: strncpy(errstr, "ERRCODE_MSGF          ", 25); break;
  } 
  return errstr;
}
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.

                                        {
  t_bool = _value;
  typenumber = RL_BOOL;
}
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.

                                                                  {
  if (_index<247){
    t_databytes[_index] = _databyte;
  }
  else
  {
    fprintf(stderr, "ERROR! set_buffer: INDEX OUT OF RANGE!\n");  
  }
}
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.

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.

                                                 {
  typenumber  = _type;
}
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.

                                            {
  typenumber  = _type;
}
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.

                                            {
  t_double = _value;
  typenumber = RL_DOUBLE;
}
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.

                                          {
  t_float = _value;
  typenumber = RL_FLOAT;
}
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.

                                      {
  t_int = _value;
  typenumber = RL_INT;
}
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.

                                        {
  t_long = _value;
  typenumber = RL_LONG;
}
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.

                                                {
  t_longlong = _value;
  typenumber = RL_LONGLONG;
}
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.

{
  bNodeFlagState.bActualError = _nodeerror;
}
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.

{
  bNodeFlagState.bNodeState = _nodestate;
  typenumber = RL_NODESTATE;
}  
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.

{
  bNodeFlagState.bNodeNoResponse   =  _bNodeNoResponse;  
  bNodeFlagState.bEmcyBuffOverflow =  _bEmcyBuffOverflow;
  bNodeFlagState.bPrmFault         =  _bPrmFault;        
  bNodeFlagState.bGuardActive      =  _bGuardActive;     
  bNodeFlagState.bDeactivated      =  _bDeactivated;     
  typenumber = RL_NODESTATE;
}
void rlCanOpenTypes::set_rlmsgerr ( long  _errnr)

sets the errornumber. refer private varibale rlmsgerr for details

Definition at line 352 of file rlcanopentypes.cpp.

                                            {
  rlmsgerr = _errnr;
}
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.

                                          {
  t_short = _value;
  typenumber = RL_SHORT;
}
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.

                                                 {
  int i=0;
  while ((_value[i] != '\0')&&(i<247)){
    t_string[i] = _value[i];
    i++;        
  }
  typenumber = RL_STRING;
}
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.

                                                  {
  t_databyte = _value;
  typenumber = RL_UCHAR;
}
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.

                                                  {
  t_ulong = _value;
  typenumber = RL_ULONG;
}
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.

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.

                                            {
  t_ushort = _value;
  typenumber = RL_USHORT;
}
bool rlCanOpenTypes::translate_CanOpenType ( int  _canopentype)

Definition at line 573 of file rlcanopentypes.cpp.

{
  switch (_canopentype){
    case rlCanOpenTypes::INTEGER24_t :
      if (t_int<0) {
        t_int = t_int * -1;
        t_databytes[3] = 00;
        t_int = t_int * -1;
      }
      else{
        t_databytes[3] = 00;
      } 
    break;
    
    case rlCanOpenTypes::INTEGER40_t :
      if (t_longlong<0) {
        t_longlong = t_longlong * -1;
        t_databytes[5] = 00;
        t_databytes[6] = 00;
        t_databytes[7] = 00;
        t_longlong = t_longlong * -1;
      }
      else{
        t_databytes[5] = 00;
        t_databytes[6] = 00;
        t_databytes[7] = 00;
      } 
    break;
      
    case rlCanOpenTypes::INTEGER48_t :return true;  
      if (t_longlong<0) {
        t_longlong = t_longlong * -1;
        t_databytes[6] = 00;
        t_databytes[7] = 00;
        t_longlong = t_longlong * -1;
      }
      else{
        t_databytes[6] = 00;
        t_databytes[7] = 00;
      } 
    break;


    case rlCanOpenTypes::INTEGER56_t :return true;  
      if (t_longlong<0) {
        t_longlong = t_longlong * -1;
        t_databytes[7] = 00;
        t_longlong = t_longlong * -1;
      }
      else{
        t_databytes[7] = 00;
      } 
    break;

    case rlCanOpenTypes::UNSIGNED24_t:
      t_databytes[3] = 00;
    break;
    case rlCanOpenTypes::UNSIGNED40_t:
      t_databytes[5] = 00;
      t_databytes[6] = 00;      
      t_databytes[7] = 00;      
    break;    
    case rlCanOpenTypes::UNSIGNED48_t:
      t_databytes[6] = 00;      
      t_databytes[7] = 00;      
    break;        
    case rlCanOpenTypes::UNSIGNED56_t:
      t_databytes[7] = 00;      
    break;        
    default                          :return false;
  };
  
  return false;
}
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.

                                         {
  char* typestr = new char[12];
  switch(_typenr)   {                               
   case RL_INT:       strncpy(typestr, "RL_INT      ", 12); break;
   case RL_FLOAT:     strncpy(typestr, "RL_FLOAT    ", 12); break;
   case RL_DOUBLE:    strncpy(typestr, "RL_DOUBLE   ", 12); break;
   case RL_SHORT:     strncpy(typestr, "RL_SHORT    ", 12); break;
   case RL_USHORT:    strncpy(typestr, "RL_USHORT   ", 12); break;
   case RL_LONGLONG:  strncpy(typestr, "RL_LONGLONG ", 12); break;
   case RL_STRING:    strncpy(typestr, "RL_STRING   ", 12); break;
   case RL_BUFFER:    strncpy(typestr, "RL_BUFFER   ", 12); break;
   case RL_UCHAR:     strncpy(typestr, "RL_UCHAR    ", 12); break;
   case RL_BOOL:      strncpy(typestr, "RL_BOOL     ", 12); break;
   case RL_LONG:      strncpy(typestr, "RL_LONG     ", 12); break;
   case RL_ULONG:     strncpy(typestr, "RL_ULONG    ", 12); break;
   case RL_ULONGLONG: strncpy(typestr, "RL_ULONGLONG", 12); break;
   case RL_PDO:       strncpy(typestr, "RL_PDO      ", 12); break;
   case RL_NODESTATE: strncpy(typestr, "RL_NODESTATE", 12); break;
   case RL_NOTYPE:    strncpy(typestr, "RL_NOTYPE   ", 12); break;
   default:           strncpy(typestr, "UNDEFINED   ", 12); 
  } 
  return typestr;
}

Member Data Documentation

union { ... } [private]

Definition at line 365 of file rlcanopentypes.h.

Definition at line 357 of file rlcanopentypes.h.

Definition at line 354 of file rlcanopentypes.h.

Definition at line 356 of file rlcanopentypes.h.

Definition at line 353 of file rlcanopentypes.h.

Definition at line 358 of file rlcanopentypes.h.

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.

Definition at line 345 of file rlcanopentypes.h.

unsigned char rlCanOpenTypes::t_databytes[247]

Definition at line 344 of file rlcanopentypes.h.

Definition at line 339 of file rlcanopentypes.h.

Definition at line 338 of file rlcanopentypes.h.

Definition at line 337 of file rlcanopentypes.h.

Definition at line 347 of file rlcanopentypes.h.

Definition at line 342 of file rlcanopentypes.h.

Definition at line 340 of file rlcanopentypes.h.

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.

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: