-
Notifications
You must be signed in to change notification settings - Fork 0
/
test (1).py
83 lines (57 loc) · 1.39 KB
/
test (1).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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import serial
import time
import datetime
import logging
FILENAME = '/home/pi/Desktop/' + str(datetime.datetime.now()) + '.log'
logging.basicConfig(filename=FILENAME,
level=logging.DEBUG,
format='%(message)s',
datefmt='%m-%d %H:%M:%S',
filemode='a')
#%(asctime)s
with serial.Serial('/dev/ttyACM0', timeout=1) as ser:
ser.baudrate = 115200
with serial.Serial('/dev/ttyACM1', timeout=1) as ser1:
ser1.baudrate = 115200
ser.open()
time.sleep(2)
ser.write(b'$X\n')
time.sleep(2)
ser.write(b'M7\n')
time.sleep(2)
ser1.open()
time.sleep(1)
ser.write(b'$HZ\n')
time.sleep(10)
ser1.write(b'a\n')
time.sleep(2)
#ser1.write(b'b\n')
time.sleep(0.01)
#for i in range(10):
ser.write(b'Z-1\n')
ser.write(b'Z0\n')
#ser.write(b'Y20\n')
ser1.write(b'b\n')
time.sleep(5)
ser1.write(b'c\n')
for i in range(0,30000):
#print(ser1.readline())
logging.info(ser1.readline())
#arr = ser1.readline()
#print(ser1.readline())
time.sleep(1/1000)
#reverse motion data collection
#time.sleep(10)
#ser.write(b'Z-0\n')
#ser1.write(b'b\n')
#time.sleep(10)
#ser1.write(b'c\n')
#for i in range(0,10000):
#print(ser1.readline())
# logging.info(ser1.readline())
# arr = ser1.readline()
# print(ser1.readline())
# time.sleep(1/1000)
ser.write(b'M9\n')
ser.close()
ser1.close()