I'm trying to know the position of an engine through a COM port thanks to the method Read(Byte(), Int32, Int32)
Whatever the serial port, when I try to read with SerialPort.Read(buffer,offset,length)
, it never stops returning.
This method reads several bytes of the SerialPort input buffer and writes them to a byte array at the specified offset position. I do not know if this is because there is not enough data or for another reason. Then, the program is closed.
Is it a problem with the driver?
I've read this msdn link. microsoft that
The
Read
method returns zero only after reaching the end of the sequence. Otherwise,Read
always reads at least one byte of the sequence before returning. If there is no data available in the stream after a call to Read, the method will be blocked until at least one byte of data can be returned.
I have to know where this engine is to move it when I move a camera that is on another COM port, and use it with a timer. I think this is what blocks the program, but I'm not sure.
How can I do to know its position without blocking the program? Do I have to use Read()
only when I move the camera?