Hi,
When using the Serial Port and associated async streams without the Prefix feature it is difficult to coordinate reception of data with periodic transmit from B4j to the serial device.
The astream_NewData function is executed on some sort of timer such that data comes in fragmented with the fragments varying in size according to system utilisation.
A lot of hardware devices such as the Tiny Spectrum Analyser and Tiny VNA have serial ports that are designed for terminal applications. They echo character inputs and reply with data or error messages then a prompt. In many cases the prompt could be used to signify the end of the data packet. Other more sophisticated instruments use industry standards such as
SCPI - Standard Commands for Programmable Instruments which is also a text based arbitrary length protocol.
For a system where the B4x app sends periodic commands to a serial port and on receipt of the reply it sends a new command it is currently necessary to send the commands on a fixed time period where the period is longer than the maximum "reply time" because there is no way of "waiting" for data completion. When this time varies depending on the configuration of the serial port device the time period has to be adjusted manually to ensure new commands are not sent before the entire reply is received.
What is needed is a configurable end of packet signature from 1 to 6 bytes such that astreams_NewData is only triggered when that pattern is received. This scheme would also require a timeout to capture comm's failure and could also specify a maximum byte limit to the same ends. i.e. if a data stream was corrupted and the "end of packet" signature missed an error would be raised on some byte count.
Regards
Rob
When using the Serial Port and associated async streams without the Prefix feature it is difficult to coordinate reception of data with periodic transmit from B4j to the serial device.
The astream_NewData function is executed on some sort of timer such that data comes in fragmented with the fragments varying in size according to system utilisation.
A lot of hardware devices such as the Tiny Spectrum Analyser and Tiny VNA have serial ports that are designed for terminal applications. They echo character inputs and reply with data or error messages then a prompt. In many cases the prompt could be used to signify the end of the data packet. Other more sophisticated instruments use industry standards such as
SCPI - Standard Commands for Programmable Instruments which is also a text based arbitrary length protocol.
For a system where the B4x app sends periodic commands to a serial port and on receipt of the reply it sends a new command it is currently necessary to send the commands on a fixed time period where the period is longer than the maximum "reply time" because there is no way of "waiting" for data completion. When this time varies depending on the configuration of the serial port device the time period has to be adjusted manually to ensure new commands are not sent before the entire reply is received.
What is needed is a configurable end of packet signature from 1 to 6 bytes such that astreams_NewData is only triggered when that pattern is received. This scheme would also require a timeout to capture comm's failure and could also specify a maximum byte limit to the same ends. i.e. if a data stream was corrupted and the "end of packet" signature missed an error would be raised on some byte count.
Regards
Rob