Skip to content

Serial Monitor does not work #2772

@davejel

Description

@davejel

Describe the problem

using serial monitor to show variables etc does not work i.e.
input string to serial input with the code below should give output on serial monitor, it outputs nothing
I tested this using Arduino 1.8.19 ----- works perfectly
then with Arduino 2.3.6 ------ no output to serial window

To reproduce

note !! return character set to carriage return for this to work

void setup() {
	Serial.begin(115200);
	while(!Serial);
	Serial.println("Serial started");
}

String kbdInput = "";
bool inptrdy = false;
//-------------------
void loop() {
	if(Serial.available()) {
		char c = Serial.read();
		if(c != 13) {
			kbdInput += c; // add c to string
		}
		else inptrdy = true;
		Serial.print("serial ok c: ");
		Serial.println(c);
		Serial.println("kbdInput: " + kbdInput);
		Serial.println("inputrdy: " + inptrdy);
	}
	if(inptrdy) {
		Serial.println("inptrdy true kbdInput: " + kbdInput);
		if(kbdInput == "c") {
			Serial.println("Keyboard commands:");
		}
		else if(kbdInput == "tables") { // print tables
			Serial.println("printTheTables()");
		}
		else if(kbdInput == "restart") { // restart node
			Serial.println("Power On Reset this node");
		}

		kbdInput = "";
		inptrdy = false;
	}
}

Expected behavior

the code above should give output in the serial window when prompted with serial input followed by return

Arduino IDE version

2.3.6

Operating system

Windows

Operating system version

11

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions