Commit b14f299 1 parent cc3f06c commit b14f299 Copy full SHA for b14f299
File tree 1 file changed +52
-0
lines changed
1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ import serial
2
+ import time
3
+
4
+ port = serial .Serial ("/dev/ttyUSB0" , baudrate = 9600 , timeout = 3.0 )
5
+
6
+
7
+
8
+ out = ""
9
+
10
+ preamble = "@253" #attention character + address
11
+ command = ""
12
+ terminator = ";FF"
13
+
14
+
15
+ outputfile = open ("mksdata.txt" , "a" )
16
+
17
+ print "hello mks program"
18
+ outputfile .write ("\n start\n " )
19
+
20
+
21
+ delay = 1
22
+ stop = time .time ()+ delay
23
+
24
+ #for i in range(0, 100):
25
+ while time .time () < stop :
26
+
27
+
28
+
29
+ command = "PR1?"
30
+
31
+ assemble = preamble + command + terminator
32
+ port .write (assemble )
33
+
34
+ print "sent: " + assemble
35
+
36
+ time .sleep (.1 )
37
+
38
+ while port .inWaiting () > 0 :
39
+ out += port .read (1 )
40
+
41
+ out = out .replace ("@253ACK" ,"" )
42
+ out = out .replace (";FF" ,"" )
43
+
44
+
45
+ print "rcvd: " + out
46
+ outputfile .write (out + "\n " )
47
+
48
+ out = ""
49
+
50
+
51
+ port .close ()
52
+ outputfile .close ()
You can’t perform that action at this time.
0 commit comments