Transform incoming HEX values via TCP binding and map file

Hi,

I finally managed to control my Arcam Solo Movie (amplifier with BD player) with openHAB 2.3 on Raspberry Pi 3 (openHABian) via TCP binding and would kindly ask you for your help!

For example I can successfully increase the volume via UP command but I am not able to read the response correctly

I added the following to the tcp.cfg

# Update the status of Items using the response received from the remote end (if the
# remote end sends replies to commands)
updatewithresponse=true

# Used character set
charset=ASCII

Here is the corresponding the Volume item:

Rollershutter	VolumeHCpm      "Lautstärke" 	    <soundvolume>   	(LivingDining, gHomecinema)		{tcp=">[UP:192.168.7.39:50000:'MAP(arcam.map)'], >[DOWN:192.168.7.39:50000:'MAP(arcam.map)'], >[STOP:192.168.7.39:50000:'MAP(arcam.map)']"}

In the arcam.map file I have:

UP=\u0021\u0001\u0008\u0002\u0010\u0010\u000D
\u0021\u0001\u0008\u0000\u0002\u0010\u0010\u000D=UP

The documentaion from Arcam tells me how the response should look like

Command:

STR ZONE CC DL Data 1 Data 2 ETR
0x21 0x01 0x08 0x02 0x10 0x10 0x0D

Response

STR ZONE CC AC DL Data 1 Data 2 ETR
0x21 0x01 0x08 0x00 0x02 0x10 0x10 0x0D

The outgoing transformation works perfectly, but the incoming is unfortunately not working

Here is my log file:

2018-06-07 23:37:13.867 [ome.event.ItemCommandEvent] - Item ‘VolumeHCpm’ received command UP

==> /var/log/openhab2/openhab.log <==

2018-06-07 23:37:13.874 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is '!

2018-06-07 23:37:13.995 [DEBUG] [ing.tcp.AbstractSocketChannelBinding] - Picked WriteBufferElement [Channel=Channel [item=VolumeHCpm, command=UP, direction=OUT, remote=/192.168.7.39:50000, buffer=, isBlocking=false, isReconnecting=true, channel=/192.168.7.253:43428::/192.168.7.39:50000, host=192.168.7.39, port=50000], buffer=!

, isblocking=false] from the queue

2018-06-07 23:37:13.998 [DEBUG] [ing.tcp.AbstractSocketChannelBinding] - Sending !

for the outbound channel /192.168.7.253:43428->/192.168.7.39:50000

2018-06-07 23:37:14.252 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.253 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.256 [WARN ] [ing.tcp.protocol.internal.TCPBinding] - Cannot parse input ! to match command OFF on item Home_cinema

2018-06-07 23:37:14.260 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.262 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.264 [WARN ] [ing.tcp.protocol.internal.TCPBinding] - Cannot parse input ! to match command ON on item Home_cinema

2018-06-07 23:37:14.267 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.269 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.273 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.275 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.281 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.283 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.287 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.291 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.293 [WARN ] [ing.tcp.protocol.internal.TCPBinding] - Cannot parse input ! to match command STOP on item VolumeHCpm

2018-06-07 23:37:14.298 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.300 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.304 [WARN ] [ing.tcp.protocol.internal.TCPBinding] - Cannot parse input ! to match command UP on item VolumeHCpm

2018-06-07 23:37:14.309 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.312 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.317 [WARN ] [ing.tcp.protocol.internal.TCPBinding] - Cannot parse input ! to match command DOWN on item VolumeHCpm

2018-06-07 23:37:14.322 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.325 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

2018-06-07 23:37:14.336 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘!’ with the file ‘arcam.map’ : Target value not found in map for ‘!’

2018-06-07 23:37:14.339 [DEBUG] [ing.tcp.protocol.internal.TCPBinding] - transformed response is ‘’

Could you please tell me, how this could work and what do I have to change?

Thank you very much for your support!

Kind regards,
picmac

Do you have what the full value is that is being receoved?

From the logs looks like it contains a ! If I a m reading correct. I would start by printing the return string to a log file so that you know what data is being receiv ed.

You are

@picmac

In a console, type telnet 192.168.7.39 50000
What is your amp sending?

Thanks

Hi guys,

thank you very much for your fast response!

I do not get any responnse via telnet after sending \x21\x01\x08\x02\x10\x7C\x0D or any other command.

[20:17:47] openhabian@openHABianPi:/var/log/openhab2$ telnet 192.168.7.39 50000
Trying 192.168.7.39...
Connected to 192.168.7.39.
Escape character is '^]'.
\x21\x01\x08\x02\x10\x7C\x0D
Connection closed by foreign host.

My problem is that the respnonse is not “human readable”. I get “! + squares”.
Because it gets lost with copy / paste I added a screenshot .

Because it is not allowed to upload log files, I uploaded them to Dropbox

Could you please take a look?
Is it OK to start a map file with a leading \ or is some escaping needed?
Are there other ways to map hex values?

Thank you!

Kind regards,
Marcus

Yes the most adequate one here would probably be the javascript transform