protect unconnected USB-CDC from being used
found a few more places where Serial was used without first checking if its connected. 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
This commit is contained in:
@@ -543,6 +543,8 @@ void show_psram_info_part2(void)
|
|||||||
|
|
||||||
void showRealSpeed() {
|
void showRealSpeed() {
|
||||||
//Serial.begin(115200);
|
//Serial.begin(115200);
|
||||||
|
if (!Serial) return; // Avoid writing to unconnected USB-CDC
|
||||||
|
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
Serial.println(F("\n"));
|
Serial.println(F("\n"));
|
||||||
for(int aa=0; aa<65; aa++) Serial.print("="); Serial.println();
|
for(int aa=0; aa<65; aa++) Serial.print("="); Serial.println();
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ void updateBaudRate(uint32_t rate){
|
|||||||
// RGB LED data return as JSON array. Slow, but easy to use on the other end.
|
// RGB LED data return as JSON array. Slow, but easy to use on the other end.
|
||||||
void sendJSON(){
|
void sendJSON(){
|
||||||
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
||||||
|
if (!Serial) return; // WLEDMM avoid writing to unconnected USB-CDC
|
||||||
uint16_t used = strip.getLengthTotal();
|
uint16_t used = strip.getLengthTotal();
|
||||||
Serial.write('[');
|
Serial.write('[');
|
||||||
for (uint16_t i=0; i<used; i++) {
|
for (uint16_t i=0; i<used; i++) {
|
||||||
@@ -55,6 +56,7 @@ void sendJSON(){
|
|||||||
// RGB LED data returned as bytes in TPM2 format. Faster, and slightly less easy to use on the other end.
|
// RGB LED data returned as bytes in TPM2 format. Faster, and slightly less easy to use on the other end.
|
||||||
void sendBytes(){
|
void sendBytes(){
|
||||||
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
if (!pinManager.isPinAllocated(hardwareTX) || pinManager.getPinOwner(hardwareTX) == PinOwner::DebugOut) {
|
||||||
|
if (!Serial) return; // WLEDMM avoid writing to unconnected USB-CDC
|
||||||
Serial.write(0xC9); Serial.write(0xDA);
|
Serial.write(0xC9); Serial.write(0xDA);
|
||||||
uint16_t used = strip.getLengthTotal();
|
uint16_t used = strip.getLengthTotal();
|
||||||
uint16_t len = used*3;
|
uint16_t len = used*3;
|
||||||
|
|||||||
Reference in New Issue
Block a user