11 #include <yarp/os/Bottle.h>
12 #include <yarp/os/Value.h>
16 using namespace yarp::os;
25 bool FakeCan::canSetBaudRate(
unsigned int rate)
30 bool FakeCan::canGetBaudRate(
unsigned int *rate)
35 bool FakeCan::canIdAdd(
unsigned int id)
40 bool FakeCan::canIdDelete(
unsigned int id)
45 bool FakeCan::canRead(CanBuffer &msgs,
51 unsigned int l=replies.size();
58 MsgIt it=replies.begin();
60 while(it!=replies.end() && k<l)
62 FCMSG *r=
reinterpret_cast<FCMSG *
>(msgs[k].getPointer());
73 bool FakeCan::canWrite(
const CanBuffer &msgs,
80 while(it!=boardList.end())
83 for(
unsigned int k=0;k<size;k++)
85 CanMessage &m=
const_cast<CanBuffer &
>(msgs)[k];
86 FCMSG *canM=
reinterpret_cast<FCMSG *
>(m.getPointer());
87 tmp->pushMessage(*canM);
98 bool FakeCan::open(yarp::os::Searchable &par)
100 cerr<<
"Opening FakeCan network" << endl;
104 int njoints=par.findGroup(
"GENERAL").find(
"Joints").asInt32();
105 Bottle &can = par.findGroup(
"CAN");
106 Bottle ids=can.findGroup(
"CanAddresses");
108 if (ids.size()<njoints/2)
110 fprintf(stderr,
"Check ini file, wrong number of board ids or joints\n");
114 for(
int i=1;i<=njoints/2;i++)
117 int id=ids.get(i).asInt32();
119 tmp->setReplyFifo(&replies);
121 boardList.push_back(
tmp);
127 bool FakeCan::close()
129 cerr<<
"Closing FakeCan network" << endl;
133 while(it!=boardList.end())
std::list< FakeBoard * >::iterator BoardsIt
std::list< FCMSG >::iterator MsgIt
bool read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)