Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,15 @@ void WLED::setup()
findWiFi(true); // start scanning for available WiFi-s

// all GPIOs are allocated at this point
#ifdef ARDUINO_USB_CDC_ON_BOOT
// USB CDC means USB D+ D- are used .. pin allocator will always return. force it as enabled instead
serialCanRX = true;
serialCanTX = true;
#else
// use RX/TX as set by the framework - these boards do _not_ have RX=3 and TX=1
serialCanRX = !PinManager::isPinAllocated(hardwareRX); // Serial RX pin (GPIO 3 on ESP32 and ESP8266)
serialCanTX = !PinManager::isPinAllocated(hardwareTX) || PinManager::getPinOwner(hardwareTX) == PinOwner::DebugOut; // Serial TX pin (GPIO 1 on ESP32 and ESP8266)
#endif // ARDUINO_USB_CDC_ON_BOOT

#ifdef WLED_ENABLE_ADALIGHT
//Serial RX (Adalight, Improv, Serial JSON) only possible if GPIO3 unused
Expand Down
4 changes: 3 additions & 1 deletion wled00/wled_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ void sendBytes(){

void handleSerial()
{
if (!(serialCanRX && Serial)) return; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true
if (serialCanRX == false && Serial) {

@softhack007 softhack007 Nov 7, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rommo911, could it be that your proposed change does not lead to the same behaviour when not having USB-CDC ?

old condition truth table:

canRX Serial result
false - true = return
true false true = return
true true false = continue

new condition truth table:

canRX Serial result
false true true = return
false false false = continue
true - false = continue

As the new condition you propose seems to be broken - how about just removing the "early exit" for the case of USB_CDC ?

#if ARDUINO_USB_CDC_ON_BOOT
   if (!Serial) return;
#else
   if (!(serialCanRX && Serial)) return;
#endif

@blazoncek not sure if serialCanRX is used in other places in the code, so we still need the change in wled.cpp?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serialCanRX is only used to determine if ADA/Improv can be used. Nothing else AFAIK.

return;
}; // arduino docs: `if (Serial)` indicates whether or not the USB CDC serial connection is open. For all non-USB CDC ports, this will always return true

static auto state = AdaState::Header_A;
static uint16_t count = 0;
Expand Down