-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathppc.py
More file actions
54 lines (50 loc) · 1.57 KB
/
ppc.py
File metadata and controls
54 lines (50 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import socket
import time
from os import system
import sys
""" #DEFINITION: PJLink tryout
HOST = '192.168.1.8' # The remote host
PORT = 4352 # The same port as used by the server
BUFSIZE = 1024
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.settimeout(2)
s.connect((HOST, PORT))
time.sleep(0.1)
acknowledge = s.recv(BUFSIZE)
if(acknowledge != b'PJLINK 0\r'):
print("Connection failed! Check the IP and check that your projector has no password.")
system('pause')
sys.exit(1)
else:
print("Connection established.")
s.send(b'%1POWR ?\r')
time.sleep(0.1)
data = s.recv(BUFSIZE)
print('Received', repr(data))
s.close()
"""
# DEFINITION: RS-232C via RJ45 (e.g. MOXA NPort 5110, UDP)
HOST = '192.168.1.254' # The remote host
PORT = 4352 # The same port as used by the server
BUFSIZE = 1024
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.settimeout(2.5)
# s.bind((HOST, PORT))
# s.connect((HOST, PORT))
# time.sleep(0.1)
# acknowledge = s.recv(BUFSIZE)
"""
" if(acknowledge != b'PJLINK 0\r'):
print("Connection failed! Check the IP and check that your projector has no password.")
system('pause')
sys.exit(1)
else:
print("Connection established.")
"""
blubber = '\x02ADZZ;QPW\x03'
bla = blubber.encode('ascii')
s.sendto(bla, (HOST, PORT))
# time.sleep(0.1)
data = s.recvfrom(BUFSIZE)
print('Received', repr(data))
s.close()