private async Task ReadAsync(CancellationToken cancellationToken)
{
Task<UInt32> loadAsyncTask;
uint ReadBufferLength = 1024;
// If task cancellation was requested, comply
cancellationToken.ThrowIfCancellationRequested();
// Set InputStreamOptions to complete the asynchronous read operation when one or more bytes is available
dataReaderObject.InputStreamOptions = InputStreamOptions.Partial;
// Create a task object to wait for data on the serialPort.InputStream
loadAsyncTask = dataReaderObject.LoadAsync(ReadBufferLength).AsTask(cancellationToken);
// Launch the task and wait
UInt32 bytesRead = await loadAsyncTask;
if (bytesRead > 0)
{
rcvdText.Text += dataReaderObject.ReadString(bytesRead);
rcvdText.Text += ";";
status.Text = "Bajty odczytano poprawnie!";
}
}
Witam,
Mam obsługę portu COM na windows 10 iot z jakiegoś przykładu udostępnionego w internecie.
Próbuję przerobić funkcję do odbierania danych i umieszczania ich w textboxie ale mam problem.
Odczyt znaków działał.
Jak przerobić teraz powyższą funkcję aby odczytywała byte i wyświetlała w textboxie ?