How to listen to stream and read after x bytes?

Topics: Bluetooth - Microsoft, Bluetooth - Other
May 12, 2014 at 1:39 PM
Hi,
I am working on bluetooth for the first time, and I'm finding I have trouble with speed when I am reading an answer from the device after I send a question. I send a question and I expect 276 bytes to be sent back to me. At the moment I just use Read(buffer, 0, 276).
But the stream seem to take a while to fill, and I have to input a Thread.sleep(100), and since I might have to do this 65 000 times, it takes waaaaaay too long. How should I do this to make it effective??
I appreciate your help a lot!!

Best regards,
Elin
Developer
May 14, 2014 at 11:39 AM
If Read returning with less than the 276 bytes at one go? To get the full piece of data you want, you should just loop calling Read time until you get the full number of bytes you want. See https://32feet.codeplex.com/wikipage?title=Stream.Read and thus http://www.yoda.arachsys.com/csharp/readbinary.html

Try that and see how it helps the 'speed'/promptness too.
May 18, 2014 at 11:12 AM
Thank you, I have tried this, but I didn't seem to change a whole lot, I think the problem might be the way we send data from the device.
Now trying to change it from ask-return-ask-return-ask-return to ask-return until stopped, I think this will improve it combined with the reading of smaller chunks for bytes.
But I've run into another question that might be able to ask while I'm at it?
I use a BluetooothClient and connect via that. Is there any way to set baud rate then??
May 19, 2014 at 4:55 AM
And will anything be faster if I create a virtual serial port instead...?