Serial binding // issue: sequence of device not equal string

I wanna control my amp by a RS232 serial interface.
Connection to openHAB is made by net2serial to read the RS232 and socat to receive the data on the server where openHAB is installed.

I have to realize that

String         STR_SERIAL_CA851A_PIUSB0_receive { serial="/dev/PIUSB0" }

does give me confusing results as the string gives me different results back if i parse expressions by REGEX. Furtheron: The status result in KARAF ist not the same as doing a log of the string expression.

Logging the binding shows:

2019-02-11 20:53:21.029 [DEBUG] [binding.serial.internal.SerialDevice] - Received message '#4,13,29^M#4,13,30^M#4,13,31^M' on serial port /dev/PIUSB0

what gives me the impression the whole sequence doing an action with the amp
shall be the string i shall expect from the binding.

The expression i get from the binding is e.g.


The problem is that i miss in a sequence the single commands that i need to get
a clear information about the state of the amp, as second using different items with the same definition i get different results. What makes sense for me if the shown sequence is the string something gets parsed. But i can never see the sequence complete in the string, i just see a more or less random portion of the sequence string from ^M to ^M. ( ^M is here the carriage return term ).
So i cannot work sequential with the received message as shown in the log

My intention is to get the complete sequence as shown in the log as a string to be able to split and separate that according my needs.

My expectation would be to get as string
using { serial="/dev/PIUSB0" }
and not e.g.

( Or: worser: Item 1 gives #4,13,29; Item 2 gives #4,13,31 from the same received message)

2nd: The shown switch in the documentation does not work, it`s always NULL.
Not sure it´s an helpful indicator.

If i observe the port e.g. by cat /dev/PIUSB0 i see the single commands in single rows ( Carriage return ) as a flow.

Serial binding is very simplistic. What you’d like to do is to configure a timeout or end-of-message character, but there is no means to do that.

One approach might be to assemble the fragments you are getting in your serial Item.
Have a rule that triggers upon update and appends this fragment to a message string.
Also starts, or restarts, a timer that allows the next fragment…
When the timer expires (fragments stopped coming), process the assembled message and clear the message string.

What’s the baud rate? this might not work if it is fast.

Alternative is a custom script to do the capture and pass to openHAB

Or node-red

Ah, I did not know node-red was “allowed” access to serial port without using binding, that makes for shareable solutions :smiley:

I use a serial node on node-red on a Pi1 to read and “translate” RFLink data and forward onto openHAB as MQTT messages