File size: 923 Bytes
f113e60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import cv2
# from AI_brain import AI
# from AI_brain_TRT import AI_TRT
import time
import serial

# cap = cv2.VideoCapture(1)

serial_port = serial.Serial(
    port="COM8",
    baudrate=9600,
    bytesize=serial.EIGHTBITS,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
)

if not serial_port.is_open:
    serial_port.open()


# Wait a second to let the port initialize
time.sleep(1)
while True:
    PUSH_RETURN = "Y:010"
    print(PUSH_RETURN)    
    bytes_written = serial_port.write(PUSH_RETURN.encode())
    print(f"Bytes sent: {bytes_written}")
    time.sleep(1)
    bytes_written = serial_port.write("x:000".encode())
    time.sleep(1)
    PUSH_RETURN = "X:000"
    print(PUSH_RETURN)    
    bytes_written = serial_port.write(PUSH_RETURN.encode())
    print(f"Bytes sent: {bytes_written}")
    time.sleep(0.5)
    bytes_written = serial_port.write("x:000".encode())
    time.sleep(2)
    
    break