sparkfun / SparkFun_Bio_Sensor_Hub_Library

26 stars 33 forks source link

Compilation Error in writeLongBytes Function #31

Open agalliani opened 8 months ago

agalliani commented 8 months ago

Hello, I encountered a compilation error while using the SparkFun_Bio_Sensor_Hub_Library with an Arduino Nano 33 Sense and a Nicla Sense Me board. The error is related to an ambiguous call to the write function in the Wire library. The issue occurs in the writeLongBytes function at lines 1416, 1417, 1418, and 1419 in the SparkFun_Bio_Sensor_Hub_Library.cpp file.

Error Message:

C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp: In member function 'uint8_t SparkFun_Bio_Sensor_Hub::writeLongBytes(uint8_t, uint8_t, uint8_t, int32_t*, size_t)':
C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:1416:61: error: call of overloaded 'write(int32_t)' is ambiguous
     _i2cPort->write(static_cast<int32_t>(_writeVal[i] >> 24));
                                                             ^
In file included from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.h:4:0,
                 from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:21:
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:59:20: note: candidate: virtual size_t arduino::MbedI2C::write(uint8_t)
     virtual size_t write(uint8_t data);
                    ^~~~~
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:60:20: note: candidate: virtual size_t arduino::MbedI2C::write(int)
     virtual size_t write(int data) {
                    ^~~~~
C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:1417:61: error: call of overloaded 'write(int32_t)' is ambiguous
     _i2cPort->write(static_cast<int32_t>(_writeVal[i] >> 16));
                                                             ^
In file included from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.h:4:0,
                 from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:21:
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:59:20: note: candidate: virtual size_t arduino::MbedI2C::write(uint8_t)
     virtual size_t write(uint8_t data);
                    ^~~~~
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:60:20: note: candidate: virtual size_t arduino::MbedI2C::write(int)
     virtual size_t write(int data) {
                    ^~~~~
C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:1418:60: error: call of overloaded 'write(int32_t)' is ambiguous
     _i2cPort->write(static_cast<int32_t>(_writeVal[i] >> 8));
                                                            ^
In file included from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.h:4:0,
                 from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:21:
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:59:20: note: candidate: virtual size_t arduino::MbedI2C::write(uint8_t)
     virtual size_t write(uint8_t data);
                    ^~~~~
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:60:20: note: candidate: virtual size_t arduino::MbedI2C::write(int)
     virtual size_t write(int data) {
                    ^~~~~
C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:1419:55: error: call of overloaded 'write(int32_t)' is ambiguous
     _i2cPort->write(static_cast<int32_t>(_writeVal[i]));
                                                       ^
In file included from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.h:4:0,
                 from C:\Users\andre\Documents\Arduino\libraries\SparkFun_Bio_Sensor_Hub_Library\src\SparkFun_Bio_Sensor_Hub_Library.cpp:21:
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:59:20: note: candidate: virtual size_t arduino::MbedI2C::write(uint8_t)
     virtual size_t write(uint8_t data);
                    ^~~~~
C:\Users\andre\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nicla\4.1.1\libraries\Wire/Wire.h:60:20: note: candidate: virtual size_t arduino::MbedI2C::write(int)
     virtual size_t write(int data) {
                    ^~~~~

exit status 1

Compilation error: exit status 1

Steps to Reproduce:

  1. Use an Arduino Nano 33 Sense or a Nicla Sense Me board.
  2. Include the SparkFun_Bio_Sensor_Hub_Library in the Arduino sketch.
  3. Attempt to compile the sketch.

Environment:

Additional Information: I have tried updating both the SparkFun_Bio_Sensor_Hub_Library and Wire library to the latest versions, but the issue persists. Additionally, I modified the writeLongBytes function by explicitly casting the values to uint8_t to address the ambiguity, but I get 255 error. Obviously this is not solving the problem.

Related Files:

Any help or guidance on resolving this issue would be greatly appreciated. Thank you!