Hi Guys,
I have managed to connect to a laser sensor and get data back from the unit into python however i think i need to decode this data. Below is what i have sent and get back.

Console Result:-

UDP target IP: 192.168.60.3
UDP target port: 9008
message: FF FF FF FF 00 00 32 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Received Message:-

b'\x00\x00\x00\x00\x00\x00NA\x00\x00\x00\x00\x00\x00FF\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' ('192.168.60.3', 9008)

How can i decode this I tried adding the code below mut just got garbage out

print(data.decode("utf_8"))
My result should be the same as the message sent but with a couple of value changes which tells me the action was carried out.
Thanks for the help

Regards
Deepthought

The response seems not alphanumeric, you must find out how the response should be interpreted and use struct module, for example.

Edited 4 Years Ago by pyTony

FF FF FF FF 00 00 32 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Hi
thanks for the answer but the type comes in, as an ascii string according to the manufacturer and should appear as above where 32 31 are it should replace with 41 41 or 4E 41 i have used a udptesttool from the internet and if i place the string in that i get a correct responce so somewhere either python is sending rubbish and the sensor responds with rubbish or python is not translating the responce correctly i have tried the program in both python 2.7 and 3.2 just incase of any differences still no joy.

Regards

DeepThought

Hi All,
After trying various ideas i realised that when i looked at the message recieved it has a backslash "\" and "x" in the recieve so I transmitted the message with the same instead of spaces ie

"FF FF FF FF" became "\xFF\xFF\xFF\xFF" and so on for all the bytes.

This returned a correctly formatted message back with the values i was expecting and the sensor reacted to the commands sent.

Hope this may help others in the future.
Regards
Deepthought

Comments
Thanks for sharing
This question has already been answered. Start a new discussion instead.