TCP/IP HEX Negative with node-red-contrib-buffer-parser

The image makes it easier to show my problem.
When motors reach negative values, I am not able to read correctly.
I need it to be shown with negative values, like this -10.2.
I'm using node-red-contrib-buffer-parser.
Is there any way to get these values ​​in negative?
obs: Positive values ​​are with correct readings.

[{"id":"98c4d4346cbba315","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"b924138725949b87","type":"tcp in","z":"98c4d4346cbba315","name":"Dados Recebidos pela SKC","server":"client","host":"192.168.108.42","port":"5300","datamode":"stream","datatype":"buffer","newline":"","topic":"Status","trim":false,"base64":false,"tls":"","x":240,"y":200,"wires":[["4e6932a9669ce7a5"]]},{"id":"a4ac8421b0565106","type":"ui_text","z":"98c4d4346cbba315","group":"f2eb440f9653bb8c","order":1,"width":0,"height":0,"name":"","label":"Atuador 1","format":"{{msg.n0}} º","layout":"row-spread","className":"","x":860,"y":140,"wires":[]},{"id":"4e6932a9669ce7a5","type":"buffer-parser","z":"98c4d4346cbba315","name":"Angulos","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"Atuador1","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador2","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador3","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador4","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador5","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador6","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador7","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador8","offset":18,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador9","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint16be","name":"Atuador10","offset":22,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":true,"setTopic":true,"outputs":1,"x":480,"y":200,"wires":[["bf3e8044c3ed9270"]]},{"id":"bf3e8044c3ed9270","type":"function","z":"98c4d4346cbba315","name":"function 14","func":"let lista = [];\nlet resposta = [];\n\nfor (var i = 0; i < 11; i++) {\n    lista[i] = msg.payload[i];\n    resposta[i] = lista[i] / 100;\n}\n\nmsg.n0 = resposta[0];\nmsg.n1 = resposta[1];\nmsg.n2 = resposta[2];\nmsg.n3 = resposta[3];\nmsg.n4 = resposta[4];\nmsg.n5 = resposta[5];\nmsg.n6 = resposta[6];\nmsg.n7 = resposta[7];\nmsg.n8 = resposta[8];\nmsg.n9 = resposta[9];\nreturn [msg, msg, msg, msg, msg, msg, msg, msg, msg, msg]\n","outputs":10,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":200,"wires":[["a4ac8421b0565106"],["d551d6e2e74f0c50"],[],[],[],[],[],[],[],[]]},{"id":"d551d6e2e74f0c50","type":"ui_text","z":"98c4d4346cbba315","group":"f2eb440f9653bb8c","order":2,"width":0,"height":0,"name":"","label":"Atuador 2","format":"{{msg.n1}} º","layout":"row-spread","className":"","x":860,"y":180,"wires":[]},{"id":"f2eb440f9653bb8c","type":"ui_group","name":"Atuadores","tab":"ceba900fb09301d5","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"ceba900fb09301d5","type":"ui_tab","name":"Atuadores","icon":"dashboard","disabled":false,"hidden":false}]

Yes, use int16 instead of uint16.

INT16 is "16 bit Integer" (e.g. -32768 ~ 32767)
UINT16 is "Unsigned 16 bit Integer" (e.g. 0 ~ 65535)

Buffer Parser Setup...

Other stuff:
image

New flow:
image

Result:
image

Demo Flow...

[{"id":"a4ac8421b0565106","type":"ui_text","z":"98c4d4346cbba315","group":"f2eb440f9653bb8c","order":1,"width":0,"height":0,"name":"","label":"Atuador 1","format":"{{msg.payload}} º","layout":"row-spread","className":"","x":760,"y":80,"wires":[]},{"id":"4e6932a9669ce7a5","type":"buffer-parser","z":"98c4d4346cbba315","name":"Angulos","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"Atuador1","offset":4,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador2","offset":6,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador3","offset":8,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16le","name":"Atuador4","offset":10,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador5","offset":12,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador6","offset":14,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador7","offset":16,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador8","offset":18,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador9","offset":20,"length":1,"offsetbit":0,"scale":"/ 100","mask":""},{"type":"int16be","name":"Atuador10","offset":22,"length":1,"offsetbit":0,"scale":"/ 100","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":true,"fanOutMultipleResult":true,"setTopic":true,"outputs":10,"x":480,"y":200,"wires":[["a4ac8421b0565106","86fe5911aebbc403"],["d551d6e2e74f0c50","d72ff97ebde890d5"],[],[],[],[],[],[],[],[]]},{"id":"d551d6e2e74f0c50","type":"ui_text","z":"98c4d4346cbba315","group":"f2eb440f9653bb8c","order":2,"width":0,"height":0,"name":"","label":"Atuador 2","format":"{{msg.payload}} º","layout":"row-spread","className":"","x":760,"y":180,"wires":[]},{"id":"c92b4beae26e261e","type":"inject","z":"98c4d4346cbba315","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":140,"wires":[["8a52afcdc1fdd752"]]},{"id":"8a52afcdc1fdd752","type":"buffer-maker","z":"98c4d4346cbba315","name":"Fake TCP Data","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"int16be","length":2,"dataType":"num","data":"0"},{"name":"item2","type":"int16be","length":1,"dataType":"num","data":"-1002"},{"name":"item3","type":"int16be","length":1,"dataType":"num","data":"-805"},{"name":"item4","type":"int16be","length":1,"dataType":"num","data":"505"},{"name":"item5","type":"int16be","length":1,"dataType":"num","data":"606"},{"name":"item6","type":"int16be","length":1,"dataType":"num","data":"707"},{"name":"item7","type":"int16be","length":10,"dataType":"num","data":"8.5"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":300,"y":200,"wires":[["4e6932a9669ce7a5"]]},{"id":"86fe5911aebbc403","type":"debug","z":"98c4d4346cbba315","name":"debug 156","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":120,"wires":[]},{"id":"d72ff97ebde890d5","type":"debug","z":"98c4d4346cbba315","name":"debug 157","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":220,"wires":[]},{"id":"f2eb440f9653bb8c","type":"ui_group","name":"Atuadores","tab":"ceba900fb09301d5","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"ceba900fb09301d5","type":"ui_tab","name":"Atuadores","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

Thank you very much !!
I followed your tip and it started to work correctly. Again thank you very much !!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.