OT?: break up an incoming data stream into fixed length lines? in bash?
Robert Heller
heller at deepsoft.com
Fri Apr 6 19:47:21 UTC 2018
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
/dev/ttyACMn).
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
https://github.com/RobertPHeller/ModelRRSystem
That do low-level serial I/O in Tcl (eg read one character at a time).
Look in these sub-directories:
trunk/Scripts/CMri
trunk/Scripts/CTIAcela
trunk/Scripts/XPressNet
They all use much the same low-level I/O structure.
>
> TIA,
>
> Dave
>
--
Robert Heller -- 978-544-6933
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller at deepsoft.com -- Webhosting Services
More information about the ubuntu-users
mailing list