mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-03 22:03:12 +00:00
onReceive does only exist for HardwareSerial not for USB CDC serial but we can at least check for USB connection in a longer interval
This commit is contained in:
parent
bb6f19dddf
commit
17ecd69416
@ -6,6 +6,14 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
|
#if defined(ARDUINO_USB_CDC_ON_BOOT) && ARDUINO_USB_CDC_ON_BOOT
|
||||||
|
#define IS_USB_SERIAL
|
||||||
|
#ifdef SERIAL_HAS_ON_RECEIVE
|
||||||
|
#undef SERIAL_HAS_ON_RECEIVE
|
||||||
|
#endif
|
||||||
|
#include "HWCDC.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RP2040_SLOW_CLOCK
|
#ifdef RP2040_SLOW_CLOCK
|
||||||
#define Port Serial2
|
#define Port Serial2
|
||||||
#else
|
#else
|
||||||
@ -23,7 +31,9 @@ SerialConsole *console;
|
|||||||
void consoleInit()
|
void consoleInit()
|
||||||
{
|
{
|
||||||
auto sc = new SerialConsole(); // Must be dynamically allocated because we are now inheriting from thread
|
auto sc = new SerialConsole(); // Must be dynamically allocated because we are now inheriting from thread
|
||||||
#ifdef SERIAL_HAS_ON_RECEIVE
|
|
||||||
|
#if defined(SERIAL_HAS_ON_RECEIVE)
|
||||||
|
// onReceive does only exist for HardwareSerial not for USB CDC serial
|
||||||
Port.onReceive([sc]() { sc->rxInt(); });
|
Port.onReceive([sc]() { sc->rxInt(); });
|
||||||
#endif
|
#endif
|
||||||
DEBUG_PORT.rpInit(); // Simply sets up semaphore
|
DEBUG_PORT.rpInit(); // Simply sets up semaphore
|
||||||
@ -74,11 +84,14 @@ int32_t SerialConsole::runOnce()
|
|||||||
return 250;
|
return 250;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SERIAL_HAS_ON_RECEIVE
|
|
||||||
int32_t delay = runOncePart();
|
int32_t delay = runOncePart();
|
||||||
|
#if defined(SERIAL_HAS_ON_RECEIVE)
|
||||||
return Port.available() ? delay : INT32_MAX;
|
return Port.available() ? delay : INT32_MAX;
|
||||||
|
#elif defined(IS_USB_SERIAL)
|
||||||
|
return HWCDC::isPlugged() ? delay : (1000 * 20);
|
||||||
#else
|
#else
|
||||||
return runOncePart();
|
return delay;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user