F FFMan Member Licensed User Longtime User May 2, 2014 #1 I'm using astreams to receive data over a Bluetooth link. If the comms gets out of sync I need to clear the buffer, before I send another request for data. but I can't see how to clear the buffer, the astreams_newdata only fires when new data is received, if there is data in the buffer I want to discard how can I read this ? thanks
I'm using astreams to receive data over a Bluetooth link. If the comms gets out of sync I need to clear the buffer, before I send another request for data. but I can't see how to clear the buffer, the astreams_newdata only fires when new data is received, if there is data in the buffer I want to discard how can I read this ? thanks
KitCarlson Active Member Licensed User Longtime User May 2, 2014 #2 I never clear the Buffer. I use Code: Copy b = b & BytesToString(Buffer, 0, Buffer.Length, "UTF8") , then use IndexOf and SubString2 to parse the string, to pull out commands to process, and to clear used part of string. Upvote 0
I never clear the Buffer. I use Code: Copy b = b & BytesToString(Buffer, 0, Buffer.Length, "UTF8") , then use IndexOf and SubString2 to parse the string, to pull out commands to process, and to clear used part of string.
F FFMan Member Licensed User Longtime User May 2, 2014 #3 I think I get characters in the buffer when the app pauses and resumes, or when I kill and restart it, so there are characters in the buffer but the event doesn't fire. I need some way of clearing the buffer before I request new data, otherwise I guess I could code in a dummy request that causes a dummy return to fore the event. just wondered if there was an easier way. Upvote 0
I think I get characters in the buffer when the app pauses and resumes, or when I kill and restart it, so there are characters in the buffer but the event doesn't fire. I need some way of clearing the buffer before I request new data, otherwise I guess I could code in a dummy request that causes a dummy return to fore the event. just wondered if there was an easier way.
KitCarlson Active Member Licensed User Longtime User May 3, 2014 #4 Have you tried setting Buffer.Length to zero? When possible, I like to use a protocol, to give identity to the request, and reply. It helps sort the handling for various processing needs. Last edited: May 3, 2014 Upvote 0
Have you tried setting Buffer.Length to zero? When possible, I like to use a protocol, to give identity to the request, and reply. It helps sort the handling for various processing needs.
Erel B4X founder Staff member Licensed User Longtime User May 4, 2014 #5 There is no buffer in AsyncStreams (unless you are using prefix mode). The events will be raised when the activity resumes. I recommend you to use a service to manage the communication. It will be simpler. Upvote 0
There is no buffer in AsyncStreams (unless you are using prefix mode). The events will be raised when the activity resumes. I recommend you to use a service to manage the communication. It will be simpler.