J
Joseph Byrns
I am using streams and the OpenNetCF Bluetooth stuff to access a BT serial
adapter, which usually works fine. However when there is no data in the
stream to be collected the stream.Read(buffer,0,length) just freezes. If I
try to identify if data exists first using stream.length, I get the
following error: "This stream does not support seek operations"
The following is the code I am using:
Dim strm As Stream = ConnectedBTClient.GetStream
strm.Flush()
strm.Write(System.Text.Encoding.ASCII.GetBytes(vbCr & "M"), 0, 2)
Dim tmpStr As String
Dim bytesRead As Integer
Dim buffer(128) As Byte
For i = 1 To 10
If Not strm.Length>0 Then ''get above error here if use this in code
bytesRead = strm.Read(buffer, 0, 128) ''freezes here if nothing to
read
If bytesRead > 0 Then
tmpStr += System.Text.Encoding.ASCII.GetString(buffer, 0,
bytesRead)
End If
Endif
Next i
any ideas appreciated.
adapter, which usually works fine. However when there is no data in the
stream to be collected the stream.Read(buffer,0,length) just freezes. If I
try to identify if data exists first using stream.length, I get the
following error: "This stream does not support seek operations"
The following is the code I am using:
Dim strm As Stream = ConnectedBTClient.GetStream
strm.Flush()
strm.Write(System.Text.Encoding.ASCII.GetBytes(vbCr & "M"), 0, 2)
Dim tmpStr As String
Dim bytesRead As Integer
Dim buffer(128) As Byte
For i = 1 To 10
If Not strm.Length>0 Then ''get above error here if use this in code
bytesRead = strm.Read(buffer, 0, 128) ''freezes here if nothing to
read
If bytesRead > 0 Then
tmpStr += System.Text.Encoding.ASCII.GetString(buffer, 0,
bytesRead)
End If
Endif
Next i
any ideas appreciated.