# Trying to get data from ascii to a string

**URL:** <https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149>\
**Category:** General\
**Created:** [12 October 2020 21:06 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149 "2020-10-12T21:06:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:06 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/1 "2020-10-12T21:06:13Z")

</div>

What am I doing wrong here? You can see the values have the ascii data in the top message but after my function I get no values?

Im trying to just take the ascii values in the buffer or array out of the modbus read and put them into a string so I can pass it to a web service.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e39864667525d41aaac4a087c90e6d766f4d75af.png)

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [12 October 2020 21:12 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/2 "2020-10-12T21:12:07Z")

</div>

Add debug node before the function and show the content of msg. Hard to say something about the mystery object you tried to deal with

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [12 October 2020 21:14 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/3 "2020-10-12T21:14:34Z")

</div>

Try to use the array spread operator (...) in the function

```javascript
msg.value = String.fromCharCode(...msg.payload.data)
return msg;

```

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:22 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/5 "2020-10-12T21:22:28Z")

</div>

Thank you! That worked in the value field. Now I just need to figure out how to set it to a global variable

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:26 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/6 "2020-10-12T21:26:24Z")

</div>

This didnt work lol

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d6be1941248ff1f38e4778ae9bc5c63d656ed51.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [12 October 2020 21:29 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/7 "2020-10-12T21:29:31Z")

</div>

> [@jeffreys](#):
>
> Now I just need to figure out how to set it to a global variable

That's explained in detail in Node-Red documentation - [Storing data](https://nodered.org/docs/user-guide/writing-functions#storing-data)  
You can store it directly from that function

> [@jeffreys](#):
>
> This didnt work lol

Should be the other way round if you gonna use a Change node. **SET** global.SN **TO** msg.value

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:32 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/8 "2020-10-12T21:32:31Z")

</div>

haha yep that will do it. See the strange character after the SN BVGJ01315?? Why is that in there?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/1326383a210bbf98a0431caae694bd36c1c6c926.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [12 October 2020 21:36 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/9 "2020-10-12T21:36:32Z")

</div>

No idea 😉  
but you could try to use pop() on that `msg.payload.data.pop()` that removes the last element from the array. If that character is always there. test it

[EDIT]

```auto
let arr = msg.payload.data;
arr.pop();
msg.value = String.fromCharCode(...arr)
return msg;

```

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:48 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/10 "2020-10-12T21:48:22Z")

</div>

> [@UnborN](#):
>
> msg.payload.data.pop()

did i use that right? no change

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/99f3e336b69e5b3bf16e4a463f7fdb8e6ae0b67c.png)

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [12 October 2020 21:51 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/11 "2020-10-12T21:51:37Z")

</div>

> [@UnborN](#):
>
> ```auto
> let arr = msg.payload.data;
> arr.pop();
> msg.value = String.fromCharCode(...arr)
> return msg;
> 
> ```

You are genius! thank you

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [12 October 2020 21:59 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/12 "2020-10-12T21:59:06Z")

</div>

Nah 😉 i just had to research half of the commands on the internet.  
But it helps if you do know they exist to look for them.

By the way, test this hackish code with pop() thoroughly so you wont miss a 'legal' character from your SN

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 October 2020 22:34 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/13 "2020-10-12T22:34:51Z")

</div>

For future reference, you might want to try [buffer parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) node. It takes care of all the byte swapping & conversions & unpacking for you.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 11:54 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/14 "2020-10-13T11:54:38Z")

</div>

Will do. I am removing the windows computer from my control systems so now a linux kernal touchscreen talks modbus to my plc and handles connecting to our IT SOAP services. Sounds like it would be a good idea to put a check on the return data.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 13:20 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/16 "2020-10-13T13:20:01Z")

</div>

The pic 2 works but pic 1 doesnt. I think i am passing too much in the payload. How can I remove the extra portions of the payload?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d08a7453366aa9062a30dc52753caa767ad9430c.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/773722fd770bd8bfd80d13fe8a72ba9061d9c484.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 13:44 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/17 "2020-10-13T13:44:18Z")

</div>

I didn't understand much of what you have tried in that Change node.  
You are trying to embed in a string the global variable SN ?

Use a Function node with the use of [template strings](https://www.youtube.com/watch?v=3ryyo3C3ejk).

for Example :

```javascript
let SN = global.get("SN");
msg.payload = `The Serial Number is ${SN} and it is embedded in a string`
return msg

```

Note that those are backticks and not single quotes.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 13:57 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/18 "2020-10-13T13:57:41Z")

