Feb-01-2019, 11:58 AM
no answer :-(
ok, i have done some modification and for the begining i want to analyze only 3 fields from the output string
main issue now is to manipulate the ouput in order to use them afterwards
like '\x01' should be translated to 1 (need to strip the unrelevant chars)
any idea ? tried a lot but without success :-(
thanks
Thomas
ok, i have done some modification and for the begining i want to analyze only 3 fields from the output string
main issue now is to manipulate the ouput in order to use them afterwards
like '\x01' should be translated to 1 (need to strip the unrelevant chars)
any idea ? tried a lot but without success :-(
thanks
Thomas
# Echo client program import socket import re #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(2048) ONOFF = data[7] # 0=OFF,1=ON SPEED = data[19] # 0=LOW,1=MED,2=HIGH MODE = data[23] # 0=VENTILATE,1=RECOVERY,2=INTAKE print(r'Received', repr(data)) print('POWER', (ONOFF)) print('SPEED', (SPEED)) print('MODE', (MODE))
Output:python Status_test.py
('Received', '"master\\x03\\x01\\t\\x00\\x0c\\x00\\x13\\x00\\r\\x00\\x1a\\x00\\x04\\x01\\x05\\x00\\x06\\x02\\x08\'\\x0e\\x00\\x00\\x00\\x12\\x00\\x14\\x00%\\x00"')
('POWER', '\x01')
('SPEED', '\x01')
('MODE', '\x02')