I am programming the Edison in C++ with eclipse and the mraa library.
I am trying to integrate an Adafruit sensor that comes with a driver that seems designed for the arduino IDE and refers to the Wiring framework (WProgram.h, wire.h).
What is the best way to use it with the minimum amount of code rewriting ?
Specifically what sensor are you using? If you take a look at https://software.intel.com/en-us/working-with-sensors-in-eclipse https://software.intel.com/en-us/working-with-sensors-in-eclipse you'll notice at the very beginning a list of the supported sensors in the UPM sensor library. Make sure your sensor is in the list of supported sensors.
If your sensor is in the list follow the steps of the guide. Do you receive any errors while trying to use the sensor with Eclipse?
Thanks for your reply. I had the BNO050 in mind when I wrote my post. It is an Adafruit IMU. Since then I solved the problem by adapting the source files. It was written with the arduino and the wire lib in mind so it was using delay, millis and other arduino functions as well as the wire/wprogram libraryto interface with the microcontroller. I did manage to adapt the source code with a few macros to replace delays and millis with equivalent standard c++ functions and changing the calls to the Wire lib by the mraa versions. Finally I replaced all the C headers includes with the equivalent C++ version [) instead of ()] to avoid confiusing the linker. Also is working fine now. Or almost ... since I ran into another issue that is the subject of another post: Apparent conflict between UART-0 and I2C-6
My broader question however was whether there was best practice in converting any of the many drivers and other pieces of code that have been written for the arduino and the Wire lib.
Thank you for sharing the procedure you used to adapt your code. Hopefully other users will find it useful. We also noticed your other thread, the one related to I2C and UART. We are currently working on it and we'll provide a suggestion soon.
Regarding the conversion of code, I'm not aware of any method or practice used that would simplify or make the overall process easier. In cases like this, users rewrite libraries that adapt to their own needs so the methods they use probably differ from each other.