Add USB<->serial loopback example to WaveShare Open103R
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
eeb900d800
commit
4505fa1926
16
examples/stm32/f1/waveshare-open103r/usbserial/echo.py
Executable file
16
examples/stm32/f1/waveshare-open103r/usbserial/echo.py
Executable file
@@ -0,0 +1,16 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
import sys
|
||||
import serial
|
||||
|
||||
def echo(text):
|
||||
s = serial.Serial()
|
||||
s.port = "/dev/ttyACM0"
|
||||
s.open()
|
||||
print s.read(s.write(text))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
echo(" ".join(sys.argv[1:]))
|
||||
else:
|
||||
print "Usage: sudo echo.py hello world"
|
||||
Reference in New Issue
Block a user