Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VISCA Over IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amalio Coron
VISCA Over IP
Commits
f66b4345
Commit
f66b4345
authored
6 years ago
by
Amalio Coron
Browse files
Options
Downloads
Patches
Plain Diff
recupération du code du PC distant
parent
6aec4640
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cam commandes.py
+98
-71
98 additions, 71 deletions
cam commandes.py
with
98 additions
and
71 deletions
cam commandes.py
+
98
−
71
View file @
f66b4345
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
=
52
0
sequence_number
=
136
0
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
(
"
salle
1
"
+
message
)
print
(
"
salle
2
"
+
message
)
sequence_number
=
sequence_number
+
1
sequence_number
=
sequence_number
+
1
if
(
command
==
"
pos
2
"
):
if
(
command
==
"
pos
1
"
):
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
(
"
salle
2
"
+
message
)
print
(
"
salle
1
"
+
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment