IPC Module - Gyroscope Service
This page contains documentation of the gyroscope part of IMU API.
According to the interface description, the values in the
a_ipc_msg_gyro_publish_ind comes as an array of bytes. To be able to read
out the actual values, these bytes need to be re-composed to an
gyro_sample
struct.
struct gyro_sample {
int16_t x;
int16_t y;
int16_t z;
int16_t pad;
int64_t ts;
} __attribute__ ((__packed__));
Here is an example of how to do this:
static void handle_publish_ind(a_ipc_msg* message)
{
struct gyro_sample {
int16_t x;
int16_t y;
int16_t z;
int16_t pad;
int64_t ts;
} __attribute__ ((__packed__));
struct gyro_sample* samples = (struct gyro_sample*)
message->gyro_publish_ind.sample_buffer.value;
int number_of_samples =
message->gyro_publish_ind.sample_buffer.length /
sizeof(struct gyro_sample);
for (int i = 0; i < number_of_samples; i++)
{
printf("Received values (sample %d of %d):\n", i + 1, number_of_samples);
printf("x: %i\n", samples[i].x);
printf("y: %i\n", samples[i].y);
printf("z: %i\n", samples[i].z);
printf("time stamp: %lu\n", samples[i].ts);
}
exit_main_loop_with_return_code(0);
}
Messages
Enums
- enum gyro_result
Result codes.
Constant
Value
Description
OK
0
OK
ERROR
1
Error