Python Forum
help on udp response analysis
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help on udp response analysis
#1
Hi,

i'm new on python and need some help on best practise for the below:

I have a device working with ESP32 with a Gui for Android but i need to control the device from my raspberry pi

in general i'm sending a udp string to the device in order to get back the status and then take action to control

here the script to request the status

# Echo client program
import socket
ON = "mobile\03\04\01\r\n"
STATUS = "mobile\01\r\n"
HOST = '192.168.0.20'    # The remote host
PORT = 4000              # The same port as used by the server
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect((HOST, PORT))
sock.sendall(STATUS)
data = sock.recv(1024)
print('Received', repr(data))
the output looks like that

Output:
('Received', "'master\\x03\\x01\\t\\x00\\x0c\\x00\\x13\\x00\\r\\x00\\x1a\\x00\\x04\\x01\\x05\\x00\\x06\\x01\\x08)\\x0e\\x00\\x00\\x00\\x12\\x00\\x14\\x00%\\x00'")
now i need to analyze the output in order to map the status for example

\x03\\x01\ represents Parameter#03 with value=01

what is the best approach to get this done ?
i tried to load it into array but without success :-(

best would be to get an output as followed

Parameter01=Value01
Parameter02=Value02
Parameter03=Value03
Parameter04=Value04
.
.
.

Thanks in advance
Thomas

The Parameters starts at x03 not at 01 !
Reply


Messages In This Thread
help on udp response analysis - by 4u2fast - Jan-30-2019, 02:39 PM
RE: help on udp response analysis - by 4u2fast - Feb-01-2019, 11:58 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020