sparkfun/SparkFun_Ublox_Arduino_Library

Error when used with Redboard Turbo - SAMD21 compatibility issue

DavidArmstrong opened this issue · 1 comments

Subject of the issue

The Ublox library generates an error when used with the Sparkfun Redboard Turbo as the target. The root cause is line 674 in SparkFun_Ublox_Arduino_Library.cpp. The code line reads as follows:

Serial.println(F("processUBX: counter hit MAX_PAYLOAD_SIZE"));

Since the SAMD processors use either SerialUSB or Serial1 as UART ports, any reference to 'Serial' will produce an error. Commenting out the line provides an immediate workaround to the issue.

I have found that if one must have Serial output specified, that the following code snippet placed at the start of the source file allows for this:

// Need the following define for SAMD processors
#if defined (ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif

Your workbench

Sparkfun Redboard Turbo
Ublox Library version 1.7.2
Arduino IDE 1.8.12

Steps to reproduce

I was able to reproduce this by using the Example1_BasicNMEARead.ino sketch and selecting the Sparkfun Redboard Turbo as the target processor. The error generated by the Arduino IDE is reported as follows:

Arduino: 1.8.12 (Windows 10), Board: "SparkFun RedBoard Turbo"

sketch\Example1_BasicNMEARead.ino.cpp.o: In function `setup':

C:\Users\xxxx\Documents\Arduino\libraries\SparkFun_Ublox_Arduino_Library\examples\Example1_BasicNMEARead/Example1_BasicNMEARead.ino:44: undefined reference to `Serial'

libraries\SparkFun_Ublox_Arduino_Library\SparkFun_Ublox_Arduino_Library.cpp.o: In function `SFE_UBLOX_GPS::processUBX(unsigned char, ubxPacket*)':

C:\Users\xxxx\Documents\Arduino\libraries\SparkFun_Ublox_Arduino_Library\src/SparkFun_Ublox_Arduino_Library.cpp:676: undefined reference to `Serial'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board SparkFun RedBoard Turbo.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Expected behavior

The library should compile without errors for any SAMD based board.

Actual behavior

See error message produced from Arduino IDE quoted above.

This is a common, annoying issue when using the SAMD21 based boards. I like your solution however it may confuse regular users of a SAM RedBoard Turbo when mysteriously Serial starts printing like SerialUSB does.

I think it's a fine fix until someone complains. I'll roll into next release.