skaarj1989 / mWebSockets

WebSockets for microcontrollers
https://skaarj1989.github.io/mWebSockets/autobahn-testsuite/servers/
MIT License
101 stars 21 forks source link

'SerialUSB' was not declared in this scope #57

Open LaudixGit opened 2 years ago

LaudixGit commented 2 years ago

Describe the bug Compile fails

Using the unmodified "simple-server" example

Environment info

Expected behavior SAMD51 should be detected correctly

Failure log

/home/laudix/Arduino/libraries/mWebSockets/src/utility.cpp: In function 'void printf(const __FlashStringHelper*, ...)':
/home/laudix/Arduino/libraries/mWebSockets/src/utility.cpp:20:3: error: 'SerialUSB' was not declared in this scope
   SerialUSB.print(buffer);
   ^~~~~~~~~
/home/laudix/Arduino/libraries/mWebSockets/src/utility.cpp:20:3: note: suggested alternative: 'Serial'
   SerialUSB.print(buffer);
   ^~~~~~~~~
   Serial
Multiple libraries were found for "Ethernet.h"
 Used: /opt/arduino-1.8.15/libraries/Ethernet
 Not used: /home/laudix/Arduino/libraries/UIPEthernet
Multiple libraries were found for "Adafruit_ZeroDMA.h"
 Used: /home/laudix/.arduino15/packages/adafruit/hardware/samd/1.7.5/libraries/Adafruit_ZeroDMA
 Not used: /home/laudix/Arduino/libraries/Adafruit_Zero_DMA_Library
exit status 1
Error compiling for board Adafruit Feather M4 Express (SAMD51).

Additional context editing platform.h (as suggested) didn't repair so reverted back

LaudixGit commented 2 years ago

note: forcing the use of Serial doesn't help because utility.cpp neglects to use the _SERIAL value

if PLATFORM_ARCH == PLATFORM_ARCHITECTURE_SAMD21XXX

define _SERIAL SerialUSB

else

define _SERIAL Serial

endif

LaudixGit commented 2 years ago

Compiles when I comment-out line 20 of /Arduino/libraries/mWebSockets/src/utility.cpp

skaarj1989 commented 2 years ago

Can't find Adafruit Feather M4 Express (SAMD51) in Arduino Board Manager, where did you get it?

LaudixGit commented 2 years ago

@skaarj1989 The Board Installer is part of a Adafruit package. There's the Adafruit sales page, and I followed their instructions to add their board to the IDE via the "Additional Boards Manager" in the preferences settings.

The enabled me to use Board Manager to install both "Arduino SAMD Boards (32-Bits ARM Cortex-M0+" and "Adafruit SAMD Boards", and finally, select Adafruit SAMD (32-bits ARM Cortex-M0+ and Cortex-M4) Boards / Adafruit Feather M4 Express (SAMD51)

A little more research this morning to list the variables with grep board=find . -name boards.txt| cut -f2 -d= | sort -u And I think the relevant IDE variable, to identify the board, is "FEATHER_M4" (but that is a guess, I am not an expert)

skaarj1989 commented 2 years ago

I will submit a fix for this soon someday.

For a quick workaround, you can change SerialUSB to Serial. This will give you some debug information (in opposition to comment-out) Anyway, have you managed to get it work?

LaudixGit commented 2 years ago

Yes. I have completed my task. But it will be nice to have the your update so future upgrades will "just work" - no modifications needed

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.