27 #include <yarp/os/Time.h>
28 #include <yarp/os/Log.h>
36 using namespace yarp::os;
64 yError() <<
"strainInterface::open(): failure because ... Driver Stopped because it was running .... very strange i should have called a strainInterface::close()";
69 yarp::os::Property params;
71 params.put(
"device", config.get_networkstring().c_str());
72 if(Network::ETH == config.network)
74 unsigned int localAddr = (10<<24)|(0<<16)|(1<<8)|104;
75 unsigned int remoteAddr = (10<<24)|(0<<16)|(1<<8)|1;
79 params.put(
"canid", config.get_canbus());
86 params.put(
"canTxQueue", 64);
87 params.put(
"canRxQueue", 64);
88 params.put(
"canTxTimeout", 2000);
89 params.put(
"canRxTimeout", 2000);
99 yDebug(
"Init ETH driver: The ETH board has just jumped to eUpdater\n Connect again");
103 yError(
"Init driver failed: Hardware busy or not connected?!");
108 yDebug(
"Driver Connected");
120 config.load_default();
131 yError() <<
"strainInterface::print(): you must call strainInterface::open() first";
139 for(
size_t n=0;
n<values.size();
n++)
141 unsigned short unsigned_gaugeData[6] = {0};
142 signed short signed_gaugeData[6] = {0};
144 for(
size_t c=0; c<6; c++)
146 unsigned_gaugeData[c] = values[values.size()-1-
n].channel[c];
147 signed_gaugeData[c] = unsigned_gaugeData[c]-0x7fff;
152 fprintf(
fp,
"%d %d %d %d %d %d %d\n",
static_cast<int>(
n),signed_gaugeData[0],signed_gaugeData[1],signed_gaugeData[2],signed_gaugeData[3],signed_gaugeData[4],signed_gaugeData[5]);
154 yDebug(
"samples:%3d [0]:%+6d [1]:%+6d [2]:%+6d [3]:%+6d [4]:%+6d [5]:%+6d\r\n",
static_cast<int>(
n),signed_gaugeData[0],signed_gaugeData[1],signed_gaugeData[2],signed_gaugeData[3],signed_gaugeData[4],signed_gaugeData[5]);
166 yError() <<
"strainInterface::get(): you must call strainInterface::open() first";
170 double t0 = yarp::os::SystemClock::nowSystem();
172 yDebug() <<
"strainInterface::get(): is acquiring" << number <<
"from the 6 channels. Please wait ...";
174 const bool calibmode =
false;
180 double t1 = yarp::os::SystemClock::nowSystem();
183 yDebug() <<
"strainInterface::get() has succesfully acquired" << values.size() <<
"values of the 6 channels in" << (t1-t0) <<
"seconds";
184 yDebug() <<
"the values are:";
185 for(
int i=0; i<values.size(); i++)
187 yDebug() <<
"#" << i+1 <<
"=" << values[i].channel[0] << values[i].channel[1] << values[i].channel[2] << values[i].channel[3] <<
188 values[i].channel[4] << values[i].channel[5] << values[i].valid;
int strain_acquire_start(int bus, int target_id, uint8_t txratemilli=20, bool calibmode=true, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
int strain_acquire_stop(int bus, int target_id, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
int strain_acquire_get(int bus, int target_id, vector< strain_value_t > &values, const unsigned int howmany=10, void(*updateProgressBar)(void *, float)=NULL, void *arg=NULL, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, const unsigned int maxerrors=1, string *errorstring=NULL)
int strain_stop_sampling(int bus, int target_id, string *errorstring=NULL)
int initdriver(yarp::os::Searchable &config, bool verbose=true)
bool get(const unsigned int number, vector< cDownloader::strain_value_t > &values)
bool print(const vector< cDownloader::strain_value_t > &values, FILE *fp=NULL)
bool open(const Config &cfg=Config())
static struct bpf_program fp