</div>

I was probably not using it right. Ok, i deleted the unused parts of the msg and got it the same as the pic 2 above but still no go quite yet. See how i dont get that soap envelope back like in pic 2?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35fe4e8607966405430f5a17c089ff99e73d77dd.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 14:01 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/19 "2020-10-13T14:01:31Z")

</div>

Rather than a screenshot of the function paste it here using the `</>` button at the top of the forum text entry field when pasting it in.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 14:06 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/20 "2020-10-13T14:06:43Z")

</div>

Yea the modbus breaks and the soap so i figured it wasn't very useful to post the code but here it is so far. `[{"id":"e6693df7.a3cfa","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"eb571ded.e53f3","type":"modbus-read","z":"e6693df7.a3cfa","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"21","rate":"1","rateUnit":"m","delayOnStart":false,"startDelayTime":"","server":"5410cb45.9afa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":110,"y":240,"wires":[[],["bf1abdfc.b1d4e","aafbdb90.305bd8"]]},{"id":"d74a4291.c4218","type":"switch","z":"e6693df7.a3cfa","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"neq","v":"1","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":350,"y":340,"wires":[["2c48206b.b7cbd"],[]]},{"id":"68d47360.93fddc","type":"function","z":"e6693df7.a3cfa","name":"","func":"\nmsg.site = 'AC'\n//msg.serial = msg.payload\nmsg.serial = global.get(\"SN\")\n\n////msg.serial = global.get(\"SN\")\n//msg.serial = 'BVGL01272'\n\n\nvar parse1 = '<?xml version=\"1.0\" encoding=\"utf-8\"?>';\nparse1 = parse1 + '\\n' + '<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">';\n//parse1 = parse1 + '\\n' + ' <soap:Header>';\n//parse1 = parse1 + '\\n' + ' <SoapSettings xmlns=\"http://tempuri.org/\">';\n//parse1 = parse1 + '\\n' + ' <IsTest>false</IsTest>';\n//parse1 = parse1 + '\\n' + ' <ApplicationID>105B9760-A4A0-4659-BE09-2B6F64980DBD</ApplicationID>';\n//parse1 = parse1 + '\\n' + ' <ApplicationKey>C565C1F9-A326-4754-B654-CFA059865820</ApplicationKey>';\n//parse1 = parse1 + '\\n' + ' </SoapSettings>';\n//parse1 = parse1 + '\\n' + ' </soap:Header>';\nparse1 = parse1 + '\\n' + ' <soap:Body>'\nparse1 = parse1 + '\\n' + ' <GetChargeRecipe xmlns=\"http://tempuri.org/\">';\nparse1 = parse1 + '\\n' + ' <serialNumber>' + global.get(\"SN\") + '</serialNumber>';\nparse1 = parse1 + '\\n' + ' <site>' + msg.site + '</site>';\n//parse1 = parse1 + '\\n' + ' <billNum>' + msg.billNum + '</billNum>';\nparse1 = parse1 + '\\n' + ' </GetChargeRecipe>';\nparse1 = parse1 + '\\n' + ' </soap:Body>';\nparse1 = parse1 + '\\n' + '</soap:Envelope>';\nmsg.payload = parse1;\n\ndelete msg.site\ndelete msg.serial\nmsg.topic = \"\";\nreturn msg;\n\n//var testval = global.get(\"test\")||0;\n//msg.payload = testval;\n//return msg;\n\n\n\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":260,"wires":[[]]},{"id":"3337f067.a4ca1","type":"simple-soap","z":"e6693df7.a3cfa","host":"http://172.16.17.6:8090/ChargeWs/ChargeService.asmx","hostType":"str","path":"","pathType":"str","action":"http://tempuri.org/GetChargeRecipe","actionType":"str","body":"payload","bodyType":"msg","mustache":false,"attrkey":"$","charkey":"_","stripPrefix":false,"simplify":false,"normalizeTags":false,"normalize":true,"topic":"","name":"","useAuth":false,"x":550,"y":240,"wires":[["bcf8e8a3.96f408","35187516.658fca"]]},{"id":"bf1abdfc.b1d4e","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data[20]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":340,"wires":[["d74a4291.c4218"]]},{"id":"7cad4f22.cfc79","type":"comment","z":"e6693df7.a3cfa","name":"Read from Wago","info":"","x":120,"y":200,"wires":[]},{"id":"37855d95.4f6b3a","type":"comment","z":"e6693df7.a3cfa","name":"Get 20th array position for serial wrote ","info":"","x":150,"y":380,"wires":[]},{"id":"eb4f9416.32b32","type":"comment","z":"e6693df7.a3cfa","name":"Check if equal 1, fire get web service","info":"","x":280,"y":420,"wires":[]},{"id":"77b13775.67d7ac","type":"comment","z":"e6693df7.a3cfa","name":"need SN put back into string global SN","info":"","x":250,"y":100,"wires":[]},{"id":"aafbdb90.305bd8","type":"function","z":"e6693df7.a3cfa","name":"","func":"//msg.value = String.fromCharCode(...msg.payload.data)\n\n//return msg;\nlet arr = msg.payload.data;\narr.pop();\nmsg.value = String.fromCharCode(...arr)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":140,"wires":[["3557e0ae.d936a"]]},{"id":"3557e0ae.d936a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"SN","pt":"global","to":"value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[[]]},{"id":"6aebd91.ca17728","type":"debug","z":"e6693df7.a3cfa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":300,"wires":[]},{"id":"1182f01a.64e21","type":"comment","z":"e6693df7.a3cfa","name":"Get global SN ","info":"","x":370,"y":220,"wires":[]},{"id":"79d279fa.08fe18","type":"debug","z":"e6693df7.a3cfa","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":280,"wires":[]},{"id":"bcf8e8a3.96f408","type":"function","z":"e6693df7.a3cfa","name":"","func":"\nglobal.set(\"CHARGEPERSYSTEM1\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM1)\nglobal.set(\"CHARGEPERSYSTEM2\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM2)\nglobal.set(\"CHARGEPERSYSTEM3\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM3)\nglobal.set(\"CHARGEPERSYSTEM4\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM4)\nglobal.set(\"CHARGEPERSYSTEM5\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM5)\nglobal.set(\"CHARGEPERSYSTEM6\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM6)\nglobal.set(\"CHARGEPERSYSTEM7\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM7)\nglobal.set(\"CHARGEPERSYSTEM8\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM8)\n\n\nmsg.CHARGEPERSYSTEM1 = global.get(\"CHARGEPERSYSTEM1\");\nmsg.CHARGEPERSYSTEM2 = global.get(\"CHARGEPERSYSTEM2\");\nmsg.CHARGEPERSYSTEM3 = global.get(\"CHARGEPERSYSTEM3\");\nmsg.CHARGEPERSYSTEM4 = global.get(\"CHARGEPERSYSTEM4\");\nmsg.CHARGEPERSYSTEM5 = global.get(\"CHARGEPERSYSTEM5\");\nmsg.CHARGEPERSYSTEM6 = global.get(\"CHARGEPERSYSTEM6\");\nmsg.CHARGEPERSYSTEM7 = global.get(\"CHARGEPERSYSTEM7\");\nmsg.CHARGEPERSYSTEM8 = global.get(\"CHARGEPERSYSTEM8\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":280,"wires":[["79d279fa.08fe18"]]},{"id":"35187516.658fca","type":"debug","z":"e6693df7.a3cfa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":240,"wires":[]},{"id":"dd225fc6.1380a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>' + global.get(\"SN\") + '</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":520,"wires":[[]]},{"id":"2c48206b.b7cbd","type":"function","z":"e6693df7.a3cfa","name":"","func":"delete msg.values\ndelete msg.input\ndelete msg.sendingNodeId\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":580,"wires":[["ab242c2d.571b5"]]},{"id":"ab242c2d.571b5","type":"function","z":"e6693df7.a3cfa","name":"","func":"let SN = global.get(\"SN\");\nmsg.payload = `\<?xml version=\"1.0\" encoding=\"utf-8\"?\> \<soap:Envelope xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)" xmlns:xsd="[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)" xmlns:soap="[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)"\> soap:Body \<GetChargeRecipe xmlns="[http://tempuri.org/](http://tempuri.org/)"\> ${SN} AC \</soap:Body\> \</soap:Envelope\>`\n//msg.topic = \"\";\ndelete msg.topic;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":680,"wires":[["3337f067.a4ca1","6aebd91.ca17728"]]},{"id":"5410cb45.9afa3c","type":"modbus-client","z":"","name":"WAGO","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"localhost","tcpPort":"503","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]`

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 14:11 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/21 "2020-10-13T14:11:08Z")

</div>

Edit you post and paste again using  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d56639561f3c9fa2f21f979311d7d4edcc5a9ef1.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 14:16 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/22 "2020-10-13T14:16:09Z")

</div>

Also what is the global context variable SN showing in the context side bar?

[Next page](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149.md?page=2)
