AlexNek
Posts: 11
Joined: Thu Nov 05, 2009 7:49 pm

What is the best way to detect data ready?

Tue Nov 17, 2009 11:25 am

As we can't use asynchronous read I want to know what is best way to wait received data with timeout?
Related question - How franson fill receiver buffer and set stream.Length? From the other side, how can I decide if I received 1x30 bytes or 2x 15bytes? What is the "signal" about read finished?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: What is the best way to detect data ready?

Tue Nov 17, 2009 4:40 pm

It's up to the underlying protocol to determine when the read is "finished". For a Stream it's no difference between 1x30 bytes compared to 2x15 bytes. The 15th byte of the first 15 bytes should be followed by an END byte of some sort. It's in the application layer.

Regards,
Jonas

AlexNek
Posts: 11
Joined: Thu Nov 05, 2009 7:49 pm

RE: What is the best way to detect data ready?

Thu Nov 19, 2009 2:40 pm

I means someting other. By sample, we have ReadCallback for async read. So franson know when Read Callback function must be called.
I looking for the same possibility but for sync read.
I don't know if nested Read Callback possible buf if you imagine nested Read Callback for sync read it could be what I means under 2x15bytes.
It is not a problem to split 30 bytes to 2x15 at the application layer. I only wnat to know - it was one package or two? /similar as I imagine that Read Callback "return" only one package/

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: What is the best way to detect data ready?

Fri Nov 20, 2009 11:21 am

No, an asynchronous read callback is not guaranteed to return 2x15 bytes. It might just as well return 1x19 and then 1x11 bytes on the next run.

Regards,
Jonas

AlexNek
Posts: 11
Joined: Thu Nov 05, 2009 7:49 pm

RE: What is the best way to detect data ready?

Fri Nov 20, 2009 3:03 pm

Nice to know. What is then data "finish event" for asynchronous read callback? Time between receiving two symbols?

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: What is the best way to detect data ready?

Mon Nov 23, 2009 7:54 pm

I don't think it's a time-limit, more likely it just reads as much data as it can find in the Stream when the thread runs.

Regards,
Jonas

AlexNek
Posts: 11
Joined: Thu Nov 05, 2009 7:49 pm

RE: What is the best way to detect data ready?

Tue Nov 24, 2009 11:25 am

I thinking "about bluetooth part". The Stream buffer must be filled by something and we need some trigger that say - fire data ready event.

Return to “BlueTools”