Converting String to Ascii for DataLogic Scanner

I have a DataLogix Scanner and I am using TCP/IP node to read barcode data from the scanner and trigger the scanner at IP and Port 51240. This is working fine but according to the manufacture you use port 1023 for changing what saved configuration on the scanner you want to use and same port for "Entering Host Mode" which allows you to change the configuration file used. The problem is this requires Ascii commands with string values for file name of the config file on the scanner I want to change and this is not working for me.
flows (5).json (3.4 KB)

Here is the instructions from the manufacture for changing the config file that is saved in the scanner memory you want to change to.

here is the instructions on getting the scanner into host mode in order to change configurations files i want to use

Its not working and I am not getting a rely like the instructions say I should.

I am not sure how to send these Ascii commands that the scanner is looking for. Any ideas on what I am doing wrong?

You dont actually send ESC and <LF> ...

image

... you should be sending the ASCII equivalent codes

also, as the device is supposed to respond, you should use the TCP Request node, like this...

:point_up: 100% untested - but should get you closer to a solution

Demo Flow...

[{"id":"f47c01500424c2da","type":"debug","z":"7c13b8452619581b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1398,"y":1024,"wires":[]},{"id":"79dd3d36b4c1d8a1","type":"tcp in","z":"7c13b8452619581b","name":"","server":"client","host":"192.168.1.50","port":"51240","datamode":"stream","datatype":"utf8","newline":"","topic":"","base64":false,"tls":"","x":1140,"y":1024,"wires":[["f47c01500424c2da"]]},{"id":"d1f99ee1e6c3b126","type":"inject","z":"7c13b8452619581b","name":"A: Exit Host Mode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"A","payloadType":"str","x":922,"y":768,"wires":[["ef2cd4b1e7de0fc3"]]},{"id":"ef2cd4b1e7de0fc3","type":"function","z":"7c13b8452619581b","name":"Generate MODE command","func":"//A == Exit Host Mode\n//B == Enter Programming Mode\n//C == Enter Host Mode\n\n\nconst ESC = '\\x1B';\nconst MODE = \"A\"; //A == Exit Host Mode\nmsg.payload = `${ESC}[${MODE}`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1192,"y":768,"wires":[["94e0163bdde35c75"]]},{"id":"bce4cad9ea51bfb3","type":"inject","z":"7c13b8452619581b","name":"B: Enter Programming Mode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"B","payloadType":"str","x":888,"y":800,"wires":[["ef2cd4b1e7de0fc3"]]},{"id":"e7eacbeafbae0d4f","type":"inject","z":"7c13b8452619581b","name":"C: Enter Host Mode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"C","payloadType":"str","x":922,"y":832,"wires":[["ef2cd4b1e7de0fc3"]]},{"id":"94e0163bdde35c75","type":"tcp request","z":"7c13b8452619581b","name":"","server":"192.168.1.50","port":"1023","out":"time","ret":"buffer","splitc":"0","newline":"","tls":"","x":1372,"y":832,"wires":[["94892378cca31021"]]},{"id":"94892378cca31021","type":"debug","z":"7c13b8452619581b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1402,"y":880,"wires":[]},{"id":"5adef4ee2d63b1b8","type":"inject","z":"7c13b8452619581b","name":"Change Scanner to Config1","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"CHANGE_CFG Config1","payloadType":"str","x":904,"y":896,"wires":[["721a64f983d3a9e5"]]},{"id":"721a64f983d3a9e5","type":"function","z":"7c13b8452619581b","name":"Add LF","func":"// \\n is the escape code for a new line (LF) in JS\n// \\r is the escape code for a carraige return (CR) in JS\nmsg.payload = `${msg.payload}\\n`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1132,"y":896,"wires":[["94e0163bdde35c75"]]},{"id":"8b2ecb1161cadae9","type":"inject","z":"7c13b8452619581b","name":"Trigger Scan","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"T","payloadType":"str","x":954,"y":976,"wires":[["1bcf0218d03d5834"]]},{"id":"1bcf0218d03d5834","type":"tcp out","z":"7c13b8452619581b","name":"","host":"192.168.1.50","port":"51240","beserver":"client","base64":false,"end":false,"tls":"","x":1354,"y":976,"wires":[]}]

Thank you, I will give it a try

Still not getting a response even though its connected

Add a debug to the output of "Generate MODE command" and "Add LF"
Check the debug sidebar - do they look correct?

Like this

it looks correct for the LF

Opps wrong snip, Here is the debug for the LF

In your screenshots, dont you see the "A" in every one of the commands? Doesnt that make you think there is a problem with the flow?

In the function Generate MODE command change the line...

const MODE = "A"; //A == Exit Host Mode

... to ...

const MODE = msg.payload; 

Yes I have to look at the function node to see why the B or C are not showing up when injected but I am not sure how to get the ascii ESC to show up instead of the ? mark.

Thank you.

ESC is a non printable character.

If you want to be certain the correct ASCII codes are being generated, convert the string to a buffer in the function by adding msg.payload=Buffer.from(msg.payload, 'utf8') just before return msg

In the debug you will see a buffer with 3 values. The are the ASCII values of ESC [ A (refer to an online ASCII table for the values)

I changed msg.payload; and now see the other letters but I'm a little confused here.. what is 'utf8" for and in the Generate Mode function node what does line 6 do, const ESC = '\x1B'; ?

in the ASCII table I am looking at the Decimal value for ESC is 27 but should I even be looking at decimal conversion?

Hexadecimal 1B is decimal 27

https://gprivate.com/5yjgn

lol...sorry total newb here. Ill see if I can figure it out.

Thanks

Got it working
Thank you Steve for your help!

1 Like

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