Skip to content

Commit

Permalink
Fixed bug with sysclock where sensor context size was not set correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
linguini1 committed May 11, 2024
1 parent 50cc989 commit 8de60ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ int main(int argc, char **argv) {
}

// Read all sensor data
errno_t read_result; // The result of a sensor read
size_t nbytes; // The number of bytes returned by a sensor read

while (!endless) {
errno_t read_result; // The result of a sensor read
size_t nbytes; // The number of bytes returned by a sensor read
for (uint8_t i = 0; i < sizeof(sensors) / sizeof(sensors[0]); i++) {

for (uint8_t i = 0; i < MAX_SENSORS; i++) {
Sensor sensor = sensors[i]; // Grab the current sensor
uint8_t data[sensor_max_dsize(&sensor)]; // Allocate sufficient data to read the sensor

Expand Down
8 changes: 4 additions & 4 deletions src/sensors/sensor_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const SensorTagData SENSOR_TAG_DATA[] = {
.dsize = sizeof(vec3d_t),
.dtype = TYPE_VEC3D},
[TAG_ANGULAR_VEL] = {.name = "Angular velocity",
.unit = "dps",
.fmt_str = "%.2fX, %.2fY, %.2fZ",
.dsize = sizeof(vec3d_t),
.dtype = TYPE_VEC3D},
.unit = "dps",
.fmt_str = "%.2fX, %.2fY, %.2fZ",
.dsize = sizeof(vec3d_t),
.dtype = TYPE_VEC3D},
};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/sensors/sysclock/sysclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
#include "sysclock.h"
#include "../sensor_api.h"
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
Expand Down Expand Up @@ -101,7 +100,7 @@ void sysclock_init(Sensor *sensor, const int bus, const uint8_t addr, const Sens
sensor->precision = precision;
sensor->loc = (SensorLocation){.bus = bus, .addr = {.addr = (addr & 0x7F), .fmt = I2C_ADDRFMT_7BIT}};
sensor->tag_list = (SensorTagList){.tags = TAGS, .len = sizeof(TAGS) / sizeof(SensorTag)};
sensor->context.size = sizeof(long);
sensor->context.size = sizeof(SysClockContext);
sensor->open = &sysclock_open;
sensor->read = &sysclock_read;
}

0 comments on commit 8de60ed

Please sign in to comment.