nodemecu/raspberry/arduinos.py

32 lines
574 B
Python
Raw Permalink Normal View History

2022-02-23 14:42:32 +00:00
#!/usr/bin/env python
import time
import serial
import sys
ser = serial.Serial(
port='/dev/serial0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
2022-04-05 20:56:40 +00:00
baudrate = 9600,
2022-02-23 14:42:32 +00:00
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=2
2022-02-23 14:42:32 +00:00
)
ser.flush()
cw = int(sys.argv[1], 0)
com = [cw]
ser.write(serial.to_bytes(com))
ser.flush()
while True:
if ser.in_waiting > 0:
line = ser.readline().decode('utf-8', errors='replace').rstrip()
print(line)
ser.flush()
break
time.sleep(1)
2022-02-23 14:42:32 +00:00
quit()