on 2020 Jul 06 10:44 AM
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?
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.