Skip to content

Instantly share code, notes, and snippets.

@tdierks
Created November 28, 2017 18:23
Show Gist options
  • Save tdierks/0128d9ecc376c9adc6c84be1b1a3d191 to your computer and use it in GitHub Desktop.
Save tdierks/0128d9ecc376c9adc6c84be1b1a3d191 to your computer and use it in GitHub Desktop.
A python script to emulate the bandwidth of a modem at certain speed.
#!/usr/bin/python -u
# Use: modem-speed.py [baud, default 1200]
import sys
from time import sleep
baud = len(sys.argv) > 1 and int(sys.argv[1]) or 1200
cps = baud/10.0 # 10 baud per octet at 8n1
while True:
c = sys.stdin.read(1)
if c == "":
break
sys.stdout.write(c)
sleep(1.0/cps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment