HDMI Matrix - Send HEX value to IP/Port



One of the things I’m looking to do is to send appropriate hex commands to my IP linked HDMI Matrix. I have this capability working on my home automation controller (using Lua) , but I really wanted to see how I could do it too with node-red.

My attempt so far is here, picking up bits and pieces from other attempts.

[{"id":"2a2a3f46.2d7348","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"4fcea536.d49b64","type":"inject","z":"2a2a3f46.2d7348","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":440,"wires":[["637facf2.a1fd04"]]},{"id":"d910d7b7.bc2858","type":"tcp out","z":"2a2a3f46.2d7348","host":"","port":"4002","beserver":"client","base64":false,"end":true,"name":"HDMI Matrix","x":480,"y":700,"wires":[]},{"id":"637facf2.a1fd04","type":"function","z":"2a2a3f46.2d7348","name":"msg.payload = new Buffer([0x02,0x32,0x31,0x32,0x03]);","func":"msg.payload = new Buffer([0x02,0x32,0x31,0x32,0x03]);\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":560,"wires":[["d910d7b7.bc2858"]]}]

When the hex command is sent the HDMI Matrix also send a response which would be good to capture, if I knew how, but I assume it’s not possible as I currently have the TCP node’s connection to close after the message is sent to allow other systems/controllers to use it.



Maybe use the tcp-request node as that will wait for a reply



It looks like the flow works, but the tcp node seems to lock the connection, even if you have ‘close connection after each message is sent’. I wonder if that is a bug?

I’ll try the tcp-request node instead.



Tcp request node seems to work better, although the debug reporting is strange, I’m expecting the HDMI Matrix to return some confirmation text, but instead the debug window shows some strange information and list of drop down numbers.

Any ideas anyone ?

29/08/2018, 08:59:21node: 3c0a75be.16f1bamsg : Object
_msgid: "d08cd439.5c7728"
topic: ""
payload: buffer[90]raw
[0 … 9]
[10 … 19]
[20 … 29]
[30 … 39]
[40 … 49]
[50 … 59]
[60 … 69]
[70 … 79]
[80 … 89]



You are getting a buffer with 90 elements, if you click on [0 ... 9] for example it will show you the first 10 elements.



If you are sure it's a string - maybe add a function node like

msg.payload = msg.payload.toString();
return msg;
1 Like


As others have said, you are getting a Buffer object. In the debug sidebar, if you click the word raw next to where it says buffer[90] it will try to display it as a String. If that is what you want, you can follow @dceejay's advice to convert it to a String in your flow.



Thanks, toggling the raw button to string changed it to the following which is what I was expecting, although the text should be longer. It’s just showing the ser2net banner message, the Matrix’s response should follow. I’ll check my tcp-request settings

29/08/2018, 20:00:16node: 3c0a75be.16f1ba
msg : Object
_msgid: "757cee7e.5c85"
topic: ""
payload: buffer[85]string
ÿûÿûÿþÿý ser2net port 4002 device /dev/ttyUSB0 [9600 N81] (Debian GNU/Linux)

The convert to string function when added (result below) presents the string slightly differently than the raw to string toggle option. Not sure what the first 8 or so characters are presented differently.

29/08/2018, 20:06:27node: 3c0a75be.16f1ba
msg : Object
_msgid: "e50c5f2c.c81ee"
topic: ""
payload: string
�������� ser2net port 4002 device /dev/ttyUSB0 [9600 N81] (Debian GNU/Linux)



The first few characters are binary in some form or other - ie not standard ASCII characters - maybe control chars ? you would need to find the spec for your device to find out what they are for - (obviously you can go back to the buffer format to see the actual hex values they are.) Or indeed they may just be garbage in the buffer before the message gets sent for some reason. If so maybe you can send a dummy message first to flush that out first.

The request node has several options for when to return - maybe try setting to 50 mS or 100mS - to see if you get the rest of the response you expect.



Thanks again,

It’s weird 50-100ms didn’t change anything, 300+ms didn’t either , but at 175-250ms it did give me more information. The following is the 175 response.

29/08/2018, 22:11:27node: 3c0a75be.16f1ba
msg : Object
_msgid: "41465248.fa43dc"
topic: ""
payload: "��������↵ser2net port 4002 device /dev/ttyUSB0 [9600 N81] (Debian GNU/Linux)↵↵S211E↵↵ Status code:110111111110101↵↵ **Refer to Install Guide or FAQ (www.octavainc.com)for serial control protocol.↵ "



Well - looks like you are in business... !



Thanks again - I’m getting there :smile:

Next on the list would be to be able to translate those responses, so I can present that information in a better way. I think the tow Status codes e.gm111110000111 relate to the configuration of all the other inputs on the matrix.

If you have time - What would be the best way to extract specific content from that response and do a look up to convert it to something more human readable/understandable?



To start with I'd just use a function node to do strong split first on code: then on the line end (arrow) character to grab out the 1 and 0. Then start reading the manual to work out what they mean and then split that further