My program is setup to use the AsyncStream, borrowed much of the code from the bluetooth example.
Well, I can send and receive packets fine. BUT....
I want my program to send a packet, and then wait around for a reply, once a reply is received the program will move on. If a reply is not received within a specified period of time, then exit and move on with null data.
Ive done this a bazillion times in VB6 with Timers, flags, DoEvents, and the OnComm routine.
Well, Trying to do this in B4A in Prefix mode, the NewData routine only gets called when the full packet arrives. that is fine. That works ok. I have the NewData setup to convert the buffer to HexString, and set the RxFlag to true.
However, If i try a simple old routine like this:
RxTimer.Enabled = true
Do until RxFlag = True OR RxTimedOut = true
DoEvents
Loop until RxFlag = true
the serial data never arrives and I could be sending it a million times, it doesnt matter. The timer still ticks and runs out though, itll run out throwing my timedout flag and it exits the Do loop with no data.
Once the loop eventually ends, the NewData routine will execute when serial data gets sent. But i never seem to get data while inside the wait loop.
ugh.
Any way to do this any better?
Well, I can send and receive packets fine. BUT....
I want my program to send a packet, and then wait around for a reply, once a reply is received the program will move on. If a reply is not received within a specified period of time, then exit and move on with null data.
Ive done this a bazillion times in VB6 with Timers, flags, DoEvents, and the OnComm routine.
Well, Trying to do this in B4A in Prefix mode, the NewData routine only gets called when the full packet arrives. that is fine. That works ok. I have the NewData setup to convert the buffer to HexString, and set the RxFlag to true.
However, If i try a simple old routine like this:
RxTimer.Enabled = true
Do until RxFlag = True OR RxTimedOut = true
DoEvents
Loop until RxFlag = true
the serial data never arrives and I could be sending it a million times, it doesnt matter. The timer still ticks and runs out though, itll run out throwing my timedout flag and it exits the Do loop with no data.
Once the loop eventually ends, the NewData routine will execute when serial data gets sent. But i never seem to get data while inside the wait loop.
ugh.
Any way to do this any better?
Last edited: