Skip to content
Snippets Groups Projects
Commit dbd3ddd9 authored by dawehr's avatar dawehr
Browse files

Keeping track of number of IIC errors.

parent cd80ff90
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,6 @@ int quad_main(int (*setup_hardware)(hardware_t *hardware_struct)) ...@@ -49,7 +49,6 @@ int quad_main(int (*setup_hardware)(hardware_t *hardware_struct))
timer_start_loop(); timer_start_loop();
// Process all received data // Process all received data
process_received(&structs); process_received(&structs);
// Get the user input and put it into user_input_struct // Get the user input and put it into user_input_struct
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#include "commands.h" #include "commands.h"
#include "type_def.h" #include "type_def.h"
//TODO: Put this in a dedicated error-handling file
static void updateError(SensorError_t*, int);
int sensor_init(hardware_t *hardware_struct, raw_sensor_t * raw_sensor_struct, sensor_t * sensor_struct) int sensor_init(hardware_t *hardware_struct, raw_sensor_t * raw_sensor_struct, sensor_t * sensor_struct)
{ {
struct IMUDriver *imu = &hardware_struct->imu; struct IMUDriver *imu = &hardware_struct->imu;
...@@ -40,19 +43,32 @@ int get_sensors(hardware_t *hardware_struct, log_t* log_struct, user_input_t* us ...@@ -40,19 +43,32 @@ int get_sensors(hardware_t *hardware_struct, log_t* log_struct, user_input_t* us
struct IMUDriver *imu = &hardware_struct->imu; struct IMUDriver *imu = &hardware_struct->imu;
struct LidarDriver *lidar = &hardware_struct->lidar; struct LidarDriver *lidar = &hardware_struct->lidar;
struct OpticalFlowDriver *of = &hardware_struct->of; struct OpticalFlowDriver *of = &hardware_struct->of;
static lidar_t lidar_val;
int status = 0; int status = 0;
status |= imu->read(imu, &raw_sensor_struct->gam); status = imu->read(imu, &raw_sensor_struct->gam);
static lidar_t lidar_val; updateError(&(raw_sensor_struct->gam.error), status);
int lidar_status = lidar->read(lidar, &lidar_val);
if (lidar_status == 0) { status = lidar->read(lidar, &lidar_val);
updateError(&(raw_sensor_struct->lidar.error), status);
if (status == 0) {
raw_sensor_struct->lidar_distance_m = lidar_val.distance_m; raw_sensor_struct->lidar_distance_m = lidar_val.distance_m;
} }
status |= lidar_status;
status |= of->read(of, &raw_sensor_struct->optical_flow); status = of->read(of, &raw_sensor_struct->optical_flow);
updateError(&(raw_sensor_struct->optical_flow.error), status);
log_struct->gam = raw_sensor_struct->gam; log_struct->gam = raw_sensor_struct->gam;
return 0; return 0;
} }
void updateError(SensorError_t *error, int status) {
if(status) {
error->errorCount++;
error->consErrorCount++;
}
else {
error->consErrorCount = 0;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment