Skip to content

Instantly share code, notes, and snippets.

@swarren
Created September 14, 2015 03:38
Show Gist options
  • Save swarren/00cee7d161a490c7da11 to your computer and use it in GitHub Desktop.
Save swarren/00cee7d161a490c7da11 to your computer and use it in GitHub Desktop.
Slowly send a series of commands to a UART. Useful if e.g. the SW behind the UART can't keep up with the baud rate.
#!/usr/bin/env python
import serial
import sys
s = """
command 1
command 2
etc.
"""
sp = serial.Serial('/dev/ttyUSB3', baudrate=115200, timeout=0.01)
for c in s:
sp.write(c)
while True:
rb = sp.read(256)
if not rb:
break
sys.stdout.write(rb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment