Hi All,
I have managed to get my program working now using UDP to send a message to a sensor and get a reply.The last major issue i am having is the data i recieve back.
data, addr = sock.recvfrom(782) # buffer size is 782 bytes
This is my line receiving the info. "data" is the Data and "addr" is the ip address where the data came from.
if i do this :-
print ("received message:- ", data,addr)
I get this:-
('received message:- ', '\xff\xff\xff\xff\x00\x00ZZ\x00\x00\x00\x00\x00\x00\x00\x00\x11\x01\x00\x00\x00\x00\x00\x00\x93n\x10\x00x\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00, ('192.168.60.3', 9008))
I can print the data perfect and thats fine except if i want to pass that "data" into another variable and then print the other variable it prints out complete nonsense.I have tried to encode the data and decode it with no luck always the same rubbish coming out for example:-
ÿÿÿÿ
These are examples I have tried some give the above values out others dont work at all
mystring = str(data)
print(str(data,'Latin_1',errors='strict'))
print ("My new string is "),mystring
ascii_text = str(data).encode('string_escape')
print ("My Ascii String",ascii_text)
(Not all at the same time of course)
I am presuming the buffer is sending bytes but i cannot seem to convert to a string that i can manipulate later
Any suggestions would be gratefully received.
Thanks again