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

message gyro_request_req
Parameters:

user (string) – User identifier, max 15 characters long.

Return message:

gyro_request_rsp

Request the gyro service.

message gyro_request_rsp
Parameters:

result (enum gyro_result) – Result of the operation

gyro request result.

message gyro_release_req_norsp
Parameters:

user (string) – User identifier, max 15 characters long.

Release gyro service for given user user.

message gyro_configure_req
Parameters:
  • samplerate_sps (uint32) – Requested sample rate in samples per second

  • samples_per_buffer (uint32) – Number of samples per buffer

Return message:

gyro_configure_rsp

Request to configure the gyro service.

The supported values for samplerate and samples per buffer is board dependent and documented at IMU.

message gyro_configure_rsp
Parameters:
  • actual_samplerate_sps (uint32) – Actual sample rate configured, in samples per second

  • result (enum gyro_result) – Result of the operation

Sent in response to gyro_configure_req message.

message gyro_publish_ind
Parameters:
  • no_of_samples (uint32) – Number of samples included in sample buffer

  • sample_buffer (uint8[]) – The sample values

Gyro data event.

message gyro_subscribe_req

Subscribe to gyro_publish_ind messages

message gyro_subscribe_rsp
Parameters:

result (enum ipc_subscribe_result)

Result from gyro_subscribe_req

message gyro_unsubscribe_req_norsp

Unsubscribe from gyro_publish_ind messages

Enums

enum gyro_result

Result codes.

Constant

Value

Description

OK

0

OK

ERROR

1

Error