rllib  1
rlcanopen.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rlcanopen.cpp - description
3  -------------------
4  begin : Tue March 03 2004
5  copyright : (C) 2004 by Marc Br�tigam, Christian Wilmes, R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 
17 //class to manage the nodes in a CanOpen network
18 
19 #include "rlcutil.h"
20 #include "rlcanopen.h"
21 
22 #ifdef RLWIN32
23 #include <windows.h>
24 #include <math.h>
25 #endif
26 
27 #include <time.h>
28 
29 rlCanOpen::rlCanOpen(char * _inifilename)
30 {
31  rlDebugPrintf("Constructer nodes class\n");
32  read_inifile(_inifilename);
33  if (enableLogging){
34  freopen (logFileName.ascii(),"w",stdout); // redirekt stdout to textfile
35  }
36  ini();
37 }
38 
39 
41 {
42  rlDebugPrintf("Constructer nodes class\n");
43  read_inifile("./canopen.ini");
44  if (enableLogging){
45  FILE* fp;
46  fp = freopen (logFileName.ascii(),"w",stdout); // redirekt stdout to textfile
47 
48  /* enable linebuffering in order to write every line to the file immediately */
49  setvbuf ( fp , NULL , _IOFBF , 1024 );
50  }
51  ini();
52 }
53 //---------------------------------------------------------------------------
55 {
56  rlDebugPrintf("destruktor rlCanOpen\n");
57  for (int i=0;i<boardcount;i++)
58  DevExitBoard(i);
59 
60 #ifdef RLWIN32
61  DevCloseDriver(0);
62 #else
63  DevCloseDriver();
64 #endif
65  if (enableLogging)
66  fclose (stdout);
67 
68 }
69 //---------------------------------------------------------------------------
72 {
73  messagenr = 0;
74  nodelist.setAutoDelete(true);
75 
76  time_t rawtime;
77  struct tm * timeinfo;
78  time ( &rawtime );
79  timeinfo = localtime ( &rawtime );
80 
81  sprintf(err_out_buf, "\nnew session startet: %s\n", asctime(timeinfo));
83 
84  if (iniboards()){
85  rlDebugPrintf("at least one board initialize!\n");
86  }
87  else
88  {
89  rlDebugPrintf("no board available or no board could be initialized correctly!\n");
90  rlDebugPrintf("Programm -> Close\n");
91  exit(0);
92  }
93 
94  // search for active nodes and create them
95 
96  createNodes();
97 
98 
99  return 1;
100 }
101 //---------------------------------------------------------------------------
104 {
105  int nodeid;
106  for (int boardid = 0;boardid<boardcount;boardid++)
107  {
108  setBoardActive(boardid);
109  for(nodeid = 0; nodeid <= MAX_NODES; nodeid++) // from node 0..127
110  if (getNodeConfiguration(nodeid)) // writes received node-configuration
111  // into class-global message-struct
112  {
113  // new node found. insert it into the nodelist
114  nodelist.resize( nodelist.size() + 1 );
115 
116  // append the new node in the list
117  nodelist.insert( nodelist.size()-1,
118  new rlCanNode(boardid,nodeid,message));
119 
120  //append Mapping data
121  if (nodelist[nodelist.size()-1]->hasMapping()){
122  if(!createMappingObjects(boardid,nodeid,DIRECTION_TRANSMIT))return 0;
123  if(!createMappingObjects(boardid,nodeid,DIRECTION_RECEIVE))return 0;
124  }
125  else
126  {
127  rlDebugPrintf("WARNING: no Mapping available on node %d.", nodeid);
128  rlDebugPrintf("Probably EDS file couldn't be found in EDS directory.\n");
129  }
130  }
131  }
132  return 1;
133 }
134 
135 //------------------------------------------------------------------------------
137 int rlCanOpen::createMappingObjects(int _boardid,int _nodeid,int _pdoDirection)
138 {
139  int pdomax = 0;
140  if (_pdoDirection == DIRECTION_RECEIVE)
141  pdomax = nodelist[nodelist.size()-1]->getReceivePdoCount();
142  else if(_pdoDirection == DIRECTION_TRANSMIT)
143  pdomax = nodelist[nodelist.size()-1]->getTransmitPdoCount();
144 
145  for (int j = 1;j<=pdomax;j++) //each receive/transmit pdo
146  if(refreshMappingList(_boardid,_nodeid,j,_pdoDirection)==0) return 0;
147  return 1;
148 
149 }
150 
151 
152 //---------------------------------------------------------------------------
155 {
156 
157  int currentboardcount=0;
158 
159  BOARD_INFO tBoardInfo;
160 
161 #ifdef RLWIN32
162  if ( (sRet = DevOpenDriver(0)) == DRV_NO_ERROR)
163 #else
164  if ( (sRet = DevOpenDriver()) == DRV_NO_ERROR)
165 #endif
166  {
167  // Driver successfully opend, read board information
168 #ifdef RLWIN32
169  if ( (sRet = DevGetBoardInfo( 0, sizeof(tBoardInfo), &tBoardInfo)) != DRV_NO_ERROR)
170 #else
171  if ( (sRet = DevGetBoardInfo( &tBoardInfo)) != DRV_NO_ERROR)
172 #endif
173  {
174  // Function error
175  rlDebugPrintf( "DevGetBoardInfo RetWert = %5d \n", sRet );
176  } else
177  {
178  // Information successfully read, save for further use
179  // Check out which boards are available
180  for ( int usIdx = 0; usIdx < MAX_DEV_BOARDS; usIdx++)
181  {
182  if ( tBoardInfo.tBoard[usIdx].usAvailable == TRUE) {
183  // Board is configured, try to init the board
184  sRet = DevInitBoard(
185 #ifdef RLWIN32
186  tBoardInfo.tBoard[usIdx].usBoardNumber, NULL);
187 #else
188  tBoardInfo.tBoard[usIdx].usBoard);
189 #endif
190  if ( sRet != DRV_NO_ERROR) {
191  // Function error
192  rlDebugPrintf( "DevInitBoard RetWert = %5d \n", sRet );
193  } else {
194  // DEVICE is available and ready............
195  currentboardcount++;
196  }
197  }
198  }
199  }
200  }
201  boardcount = currentboardcount;
202 
203  if (currentboardcount!=0)
204  return 1;
205  else
206  return 0;
207 }
208 
209 //---------------------------------------------------------------------------
212 {
213  return boardcount;
214 }
215 //---------------------------------------------------------------------------
216 //* this function reads out the configuration of a specific node
218 {
219  //build message
220  message.rx = CAN_TASK;
221  message.tx = USER_AT_HOST;
222  message.ln = 8;
223  message.nr =messagenr++;
224  message.a =0;
225  message.f =0;
227  message.e =0x00; //fragmentation
228  message.device_adr =_nodeID;
229  message.data_area =0;
230  message.data_adr =0;
231  message.data_idx =0;
232  message.data_cnt =0;
233  message.data_type =0;
234  message.function =0;
235 
236  //put configuration request
237  DevPutMessage(0, (MSG_STRUC *)&message,5000L) ;
238 
239  //receive answer message
240  sRet = DevGetMessage ( 0,
241  sizeof(message),
242  (MSG_STRUC *)&message,
243  2000L );
244 
245  unsigned char msgnrlocal = messagenr -1;
246 
247  // receive correct answer
248  if((message.a == RESPONSE_CODE_GET_CONFIGURATION) && (message.nr == msgnrlocal))
249  if (message.f == ERRCODE_NOERROR) // node active, no error
250  if(message.e == 0x00) //configuration fits in the message
251  {
252  sprintf(err_out_buf, "Board %d node %d is active. No problems found\n",
253  getActiveBoard(), _nodeID);
254 
256  return 1;
257  }
258  else
259  {
260  sprintf(err_out_buf, "Board %d node %d is active. \n",
261  getActiveBoard(), _nodeID);
262 
264  rlDebugPrintf("Configuration data does not fit in one message,\n");
265  rlDebugPrintf("so the current node does not include the complete data\n");
266  rlDebugPrintf(" - multiplex configration data is not yet implemented!!! -\n");
267  return 1;
268  }
269  else return 0;
270  else
271  {
272  sprintf(err_out_buf, "---->message.a=%d, message.nr=%d unsere msg nr: %d\n",
273  message.a, message.nr, msgnrlocal);
274 
276  sprintf(err_out_buf, "%s\n", "Communication ERROR!!!");
278  return 0;
279  }
280 }
281 
282 
283 //---------------------------------------------------------------------------
285 short rlCanOpen::setBoardActive(int _boardnr)
286 {
287 
288  if ( (sRet = DevSetHostState( _boardnr, HOST_READY, 0L) == DRV_NO_ERROR) )
289  activeboard = _boardnr;
290 
291  return sRet;
292 }
293 
294 //---------------------------------------------------------------------------
297 {
298  return activeboard;
299 }
300 
301 //---------------------------------------------------------------------------
303 bool rlCanOpen::showNodeConfiguration(int _boardnr,int _nodeid)
304 {
305  for( unsigned int i = 0; i < nodelist.size(); i++)
306  {
307  if ((nodelist[i]->getNodeID() == _nodeid) &&
308  (nodelist[i]->getBoardID() == _boardnr))
309  {
310  nodelist[i]->showConfiguration();
311  return true;
312 
313  }
314  }
315 
316  return false;
317 }
318 //---------------------------------------------------------------------------
321 {
322  if(nodelist.size() == 0) return 0;
323  for(unsigned int i = 0; i < nodelist.size(); i++)
324  {
325  nodelist[i]->showConfiguration();
326  }
327  return 1;
328 }
329 //---------------------------------------------------------------------------
330 
332 int rlCanOpen::sdo_read( int _boardnr,
333  int _nodeid,
334  int _objectindex,
335  int _subindex,
336  rlCanOpenTypes &_sdo_data)
337 {
338  int datalength;
339  int canopentype;
340  int nodeindex;
341 
342  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
343  {
344  rlDebugPrintf("ERROR: specified node does not exist! SDO write failed!");
345  rlDebugPrintf("BoardId: %d NodeId: %d Objektindex: %d Subindex: %d\n",
346  _boardnr, _nodeid, _objectindex, _subindex);
347 
349  return 0;
350  }
351 
352 
353  delmsg();
354  setBoardActive(_boardnr);
355 
356  message.rx = CAN_TASK;
357  message.tx = USER_AT_HOST;
358  message.ln = 8;
359  message.nr = messagenr++;
360  message.a = 0;
361  message.f = 0;
363  message.e = 0;
364  message.device_adr = _nodeid;
365  message.data_area = 0;
366  message.data_adr = _objectindex;
367  message.data_idx = _subindex;
368  message.data_cnt = 0;
369  message.data_type = 0;
370  message.function = TASK_TFC_READ;
371 
372  if(DevPutMessage(0, (MSG_STRUC *)&message,5000L) != DRV_NO_ERROR) return 0;
373 
374  delmsg();
375  // receive the answer
376 
377  sRet = DevGetMessage( getActiveBoard(), // Device Number
378  sizeof(message),
379  (MSG_STRUC *)&message, // Pointer to user buffer
380  2000L ); // Timeout
381  unsigned char msgnrlocal;
382  msgnrlocal = messagenr - 1;
383 
384  // receive correct answer
385  if((message.a == CMDCODE_SDO_UPDOWNLOAD)&&(message.nr == msgnrlocal)){
386  _sdo_data.set_rlmsgerr(message.f);
387  if (message.f == ERRCODE_NOERROR) // node active, no error
388  {
389  canopentype=getObjectType(_boardnr, _nodeid, _objectindex, _subindex);
390  if (canopentype!=rlCanOpenTypes::RL_NOTYPE){
391  _sdo_data.set_CanOpenType(canopentype);
392  datalength = _sdo_data.getLength();
393  }
394  else
395  {
397  datalength = MAX_SDO_BUFFERSIZE;
398  }
399  _sdo_data.clearBuffer();
400  for(int i = 0; i < datalength; i++)
401  _sdo_data.set_buffer(i, message.d[i]);
402 
403  // if CanOpen-Type is a twistet integer (etc. 52Bit ) the value will be converted
404  if ((is_twisted_type(canopentype)) && (nodelist[nodeindex]->hasMapping()))
405  _sdo_data.translate_CanOpenType(canopentype);
406 
407  return 1;
408  }
409  else
410  {
411  rlDebugPrintf("message.f = %d message.f = %x Hex \n", message.f, message.f);
412  }
413  }
414  else
415  {
416  rlDebugPrintf("message.a = %d message.nr = %d vergleich mit: %d\n",
417  message.a, message.nr, msgnrlocal);
418 
419  _sdo_data.set_rlmsgerr(-1);
420  }
421  rlDebugPrintf("ERROR during read SDO message!");
422  rlDebugPrintf("BoardId: %d NodeId: %d Obj: %x Sub: %x\n",
423  _boardnr, _nodeid, _objectindex, _subindex);
424 
425 
426  return 0;
427 }
428 //---------------------------------------------------------------------------
429 
431 int rlCanOpen::sdo_write( int _boardnr,
432  int _nodeid,
433  int _objectindex,
434  int _subindex,
435  rlCanOpenTypes &_sdo_data)
436 {
437  int length;
438  int pdoid;
439  length = _sdo_data.getLength();
440  int nodeindex;
441  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
442  {
443  rlDebugPrintf("ERROR: specified node does not exist! SDO write failed!");
444  rlDebugPrintf("BoardId: %d NodeId: %d Objektindex: %d Subindex: %d\n",
445  _boardnr, _nodeid, _objectindex, _subindex);
446 
448  return 0;
449  }
450 
451  // if CanOpen-Type is a twistet integer (etc. 52Bit ) the datalength must be adjusted
452  int canopentype = getObjectType(_boardnr, _nodeid, _objectindex, _subindex);
453 
454  if ((is_twisted_type(canopentype)) && (nodelist[nodeindex]->hasMapping()))
455  length = _sdo_data.get_CanOpenTypeLength(canopentype);
456 
457  for(int i = 0;i<length;i++)
458  message.d[i] = _sdo_data.get_buffer(i);
459 
460 
461  setBoardActive(_boardnr);
462 
463  message.rx = CAN_TASK;
464  message.tx = USER_AT_HOST;
465  message.ln = 8+ length;
466  message.nr = messagenr++;
467  message.a = 0;
468  message.f = 0;
470  message.e = 0;
471  message.device_adr = _nodeid;
472  message.data_area = 0;
473  message.data_adr = _objectindex;
474  message.data_idx = _subindex;
475  message.data_cnt = length;
476  message.data_type = 0;
477  message.function = TASK_TFC_WRITE;
478 
479  if(DevPutMessage(0, (MSG_STRUC *)&message,5000L) != DRV_NO_ERROR) return 0;
480 
481 
482  // receive the answer
483 
484  sRet = DevGetMessage ( _boardnr, // Device Number
485  sizeof(message),
486  (MSG_STRUC *)&message, // Pointer to user buffer
487  2000L ); // Timeout
488 
489  unsigned char msgnrlocal = messagenr - 1;
490 
491  // receive correct answer
492  if((message.a == CMDCODE_SDO_UPDOWNLOAD)&&(message.nr == msgnrlocal)){
493  _sdo_data.set_rlmsgerr(message.f);
494  if (message.f == ERRCODE_NOERROR) // node active, no error
495  {
496  //check if the mapping has changed
497  if( (_objectindex >= TRANSMIT_PDO_MAPPING_STARTADRESS) &&
498  (_objectindex <= TRANSMIT_PDO_MAPPING_MAXADRESS) &&
499  (nodelist[nodeindex]->hasMapping()) )
500  {
501  rlDebugPrintf("Mapping has changed: boardid %d, nodeid %d, objectindex %x\n",
502  _boardnr, _nodeid, _objectindex);
503 
504  pdoid = getPdoID(_boardnr, _nodeid, _objectindex, DIRECTION_TRANSMIT);
505  refreshMappingList(_boardnr,_nodeid,pdoid,DIRECTION_TRANSMIT);
506  }
507  else if ( (_objectindex >= RECEIVE_PDO_MAPPING_STARTADRESS) &&
508  (_objectindex <= RECEIVE_PDO_MAPPING_MAXADRESS) &&
509  (nodelist[nodeindex]->hasMapping()) )
510  {
511  rlDebugPrintf("Mapping has changed: boardid %d, nodeid %d, objectindex %x\n",
512  _boardnr, _nodeid, _objectindex);
513  pdoid = getPdoID(_boardnr, _nodeid, _objectindex, DIRECTION_RECEIVE);
514  refreshMappingList(_boardnr,_nodeid,pdoid,DIRECTION_RECEIVE);
515  }
516  return 1;
517  }
518  else
519  {
520  sprintf(err_out_buf, "message.f = %d message.f = %x Hex \n",
521  message.f, message.f);
522 
524  _sdo_data.set_rlmsgerr(message.f);
525  }
526  }
527  else
528  {
529  _sdo_data.set_rlmsgerr(-1);
530  sprintf(err_out_buf, "message.a = %d message.nr = %d vergleich mit: %d\n",
531  message.a, message.nr, msgnrlocal);
532 
534  }
535  rlDebugPrintf("ERROR during read SDO message!");
536  rlDebugPrintf("BoardId: %d NodeId: %d Obj: %x Sub: %x\n",
537  _boardnr, _nodeid, _objectindex, _subindex);
538 
540  return 0;
541 }
542 //---------------------------------------------------------------------------
544 int rlCanOpen::pdo_receive( int _boardnr,
545  int _nodeid,
546  int _pdonr,
547  int _mappingnr,
548  rlCanOpenTypes &_pdo_data)
549 {
550 
551  int nodeindex;
552  unsigned char buffer[8];
553 
554  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
555  {
556  rlDebugPrintf("ERROR: specified node does not exist! PDO receive failed!");
557  rlDebugPrintf("BoardId: %d NodeId: %d PDO ID: %d Mappingnr: %d\n",
558  _boardnr, _nodeid, _pdonr, _mappingnr);
559 
561  return 0;
562  }
563  if (nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT].size() < (unsigned int) _pdonr){
564  rlDebugPrintf("ERROR: specified PDO ID does not exist! PDO receive failed!");
565  rlDebugPrintf("BoardId: %d NodeId: %d PDO ID: %d Mappingnr: %d\n",
566  _boardnr, _nodeid, _pdonr, _mappingnr);
567 
569  return 0;
570  }
571  else if (nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr -1]->mappingList.size()
572  < (unsigned int) _mappingnr){
573  rlDebugPrintf("ERROR: specified Mappingnr does not exist! PDO receive failed!");
574  rlDebugPrintf("BoardId: %d NodeId: %d PDO ID: %d Mappingnr: %d\n",
575  _boardnr, _nodeid, _pdonr, _mappingnr);
576 
578  return 0;
579  }
580 
581  // PDO No.1 has the index 0 !!!
582  int pdosize = nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr-1]->bPDOSize;
583  int pdooffset = nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr-1]->usPDOAddress;
584 
585  //cout<<"size ="<<pdosize<<" offset = "<<pdooffset<<"\n";
586 
587  if ( (sRet = DevExchangeIO( _boardnr, // Board NO
588  0, //offset send data
589  0, //Length of the send IO data
590  NULL, //Pointer to the user send data buffer
591  pdooffset, //Byte offset in the receive IO data area
592  pdosize, //Length of the receive IO data
593  &buffer[0], //Pointer to the user read data buffer
594  100L) //timeout in milliseconds
595  ) == DRV_NO_ERROR)
596  {
597 
598  int length_in_byte = nodelist[nodeindex]->
599  pdoList[DIRECTION_TRANSMIT][_pdonr-1]->mappingList[_mappingnr-1]->length/8;
600 
601  int position_in_byte = nodelist[nodeindex]->
602  pdoList[DIRECTION_TRANSMIT][_pdonr-1]->mappingList[_mappingnr-1]->position/8;
603 
604  _pdo_data.clearBuffer();
605 
606  for(int i = position_in_byte; i< length_in_byte+position_in_byte;i++)
607  {
608  _pdo_data.set_buffer(i-position_in_byte,buffer[i]);
609  }
610 
611  _pdo_data.set_DaemonType( nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr-1]->
612  mappingList[_mappingnr-1]->etype);
613 
614 
615  _pdo_data.set_rlmsgerr(ERRCODE_NOERROR);
616 
617 
618  // if CanOpen-Type is a twistet integer (etc. 52Bit ) the value will be converted
619  int canopentype = nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr-1]->
620  mappingList[_mappingnr-1]->canopentype;
621 
622  if (is_twisted_type(canopentype))
623  _pdo_data.translate_CanOpenType(canopentype);
624 
625  return 1;
626  }
627  rlDebugPrintf("ERROR: PDO receive failed!");
628  rlDebugPrintf("BoardId: %d NodeId: %d PDO ID: %d Mappingnr: %d\n",
629  _boardnr, _nodeid, _pdonr, _mappingnr);
630 
632 
633  return 0;
634 }
635 //---------------------------------------------------------------------------
637 int rlCanOpen::pdo_receive( int _boardnr,
638  int _nodeid,
639  int _pdonr,
640  rlCanOpenTypes &_pdo_data)
641 {
642 
643  int nodeindex;
644  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
645  {
646  sprintf(err_out_buf, "ERROR: specified node does not exist! PDO \
647  receive failed! BoardId: %d NodeId: %d PDO \
648  ID: %d\n", _boardnr, _nodeid, _pdonr);
650 
651  //cout<<"ERROR: specified node does not exist!\n";
653  return 0;
654  }
655 
656  if (nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT].size() < (unsigned int) _pdonr){
657  sprintf(err_out_buf, "ERROR: specified PDO ID does not exist! \
658  PDO receive failed! BoardId: %d NodeId: \
659  %d PDO ID: %d\n", _boardnr, _nodeid, _pdonr);
661 
662  //cout<<"PDO ID does not exists!\n";
664  return 0;
665  }
666 
667  int pdosize = nodelist[nodeindex]->pdoList[DIRECTION_TRANSMIT][_pdonr-1]->bPDOSize;
668 
669  int pdooffset = nodelist[nodeindex]->
670  pdoList[DIRECTION_TRANSMIT][_pdonr-1]->usPDOAddress;
671 
672  //cout<<"\nsize ="<<pdosize<<" offset = "<<pdooffset;
673 
674  if ( (sRet = DevExchangeIO( _boardnr, // Board NO
675  0, //offset send data
676  0, //Length of the send IO data
677  NULL, //Pointer to the user send data buffer
678  pdooffset, //Byte offset in the receive IO data area
679  pdosize, //Length of the receive IO data
680  &_pdo_data.pdobuffer[0],//Pointer to the user read data buffer
681  100L) //timeout in milliseconds
682  ) == DRV_NO_ERROR)
683  {
684  _pdo_data.pdobuf2buf();
685  //rlDebugPrintf("PDO recieve successfull!\n");
686  _pdo_data.set_rlmsgerr(ERRCODE_NOERROR);
687  return 1;
688 
689  }
690  sprintf(err_out_buf, "ERROR: PDO receive failed! \
691  BoardId: %d NodeId: %d PDO \
692  ID: %d\n", _boardnr, _nodeid, _pdonr);
694 
695  //rlDebugPrintf("ERROR: PDO RECEIVE FAILED\n");
697  return 0;
698 }
699 
700 
701 //---------------------------------------------------------------------------
703 int rlCanOpen::pdo_transmit( int _boardnr,
704  int _nodeid,
705  int _pdonr,
706  int _mappingnr,
707  rlCanOpenTypes &_pdo_data)
708 {
709  int nodeindex;
710  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
711  {
712  sprintf(err_out_buf, "ERROR: specified node does not exist! PDO transmit \
713  failed! BoardId: %d NodeId: %d PDO ID: %d Mappingnr:\
714  %d\n", _boardnr, _nodeid, _pdonr, _mappingnr);
717  return 0;
718  }
719  if (nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE].size() < (unsigned int) _pdonr){
720  sprintf(err_out_buf, "ERROR: specified PDO ID does not exist! PDO transmit\
721  failed! BoardId: %d NodeId: %d PDO ID: %d Mappingnr:\
722  %d\n", _boardnr, _nodeid, _pdonr, _mappingnr);
724 
725  //cout<<"PDO ID does not exists!\n";
727  return 0;
728  }
729  else if (nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr -1]->mappingList.size()
730  < (unsigned int) _mappingnr){
731  sprintf(err_out_buf, "ERROR: specified mappingnr does not exist! PDO \
732  transmit failed! BoardId: %d NodeId: %d PDO \
733  ID: %d Mappingnr: %d\n",
734  _boardnr, _nodeid, _pdonr, _mappingnr);
736 
737  //cout<<"mapping ID does not exists!\n";
739  return 0;
740  }
741 
742  // PDO No.1 has the index 0 !!!
743  int pdosize = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->bPDOSize;
744  int pdooffset = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->usPDOAddress;
745 
746  int length_in_byte = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->
747  mappingList[_mappingnr-1]->length/8;
748 
749  int position_in_byte = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->
750  mappingList[_mappingnr-1]->position/8;
751 
752  if (_pdo_data.get_DaemonType() != (nodelist[nodeindex]->
753  pdoList[DIRECTION_RECEIVE][_pdonr-1]->mappingList[_mappingnr-1]->etype))
754  {
755 
756  sprintf(err_out_buf, "ERROR: invalid type! Expected type: %d Your Type:\
757  %d! PDO transmit failed! BoardId: %d NodeId: %d \
758  PDO ID: %d Mappingnr: %d\n",
759  nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->
760  mappingList[_mappingnr-1]->etype,
761  _pdo_data.get_DaemonType(), _boardnr, _nodeid, _pdonr, _mappingnr);
762 
763 
765  _pdo_data.get_DaemonType();
767  return 0;
768  }
769 
770  _pdo_data.buf2pdobuf();
771 
772  // no conversion necessary. correct length in mapping list
773 
774  pdooffset = pdooffset + position_in_byte;
775  pdosize = length_in_byte;
776 
777 
778 
779  //cout<<"size ="<<pdosize<<" offset = "<<pdooffset<<"\n";
780 
781  if ( (sRet = DevExchangeIO( _boardnr, // Board NO
782  pdooffset, //offset send data
783  pdosize, //Length of the send IO data
784  &_pdo_data.pdobuffer[0],//Pointer to the user send data buffer
785  0, //Byte offset in the receive IO data area
786  0, //Length of the receive IO data
787  NULL, //Pointer to the user read data buffer
788  100L) //timeout in milliseconds
789  ) == DRV_NO_ERROR)
790  {
791  _pdo_data.set_rlmsgerr(0);
792  //rlDebugPrintf("PDO transmit successful! \n");
793  return 1;
794  }
795  sprintf(err_out_buf, "ERROR: PDO transmit failed! BoardId: %d NodeId: %d \
796  PDO ID: %d Mappingnr: %d\n",
797  _boardnr, _nodeid, _pdonr, _mappingnr);
799 
801  return 0;
802 }
803 //---------------------------------------------------------------------------
804 
806 int rlCanOpen::pdo_transmit( int _boardnr,
807  int _nodeid,
808  int _pdonr,
809  rlCanOpenTypes &_pdo_data)
810 {
811  int nodeindex;
812  _pdo_data.buf2pdobuf();
813 
814  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== 0)
815  {
816  sprintf(err_out_buf, "ERROR: specified node does not exist! PDO transmit\
817  failed! BoardId: %d NodeId: %d PDO ID: %d \n",
818  _boardnr, _nodeid, _pdonr);
819 
822  return 0;
823  }
824  if (nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE].size() < (unsigned int) _pdonr){
825  sprintf(err_out_buf, "ERROR: specified PDO ID does not exist! PDO \
826  transmit failed! BoardId: %d NodeId: %d PDO \
827  ID: %d \n", _boardnr, _nodeid, _pdonr);
830  return 0;
831  }
832 
833  int pdosize = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->bPDOSize;
834  int pdooffset = nodelist[nodeindex]->pdoList[DIRECTION_RECEIVE][_pdonr-1]->usPDOAddress;
835 
836  if ( (sRet = DevExchangeIO( _boardnr, // Board NO
837  pdooffset, //offset send data
838  pdosize, //Length of the send IO data
839  &_pdo_data.pdobuffer[0],//Pointer to the user send data buffer
840  0, //Byte offset in the receive IO data area
841  0, //Length of the receive IO data
842  NULL, //Pointer to the user read data buffer
843  100L) //timeout in milliseconds
844  ) == DRV_NO_ERROR)
845  {
846  _pdo_data.set_rlmsgerr(ERRCODE_NOERROR);
847  return 1;
848  }
849  sprintf(err_out_buf, "ERROR: PDO transmit failed! BoardId: %d NodeId: %d \
850  PDO ID: %d \n", _boardnr, _nodeid, _pdonr);
852 
854  return 0;
855 }
856 
857 //---------------------------------------------------------------------------
860  message.rx =0;
861  message.tx =0;
862  message.ln =0;
863  message.nr =0;
864  message.a =0;
865  message.f =0;
866  message.b =0;
867  message.e =0;
868  message.device_adr =0;
869  message.data_area =0;
870  message.data_adr =0;
871  message.data_idx =0;
872  message.data_cnt =0;
873  message.data_type =0;
874  message.function =0;
875 
876  for (int i = 0; i < MAX_SDO_BUFFERSIZE; i++)
877  message.d[i] = 0;
878 
879 }
880 //---------------------------------------------------------------------------
882 int rlCanOpen::getNodeIndex(int _boardnr,int _nodeid,int & _index)
883 {
884  for(unsigned int i = 0; i < nodelist.size(); i++)
885  {
886  if ((nodelist[i]->getNodeID() == _nodeid) &&
887  (nodelist[i]->getBoardID() == _boardnr))
888  {
889  _index = i;
890  return true;
891  }
892  }
893  return false;
894 }
895 //---------------------------------------------------------------------------
897 int rlCanOpen::getObjectType( int _boardnr,
898  int _nodeid,
899  int _objectindex,
900  int _subindex)
901 {
902  int nodeindex;
903  if (getNodeIndex(_boardnr, _nodeid, nodeindex)){
904  if (nodelist[nodeindex]->hasMapping())
905  return nodelist[nodeindex]->objecttype(_objectindex, _subindex);
906  else
908  }
909  else{
911  }
912 }
913 
914 //---------------------------------------------------------------------------
917 int rlCanOpen::refreshMappingList( int _boardnr,
918  int _nodeid,
919  int _pdoID,
920  int _pdoDirection)
921 {
922  //rlDebugPrintf("refresh mappinglist1\n");
923  int nodeindex;
924  int madress=0;
925 
926 
927  madress = nodelist[nodelist.size()-1]->
928  pdoList[_pdoDirection][_pdoID -1]->mappingOvAdress;
929 
930  if (getNodeIndex(_boardnr,_nodeid,nodeindex)== false)
931  {
932  sprintf(err_out_buf, "ERROR: specified node does not exist! refresh \
933  mapping list failed! BoardId: %d NodeId: %d \
934  PDO ID: %d \n", _boardnr, _nodeid, _pdoID);
936  return 0;
937  }
938 
939 
940  if(nodelist[nodeindex]->pdoList[_pdoDirection].size() < (unsigned int) _pdoID)
941  {
942  sprintf(err_out_buf, "ERROR: PDO does not exist! refresh \
943  mapping list failed! BoardId: %d NodeId: %d \
944  PDO ID: %d \n", _boardnr, _nodeid, _pdoID);
946  return 0;
947  }
948 
949  //append Mapping data
950  rlCanOpenTypes sdobuffer;
951  int mappingcount;
952  rlCanMapping * mappingobject;
953 
954  //get mapping count
955  if (sdo_read(_boardnr,_nodeid,madress,0,sdobuffer) == 0){
956  sprintf(err_out_buf, "ERROR: read sdo data! refresh mapping list failed! \
957  BoardId: %d NodeId: %d PDO ID: %d \n",
958  _boardnr, _nodeid, _pdoID);
960  }
961 
962  mappingcount = sdobuffer.get_uchar();
963 
964  sprintf(err_out_buf, "Current mappingcount: %d\n", mappingcount);
966 
967  nodelist[nodeindex]->pdoList[_pdoDirection][_pdoID-1]->
968  mappingList.resize(mappingcount);
969 
970  int currentposition = 0;
971  for (int mcount = 1; mcount <= mappingcount;mcount++) //each mappingobject
972  {
973  mappingobject = new rlCanMapping; //create new mappingobject in memory
974  mappingobject->mappingId = mcount;
975 
976 
977  if (sdo_read(_boardnr,_nodeid,madress,mcount,sdobuffer) == 0){
978  sprintf(err_out_buf, "ERROR: read sdo data! refresh mapping list failed! \
979  BoardId: %d NodeId: %d PDO ID: %d \n",
980  _boardnr, _nodeid, _pdoID);
982  //cout<<"Error during create Mappinglist!\n";
983  }
984 
985  //get length of mapping object
986  int mlength = sdobuffer.get_buffer(0);
987  mappingobject->length = mlength;
988 
989  //calculate the mapping position
990  if (mcount>1)
991  mappingobject->position = currentposition;
992  else
993  mappingobject->position = 0;
994  currentposition+=mlength;
995 
996  // get the ov adress of the current mapped object
997  int mi = (int) (sdobuffer.get_buffer(3)*pow(256,1)
998  + sdobuffer.get_buffer(2));
999 
1000  unsigned char msi = sdobuffer.get_buffer(1);
1001 
1002  rlCanOpenTypes temptype;
1003  mappingobject->etype = temptype.canOpenType2DeamonType
1004  (nodelist[nodelist.size()-1]->objecttype(mi, msi));
1005 
1006  // insert the mappingobject to mappinglist
1007  nodelist[nodeindex]->pdoList[_pdoDirection][_pdoID-1]->
1008  mappingList.insert(mcount-1,mappingobject);
1009 
1010  }
1011  return 1;
1012 }
1013 //---------------------------------------------------------------------------
1015 int rlCanOpen::getPdoID( int _boardnr,
1016  int _nodeid,
1017  int _objektindex,
1018  int _direction){
1019  int pdomax=0;
1020  int nodeindex=0;
1021  int madress=0;
1022  // get index of node in nodelist depending on boardid and nodeid
1023  // index is stored in nodeindex variable
1024  getNodeIndex(_boardnr, _nodeid, nodeindex);
1025 
1026  // get number of elements in particular PDO list
1027  if (_direction == DIRECTION_RECEIVE)
1028  pdomax = nodelist[nodeindex]->getReceivePdoCount();
1029  if (_direction == DIRECTION_TRANSMIT)
1030  pdomax = nodelist[nodeindex]->getTransmitPdoCount();
1031 
1032  /* iterate through every element of particular list until mapping
1033  object adress matches given objectindex */
1034  for (int j=1;j<=pdomax;j++)
1035  {
1036 
1037  madress = nodelist[nodeindex]->pdoList[_direction][j-1]->mappingOvAdress;
1038  if (madress == _objektindex)
1039  return j;
1040  }
1041  return 0;
1042 }
1043 //---------------------------------------------------------------------------
1045 int rlCanOpen::getNodeState(int _boardnr, int _nodeid, rlCanOpenTypes &_data)
1046 {
1047 
1048  setBoardActive(_boardnr);
1049 
1050  COM_ND_DIAGNOSTICS * diag;
1051  diag = (COM_ND_DIAGNOSTICS*) &message.d[0];
1052 
1053  message.rx = CAN_TASK ;//receiver = user at HOST
1054  message.tx = USER_AT_HOST ;// transmitter = USR_INTF-Task
1055  message.ln = 8 ;//length of message
1056  message.nr = messagenr++ ;//number of the message
1057  message.a = 0 ;//no answer
1058  message.f = 0 ;//error, status
1059  message.b = CMDCODE_Node_Diag;//command = COM_Node_Diag
1060  message.e =0 ;//extension
1061  message.device_adr = _nodeid ;//k Rem_Adr
1062  message.data_area = 0 ;// data area, unused
1063  message.data_adr = 0 ;//data address, unused
1064  message.data_idx = 0 ;//data index, unused
1065  message.data_cnt = 0 ;//data count, unused
1066  message.data_type = 5 ;// data type byte string
1067  message.function = 1 ;//function read
1068 
1069 
1070  if ( (sRet = DevPutMessage(_boardnr, (MSG_STRUC *)&message, 5000L))
1071  == DRV_NO_ERROR )
1072  {
1073  while( (sRet = DevGetMessage(_boardnr, sizeof(message),
1074  (MSG_STRUC *)&message, 0))
1075  == DRV_DEV_GET_NO_MESSAGE )
1076  {
1077  continue;
1078  }
1079  if ( sRet == DRV_NO_ERROR )
1080  {
1081  rlDebugPrintf("message successfully received\n");
1082  // continue;
1083  }
1084  else
1085  {
1086  rlDebugPrintf("Error Message (f = %d))\n",message.f);
1087  rlDebugPrintf("\nDevGetMessage(%d, sizeof(message), &message, 500): %d\n",
1088  _boardnr, (int)sRet);
1089 
1090  return 0;
1091  }
1092  }
1093  else
1094  {
1095  rlDebugPrintf("\nDevPutMessage(%d, &message, 5000): %d\n",_boardnr, (int)sRet);
1096  return 0;
1097  }
1098  _data.set_nodestateFlags( diag->bNodeStatus_1.bNodeNoResponse,
1099  diag->bNodeStatus_1.bEmcyBuffOverflow,
1100  diag->bNodeStatus_1.bPrmFault,
1101  diag->bNodeStatus_1.bGuardActive,
1102  diag->bNodeStatus_1.bDeactivated );
1103 
1104  _data.set_nodestate(diag->bNodeState);
1105  _data.set_nodeerror(diag->bActualError);
1106 
1108 
1109  return 1;
1110 }
1111 
1112 //---------------------------------------------------------------------------
1114 int rlCanOpen::restartBoard(int _boardnr, int _restarttype)
1115 {
1116  //COLDSTART 2
1117  //WARMSTART 3
1118  //BOOTSTART 4
1119 
1120  if ( (sRet = DevReset(_boardnr, _restarttype, 5000L) != DRV_NO_ERROR ))
1121  {
1122  rlDebugPrintf("restart failed!\n");
1123  rlDebugPrintf("DevReset(%d, Restart, 5000): %d\n", _boardnr, sRet);
1124  return 0;
1125  }
1126 
1127  rlDebugPrintf("restart successfully\n");
1128  return 1;
1129 }
1130 //---------------------------------------------------------------------------
1132 int rlCanOpen::sendNMTCommand(int _boardnr, int _nodeid, unsigned char _cmd)
1133 {
1134  MSG_STRUC message;
1135  setBoardActive(_boardnr);
1136 
1137  message.rx = CAN_TASK ;//receiver = user at HOST
1138  message.tx = USER_AT_HOST ;// transmitter = USR_INTF-Task
1139  message.ln = 2 ;//length of message
1140  message.nr = messagenr++ ;//number of the message
1141  message.a = 0 ;//no answer
1142  message.f = 0 ;//error, status
1143  message.b = CMD_NMT_Module_Protocol;//command = COM_Node_Diag
1144  message.e = 0 ;//extension
1145 
1146  // NMT Command specifier
1147  //1 Start Remote Node
1148  //2 Stop Remote Node
1149  //128 Enter Pre-Operational
1150  //129 Reset Node
1151  //130 Reset Communication
1152  message.data[0] = _cmd ;//NMT Command specifier
1153  message.data[1] = _nodeid ;//NodeID
1154 
1155  if ( (sRet = DevPutMessage(_boardnr, (MSG_STRUC *)&message, 5000L))
1156  == DRV_NO_ERROR )
1157  {
1158  while( (sRet = DevGetMessage(_boardnr, sizeof(message),
1159  (MSG_STRUC *)&message, 0))
1160  == DRV_DEV_GET_NO_MESSAGE )
1161  {
1162  continue;
1163  }
1164  if ( sRet == DRV_NO_ERROR )
1165  {
1166  rlDebugPrintf("NMT message successfully received\n");
1167  // continue;
1168  }
1169  else
1170  {
1171  rlDebugPrintf("Error Message (f = %d))\n",message.f);
1172  rlDebugPrintf("\nDevGetMessage(%d, sizeof(message), &message, 500): %d\n",
1173  _boardnr, (int)sRet);
1174 
1175  return 0;
1176  }
1177  }
1178  else
1179  {
1180  rlDebugPrintf("\nDevPutMessage(NMT)(%d, &message, 5000): %d\n",_boardnr, (int)sRet);
1181  return 0;
1182  } /* if ( (sRet = DevPutMessage(...)) == DRV_NO_ERROR ) else */
1183 
1184  return 1;
1185 }
1186 
1187 //---------------------------------------------------------------------------
1189 void rlCanOpen::read_inifile(const char* _filename){
1190  rlIniFile ini;
1191  QString buffer;
1192  if (ini.read(_filename)!=-1){
1193  rlDebugPrintf("used inifile: %s\n", _filename);
1194 
1195  // read EDS directory location
1196  buffer=QString(ini.text("DIRECTORIES","EdsDir"));
1197  buffer.remove((char) ACSII_CODE_CARRIAGE_RETURN);
1198  rlDebugPrintf("EdsDir: %s\n", buffer.ascii());
1199  // store EDS directory location in environmet variable
1200 #ifdef RLWIN32
1201  SetEnvironmentVariable("EdsDir", buffer.ascii());
1202 #else
1203  setenv("EdsDir", buffer.ascii(), 1);
1204 #endif
1205 
1206  // read Logfilename
1207  logFileName=QString(ini.text("DIRECTORIES","LogFileName"));
1208  logFileName.remove((char) ACSII_CODE_CARRIAGE_RETURN);
1209  rlDebugPrintf("Log Filename: %s\n", logFileName.ascii());
1210 
1211  // read loggin-option
1212  buffer=QString(ini.text("OPTIONS","enableLoggin"));
1213  if (buffer.contains("yes", false)==1)
1214  enableLogging=true;
1215  else
1216  enableLogging=false;
1217  }
1218  else
1219  {
1220  logFileName= "./outfile.txt";
1221  rlDebugPrintf("ERROR: INIFILE NOT FOUND\n");
1222  }
1223 }
1224 
1225 //-------------------------------------------------------------------------
1226 bool rlCanOpen::is_twisted_type(int _canopentype)
1227 {
1228  switch (_canopentype){
1229 
1230  case rlCanOpenTypes::INTEGER24_t :return true;
1231  case rlCanOpenTypes::INTEGER40_t :return true;
1232  case rlCanOpenTypes::INTEGER48_t :return true;
1233  case rlCanOpenTypes::INTEGER56_t :return true;
1234  case rlCanOpenTypes::UNSIGNED24_t:return true;
1235  case rlCanOpenTypes::UNSIGNED40_t:return true;
1236  case rlCanOpenTypes::UNSIGNED48_t:return true;
1237  case rlCanOpenTypes::UNSIGNED56_t:return true;
1238  default :return false;
1239  };
1240 
1241 }
1242 
unsigned short mappingId
the mapping ID determines the mapping object within the PDO (1 to n)
#define ERRCODE_INVALID_RLTYPE
#define MAX_NODES
#define CMDCODE_SDO_UPDOWNLOAD
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61
int activeboard
the currently active board
Definition: rlcanopen.h:219
void set_CanOpenType(int _type)
recieves an CANopen typenumber and returns appropiate RL-Type
int getActiveBoard()
returns the number of currently active board
Definition: rlcanopen.cpp:296
#define DIRECTION_RECEIVE
definition of CanOpen structs for CanOpen Deamon
#define TASK_TFC_READ
#define TRANSMIT_PDO_MAPPING_MAXADRESS
void set_nodeerror(unsigned char _nodeerror)
void delmsg()
clear message struct by setting all elements to zero
Definition: rlcanopen.cpp:859
int getBoardCount()
returns the number of available boards
Definition: rlcanopen.cpp:211
int boardcount
the current count of CanOpenMaster cards
Definition: rlcanopen.h:253
void set_DaemonType(rl_types _type)
alternative setter receives integer typenumber
#define DIRECTION_TRANSMIT
#define CAN_TASK
Hilscher device-communication constants.
short setBoardActive(int _boardnr)
sets a desired CanOpenMaster active, so that it can be used
Definition: rlcanopen.cpp:285
QString logFileName
name of logfile stdout is redirected to
Definition: rlcanopen.h:244
class to handle CANopen types
#define CMD_NMT_Module_Protocol
#define ERRCODE_INVALID_NODEID
int refreshMappingList(int _boardnr, int _nodeid, int _pdoID, int _pdoDirection)
Definition: rlcanopen.cpp:917
#define RLWIN32
Definition: rldefine.h:42
int sdo_read(int _boardnr, int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
read a certain object from the object dictionary of a node
Definition: rlcanopen.cpp:332
bool ini()
initialize nodes and create nodelist
Definition: rlcanopen.cpp:71
static int canOpenType2DeamonType(int _canopentype)
Function for typenumber conversion.
void read_inifile(const char *_filename)
read properties of inifile
Definition: rlcanopen.cpp:1189
int getNodeIndex(int _boardnr, int _nodeid, int &_index)
this function returns the listindex of a desired node
Definition: rlcanopen.cpp:882
#define ERRCODE_PDORCV_FAIL
int sendNMTCommand(int _boardnr, int _nodeid, unsigned char _cmd)
send a NMT Command to one or all nodes (of one board)
Definition: rlcanopen.cpp:1132
void pdobuf2buf()
exchange bytes 0-7 from pdobuffer to databuffer
int get_DaemonType()
returns current of data stored in databuffer
unsigned short position
its position in within the 8Byte
#define TRANSMIT_PDO_MAPPING_STARTADRESS
int pdo_transmit(int _boardnr, int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
transmit a mapped object within a PDO to a specific node
Definition: rlcanopen.cpp:703
#define ERRCODE_INVALID_MAPID
int restartBoard(int _boardnr, int _restarttype)
using this function you are able to restart a CanOpenMaster board
Definition: rlcanopen.cpp:1114
unsigned char get_uchar()
returns databuffer-content as uchar type
void set_rlmsgerr(long _errnr)
sets the errornumber. refer private varibale rlmsgerr for details
bool showNodeConfiguration()
prints out the configuration off all available nodes from all boards
Definition: rlcanopen.cpp:320
#define CMDCODE_GET_CONFIGURATION
int pdo_receive(int _boardnr, int _nodeid, int _pdonr, int _mappingnr, rlCanOpenTypes &_pdo_data)
using the pdo_receive function you can receive a mapped object within PDO
Definition: rlcanopen.cpp:544
void buf2pdobuf()
exchange bytes 0-7 from databuffer to pdobuffer
char err_out_buf[255]
this string buffer is usually written with sprintf before sent to stdout
Definition: rlcanopen.h:235
void clearBuffer()
sets all bytes in databuffer to zero
int sdo_write(int _boardnr, int _nodeid, int _objectindex, int _subindex, rlCanOpenTypes &_sdo_data)
write data into a certain object from the object dictionary of a node
Definition: rlcanopen.cpp:431
#define ERRCODE_NOERROR
ERRCODES.
mapping object which is part of the mappinglist of a PDO
int getLength()
returns number of bytes used for current type
int getObjectType(int _boardnr, int _nodeid, int _objectindex, int _subindex)
returns daemontype number of a specific object
Definition: rlcanopen.cpp:897
#define RECEIVE_PDO_MAPPING_MAXADRESS
int getPdoID(int _boardnr, int _nodeid, int _objektindex, int _direction)
return PdoId of mapped object.
Definition: rlcanopen.cpp:1015
bool enableLogging
Definition: rlcanopen.h:281
int createMappingObjects(int _boardid, int _nodeid, int _pdoDirection)
this function writes the mapping objects for each pdo of a node
Definition: rlcanopen.cpp:137
int get_CanOpenTypeLength(int _canopentype)
QPtrVector< rlCanNode > nodelist
this list contains all nodes from all boards
Definition: rlcanopen.h:250
bool is_twisted_type(int _canopentype)
Definition: rlcanopen.cpp:1226
unsigned char messagenr
message counter
Definition: rlcanopen.h:256
int etype
its current type (int32, float, char, ...)
unsigned char pdobuffer[8]
external buffer for pdotransfer
bool iniboards()
Read informations about installed devices.
Definition: rlcanopen.cpp:154
#define RECEIVE_PDO_MAPPING_STARTADRESS
#define TASK_TFC_WRITE
int createNodes()
Search for nodes in all boards and append it into the nodelist.
Definition: rlcanopen.cpp:103
#define USER_AT_HOST
#define ERRCODE_INVALID_PDOID
unsigned char get_buffer(int _index)
returns 1 byte from databuffer
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 translate_CanOpenType(int _canopentype)
#define ERRCODE_PDOSND_FAIL
unsigned short length
length of mappend object in bits
short sRet
return value for hilscher specific message functions
Definition: rlcanopen.h:238
int getNodeState(int _boardnr, int _nodeid, rlCanOpenTypes &_data)
use this function to get information about a specific node
Definition: rlcanopen.cpp:1045
class to manage one node of a CanOpenMaster board in a CanOpen network
Definition: rlcannode.h:48
void set_buffer(int _index, unsigned char _databyte)
transfer raw data into the databuffer
#define MAX_SDO_BUFFERSIZE
bool getNodeConfiguration(int _nodeID)
Definition: rlcanopen.cpp:217
#define RESPONSE_CODE_GET_CONFIGURATION
#define CMDCODE_Node_Diag
RCS_MESSAGETELEGRAM_10 message
hilscher specific message structur which will be sent to the master card
Definition: rlcanopen.h:247
void set_nodestate(unsigned char _nodestate)
sets current state of node.