How to read line data send to COM from PC

569 Views Asked by At

I was going through planty of nf samples (many thanks for that), but couldn't find any, where I can read data sent by USB cable (serial port).

In arduino I would simply write: Serial.readString() to get data sent through COM. How that could be acomplished in nanoframework?

1

There are 1 best solutions below

2
On

You should use the System.IO.Ports API. Windows.Devices.SerialCommunication is the UWP API that we're discontinuing and replacing with the IoT Core API.

Please check the sample pack here and look at Scenario3 Read. After properly setting up the SerialPort device, you can call serialDevice.Read(buffer, 0, buffer.Length).