15#include <yarp/dev/CanBusInterface.h> 
   16#include <yarp/os/Bottle.h> 
   19using namespace yarp::os;
 
   26    handle = 
new NTCAN_HANDLE;
 
 
   44    int res=::canSetBaudrate(*handle, baud);
 
   46    if (res!=NTCAN_SUCCESS)
 
 
   61    int res=::canGetBaudrate(*handle, &baud);
 
   64    if (res!=NTCAN_SUCCESS)
 
 
   72    int res=
::canIdAdd(*handle, 
static_cast<long>(
id));
 
   73    if (res!=NTCAN_SUCCESS)
 
 
   82    if (res!=NTCAN_SUCCESS)
 
 
  101    CMSG *tmp=
reinterpret_cast<CMSG *
>(msgs[0].getPointer());
 
  105        res=::canTake(*handle, tmp, &lRead);
 
  109    if ( (res==NTCAN_SUCCESS)||(res==NTCAN_RX_TIMEOUT))
 
  112    fprintf(stderr, 
"Error: canRead returned with code:%.8X\n", res);
 
 
  129    CanBuffer &buffer=
const_cast<CanBuffer &
>(msgs);
 
  130    const CMSG *tmp=
reinterpret_cast<const CMSG *
>(buffer[0].getPointer());
 
  133        res=
::canWrite(*handle, 
const_cast<CMSG *
>(tmp), &lRead, 0);
 
  139    if (res!=NTCAN_SUCCESS)
 
  141            fprintf(stderr, 
"Error: canWrite returned with code:%.8X\n", res);
 
 
  156                         netId=par.check(
"CanDeviceNum", Value(-1), 
"numeric identifier of the can device").asInt32();
 
  157    if  (netId == -1)    netId=par.check(
"canDeviceNum", Value(-1), 
"numeric identifier of the can device").asInt32();
 
  159                           txTimeout=par.check(
"CanTxTimeout", Value(500), 
"timeout on transmission [ms]").asInt32();
 
  160    if  (txTimeout == 500) txTimeout=par.check(
"canTxTimeout", Value(500), 
"timeout on transmission [ms]").asInt32();
 
  162                           rxTimeout=par.check(
"CanRxTimeout", Value(500), 
"timeout on receive when calling blocking read [ms]").asInt32() ;
 
  163    if  (rxTimeout == 500) rxTimeout=par.check(
"canRxTimeout", Value(500), 
"timeout on receive when calling blocking read [ms]").asInt32() ;
 
  165                                      canTxQueue=par.check(
"CanTxQueue", Value(
TX_QUEUE_SIZE), 
"length of tx buffer").asInt32();
 
  168                                      canRxQueue=par.check(
"CanRxQueue", Value(
RX_QUEUE_SIZE), 
"length of rx buffer").asInt32() ;
 
  173    int res = ::canOpen (netId, mode, canTxQueue, canRxQueue, txTimeout, rxTimeout, handle);
 
  174    if (res != NTCAN_SUCCESS)
 
 
  189    res=::canClose (*handle);
 
  191    if (res!=NTCAN_SUCCESS)
 
 
virtual bool canGetBaudRate(unsigned int *rate)
 
virtual bool canIdDelete(unsigned int id)
 
virtual bool canWrite(const CanBuffer &msgs, unsigned int size, unsigned int *sent, bool wait=false)
 
virtual bool open(yarp::os::Searchable &par)
 
virtual bool canSetBaudRate(unsigned int rate)
 
virtual bool canIdAdd(unsigned int id)
 
virtual bool canRead(CanBuffer &msgs, unsigned int size, unsigned int *read, bool wait=false)