yasheena / telnetspy

Telnet Server For ESP8266: Cloning the serial port via Telnet. "Debugging over the air"
MIT License
59 stars 31 forks source link

Error compiling on Arduino Nano ESP32 - cannot convert USBCDC* to HardwareSerial* #22

Open rogerw-gh opened 5 months ago

rogerw-gh commented 5 months ago

Had this error building synman/BME280 for an Arduino Nano ESP32 on PlatformIO.

lib/TelnetSpy/TelnetSpy.cpp:43:13: error: cannot convert 'USBCDC' to 'HardwareSerial' in assignment Google suggested this compile flag: platformio_options: board_build.extra_flags:

Which didn't solve the problem because I put the entire section in, when it should have looked like: build_flags = -D PROJECT_NAME='"BME280 Sensor Publisher"' -D HOSTNAME='"bme280-env-sensor"' -D ELEGANTOTA_USE_ASYNC_WEBSERVER=1 -D ARDUINO_USB_CDC_ON_BOOT=0 -D BS_USE_TELNETSPY -D BME280_LOG_LEVEL_BASIC

I kept searching and found an alternative fix...

https://www.esphome.io/api/uart__component__esp32__arduino_8cpp_source

There's this small section :

if ARDUINO_USB_CDC_ON_BOOT

 this->hw_serial_ = &Serial0;

else

 this->hw_serial_ = &Serial;

endif

The build has the flag set to 0, which forces the serial value to &Serial which fails on the ESP32S3. Changing the build flag to 1 has no effect.

So I tried changing the value of usedSer = &Serial to usedSer = &Serial0, that worked, but so did the compile flag when platformio.ini was configured properly, my bad.

The compile now runs to building a firmware image :-)

rogerw-gh commented 5 months ago

So I've closed the issue, hoping that Google etc. will pick up the necessary change to platformio.ini as a fix when building this code for an Arduino Nano ESP32.