-
Notifications
You must be signed in to change notification settings - Fork 1
/
ls336.py
executable file
·31 lines (26 loc) · 1.08 KB
/
ls336.py
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
#!/usr/bin/env python
# make sure bridge.py is on the python path
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
from bridge import Connect
# If the control computer is disconnected, then when it is
# reconnected it will be expecting to send a command to
# the bridge, not read a response. So set it up with retry="read"
# so that on readline error it reopens the channel but ignore write
# immediately. Similarly, if the Lakeshore is disconnected, it
# will be expecting to receive a new command not send a response,
# so retry the write command.
RS232 = Connect("/dev/ttyOutputRS232", retry="read",
baudrate=9600, parity='O', bytesize=7, stopbits=1)
lakeshore = Connect("/dev/ttyLakeshore336", retry="write",
baudrate=57600, parity='O', bytesize=7, stopbits=1)
while True:
print "Waiting for next command..."
command = RS232.readline()
print "Command",command.strip()
lakeshore.write(command)
if '?' in command:
print "Waiting for reply..."
reply = lakeshore.readline()
print "Reply",reply.strip()
RS232.write(reply)