Skip to content
Snippets Groups Projects
Commit 9d050079 authored by Pierre Minssen's avatar Pierre Minssen
Browse files

Comentaire de fonction de 3h30 du mat post nano

parent e179d781
Branches master
No related tags found
No related merge requests found
......@@ -19,10 +19,16 @@ class Camera:
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
self.UDP_IP = UDP_IP
def move_to_absolute_position(YCoordinates, ZCoordinates):
def move_to_absolute_position(self, YCoordinates, ZCoordinates):
"""
command of absolute position mouvement
:param YCoordinates: YYYY from to
:param ZCoordinates: ZZZZ from to
:return:
"""
payload = "81 01 06 02" # Absolute position moove
payload = payload + self.VV + self.WW # add move speed
for i in LYZ: # add position
for i in [YCoordinates, ZCoordinates]: # add position
for j in i:
payload = payload + "0" + j
payload = payload + "FF" # end byte
......@@ -31,7 +37,13 @@ class Camera:
message = payloadtype + header + payload
return message
def payload2header(self, payload: str) -> str: # hex
def payload2header(self, payload: str) -> str:
"""
take the payload, calculate the payload lenght and add the sequence number
:param payload:
:return: header = payloadlenght + seq_num
"""
lenght = hex(len(payload.replace(' ', '')))
payloadlenght = lenght[2:]
if len(lenght) == 1:
......@@ -42,6 +54,11 @@ class Camera:
return header
def send(self, message: str) -> bool:
"""
Envoie le message à la cam
:param message: message str['hex']
:return: True si c'est bien passé
"""
self.sock.sendto(bytes.fromhex(message.replace(' ', '')), (self.UDP_IP, self.UDP_PORT))
self.seq_num += 1 # ballec de l'hexa pour l'instant
print("fait " + self.seq_num)
......@@ -74,7 +91,13 @@ class Camera:
message = payloadtype + header + payload
return message
def focus(self, b: bool) -> str: # hex #focus2payload(0) = autofocus
def focus(self, b: bool) -> str:
"""
Command the focus auto or manual
:param b: bool = 1 : autofocus ; bool = 0 : manualfocus
:return: commande
"""
# hex #focus2payload(0) = autofocus
if b:
payload = "81 01 04 38 02 FF" # autofocus
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment