cancel
Showing results for 
Search instead for 
Did you mean: 

PCo ASCII to string for comma separated ASCII

scottp
Explorer
0 Kudos
450

We have several tags providing a string encoded to ASCII, during the notification process we need to decode this to the readable text and store.

PCo's asciitostring function works perfectly for a single ASCII character, but in this case we have multiple characters, comma separated (eg 110,108) which should convert to "nl".

Does anyone know which functions can be used to return the required output?

Accepted Solutions (1)

Accepted Solutions (1)

Kevin_Hunter
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Scott,

Is your data a fixed length ? Could you give more details of the message format, the use case etc ?

If the data is a fixed length you could split the data into an array,and convert each value separately like this :

asciitostring(arrayGetValue(stringsplittoarray("104,101,108,108,111", ","),0)) & asciitostring(arrayGetValue(stringsplittoarray("104,101,108,108,111", ","),1)) & asciitostring(arrayGetValue(stringsplittoarray("104,101,108,108,111", ","),2)) & asciitostring(arrayGetValue(stringsplittoarray("104,101,108,108,111", ","),3)) & asciitostring(arrayGetValue(stringsplittoarray("104,101,108,108,111", ","),4))

If its not a fixed length then you would have to have a loop and i can see a way of doing that in the expression editor, maybe pass the ascii to MII and do it in MII or maybe a multiple call destination could do it.

If you let me know more details I can see what I can come up with.

I think this may be a good enhancement as well so I will talk to the product owner.

Thanks

Kevin

Kevin_Hunter
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Scott,

If you have the latest version of PCo installed you could try the getStringFromByteArrayUtf8 command .

Thanks

Kevin

scottp
Explorer

Hi Kevin,

I updated our PCo install to 15.4 and have used the getStringFromByteArrayUtf8 command as suggested. This is working perfectly where the data we receive is actually in an array.

Part of my original problem was that some of the data we are getting from the PLC is badly formatted and not always in an array, currently there is only some simple test data while everything in being installed.

Many thanks, Scott.

Answers (0)