40 #include <boost/format.hpp> 44 #include "log4cxx/logger.h" 49 char dev_model_num[17];
50 char dev_serial_num[17];
57 char *dev_name_ptr = dev_name;
58 char *dev_model_num_ptr = dev_model_num;
59 char *dev_serial_num_ptr = dev_serial_num;
61 while (*dev_name_ptr ==
' ')
63 while (*dev_model_num_ptr ==
' ')
65 while (*dev_serial_num_ptr ==
' ')
68 return (boost::format(
"%s_%s-%s")%dev_name_ptr%dev_model_num_ptr%dev_serial_num_ptr).str();
71 int main(
int argc,
char **argv)
73 if (argc < 2 || argc > 3)
75 fprintf(stderr,
"usage: get_id /dev/ttyUSB? [quiet]\nOutputs the device ID of an IMU at that port. Add a second argument for script friendly output.\n");
79 bool verbose = (argc == 2);
94 catch (microstrain_3dmgx2_imu::Exception& e)
96 fprintf(stderr,
"Unable to open IMU at port %s. IMU may be disconnected.\n%s", argv[1], e.what());
102 std::string
id =
getID(imu);
105 fprintf(stdout,
"IMU Device at port %s has ID: ", argv[1]);
106 fprintf(stdout,
"%s\n",
id.c_str());
112 catch (microstrain_3dmgx2_imu::Exception& e)
114 fprintf(stderr,
"Exception thrown while stopping IMU.\n%s", e.what());
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
void openPort(const char *port_name)
Open the port.
void closePort()
Close the port.
void initTime(double fix_off)
Initialize timing variables.
A class for interfacing to the microstrain 3dmgx2 and inertialink IMUs.
std::string getID(microstrain_3dmgx2_imu::IMU &imu)
Recovers hardware ID from IMU device.
int main(int argc, char **argv)
bool getDeviceIdentifierString(id_string type, char id[17])
Read one of the device identifier strings.
#define ROSCONSOLE_DEFAULT_NAME