fu-hsi / FuGPS

Arduino library for parsing NMEA 0183 (GPS) sentences.
MIT License
11 stars 6 forks source link

Trouble using HardwareSerial with ESP32 (not a bug, need advice) #9

Closed strud closed 4 years ago

strud commented 4 years ago

Hi

I am trying to use the library in an APRS project. This is on ESP32 hardware hence libraries are implemented for ESP32 not std Arduino boards.

I am having a hardtime passing the HardwareSerial object to the FuGPS constructor, this is not working since it is not a stream although is derived from one.

Definitions; `HardwareSerial gpsSerial(1);

FuGPS fuGPS(gpsSerial); `

Some of the errors I've getting are

"C:\Users\T520\Documents\Arduino\libraries\FuGPS_Library\src\FuGPS.cpp: In member function 'void FuGPS::sendCommand(const char*)':

C:\Users\T520\Documents\Arduino\libraries\FuGPS_Library\src\FuGPS.cpp:57:28: error: passing 'const Stream' as 'this' argument discards qualifiers [-fpermissive]

 _stream.println(command);"

and "C:\Users\T520\Documents\Arduino\libraries\FuGPS_Library\src\FuGPS.cpp: In member function 'bool FuGPS::read()':

C:\Users\T520\Documents\Arduino\libraries\FuGPS_Library\src\FuGPS.cpp:122:27: error: passing 'const Stream' as 'this' argument discards qualifiers [-fpermissive]

 if (_stream.available())"

This is not a bug (I assume), but I note that in the examples it is recommended to use HardwareSerial hence my motivation to keep trying.

From your source it seems you are expecting a Stream object to be passed in the constructor, how can I do this and use a HardwareSerial lib?

fu-hsi commented 4 years ago

Hi. But ESP32 is compatible with Arduino. HardwareSerial implement Stream: https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/HardwareSerial.h

strud commented 4 years ago

Hi @fu-hsi

There was some corruption in my Arduino installation, and after this was resolved the issue has gone away.