// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- // // test harness for vibration testing // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if CONFIG_HAL_BOARD == HAL_BOARD_PX4 #include #include #include #include #include #include const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; static int accel_fd[INS_MAX_INSTANCES]; static int gyro_fd[INS_MAX_INSTANCES]; static uint32_t total_samples[INS_MAX_INSTANCES]; static uint64_t last_accel_timestamp[INS_MAX_INSTANCES]; static uint64_t last_gyro_timestamp[INS_MAX_INSTANCES]; static DataFlash_File DataFlash("/fs/microsd/VIBTEST"); #define LOG_ACC1_MSG 215 #define LOG_GYR1_MSG 225 struct PACKED log_ACCEL { LOG_PACKET_HEADER; uint32_t timestamp; uint32_t timestamp_us; float AccX, AccY, AccZ; }; struct PACKED log_GYRO { LOG_PACKET_HEADER; uint32_t timestamp; uint32_t timestamp_us; float GyrX, GyrY, GyrZ; }; static const struct LogStructure log_structure[] PROGMEM = { LOG_COMMON_STRUCTURES, { LOG_ACC1_MSG, sizeof(log_ACCEL), "ACC1", "IIfff", "TimeMS,TimeUS,AccX,AccY,AccZ" }, { LOG_ACC1_MSG+1, sizeof(log_ACCEL), "ACC2", "IIfff", "TimeMS,TimeUS,AccX,AccY,AccZ" }, { LOG_ACC1_MSG+2, sizeof(log_ACCEL), "ACC3", "IIfff", "TimeMS,TimeUS,AccX,AccY,AccZ" }, { LOG_GYR1_MSG, sizeof(log_GYRO), "GYR1", "IIfff", "TimeMS,TimeUS,GyrX,GyrY,GyrZ" }, { LOG_GYR1_MSG+1, sizeof(log_GYRO), "GYR2", "IIfff", "TimeMS,TimeUS,GyrX,GyrY,GyrZ" }, { LOG_GYR1_MSG+2, sizeof(log_GYRO), "GYR3", "IIfff", "TimeMS,TimeUS,GyrX,GyrY,GyrZ" } }; void setup(void) { for (uint8_t i=0; ipanic("Failed to open accel/gyro 0"); } for (uint8_t i=0; iprintf("t=%lu total_samples=%lu/%lu/%lu\n", hal.scheduler->millis(), total_samples[0], total_samples[1],total_samples[2]); } } } while (got_sample); hal.scheduler->delay_microseconds(200); } #else const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER; void setup() {} void loop() {} #endif // CONFIG_HAL_BOARD AP_HAL_MAIN();