56 int main(
int argc,
char *argv[]) {
62 if (argc - optind != 1) {
64 fprintf(stderr,
"%s <datafile>\n", argv[0]);
68 FILE *nf = fopen(argv[optind],
"r");
71 log_error(&state,
"Unable to open input file \"%s\"", argv[optind]);
77 bool processing =
true;
83 while (processing || hw > 10) {
85 if (feof(nf) && processing) {
86 log_info(&state, 2,
"End of file reached");
93 perror(
"lpms_message calloc");
116 log_info(&state, 1,
"%02x: Timestamp: %u", m->
id,
126 "%02x: Raw Acceleration: (%+.4f, %+.4f, %+4.f)",
133 "%02x: Calibrated Acceleration: (%+.4f, %+.4f, %+4.f)",
139 "%02x: Raw Gyro: (%+.4f, %+.4f, %+4.f)", m->
id,
144 "%02x: Calibrated Gyro: (%+.4f, %+.4f, %+4.f)",
150 "%02x: Aligned Gyro: (%+.4f, %+.4f, %+4.f)",
156 "%02x: Raw Magnetic Field: (%+.4f, %+.4f, %+4.f)",
162 "%02x: Calibrated Magnetic Field: (%+.4f, %+.4f, %+4.f)",
167 "%02x: Euler roll angles: (%+.4f, %+.4f, %+.4f)",
172 log_info(&state, 1,
"%02x: Altitude: %.2f", m->
id,
176 log_info(&state, 1,
"%02x: Temperature: %.2f", m->
id,
181 log_info(&state, 2,
"%02x: Command %02x, %u bytes, checksum %s",
187 if (m->
id == 0xAA || m->
id == 0xEE) {
190 "Error reading messages from file (Code: 0x%02x)\n",
197 if (end < hw) { end++; }
207 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.
int main(int argc, char *argv[])
#define BUFSIZE
Allocated read buffer size.
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_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.
#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.
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.