Skip to content

Library supports one BNO080 instance. #14

@felixcollins

Description

@felixcollins

There seem to be three implementation decisions that make the driver only function with a single BNO080.

  1. Use of global data at line 429 of sh.c static sh2_t sh2;
  2. Use of global data at line 150 of shtp.c static shtp_t shtp;
  3. Hard coded calls to a particular to the HAL without passing any instance information that would allow switching the communications channel.

Are there any other spots I missed?

It would seem to be quite a big job to fix this. A couple of possibilities:

  1. Add functions to create an instance of the sensor returning a handle. The caller would be responsible for allocating memory perhaps? All calls would take the handle to identify the instance intended for the call. (This would be a fair bit of work and would be a breaking change to the library). Global data is the root of all evil LOL!
  2. Replace the global data access with access via a pointer (search and replace . operator with ->). Once that is done it would be possible to swap (via additional functions) which instance the library is working with. For the example code, great care would be needed to avoid threading issues. All extant instances would have to be operated from one task.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions