I'm trying to pass a string from LabVIEW into a Python Node. The string is a whole bunch of bytes (U8) which need to be properly decoded (they are Google Protobuf data received over UDP). However, when I pass a string of length 152, I only receive a string of length ~18 back. I think something goes wrong in the spot where there are 5 consecutive 0s in the file. There are also several other escape characters that probably need to be ignored.
Here is my Python (3.6.8) code:
def Parse(s):
return str(len(s))
If I pass a string of 152 length in, I expect 152 to return from this function.
Here is an example string I want to pass between the two (they are in ASCII form when being sent):
0A 95 01 0A 01 47 12 02 31 43 18 1E 20 1E 29 00 00 00 00 00 38 8B 40 31 00 00 00 00 00 EC A3 40 38 AC F2 FB 0B 50 80 89 7A 59 00 00 00 A0 0C FA 85 40 61 00 00 00 E0 32 0F F3 BF 69 00 00 00 60 49 36 46 40 71 7A 9F B9 01 F1 0F A2 40 79 31 67 14 06 29 B5 81 C1 81 01 00 00 E9 EA 15 B6 DB 3F 88 01 C2 F7 D4 E6 11 90 01 01 98 01 01 A0 01 01 A8 01 C8 A7 B6 9B 01 B1 01 08 BF E1 E1 D9 8E 74 41 B9 01 29 5C 8F C2 F1 E4 13 41 C0 01 01 C9 01 7E 44 18 D0 93 6D B3 41
Could this be an issue going from LV to Python? Or is it entirely a Python issue?
Thanks,
JT
UTF8 has issues decoding a Null (0x00) character.
LabVIEW does not have any real concerns with this because it maintains a length parameter that allows it to know how long its strings are. Given that python strings are in fact lists (without a defined length) I believe this is likely an issue with python decoding the null character as the end of the string.
If you attempt to pass the string into python as a byte array and then convert to a string within python it should be able to handle this without concern.