iCub-main
driver.cpp
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4  * Copyright (C) 2008 RobotCub Consortium
5  * Author: Marco Maggiali, Marco Randazzo, Marco Accame
6  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7  *
8  */
9 #include "driver.h"
10 #include <stdio.h>
11 
12 #include <yarp/os/Time.h>
13 #include <yarp/os/Bottle.h>
14 
15 #include "EoUpdaterProtocol.h"
16 
17 using namespace yarp::os;
18 using namespace yarp::dev;
19 
20 
21 // marco.accame: the new cDriver2 is just a copy of old cDriver but with different APIs
22 
24 {
25  _verbose = true;
26 }
27 
28 
29 int cDriver2::init (Searchable &config, bool verbose)
30 {
31  bool ret;
32 
33  _verbose = verbose;
34 
35  ret=dd.open(config);
36  if (!ret)
37  return -1;
38 
39  dd.view(iCanBus);
40  dd.view(iFactory);
41 
42  if (iCanBus==0)
43  return -1;
44  if (iFactory==0)
45  return -1;
46 
47  // creating once for all the buffers used to tx and rx can frames.
48  canTXbuffer = createCanBuffer(MAX_WRITE_MSG);
49  canRXbuffer = createCanBuffer(MAX_READ_MSG);
50 
51 
52  int i;
53  for (i = 0x700; i < 0x7FF; i++) iCanBus->canIdAdd (i);
54  for (i = 0x200; i < 0x2FF; i++) iCanBus->canIdAdd (i); //for strain board (polling messages used for calibration)
55 
56  iCanBus->canSetBaudRate(0); //0=1Mbit/s
57 
58  yarp::os::Time::delay(2.0);
59 
60  return 0;
61 }
62 
63 
65 {
66  // should destroy the can buffers ... however, at date of 22 jun 16, i have seen that application crashes.
67  // destroyCanBuffer(canRXbuffer);
68  // destroyCanBuffer(canTXbuffer);
69 
70  dd.close();
71  return true;
72 }
73 
74 
75 int cDriver2::receive_message(vector<CanPacket> &canpackets, int howMany, double TIMEOUT)
76 {
77  bool ret;
78 
79  int maxreadmsg = MAX_READ_MSG;
80 
81  // or even better:
82  maxreadmsg = canpackets.size();
83 
84  if (howMany>maxreadmsg)
85  return 0;
86 
87  unsigned int how_many_messages=0;
88  int read=0;
89 // int count=0;
90 
91  double start=Time::now();
92  double now=start;
93  bool done=false;
94 
95 
96  while(!done)
97  {
98 
99  ret=iCanBus->canRead(canRXbuffer, maxreadmsg, &how_many_messages, false);
100 
101  if (read+how_many_messages>maxreadmsg)
102  {
103  how_many_messages=(maxreadmsg-read);
104  }
105 
106  for(unsigned int k=0;k<how_many_messages;k++)
107  {
108  // convert a yarp::dev::CanMessage into a CanPacket. we use operator = of CanPacket.
109  canpackets[read].setLen(canRXbuffer[k].getLen());
110  canpackets[read].setId(canRXbuffer[k].getId());
111  memcpy(canpackets[read].getData(), canRXbuffer[k].getData(), canRXbuffer[k].getLen());
112  //canpackets[read] = canRXbuffer[k];
113  read++;
114  }
115 
116  now=Time::now();
117 
118  if (read>=howMany)
119  {
120  done=true;
121  read=howMany;
122  }
123 
124  if ( (now-start)>TIMEOUT)
125  done=true;
126 
127 
128  // Time::delay(0.0);
129  }
130 
131  if(!ret)
132  return 0;
133 
134  return read;
135 }
136 
137 
138 int cDriver2::send_message(vector<CanPacket> &canpackets, int n)
139 {
140  unsigned int sent=0;
141 
142  if(n > canpackets.size())
143  { // just a control
144  n = canpackets.size();
145  }
146 
147  if(n > MAX_WRITE_MSG)
148  {
149  n = MAX_WRITE_MSG;
150  }
151 
152 
153  for(int i=0; i<n; i++)
154  {
155  // in here it would be nice having operator = in class yarp::dev::CanMessage or in class CanPacket so that we can just use following line
156  // canTXbuffer[0] = canpackets[0];
157  canTXbuffer[i].setId(canpackets[i].getId());
158  canTXbuffer[i].setLen(canpackets[i].getLen());
159  void * src = canpackets[i].getData();
160  void * dst = canTXbuffer[i].getData();
161  memcpy(dst, src, canpackets[i].getLen());
162  //canTXbuffer[i].setBuffer(canpackets[i].getData());
163  // or ... memcpy(canTXbuffer[0].getData(), canpackets[0].getData(), canpackets[0].getLen());
164  }
165 
166  bool ret = iCanBus->canWrite(canTXbuffer, n, &sent);
167 
168 
169  if(!ret)
170  return 0;
171  else
172  return sent;
173 }
174 
175 
176 yarp::dev::CanBuffer cDriver2::createCanBuffer(int m)
177 {
178  return iFactory->createBuffer(m);
179 }
180 
181 
182 void cDriver2::destroyCanBuffer(yarp::dev::CanBuffer &buff)
183 {
184  iFactory->destroyBuffer(buff);
185 }
186 
187 
188 // types used by eDriver
189 
190 
191 // - class eDriver2
192 
194 {
195  mSocket = new CanSocket;
196  _verbose = true;
197 }
198 
200 {
201  delete mSocket;
202 }
203 
204 #undef USE_LEGACY_0X20_MESSAGE
205 
206 int eDriver2::init(yarp::os::Searchable &config, bool verbose)
207 {
208  ACE_UINT32 local=(ACE_UINT32)config.find("local").asInt32();
209 
210  _verbose = verbose;
211 
212  int ret = 0;
213 
214  if (!mSocket->create(3334,local))
215  {
216  yError("invalid address\n");
217  return -1;
218  }
219 
220  mBoardAddr=(ACE_UINT32)config.find("remote").asInt32();
221 
222 // mCanBusId=config.check("canid")?config.find("canid").asInt32():0;
224 
225  timestart = yarp::os::Time::now();
226 
227  // marco.accame on 23 may 16: review this value.
228  // if we remove the delay the risk is that the ETH link is not up yet if we send the connect as soon as we power motors on.
229  // but ... is it still true?
230  // on the other hand, we could just reduce it to 1 sec. is it enough?
231  // NOTE: on cDriver::init() there is the same delay(2.0), hence it is better keep it the same.... or make it 1.750
232 
233  //yarp::os::Time::delay(0.5); // avoids that the user sends a message too soon (2.0 is a good value)
234 
235  // removed the command to avoid a bootstrap
236  // unsigned char CMD_JMP_UPD=0x0C;
237  // mSocket->sendTo(&CMD_JMP_UPD,1,3333,mBoardAddr);
238 
239  yarp::os::Time::delay(2.0); // (was 3)
240 
241 
242 
243 #if defined(USE_LEGACY_0X20_MESSAGE)
244 
246  //unsigned char CMD_CANGTW_START=0x20;
247  //mSocket->sendTo(&CMD_CANGTW_START, 1, 3333, mBoardAddr);
248  static unsigned char cmd_cangtw_start[8] = {0x20, 0, 0, 0, 0, 0, 0, 0};
249  if(_verbose) yDebug() << "byte is ...." << cmd_cangtw_start[0];
250 
251  mSocket->sendTo(cmd_cangtw_start, 1, 3333, mBoardAddr);
252 
253  // marco.accame on 23 may 16: review this value. 250 ms is ok.
254 
255  // version 2.2 of the eUpdater waits for 2 seconds after reception of GTW_START before forwarding udp packets to can.
256  // we wait for 1.5 sec so that max wait of the udp packet is 0.5 sec and the timeout is not triggered.
257  // for next versions of eUpdater we may reduce this time to 0.5 or even entirely remove the delay.
258  yarp::os::Time::delay(1.5);
259 
260 #else
261 
262  if(_verbose) yWarning("sending request to start can gateway mode");
263 
264  const uint16_t t_can_stabilisation = 900; // ms
265  const uint8_t b_send_ff_after_can_stabilisation = 0;
266  const uint16_t t_wait_for_can_reply = 0; // ms
267  const uint8_t b_clear_can_buffers_on_start_gtw = 0;
268  const uint8_t b_send_ack = 1;
269 
270 // unsigned char cmd_cangtw_start[8] =
271 // {
272 // 0x20,
273 // t_can_stabilisation & 0xff,
274 // t_can_stabilisation >> 8,
275 // b_send_ff_after_can_stabilisation,
276 // t_wait_for_can_reply & 0xff,
277 // t_wait_for_can_reply >> 8,
278 // b_clear_can_buffers_on_start_gtw,
279 // b_send_ack
280 // };
281 
282  eOuprot_cmd_CANGATEWAY_t command = {0};
283  command.opc = uprot_OPC_LEGACY_CANGATEWAY;
284  command.sendcanbroadcast = b_send_ff_after_can_stabilisation;
285  command.time4canstable = t_can_stabilisation;
286  command.time2waitcanreply = t_wait_for_can_reply;
287  command.rxcanbufferclear = b_clear_can_buffers_on_start_gtw;
288  command.ackrequired = b_send_ack;
289 
290 
291  mSocket->sendTo(&command, sizeof(eOuprot_cmd_CANGATEWAY_t), 3333, mBoardAddr);
292 
293 
294  ACE_UINT16 port;
295  ACE_UINT32 address;
296 
297  const double waitingTime = 1.5; // in seconds
298 
299 
300  if(1 == b_send_ack)
301  {
302  eOuprot_cmdREPLY_t cmdreply = {0};
303 
304  if(_verbose) yDebug("waiting for an ack/nak from board");
305 
306  // we wait at least waitingTime sec because if the remote board does not run the new protocol, then it will not send an ack back.
307  // and we must wait the rigth amout of time
308  int mswait = 1000.0f * waitingTime;
309  int nrec = mSocket->receiveFrom(&cmdreply, sizeof(cmdreply), address, port, mswait);
310 
311  if(-1 == nrec)
312  {
313  if(_verbose) yWarning("remote board did not sent any ack to command 0x20. it may have a version of eUpdater older than 6.6");
314  ret = 0;
315  }
316  else if(sizeof(cmdreply) == nrec)
317  {
318  if((uprot_OPC_CANGATEWAY == cmdreply.opc) && (uprot_RES_OK == cmdreply.res))
319  {
320  if(_verbose) yDebug("REMOTE BOARD is in CAN gateway now");
321  ret = 0;
322  }
323  else if((uprot_OPC_CANGATEWAY == cmdreply.opc) && (uprot_RES_OK != cmdreply.res))
324  {
325  if(uprot_RES_ERR_TRYAGAIN == cmdreply.res)
326  {
327  if(_verbose) yWarning("REMOTE BOARD tells that it cannot go to CAN gateway mode, BUT: The eApplication has jumped to eUpdater. Try connect again.");
328  ret = -2;
329  }
330  else
331  {
332  if(_verbose) yWarning("REMOTE BOARD tells that it cannot go to CAN gateway mode.");
333  ret = -1;
334  }
335  }
336  else
337  {
338  uint8_t *bb = (uint8_t*) &cmdreply;
339  if(_verbose) yWarning("REMOTE BOARD sends an unknown reply[%d] = {%x, %x, %x, %x}.", nrec, bb[0], bb[1], bb[2], bb[3]);
340  ret = -1;
341  }
342  }
343  else
344  {
345  uint8_t *bb = (uint8_t*) &cmdreply;
346  if(_verbose) yWarning("REMOTE BOARD sends an unknown reply[%d] = {%x, %x, %x, %x}.", nrec, bb[0], bb[1], bb[2], bb[3]);
347  ret = -1;
348  }
349  }
350  else
351  {
352  // we must wait the value specified by board to enter in GTW: 1 sec but we make 1.5
353  yarp::os::Time::delay(waitingTime);
354  ret = 0;
355  }
356 
357 
358 #endif
359 
360  //printf("@ %f sec from start: exit init phase\n", yarp::os::Time::now() - timestart);
361 
362  return ret;
363 }
364 
365 
367 {
368 // static char CMD_CANGTW_STOP = 0x21;
369 
370 // mSocket->sendTo(&CMD_CANGTW_STOP,1,3334,mBoardAddr);
371 
372  mSocket->close();
373 
374  return 0;
375 }
376 
377 
378 int eDriver2::receive_message(vector<CanPacket> &canpackets, int howMany, double TIMEOUT)
379 {
380  CanPkt_t canPkt;
381  ACE_UINT16 port;
382  ACE_UINT32 address;
383 
384  double tstart=yarp::os::Time::now();
385 
386  int nread=0;
387 
388  while (true)
389  {
390  int nrec=mSocket->receiveFrom(&canPkt,sizeof(CanPkt_t),address,port,1);
391 
392  if (nrec==sizeof(CanPkt_t))
393  {
394  // uncomment for print
395  // printf(">> received a packet of size %d\n", nrec);
396 
397  if (address==mBoardAddr && port==3334)
398  {
399  int nframes=canPkt.header.canFrameNumOf;
400 
401  for (int f=0; f<nframes; ++f)
402  {
403  //if (!mCanBusId || canPkt.frames[f].canBus==mCanBusId)
404  int canbus = canPkt.frames[f].canBus;
405  {
406  //printf(">>> (RX) Len=%d ID=%x Data=",canPkt.frames[0].len,canPkt.frames[0].canId);
407  //for (int l=0; l<canPkt.frames[0].len; ++l) printf("%x ",canPkt.frames[0].data[l]);
408  //printf("<<<\n");
409 
410  canpackets[nread].setCanBus(canbus);
411 
412  canpackets[nread].setLen(canPkt.frames[f].len);
413  canpackets[nread].setId(canPkt.frames[f].canId);
414  memcpy(canpackets[nread].getData(), canPkt.frames[f].data, canPkt.frames[f].len);
415 
416  if (++nread>=howMany) return nread;
417  }
418  }
419  }
420  }
421 
422  if (yarp::os::Time::now()-tstart>TIMEOUT) break;
423  }
424 
425  return nread;
426 }
427 
428 
429 int eDriver2::send_message(vector<CanPacket> &canpackets, int n)
430 {
431  CanPkt_t canPkt;
432  static ACE_UINT32 prognumber = 0;
433 
434 
435  for (int i=0; i<n; ++i)
436  {
437  canPkt.header.signature=0x12;
438  canPkt.header.canFrameNumOf=1;
439 #ifdef USE_PROG_ID
440  canPkt.header.progressive = prognumber++;
441 #endif
442 
443  canPkt.frames[0].canBus = canpackets[i].getCanBus();
444  canPkt.frames[0].canId = canpackets[i].getId();
445  canPkt.frames[0].len = canpackets[i].getLen();
446  memcpy(canPkt.frames[0].data, canpackets[i].getData(), canpackets[i].getLen());
447 
448  //printf("<<< (TX) Len=%d ID=%x Data=",message[i].getLen(),message[i].getId());
449  //for (int l=0; l<message[i].getLen(); ++l) printf("%x ",message[i].getData()[l]);
450  //printf(">>>\n");
451 
452  if(CanPacket::everyCANbus == canpackets[i].getCanBus())
453  { // send to both can1 and can2
454  canPkt.frames[0].canBus = 1;
455  mSocket->sendTo(&canPkt,sizeof(CanPkt_t), 3334, mBoardAddr);
456  yarp::os::Time::delay(0.001);
457 
458  canPkt.frames[0].canBus = 2;
459  mSocket->sendTo(&canPkt,sizeof(CanPkt_t), 3334, mBoardAddr);
460  yarp::os::Time::delay(0.001);
461  }
462  else
463  { // send it to the relevant bus
464  mSocket->sendTo(&canPkt,sizeof(CanPkt_t), 3334, mBoardAddr);
465  yarp::os::Time::delay(0.001);
466  }
467 
468  //printf("@ %f sec from start: sent udp packet\n", yarp::os::Time::now() - timestart);
469 
470  // limit througput so that the ems board can safely receive the packet.
471  // without this delay, the ems receives many udp packets withing a few micro-seconds, and
472  // its dma buffer goes in overflow because the eth isr cannot execute at such speed.
473  //yarp::os::Time::delay(0.001);
474  }
475 
476  return n;
477 }
478 
479 
480 // in here we have the old cDriver
481 
482 #if defined(DRIVER_KEEP_LEGACY_IDRIVER)
483 
484 
486 {
487 }
488 
489 
490 int cDriver::init (Searchable &config)
491 {
492  bool ret;
493 
494  ret=dd.open(config);
495  if (!ret)
496  return -1;
497 
498  dd.view(iCanBus);
499  dd.view(iFactory);
500 
501  if (iCanBus==0)
502  return -1;
503  if (iFactory==0)
504  return -1;
505 
506  int i;
507  for (i = 0x700; i < 0x7FF; i++) iCanBus->canIdAdd (i);
508  for (i = 0x200; i < 0x2FF; i++) iCanBus->canIdAdd (i); //for strain board (polling messages used for calibration)
509 
510  iCanBus->canSetBaudRate(0); //0=1Mbit/s
511 
512  yarp::os::Time::delay(2.0);
513 
514  return 0;
515 }
516 
517 
519 {
520  dd.close();
521  return true;
522 }
523 
524 
525 int cDriver::receive_message(CanBuffer &messages, int howMany, double TIMEOUT)
526 {
527  bool ret;
528 
529  if (howMany>MAX_READ_MSG)
530  return 0;
531 
532  unsigned int how_many_messages=0;
533  int read=0;
534  int count=0;
535 
536  double start=Time::now();
537  double now=start;
538  bool done=false;
539 
540  CanBuffer tmpBuff=createBuffer(MAX_READ_MSG);
541  while(!done)
542  {
543 
544  ret=iCanBus->canRead(tmpBuff, MAX_READ_MSG, &how_many_messages, false);
545 
546  if (read+how_many_messages>MAX_READ_MSG)
547  {
548  how_many_messages=(MAX_READ_MSG-read);
549  }
550 
551  for(unsigned int k=0;k<how_many_messages;k++)
552  {
553  messages[read]=tmpBuff[k];
554  read++;
555  }
556 
557  now=Time::now();
558 
559  if (read>=howMany)
560  {
561  done=true;
562  read=howMany;
563  }
564 
565  if ( (now-start)>TIMEOUT)
566  done=true;
567 
568 
569  // Time::delay(0.0);
570  }
571 
572  destroyBuffer(tmpBuff);
573  if(!ret)
574  return 0;
575 
576  return read;
577 }
578 
579 
580 int cDriver::send_message(CanBuffer &message, int messages)
581 {
582  unsigned int sent=0;
583 
584  bool ret = iCanBus->canWrite(message, messages, &sent);
585 
586  if(!ret)
587  return 0;
588  else
589  return sent;
590 }
591 
592 
593 yarp::dev::CanBuffer cDriver::createBuffer(int m)
594 {
595  return iFactory->createBuffer(m);
596 }
597 
598 
599 void cDriver::destroyBuffer(yarp::dev::CanBuffer &buff)
600 {
601  iFactory->destroyBuffer(buff);
602 }
603 
604 
605 
606 
607 
608 
609  int eDriver::init(yarp::os::Searchable &config)
610  {
611  ACE_UINT32 local=(ACE_UINT32)config.find("local").asInt32();
612 
613  if (!mSocket.create(3334,local))
614  {
615  yError("invalid address\n");
616  return -1;
617  }
618 
619  mBoardAddr=(ACE_UINT32)config.find("remote").asInt32();
620 
621  mCanBusId=config.check("canid")?config.find("canid").asInt32():0;
623 
624  timestart = yarp::os::Time::now();
625 
626  // marco.accame on 23 may 16: review this value.
627  // if we remove the delay the risk is that the ETH link is not up yet if we send the connect as soon as we power motors on.
628  // but ... is it still true?
629  // on the other hand, we could just reduce it to 1 sec. is it enough?
630  // NOTE: on cDriver::init() there is the same delay(2.0), hence it is better keep it the same.... or make it 1.750
631 
632  //yarp::os::Time::delay(2.0); // avoids that the user sends a message too soon (2.0 is a good value)
633  yarp::os::Time::delay(1.75);
634 
635  // removed the command to avoid a bootstrap
636  // unsigned char CMD_JMP_UPD=0x0C;
637  // mSocket.sendTo(&CMD_JMP_UPD,1,3333,mBoardAddr);
638 
639  // yarp::os::Time::delay(0.5); // (was 3)
640 
642  unsigned char CMD_CANGTW_START=0x20;
643 
644  mSocket.sendTo(&CMD_CANGTW_START,1,3333,mBoardAddr);
645 
646  // marco.accame on 23 may 16: review this value. 250 ms is ok.
647 
648  // version 2.2 of the eUpdater waits for 2 seconds after reception of GTW_START before forwarding udp packets to can.
649  // we wait for 1.5 sec so that max wait of the udp packet is 0.5 sec and the timeout is not triggered.
650  // for next versions of eUpdater we may reduce this time to 0.5 or even entirely remove the delay.
651  //yarp::os::Time::delay(1.5);
652  yarp::os::Time::delay(0.25);
653 
654  //printf("@ %f sec from start: exit init phase\n", yarp::os::Time::now() - timestart);
655 
656  return 0;
657  }
658 
660  {
661  static char CMD_CANGTW_STOP = 0x21;
662 
663  mSocket.sendTo(&CMD_CANGTW_STOP,1,3334,mBoardAddr);
664 
665  mSocket.close();
666 
667  return 0;
668  }
669 
670  int eDriver::receive_message(yarp::dev::CanBuffer &messages, int howMany, double TIMEOUT)
671  {
672  CanPkt_t canPkt;
673  ACE_UINT16 port;
674  ACE_UINT32 address;
675 
676  double tstart=yarp::os::Time::now();
677 
678  int nread=0;
679 
680  while (true)
681  {
682  int nrec=mSocket.receiveFrom(&canPkt,sizeof(CanPkt_t),address,port,1);
683 
684  if (nrec==sizeof(CanPkt_t))
685  {
686  if (address==mBoardAddr && port==3334)
687  {
688  int nframes=canPkt.header.canFrameNumOf;
689 
690  for (int f=0; f<nframes; ++f)
691  {
692  if (!mCanBusId || canPkt.frames[f].canBus==mCanBusId)
693  {
694  //printf(">>> (RX) Len=%d ID=%x Data=",canPkt.frames[0].len,canPkt.frames[0].canId);
695  //for (int l=0; l<canPkt.frames[0].len; ++l) printf("%x ",canPkt.frames[0].data[l]);
696  //printf("<<<\n");
697 
698  messages[nread].setLen(canPkt.frames[f].len);
699  messages[nread].setId(canPkt.frames[f].canId);
700  memcpy(messages[nread].getData(),canPkt.frames[f].data,canPkt.frames[f].len);
701 
702  if (++nread>=howMany) return nread;
703  }
704  }
705  }
706  }
707 
708  if (yarp::os::Time::now()-tstart>TIMEOUT) break;
709  }
710 
711  return nread;
712  }
713 
714  int eDriver::send_message(yarp::dev::CanBuffer &message, int n)
715  {
716  CanPkt_t canPkt;
717  static ACE_UINT32 prognumber = 0;
718 
719 
720  for (int i=0; i<n; ++i)
721  {
722  canPkt.header.signature=0x12;
723  canPkt.header.canFrameNumOf=1;
724 #ifdef USE_PROG_ID
725  canPkt.header.progressive = prognumber++;
726 #endif
727 
728  canPkt.frames[0].canBus=mCanBusId;
729  canPkt.frames[0].canId=message[i].getId();
730  canPkt.frames[0].len=message[i].getLen();
731  memcpy(canPkt.frames[0].data,message[i].getData(),message[i].getLen());
732 
733  //printf("<<< (TX) Len=%d ID=%x Data=",message[i].getLen(),message[i].getId());
734  //for (int l=0; l<message[i].getLen(); ++l) printf("%x ",message[i].getData()[l]);
735  //printf(">>>\n");
736 
737  mSocket.sendTo(&canPkt,sizeof(CanPkt_t),3334,mBoardAddr);
738 
739  //printf("@ %f sec from start: sent udp packet\n", yarp::os::Time::now() - timestart);
740 
741  // limit througput so that the ems board can safely receive the packet.
742  // without this delay, the ems receives many udp packets withing a few micro-seconds, and
743  // its dma buffer goes in overflow because the eth isr cannot execute at such speed.
744  yarp::os::Time::delay(0.001);
745  }
746 
747  return n;
748  }
749 
750  yarp::dev::CanBuffer eDriver::createBuffer(int m)
751  {
752  return yarp::dev::ImplementCanBufferFactory<EthCanMessage,ECMSG>::createBuffer(m);
753  }
754 
755  void eDriver::destroyBuffer(yarp::dev::CanBuffer &buff)
756  {
757  yarp::dev::ImplementCanBufferFactory<EthCanMessage,ECMSG>::destroyBuffer(buff);
758  }
759 
760 
761 #endif//defined(DRIVER_KEEP_LEGACY_IDRIVER)
762 
763 
764 // eof
765 
766 
@ everyCANbus
Definition: driver.h:51
int receive_message(vector< CanPacket > &canpackets, int howMany=MAX_READ_MSG, double TIMEOUT=1)
Definition: driver.cpp:75
int init(yarp::os::Searchable &config, bool verbose=true)
Definition: driver.cpp:29
int send_message(vector< CanPacket > &canpackets, int n)
Definition: driver.cpp:138
cDriver2()
Definition: driver.cpp:23
int uninit()
Definition: driver.cpp:64
int receive_message(yarp::dev::CanBuffer &messages, int howMany=MAX_READ_MSG, double TIMEOUT=1)
Definition: driver.cpp:525
int send_message(yarp::dev::CanBuffer &message, int n)
Definition: driver.cpp:580
int init(yarp::os::Searchable &config)
Definition: driver.cpp:490
cDriver()
Definition: driver.cpp:485
void destroyBuffer(yarp::dev::CanBuffer &buff)
Definition: driver.cpp:599
int uninit()
Definition: driver.cpp:518
yarp::dev::CanBuffer createBuffer(int m)
Definition: driver.cpp:593
eDriver2()
Definition: driver.cpp:193
int init(yarp::os::Searchable &config, bool verbose=true)
Definition: driver.cpp:206
int uninit()
Definition: driver.cpp:366
int receive_message(vector< CanPacket > &canpackets, int howMany=MAX_READ_MSG, double TIMEOUT=1)
Definition: driver.cpp:378
~eDriver2()
Definition: driver.cpp:199
int send_message(vector< CanPacket > &canpackets, int n)
Definition: driver.cpp:429
int init(yarp::os::Searchable &config)
Definition: driver.cpp:609
void destroyBuffer(yarp::dev::CanBuffer &buff)
Definition: driver.cpp:755
int receive_message(yarp::dev::CanBuffer &messages, int howMany=MAX_READ_MSG, double TIMEOUT=1.0)
Definition: driver.cpp:670
int send_message(yarp::dev::CanBuffer &message, int n)
Definition: driver.cpp:714
yarp::dev::CanBuffer createBuffer(int m)
Definition: driver.cpp:750
int uninit()
Definition: driver.cpp:659
int n
#define MAX_WRITE_MSG
Definition: driver.h:41
#define MAX_READ_MSG
Definition: driver.h:40
bool done
Definition: main.cpp:42
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
Definition: ethParser.cpp:92
unsigned short canId
Definition: driver.h:191
unsigned char canBus
Definition: driver.h:189
unsigned char len
Definition: driver.h:190
unsigned char data[8]
Definition: driver.h:193
unsigned char signature
Definition: driver.h:177
ACE_UINT32 progressive
Definition: driver.h:181
unsigned char canFrameNumOf
Definition: driver.h:178
CanPktFrame_t frames[1]
Definition: driver.h:199
CanPktHeader_t header
Definition: driver.h:198