Serial binding - regexps


I use the standard serial binding from the 2.3.0 release.

I configure two items, with different REGEX to parse acknoledgements received on the serial interface :

Rollershutter Shutters_Living “Volets - Salon” (Shutters) { serial="/dev/shutters@9600,REGEX([CD]([0-9.]*)),UP(c\n),DOWN(d\n),STOP(c\n)" }
Rollershutter Shutters_Rooms “Volets - Chambres” (Shutters) { serial="/dev/shutters@9600,REGEX([EF]([0-9.]*)),UP(e\n),DOWN(f\n),STOP(e\n)" }

And it appears to be loaded correctly :

[del.core.internal.ModelRepositoryImpl] - Loading model ‘shutters.items’
12:08:07.851 [DEBUG] [binding.serial.internal.SerialBinding] - Port: /dev/shutters
12:08:07.852 [DEBUG] [binding.serial.internal.SerialBinding] - Baud rate: 9600
12:08:07.855 [DEBUG] [.binding.serial.internal.SerialDevice] - Serial port ‘/dev/shutters’ has been found.
12:08:07.862 [DEBUG] [binding.serial.internal.SerialBinding] - REGEX: ‘[CD]([0-9.]
12:08:07.863 [DEBUG] [binding.serial.internal.SerialBinding] - UP: ‘c’
12:08:07.863 [DEBUG] [binding.serial.internal.SerialBinding] - DOWN: ‘d’
12:08:07.864 [DEBUG] [binding.serial.internal.SerialBinding] - STOP: 'c

12:08:07.864 [DEBUG] [binding.serial.internal.SerialBinding] - Port: /dev/shutters
12:08:07.865 [DEBUG] [binding.serial.internal.SerialBinding] - Baud rate: 9600
12:08:07.865 [DEBUG] [binding.serial.internal.SerialBinding] - REGEX: '[EF]([0-9.]

12:08:07.866 [DEBUG] [binding.serial.internal.SerialBinding] - UP: ‘e’
12:08:07.867 [DEBUG] [binding.serial.internal.SerialBinding] - DOWN: ‘f’
12:08:07.867 [DEBUG] [binding.serial.internal.SerialBinding] - STOP: 'e

Notice REGEX: '[CD] and REGEX: '[EF]

But when something comes on the interface, only the first item (I think) REGEX (with CD) is used to evaluate the string, whereas the EF REGEX is never exploited :

12:08:58.205 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Shutters_Rooms’ received command UP
12:08:58.205 [DEBUG] [.binding.serial.internal.SerialDevice] - Writing ‘e’ to serial port /dev/shutters
12:08:58.721 [DEBUG] [.binding.serial.internal.SerialDevice] - Received message 'E0
’ on serial port /dev/shutters
12:08:58.728 [DEBUG] [g.serial.internal.RegexPatternMatcher] - about to transform 'E0
’ by the function ‘[CD]([0-9.]*’
12:08:58.728 [INFO ] [smarthome.event.ItemStateChangedEvent] - Shutters_Special changed from C0
to E0

12:09:04.743 [INFO ] [smarthome.event.ItemCommandEvent ] - Item ‘Shutters_Living’ received command UP
12:09:04.745 [DEBUG] [.binding.serial.internal.SerialDevice] - Writing ‘c’ to serial port /dev/shutters
12:09:05.260 [DEBUG] [.binding.serial.internal.SerialDevice] - Received message 'C0
’ on serial port /dev/shutters
12:09:05.266 [DEBUG] [g.serial.internal.RegexPatternMatcher] - about to transform 'C0
’ by the function ‘[CD]([0-9.]*’

Where am I wrong ? In the doc, there are examples for different items definition using different REGEX, so I assume each item could evaluate it’s own REGEX.



Looks like the last update, which was intended to fix a parsing problem, caused this parsing problem.

Try this jar, which is based on this code change.

1 Like

Thank you very much @namraccr , your update fixed my problem.

It’s always a pleasure to use openhab with so nice maintainers :slight_smile: