Hi there,
I am very new to B4A and am developing a remote control app that communicates with an Arduino Uno via the Bluetooth serial port. 5 bytes get sent in one direction or the other about 30msec minimum between packets. The writes from the tablet to the micro are working very well. I have question regarding the speed at which B4A can receive BT serial input and how to implement a timeout of some kind.
Originally we were using Asyncstreams in prefix mode and it seemed like it could keep up. However, we would occasionally receive only part of the packet ( we think) and all the following packets would become unsynced. For example if we received only 4 of the 5 bytes in our packet then the following packet would scoop the first byte to complete the prefix mode number of expected bytes and launch newdata. From a post we spotted prefix mode will simply wait until it gets the expected number of bytes without any timeout. Please set us straight if that is not the case! Is it possible to implement a timeout and clear the unfinished data packet so it will be ready for the next packet to come in?
We couldn't see anyway to do this in prefix mode and so we are currently trying the non-prefix version of asyncstreams. While prefix mode would sure be easier to handle (since the entire packets is read in only one newdata event) we figured it might be the only way to implement a timeout. When we send the data slow enough it is able to keep up most of the time, though we still lose a packet every once in a while. But when we send the data packet quickly (once every 30 milliseconds or so) we get the following error message: "Sending message to waiting queue" and then after some time "Ignoring Event (too many queued events: astreams_newdata)".
Any help or suggestions would be very much appreciated! Feel free to request any further details such as specific code / logs.
Thanks!
Taylor
I am very new to B4A and am developing a remote control app that communicates with an Arduino Uno via the Bluetooth serial port. 5 bytes get sent in one direction or the other about 30msec minimum between packets. The writes from the tablet to the micro are working very well. I have question regarding the speed at which B4A can receive BT serial input and how to implement a timeout of some kind.
Originally we were using Asyncstreams in prefix mode and it seemed like it could keep up. However, we would occasionally receive only part of the packet ( we think) and all the following packets would become unsynced. For example if we received only 4 of the 5 bytes in our packet then the following packet would scoop the first byte to complete the prefix mode number of expected bytes and launch newdata. From a post we spotted prefix mode will simply wait until it gets the expected number of bytes without any timeout. Please set us straight if that is not the case! Is it possible to implement a timeout and clear the unfinished data packet so it will be ready for the next packet to come in?
We couldn't see anyway to do this in prefix mode and so we are currently trying the non-prefix version of asyncstreams. While prefix mode would sure be easier to handle (since the entire packets is read in only one newdata event) we figured it might be the only way to implement a timeout. When we send the data slow enough it is able to keep up most of the time, though we still lose a packet every once in a while. But when we send the data packet quickly (once every 30 milliseconds or so) we get the following error message: "Sending message to waiting queue" and then after some time "Ignoring Event (too many queued events: astreams_newdata)".
Any help or suggestions would be very much appreciated! Feel free to request any further details such as specific code / logs.
Thanks!
Taylor