35#include <yarp/os/Network.h>
36#include <yarp/dev/ControlBoardInterfaces.h>
37#include <yarp/dev/PolyDriver.h>
38#include <yarp/dev/CanBusInterface.h>
39#include <yarp/os/Time.h>
40#include <yarp/sig/Vector.h>
42#include <yarp/os/PeriodicThread.h>
48using namespace yarp::sig;
49using namespace yarp::os;
60 ICanBufferFactory *iBufferFactory;
74 prop.put(
"device", devname.c_str());
76 prop.put(
"CanTxTimeout", 500);
77 prop.put(
"CanRxTimeout", 500);
78 prop.put(
"CanDeviceNum", port);
79 prop.put(
"CanMyAddress", 0);
86 if (!driver.isValid())
88 fprintf(stderr,
"Error opening PolyDriver check parameters\n");
93 driver.view(iBufferFactory);
95 iCanBus->canSetBaudRate(0);
104 unsigned int readMessages=0;
105 bool res=iCanBus->canRead(readBuffer, messages, &readMessages);
107 fprintf(stderr,
"Read %u messages\n", readMessages);
109 fprintf(stderr,
"Failed (read %u messages)\n", readMessages);
114 iBufferFactory->destroyBuffer(readBuffer);
124int main(
int argc,
char *argv[])
128 yarp::dev::DriverCollection dev;
131 if (argc!=3 && argc!=5)
133 std::cout<<
"Usage: --device device_name {ecan|pcan|...}\n";
134 std::cout<<
"Optional: --port {int} (default 0)\n";
138 std::string p1=std::string(argv[1]);
139 std::string p2=std::string(argv[2]);
144 std::string tmp=std::string(argv[3]);
153 std::cout<<
"Usage: --device device_name {ecan|pcan}\n";
161 std::cerr<<
"Error thread did not start, quitting\n";
SnifferThread(std::string dname, int p, int r=SNIFFER_THREAD_RATE)
const int SNIFFER_THREAD_RATE
const int localBufferSize
const int CAN_DRIVER_BUFFER_SIZE
Copyright (C) 2008 RobotCub Consortium.