52 int main(
int argc,
char *argv[]) {
56 char *usage =
"Usage: %1$s [-v] [-q] datfile\n"
57 "\t-v\tIncrease verbosity\n"
58 "\t-q\tDecrease verbosity\n"
64 while ((go = getopt(argc, argv,
"vq")) != -1) {
73 log_error(&state,
"Unknown option `-%c'", optopt);
79 if (argc - optind != 1) {
85 fprintf(stderr, usage, argv[0]);
89 FILE *nf = fopen(argv[optind],
"r");
92 log_error(&state,
"Unable to open input file \"%s\"", argv[optind]);
97 bool processing =
true;
103 while (processing || hw > 10) {
104 if (feof(nf) && processing) {
105 log_info(&state, 2,
"End of file reached");
110 perror(
"lpms_message calloc");
132 log_info(&state, 1,
"%02x: Timestamp: %u", m->
id,
139 "%02x: Raw Acceleration: (%+.4f, %+.4f, %+4.f)",
146 "%02x: Calibrated Acceleration: (%+.4f, %+.4f, %+4.f)",
152 "%02x: Raw Gyro: (%+.4f, %+.4f, %+4.f)", m->
id,
157 "%02x: Calibrated Gyro: (%+.4f, %+.4f, %+4.f)",
163 "%02x: Aligned Gyro: (%+.4f, %+.4f, %+4.f)",
169 "%02x: Raw Magnetic Field: (%+.4f, %+.4f, %+4.f)",
175 "%02x: Calibrated Magnetic Field: (%+.4f, %+.4f, %+4.f)",
180 "%02x: Euler roll angles: (%+.4f, %+.4f, %+.4f)",
185 log_info(&state, 1,
"%02x: Pressure: %.2f", m->
id,
189 log_info(&state, 1,
"%02x: Altitude: %.2f", m->
id,
193 log_info(&state, 1,
"%02x: Temperature: %.2f", m->
id,
197 log_info(&state, 2,
"%02x: Command %02x, %u bytes, checksum %s",
202 if (m->
id == 0xAA || m->
id == 0xEE) {
204 "Error reading messages from file (Code: 0x%02x)\n",
210 if (end < hw) { end++; }
220 log_info(&state, 0,
"%d messages successfully read from file", count);
bool lpms_readMessage_buf(int handle, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw)
Read data from handle, and parse message if able.
bool lpms_imu_set_temperature(const lpms_message *msg, lpms_data *d)
Extract temperature from lpms_message into lpms_data, if available.
bool lpms_checksum(const lpms_message *msg, uint16_t *csum)
Calculate checksum for LPMS message packet.
bool lpms_imu_set_gyro_aligned(const lpms_message *msg, lpms_data *d)
Extract gyro_aligned from lpms_message into lpms_data, if available.
bool lpms_imu_set_mag_cal(const lpms_message *msg, lpms_data *d)
Extract mag_cal from lpms_message into lpms_data, if available.
bool lpms_imu_set_altitude(const lpms_message *msg, lpms_data *d)
Extract altitude from lpms_message into lpms_data, if available.
bool lpms_imu_set_euler_angles(const lpms_message *msg, lpms_data *d)
Extract euler_angles from lpms_message into lpms_data, if available.
bool lpms_imu_set_gyro_raw(const lpms_message *msg, lpms_data *d)
Extract gyro_raw from lpms_message into lpms_data, if available.
bool lpms_imu_set_accel_raw(const lpms_message *msg, lpms_data *d)
Extract accel_raw from lpms_message into lpms_data, if available.
bool lpms_imu_set_timestamp(const lpms_message *msg, lpms_data *d)
Extract timestamp from lpms_message into lpms_data, if available.
bool lpms_imu_set_accel_cal(const lpms_message *msg, lpms_data *d)
Extract accel_cal from lpms_message into lpms_data, if available.
bool lpms_imu_set_pressure(const lpms_message *msg, lpms_data *d)
Extract pressure from lpms_message into lpms_data, if available.
bool lpms_imu_set_mag_raw(const lpms_message *msg, lpms_data *d)
Extract mag_raw from lpms_message into lpms_data, if available.
bool lpms_imu_set_gyro_cal(const lpms_message *msg, lpms_data *d)
Extract gyro_cal from lpms_message into lpms_data, if available.
int main(int argc, char *argv[])
#define BUFSIZE
Allocated read buffer size.
#define LPMS_IMU_MAG_RAW
mag_raw[] will contain data
#define LPMS_IMU_EULER
euler[] will contain data
#define LPMS_IMU_OMEGA
omega[] will contain data
#define LPMS_IMU_ACCEL_CAL
accel_cal[] will contain data
#define LPMS_IMU_MAG_CAL
mag_cal[] will contain data
#define LPMS_IMU_GYRO_ALIGN
gyro_align[] will contain data
#define LPMS_IMU_TEMPERATURE
temperature will contain data
#define LPMS_IMU_ALTITUDE
altitude will contain data
#define LPMS_IMU_GYRO_CAL
gyro_cal[] will contain data
#define LPMS_IMU_GYRO_RAW
gyro_raw[] will contain data
#define LPMS_IMU_ACCEL_RAW
accel_raw[] will contain data
#define LPMS_MSG_GET_IMUDATA
IMU data, as configured by LPMS_MSG_SET_OUTPUTS.
void log_info(const program_state *s, const int level, const char *format,...)
Output formatted information message at a given level.
void log_warning(const program_state *s, const char *format,...)
Output formatted warning message.
void log_error(const program_state *s, const char *format,...)
Output formatted error message.
float euler_angles[3]
Orientation as Euler roll angles [X].
float altitude
Altitude [m].
float temperature
Temperature [Celsius].
float gyro_aligned[3]
Calibrated and aligned gyroscope values [X/s].
float mag_cal[3]
Calibrated magnetometer values [uT].
float gyro_raw[3]
Raw gyroscope values [X/s].
uint32_t timestamp
Counted in 0.002s increments.
float accel_cal[3]
Calibrated accelerometer values [g].
float gyro_cal[3]
Calibrated gyroscope values [X/s].
float mag_raw[3]
Raw magnetometer values [uT].
float accel_raw[3]
Raw accelerometer values [g].
uint32_t present
Bitmask indicating set/valid members.
float pressure
Atmospheric pressure [kPa].
uint16_t length
Length of data, in bytes.
uint16_t checksum
Sum of all preceding message bytes.
uint8_t * data
Pointer to data array.
uint16_t id
Source/Destination Sensor ID.
uint16_t command
Message type.
Program state and logging information.
int verbose
Current log verbosity (console output)
bool started
Indicates startup completed.
#define GIT_VERSION_STRING
Git version description.