13 #include "libcfw002.h"
14 #include <yarp/dev/CanBusInterface.h>
15 #include <yarp/os/Bottle.h>
16 #include <yarp/os/Value.h>
20 using namespace yarp::os;
24 handle =
new CFWCAN_HANDLE;
49 #ifdef CFW2_HAS_FILTERS
51 res = cfwCanSetIdFilter(*
handle ,
id , 1);
59 #ifdef CFW2_HAS_FILTERS
61 res = cfwCanSetIdFilter(*
handle ,
id , 0);
73 CFWCAN_MSG *
tmp=
reinterpret_cast<CFWCAN_MSG *
>(msgs[0].getPointer());
93 CanBuffer &buffer=
const_cast<CanBuffer &
>(msgs);
94 const CFWCAN_MSG *
tmp=
reinterpret_cast<const CFWCAN_MSG *
>(buffer[0].getPointer());
97 res=cfwCanWrite(*
handle,
const_cast<CFWCAN_MSG *
>(
tmp), sent, 1);
99 res=cfwCanWrite(*
handle,
const_cast<CFWCAN_MSG *
>(
tmp), sent, 0);
115 netId=par.check(
"CanDeviceNum", Value(-1),
"numeric identifier of the can device").asInt32();
116 if (netId == -1) netId=par.check(
"canDeviceNum", Value(-1),
"numeric identifier of the can device").asInt32();
118 txTimeout=par.check(
"CanTxTimeout", Value(0),
"timeout on transmission [ms]").asInt32();
119 if (txTimeout == 0) txTimeout=par.check(
"canTxTimeout", Value(0),
"timeout on transmission [ms]").asInt32();
121 rxTimeout=par.check(
"CanRxTimeout", Value(0),
"timeout on receive when calling blocking read [ms]").asInt32() ;
122 if (rxTimeout == 0) rxTimeout=par.check(
"canRxTimeout", Value(0),
"timeout on receive when calling blocking read [ms]").asInt32() ;
124 int res = cfwCanOpen (netId, txQueueSize, rxQueueSize, txTimeout, rxTimeout,
handle);
127 fprintf(stderr,
"Cfw2Can::open() returning error %d\n", res);
130 #ifdef CFW2_HAS_FILTERS
131 int rtxEnable = cfwCanRtxEnable(*
handle);
132 if( rtxEnable != 0) {
133 fprintf(stderr,
"Cfw2Can::RtxEnable() returning error %d\n", rtxEnable);
146 #ifdef CFW2_HAS_FILTERS
147 int rtxDisable = cfwCanRtxDisable(*
handle);
148 if(rtxDisable != 0) {
149 fprintf(stderr,
"Cfw2Can::RtxDisabling() returning error %d\n", rtxDisable);
153 res=cfwCanClose (*
handle);
181 memcpy(msg,
tmp.msg,
sizeof(CFWCAN_MSG));
virtual CanMessage & operator=(const CanMessage &l)
This operator is defined in a general way, but it will crash if you try to assign to a Cfw2CanMessage...
virtual bool canRead(CanBuffer &msgs, unsigned int size, unsigned int *read, bool wait=false)
virtual bool canWrite(const CanBuffer &msgs, unsigned int size, unsigned int *sent, bool wait=false)
virtual bool open(yarp::os::Searchable &par)
virtual bool canIdAdd(unsigned int id)
virtual bool canGetBaudRate(unsigned int *rate)
virtual bool canIdDelete(unsigned int id)
virtual bool canSetBaudRate(unsigned int rate)
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)