38 #ifndef WIN32_LEAN_AND_MEAN    39 #define WIN32_LEAN_AND_MEAN 1    65 volatile bool doneG         = 
false;
    66 FILE*         logFileP      = stdout;
    67 uint32_t      accel_samples = 0;
    68 uint32_t      gyro_samples  = 0;
    69 uint32_t      mag_samples   = 0;
    70 int64_t       sequence      = -1;
    71 uint32_t      messages      = 0;
    74 void usage(
const char *programNameP) 
    76     std::cerr << 
"USAGE: " << programNameP << 
" [<options>]" << std::endl;
    77     std::cerr << 
"Where <options> are:" << std::endl;
    78     std::cerr << 
"\t-a <ip_address>    : IPV4 address (default=10.66.171.21)" << std::endl;
    79     std::cerr << 
"\t-m <mtu>           : default=7200" << std::endl;
    80     std::cerr << 
"\t-f <log_file>      : FILE to log IMU data (stdout by default)" << std::endl;
    86 BOOL WINAPI signalHandler(DWORD dwCtrlType)
    88     std::cerr << 
"Shutting down on signal: CTRL-C" << std::endl;
    93 void signalHandler(
int sig)
    95     std::cerr << 
"Shutting down on signal: " << strsignal(sig) << std::endl;
   103     std::vector<imu::Sample>::const_iterator it = header.
samples.begin();
   105     for(; it!=header.
samples.end(); ++it) {
   116             fprintf(logFileP, 
"%d %.6f %.6f %.6f %.6f\n",
   124     else if ((sequence + 1) != header.
sequence) {
   125         const int32_t 
d = 
static_cast<int32_t
> (header.
sequence - (sequence + 1));
   138     std::string currentAddress = 
"10.66.171.21";
   139     const char *logFileNameP   = NULL;
   143     SetConsoleCtrlHandler (signalHandler, TRUE);
   145     signal(SIGINT, signalHandler);
   153     while(-1 != (c = 
getopt(argc, argvPP, 
"a:f:m:v")))
   155         case 'a': currentAddress = std::string(
optarg);    
break;
   156         case 'f': logFileNameP   = 
optarg;                 
break;
   157         case 'm': mtu            = atoi(
optarg);           
break;
   158         default: 
usage(*argvPP);                           
break;
   165     if (NULL == channelP) {
   166         std::cerr << 
"Failed to establish communications with \"" << currentAddress << 
"\"" << std::endl;
   185         std::cerr << 
"IMU support requires sensor firmware version v2.3 or greater, sensor is " <<
   202     if (NULL != logFileNameP) {
   207         logFileP = fopen(logFileNameP, 
"w+");
   208         if (NULL == logFileP) {
   209             std::cerr << 
"Failed to open \"" << logFileNameP << 
"\" for writing: " << strerror(errno) << std::endl;
   218     status = channelP->
setMtu(mtu);
   253         int64_t imu_total = accel_samples + gyro_samples + mag_samples;
   255             std::cerr << 
"IMU samples : " <<
   256                          "total: " << imu_total << 
", " <<
   257                          "accel: " << std::fixed << std::setprecision(1) << (100.0 * 
static_cast<double>(accel_samples) / static_cast<double>(imu_total)) << 
"%, " <<
   258                          "gyro: " << std::fixed << std::setprecision(1) << (100.0 * 
static_cast<double>(gyro_samples) / static_cast<double>(imu_total)) << 
"%, " <<
   259                          "mag: " << std::fixed << std::setprecision(1) << (100.0 * 
static_cast<double>(mag_samples) / static_cast<double>(imu_total)) << 
"%" << std::endl;
   263             std::cerr << 
"IMU messages: total: " << messages << 
", " <<
   264                          "dropped: " << dropped << 
"(" << std::fixed << std::setprecision(6) << (100* static_cast<double>(dropped) / static_cast<double>(messages+dropped)) << 
"%)" << std::endl;
 virtual Status startStreams(DataSource mask)=0
static CRL_CONSTEXPR Type Type_Accelerometer
static const char * statusString(Status status)
virtual Status stopStreams(DataSource mask)=0
static Channel * Create(const std::string &sensorAddress)
int main(int argc, char **argvPP)
static CRL_CONSTEXPR Type Type_Magnetometer
virtual Status getVersionInfo(system::VersionInfo &v)=0
int getopt(int argc, char **argv, char *opts)
virtual Status addIsolatedCallback(image::Callback callback, DataSource imageSourceMask, void *userDataP=NULL)=0
static CRL_CONSTEXPR DataSource Source_Imu
static CRL_CONSTEXPR Status Status_Ok
virtual Status setMtu(int32_t mtu)=0
VersionType sensorFirmwareVersion
uint32_t timeMicroSeconds
static void Destroy(Channel *instanceP)
static CRL_CONSTEXPR Type Type_Gyroscope
static CRL_CONSTEXPR DataSource Source_All