Beja Expert Licensed User Longtime User Nov 12, 2013 #1 While playing with serial communications I found, in the incoming data, the first byte was missing-in-action, so I put a simple delay loop and it worked, please don't ask my how it worked! Code: Copy Sub AStream_NewData (Buffer() As Byte) Dim i As Long For i = 1 To 1000 : Next Enjoy (or correct). Sorry, that was not reliable solution.. Any help? Last edited: Nov 12, 2013
While playing with serial communications I found, in the incoming data, the first byte was missing-in-action, so I put a simple delay loop and it worked, please don't ask my how it worked! Code: Copy Sub AStream_NewData (Buffer() As Byte) Dim i As Long For i = 1 To 1000 : Next Enjoy (or correct). Sorry, that was not reliable solution.. Any help?
Beja Expert Licensed User Longtime User Nov 12, 2013 #2 Sorry that (solution) was not right.. the problem still there that the first byte does not stay.. my controller is sending a byte array and I can read all of them using CommX utillity, but in my phone running Erel's example, the first byte is not logged... with any number of bytes in the array only the first byte that is not showing. Please help. Upvote 0
Sorry that (solution) was not right.. the problem still there that the first byte does not stay.. my controller is sending a byte array and I can read all of them using CommX utillity, but in my phone running Erel's example, the first byte is not logged... with any number of bytes in the array only the first byte that is not showing. Please help.
Erel B4X founder Staff member Licensed User Longtime User Nov 13, 2013 #3 You should post your code. Upvote 0
Beja Expert Licensed User Longtime User Nov 13, 2013 #4 Hi Erel and thanks.. here is the code and it is the very same one of the serial chat example. Code: Copy Sub AStream_NewData (Buffer() As Byte) Dim i As Long LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8")) LogMessage("You", BConv.HexFromBytes(Buffer)) txtLog.Text = BConv.HexFromBytes(Buffer) End Sub Upvote 0
Hi Erel and thanks.. here is the code and it is the very same one of the serial chat example. Code: Copy Sub AStream_NewData (Buffer() As Byte) Dim i As Long LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8")) LogMessage("You", BConv.HexFromBytes(Buffer)) txtLog.Text = BConv.HexFromBytes(Buffer) End Sub
Erel B4X founder Staff member Licensed User Longtime User Nov 13, 2013 #5 Are you using prefix mode? What is the value of the missing byte? Upvote 0
Beja Expert Licensed User Longtime User Nov 13, 2013 #6 Took the prefix away... The byte is not a fixed value and it changes. e.g. if I send F8 BB 23 85, only BB 23 85 shows on the phone. But sometimes all bytes show in the beginning of the app start, but still sometimes and not all the time. The byte array is also variable. If you send 2 bytes, only the last one shows.. or if 10 bytes the last 9... etc. I noticed one thing though. that the first byte comes in the beginning by itself and then disappears quickly in a fraction of a second. I didn't notice that before. I am using Huawei Y301A1, Android 4.1.1, B4A3. Let me do a little more troubleshooting and will come back with more info. (will use another device). Upvote 0
Took the prefix away... The byte is not a fixed value and it changes. e.g. if I send F8 BB 23 85, only BB 23 85 shows on the phone. But sometimes all bytes show in the beginning of the app start, but still sometimes and not all the time. The byte array is also variable. If you send 2 bytes, only the last one shows.. or if 10 bytes the last 9... etc. I noticed one thing though. that the first byte comes in the beginning by itself and then disappears quickly in a fraction of a second. I didn't notice that before. I am using Huawei Y301A1, Android 4.1.1, B4A3. Let me do a little more troubleshooting and will come back with more info. (will use another device).
Erel B4X founder Staff member Licensed User Longtime User Nov 14, 2013 #8 You should expect messages to be split (when not using Prefix mode). Upvote 0