Skip to content
Snippets Groups Projects
Commit f66b4345 authored by Amalio Coron's avatar Amalio Coron
Browse files

recupération du code du PC distant

parent 6aec4640
No related branches found
No related tags found
No related merge requests found
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sequence_number=520
sequence_number=1360
UDP_IP = "192.168.0.100"
UDP_PORT = 52381
......@@ -8,14 +8,16 @@ VV = "10 " # Pan speed setting between 01 and 18 in normal speed, up to 0x7E in
WW = "10 " # Tilt speed
POS_1=["0A00","FB00"]
POS_2=["F700","FB00"]
#sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
payload = ""
header=""
message=""
commande = ""
while True:
command = input('Indique ta commande : pos1, pos2, reset \n')
if(command == "pos1"):
while commande != "reset":
command = input('Indique ta commande : pos1, pos2, movetuyau, manualfocus, \n focustuyau, autofocus, zoom0, zoom2 \n')
if command in ["pos1", "pos2", "reset"]:
if(command == "pos2"):
payload = "81 01 06 02 " #Movetoabsoluteposition in POS
payload = payload + VV + WW #add move speed
for i in POS_1: #add position
......@@ -29,9 +31,9 @@ while True:
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("salle1" + message)
print("salle2" + message)
sequence_number = sequence_number+1
if(command=="pos2"):
if(command=="pos1"):
payload = "81 01 06 02 " #Movetoabsoluteposition in POS
payload = payload + VV + WW #add move speed
for i in POS_2: #add position
......@@ -45,47 +47,72 @@ while True:
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("salle2 " + message)
print("salle1 " + message)
sequence_number=sequence_number+1
if(command=="reset"):
payload = "01 " #Movetoabsoluteposition in POS
payload = payload + "FF " #end byte
header = "02 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
#header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
header=header + '01 '
header = header + "00 00 00 00"
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("reset " + message)
sequence_number=1
""""if(command=='moveleft'):
payload = "81 01 06 01 03 03 01 03 FF"
# if(command=="reset"):
# payload = "01 " #Movetoabsoluteposition in POS
# payload = payload + "FF " #end byte
#
# header = "02 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
#
# #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
# header=header + '01 '
# header = header + "00 00 00 00"
# message = header + payload
#
# sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
# print("reset " + message)
# sequence_number = sequence_number+1
else:
if(command=='moveleft_c'):
payload = "81 01 06 01 18 17 01 03 FF"
header = "10 00 00 09"
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("Moveleft : " + message)
if(command =='moveright'):
payload = "81 01 06 01 03 03 02 03 FF"
if(command =='moveright_c'):
payload = "81 01 06 01 18 17 02 03 FF"
header = "10 00 00 09"
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("Moveleft : " + message)"""
""" if(command=="zoom0"):
if(command == 'stop'):
payload = "81 01 06 01 00 00 03 03 FF"
header = "10 00 00 09"
if(command=='d'):
# payload = "81 01 06 03 VV WW 0Y 0Y 0Y 0Y 00 00 00 00 FF YYYY de DE00 à 2200 center 0000
payload = "81 01 06 03 09 09 00 01 02 02 00 00 00 00 FF"
header = "01 00 00 0F"
if(command =='q'):
payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 00 00 FF"
header = "01 00 00 0F"
if(command =='z'):
payload = "81 01 06 03 09 09 0F 0E 0D 0E 0 00 00 00 FF"
header = "01 00 0q
q
dezo 0 0F"
if(command =='s'):
payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 00 00 FF"
header = "01 00 00 0F"
if(command=="zoom0"):
payload="81 01 04 47 00 00 00 00 FF"
header = "01 00 00 09"
if(command=="zoom2"):
payload="81 01 04 47 01 06 0A 01 FF"
header = "01 00 00 09"
if(command=="focustuyau"): #6m
payload="81 01 04 48 04 00 00 00 FF"
header = "01 00 00 09"
if(command=="manualfocus"):
payload="81 01 04 38 03 FF"
header = "01 00 00 06"
if(command=="autofocus"):
payload="81 01 04 38 02 FF"
header = "01 00 00 06"
if(command=="movetuyau"):
payload="81 01 06 02 10 10 01 02 00 00 0F 0E 0C 00 ff"""
payload="81 01 06 02 10 10 01 02 00 00 0F 0E 0C 00 FF"
header = "01 00 00 0F"
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("fait "+ command)
sequence_number = sequence_number + 1
print(sequence_number)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment