i have a service that sends eight bytes to a microcontroller one byte at a time through a usb ftdi cable. each byte sent is returned with a value. so one byte in, one byte out. the bytes are sent using asyncstreams with a timer set to send one byte every 5 mSecs. i sporadically have the bytes come back out of order.
i attached my logic analyzer to the tx/rx lines going into the microcontroller and can verify that the bytes going in and coming back out are in the correct order. i currently have the bytes returned captured as follows for testing purposes:
ecutrace is a list. when i print out the list it shows the bytes being captured out of order. 95% of the time they are correct but it obviously needs to be 100% correct. sometimes the buffer array contains 1 byte and other times multiple bytes, which makes sense due to the threading and ability of the thread to respond to the bytes coming in.
1) any ideas on what is happening?
2) does the newdata sub ALWAYS fully complete before being fired again?
3) How big is the "internal" buffer used by the stream?
i am able to get it to work if i only process one byte at a time and wait for it to come back before sending the next byte. unfortunately it is dreadfully slow.
i attached my logic analyzer to the tx/rx lines going into the microcontroller and can verify that the bytes going in and coming back out are in the correct order. i currently have the bytes returned captured as follows for testing purposes:
B4X:
Sub astreams_NewData (Buffer() As Byte)
ecutrace.Add("rec time:" & DateTime.Now)
ecutrace.AddAll(Buffer)
end sub
ecutrace is a list. when i print out the list it shows the bytes being captured out of order. 95% of the time they are correct but it obviously needs to be 100% correct. sometimes the buffer array contains 1 byte and other times multiple bytes, which makes sense due to the threading and ability of the thread to respond to the bytes coming in.
1) any ideas on what is happening?
2) does the newdata sub ALWAYS fully complete before being fired again?
3) How big is the "internal" buffer used by the stream?
i am able to get it to work if i only process one byte at a time and wait for it to come back before sending the next byte. unfortunately it is dreadfully slow.