OT?: break up an incoming data stream into fixed length lines? in bash?
At Fri, 6 Apr 2018 11:04:08 -0700 "Ubuntu user technical support, not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
> I'm using U16.04 to read data from a sensor. The incoming serial data
> stream has no newlines, just continuous bytes. In the datastream the
> letters B and M occur together at the start of every 24 byte
> subsequence. I'm reading the data using getserial with appropriate
> speed and parity parms. I don't see a simple way to break it up into
> lines with each line having 24 bytes. Does anyone care to suggest a
> method? I'd use a bash function if there is one.
You are going to have to use low-level serial I/O. I am presuming we are
talking about RS232/485 (/dev/ttySnn) OR a USB/Serial device (/dev/ttyUSBn or
Commonly, that would mean have way to much fun coding in C/C++, but it is
actually possible to do that with Tcl -- something I have done for various
serial-based Model Railroad interfaces. (It might be possible with Python, but
I don't use Python, so I have no clue).
There is Tcl code libraries under
That do low-level serial I/O in Tcl (eg read one character at a time).
Look in these sub-directories:
They all use much the same low-level I/O structure.
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller at deepsoft.com -- Webhosting Services