B4J Question AsyncStreamsText library - bdunkleysmith (first post)    Jul 27, 2023   (1 reaction) It is a class: AsyncStreamsText - Useful when working with streams of text B4A Question [Solved] buffer fragmented packet - emexes (first post)    Sep 05, 2022   (1 reaction) AsyncStreamsText relies on having end-of-line characters - ie CHR(13) and/or CHR(10) - to mark the end of a packet line, and thus won't work for your data which is fixed-length packets with no end-of-packet marker. B4A Tutorial [B4X] The Networker's Guide To The Galaxy - Erel    Jul 14, 2016   (32 reactions) cgxWP4Wu77s The purpose of this tutorial is to cover the various communication options available for B4X developers. Will start with two important utilities: AsyncStreams: Asynchronously reads and writes to any stream and avoids blocking the main thread. Do not assume that messages will arrive as B4R Tutorial HC 05 Classic Bluetooth - Erel    Apr 08, 2019   (10 reactions) AsyncStreamsText will cut the message here
End Sub
Sub AStream_NewData (Buffer() As Byte)
For i = 0 To Buffer.Length - 2 Step 2
Dim ledNumber As Byte = Buffer(i)
Dim value As Boolean = Buffer(i + 1) = 1
leds(ledNumber).DigitalWrite(value)
Next
End Sub B4A Question AsyncStreams, non prefix, long messages - emexes (first post)    Aug 29, 2022 Erel's right: AsyncStreamsText is a better solution, provided that your data doesn't include ASCII 10 (line feed).
Also, note that AsyncStreamsText interprets the incoming bytes as UTF8, which means that ASCII byte values 0..127 will be fine (except for end-of-line bytes 10 and 13), but byte values B4A Library [B4X] FTP Server implemented with Socket and AsyncStreams - Erel    Jul 18, 2022   (40 reactions) https://www.b4x.com/images/ftp.gif (Note that the FTP client above is not part of this solution. It only demonstrates how you can use a standard FTP client to communicate with the server.) This is an example of using low level network features to implement a high level protocol. It is an implementa B4A Question What causes AsyncStreams "Connection Terminated"? - Erel (first post)    Apr 01, 2015 The purpose of AsyncStreamsText is to collect the data from multiple packets and find complete messages. You shouldn't assume that the data arrives in a single packet.
So your code is not correct. You should wait for NewText to be raised and only then you know that a complete message was received. B4J Question Why doesn't Wait For work in a loop? - emexes (first post)    Feb 26, 2024 AsyncStreamsText would work great except for receiving the ready for next command prompt that likely has no end-of-line termination character. B4J Question Reading serial ports - bdunkleysmith (first post)    Jun 21, 2020   (1 reaction) I suggest you have a look at the AsyncStreamsText class. B4A Question How to use AsyncStreamsText - Erel (first post)    Apr 04, 2021   (1 reaction) Why use AsyncStreamsText?
The simplest way is with AsyncStreams in prefix mode. Start with this example: Network + AsyncStreams + B4XSerializator Page: 1   2   3   4   5   6   7   Powered by ColBERT |