-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsyringePump.py
62 lines (50 loc) · 1.04 KB
/
syringePump.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import serial
import time
def cSum(l):
cS = o
for i in range(len(l)):
cS ^= l[i]
print 'csum( ', str(l), ' ) is ', cS
print formate(cS, '02x')
return cS
s = serial.Serial('COM4')
print 's', s
# s.close()
# s.open()
# print 's opened', s
# isopen = s.isOpen()
# print 'isopen', isopen
### working
# s.write('ratew?' + '\r\n')
# s.write('volw?' + '\r\n')
# s.write('mode W' + '\r\n')
# s.write('mode?' + '\r\n')
mode = 'i'
# mode = 'W'
iVolume = 2
iRate = 1500
wVolume = 1
wRate = 150
### Withdrawal
if mode == 'W':
s.write('mode W' + '\r\n')
time.sleep(0.2)
s.write('volw ' + str(wVolume) + ' ml' + '\r\n')
time.sleep(0.2)
s.write('ratew '+ str(wRate) + ' ml/h' + '\r\n')
time.sleep(0.2)
elif mode == 'i':
### Infusion
s.write('mode i' + '\r\n')
time.sleep(0.2)
s.write('voli ' + str(iVolume) + ' ml' + '\r\n')
time.sleep(0.2)
s.write('ratei ' + str(iRate) + ' ml/h' + '\r\n')
time.sleep(0.2)
s.write('run' + '\r\n')
# s.write('stop' + '\r\n')
time.sleep(0.1)
# read = s.read(6)
read = s.read(3)
print 'read', len(read), read
s.close()