Skip to content

Serial.readString() returns empty String #10

@eziya

Description

@eziya

Hi,

I used Serial.readString() method to receive string message from string monitor.
but it returns empty string.

#include "Arduino.h"
#include "FreeRTOS_AVR.h"

void setup()
{
	Serial.begin(9600);
	xTaskCreate(vTaskSerial,  NULL, configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	vTaskStartScheduler();

	while(1);
}

void vTaskSerial(void *pvParameters) {

	while(1) {
		if(Serial.available() > 0) {
			Serial.println("Serial is available");
			String msg = Serial.readString();
			Serial.println(msg);
			Serial.println("Message printing ends");
		}

		vTaskDelay(100 / portTICK_PERIOD_MS);
	}
}

void loop() {

}
>>Send to COM3: "hello"<<
Serial is available
 
Message printing ends 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions