Main Site Documentation

How to determine the available data size when reading serial via USbHost


#1

Is there any way to determine how much data is avaiable in teh Serial using UsbHost

_serialUsb.Read(data, 0, data.Length);

how to define the data length - I do not want to read several times if the data is available to read in one time + do not want to allocate max length of int as well…


#2

Don’t know if it will answer your question but when I use CDC on EMX, there’s no direct way to know if data are available nor the size of incoming data like on a normal serial port. However you can poll the bus and check incoming bytes. If no data are availbale then you are receiving 0x00 bytes. You can also add starter and ender to your transmitted data to ease stream recognition.