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
Branches
No related tags found
No related merge requests found
import socket import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sequence_number=520 sequence_number=1360
UDP_IP = "192.168.0.100" UDP_IP = "192.168.0.100"
UDP_PORT = 52381 UDP_PORT = 52381
...@@ -8,14 +8,16 @@ VV = "10 " # Pan speed setting between 01 and 18 in normal speed, up to 0x7E in ...@@ -8,14 +8,16 @@ VV = "10 " # Pan speed setting between 01 and 18 in normal speed, up to 0x7E in
WW = "10 " # Tilt speed WW = "10 " # Tilt speed
POS_1=["0A00","FB00"] POS_1=["0A00","FB00"]
POS_2=["F700","FB00"] POS_2=["F700","FB00"]
#sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
payload = "" payload = ""
header="" header=""
message="" message=""
commande = ""
while True: while commande != "reset":
command = input('Indique ta commande : pos1, pos2, reset \n') command = input('Indique ta commande : pos1, pos2, movetuyau, manualfocus, \n focustuyau, autofocus, zoom0, zoom2 \n')
if(command == "pos1"): if command in ["pos1", "pos2", "reset"]:
if(command == "pos2"):
payload = "81 01 06 02 " #Movetoabsoluteposition in POS payload = "81 01 06 02 " #Movetoabsoluteposition in POS
payload = payload + VV + WW #add move speed payload = payload + VV + WW #add move speed
for i in POS_1: #add position for i in POS_1: #add position
...@@ -29,9 +31,9 @@ while True: ...@@ -29,9 +31,9 @@ while True:
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT)) sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("salle1" + message) print("salle2" + message)
sequence_number = sequence_number+1 sequence_number = sequence_number+1
if(command=="pos2"): if(command=="pos1"):
payload = "81 01 06 02 " #Movetoabsoluteposition in POS payload = "81 01 06 02 " #Movetoabsoluteposition in POS
payload = payload + VV + WW #add move speed payload = payload + VV + WW #add move speed
for i in POS_2: #add position for i in POS_2: #add position
...@@ -45,47 +47,72 @@ while True: ...@@ -45,47 +47,72 @@ while True:
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number))
message = header + payload message = header + payload
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT)) sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("salle2 " + message) print("salle1 " + message)
sequence_number=sequence_number+1 sequence_number=sequence_number+1
if(command=="reset"): # if(command=="reset"):
payload = "01 " #Movetoabsoluteposition in POS # payload = "01 " #Movetoabsoluteposition in POS
payload = payload + "FF " #end byte # 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 = "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 + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
header=header + '01 ' # header=header + '01 '
header = header + "00 00 00 00" # header = header + "00 00 00 00"
message = header + payload # message = header + payload
#
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT)) # sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
print("reset " + message) # print("reset " + message)
sequence_number=1 # sequence_number = sequence_number+1
""""if(command=='moveleft'): else:
payload = "81 01 06 01 03 03 01 03 FF" if(command=='moveleft_c'):
payload = "81 01 06 01 18 17 01 03 FF"
header = "10 00 00 09" header = "10 00 00 09"
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) if(command =='moveright_c'):
message = header + payload payload = "81 01 06 01 18 17 02 03 FF"
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"
header = "10 00 00 09" header = "10 00 00 09"
header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) if(command == 'stop'):
message = header + payload payload = "81 01 06 01 00 00 03 03 FF"
sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT)) header = "10 00 00 09"
print("Moveleft : " + message)""" 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
""" if(command=="zoom0"): 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" payload="81 01 04 47 00 00 00 00 FF"
header = "01 00 00 09"
if(command=="zoom2"): if(command=="zoom2"):
payload="81 01 04 47 01 06 0A 01 FF" payload="81 01 04 47 01 06 0A 01 FF"
header = "01 00 00 09"
if(command=="focustuyau"): #6m if(command=="focustuyau"): #6m
payload="81 01 04 48 04 00 00 00 FF" payload="81 01 04 48 04 00 00 00 FF"
header = "01 00 00 09"
if(command=="manualfocus"): if(command=="manualfocus"):
payload="81 01 04 38 03 FF" payload="81 01 04 38 03 FF"
header = "01 00 00 06"
if(command=="autofocus"): if(command=="autofocus"):
payload="81 01 04 38 02 FF" payload="81 01 04 38 02 FF"
header = "01 00 00 06"
if(command=="movetuyau"): 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