Has anyone looked at porting the Bosch BNO055 library. I have and application that uses the 9-Axis shield and the Bosch library with and Arduino Mega and the YUN Shield. I would like to use this on Particle.
I started to see if it would be easy to port and had thing down to a couple of issues and the fix for that exploded into 370 errors where I get errors like ‘uint8_t does not name a type’ from statements like the one below.
The original code was rather abstract it what looks like an attempt to make the library work on nearly any machine as it had a typedefs like this and macros like the above:
/* singed integer type*/
typedef int8_t s_8;/**< used for signed 8bit */
typedef int16_t s_16;/**< used for signed 16bit */
typedef int32_t s_32;/**< used for signed 32bit */
typedef int64_t s_64;/**< used for signed 64bit */
But these caused problems so I did a simple replace of “s_8” with “int8_t” which solved most problems but I am kind of stuck do impart from my limited knowledge of the c language.
I’m sure that I could rework my application. I need the ability to store and recall calibration and I don’t know if the Adafruit lib can do that. Also I spent significant time getting my application working.
Do you know why the c code isn’t compatible? It seems that Bosch went to extremes to make their code easy to port to machines with different word lengths. Either they used some nonstandard C constructs or the Particle platform does.
I don’t know if this will work, but it does compile. I was getting lots of duplicate definition errors, so i got rid of almost all the typedef’s at the top of the .h file leaving this as the top of that file down to where it says, “BUS READ AND WRITE FUNCTIONS”
#ifndef __BNO055_H__
#define __BNO055_H__
#include <stdint.h>
/*unsigned integer types*/
typedef uint8_t u8;/**< used for unsigned 8bit */
typedef uint16_t u16;/**< used for unsigned 16bit */
typedef uint32_t u32;/**< used for unsigned 32bit */
/*signed integer types*/
typedef int8_t s8;/**< used for signed 8bit */
typedef int16_t s16;/**< used for signed 16bit */
typedef int32_t s32;/**< used for signed 32bit */
typedef signed char s8;/**< used for signed 8bit */
typedef signed short int s16;/**< used for signed 16bit */
typedef signed long int s32;/**< used for signed 32bit */
/*unsigned integer types*/
typedef unsigned char u8;/**< used for unsigned 8bit */
typedef unsigned short int u16;/**< used for unsigned 16bit */
typedef unsigned long int u32;/**< used for unsigned 32bit */
/***************************************************************/
/**\name BUS READ AND WRITE FUNCTIONS */
/***************************************************************/
After Edit:
I just tested replacing #include < stdint.h> with #include < Particle.h>, and with that change, none of those typedefs seem to be necessary (i.e. it compiles without them).
I didn't see the NAxisMotion files. I just made the changes I mentioned above, and compiled a simple .ino file with the bno055.h and bno055.cpp files added to the app (via the tabs).
I was trying to duplicate your results. I took a fresh copy of BNO055.h and BNO055.c (renamed to BNO055.cpp) and a file BNO.ino. I changed BON055.h line 113 to #include <Particle.h> ad nothing else but I get 30 errors.
The first error is "expected identifier before '(' token" ...BNO055.h:759:22
Thank you helping me with this. I don't know what I am doing wrong. This is however the first thing I have tried with the Particle so there are a lot of things (everything really) about the development environment.
I don’t have the line “#define ARRAY_SIZE_TWO 2” in either the .h or .cpp file, so there is something different between our two apps. Could that be in your .ino file? The error should say which file it’s in.
On the other hand, why is this a #define and not a typedef?
Otherwise could you post the code round about the proposed error line 759?
If you can’t see the problem at that position it may well be somewhere near it