hi,
I'm using the following read method to get the data from serial device.
As i'm reading byte by byte i must know how much length it'll be. At present I'm using for loop (approx. ranges from 0 t0 100)to get all the data from the device. how to find there is no character in serial buffer.
So that i can stop looping. I cannot use EOC (End of charcter). B'cos 3 or 4 commands can be sent to device as a hex string. For each command it replies with start ,data and end of character.
Can anyone suggest how to find the buffer is empty?
Thank You!
I'm using the following read method to get the data from serial device.
VB.NET:
Public Function Read() As Byte
Dim rd As Integer
Dim ovl As New OVERLAPPED
Dim dt As Byte()
dt = Array.CreateInstance(GetType(Byte), 1) 'Initialize the buffer
If Opened = True Then
ReadFile(hPort, dt, 1, rd, ovl)
Else
Throw New Exception("Comport not opened")
End If
Return dt(0)
End Function
So that i can stop looping. I cannot use EOC (End of charcter). B'cos 3 or 4 commands can be sent to device as a hex string. For each command it replies with start ,data and end of character.
Can anyone suggest how to find the buffer is empty?
Thank You!
Last edited by a moderator: