Skip to content

Commit

Permalink
Merge pull request usb-tools#9 from BenGardiner/rate-limit-inject
Browse files Browse the repository at this point in the history
Rate limit inject
  • Loading branch information
pojungc committed Nov 24, 2015
2 parents 96a6571 + fd8538f commit 8d72ec0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bindings/python/USBKeyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, verbose=0, text=None):
contents.close()

#arduino led tubes
#TODO: run stty to set 115200,sane
os.system("stty -F %s 115200 cs8 -icrnl ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts" % '/dev/ttyACM0')
self.led_tubes_pipe = open('/dev/ttyACM0', 'wb')
self.NUM_TUBE_LEDS = 13.0 #set these as floats to keep increased granularity from evdev timestamps
self.MAX_TUBE_SECONDS = 5.0
Expand Down
23 changes: 23 additions & 0 deletions src/tools/loopbacktest
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
SCRIPT_DIR="$(readlink -m $(dirname $0))"

touch /tmp/loopbacktestref
${SCRIPT_DIR}/write-loopbacktest /tmp/loopbacktestref 2>/dev/null
echo IRDETO Echo Test:|cat - /tmp/loopbacktestref >/tmp/tmp
mv /tmp/tmp /tmp/loopbacktestref

stdbuf -o0 cat /dev/ttyACM0 > /tmp/loopbacktest &
sleep 2

${SCRIPT_DIR}/write-loopbacktest /dev/ttyACM0

sleep 2

if ! cmp -b /tmp/loopbacktestref /tmp/loopbacktest; then
echo FAIL
else
echo PASS
fi

kill %%

11 changes: 11 additions & 0 deletions src/tools/write-loopbacktest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

import os
import sys

os.system("stty -F %s 115200 cs8 -icrnl ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts" % sys.argv[1])
fd = open(sys.argv[1], 'w')
for x in range(0,256):
val = int(x)
fd.write(chr(val))
fd.flush()

0 comments on commit 8d72ec0

Please sign in to comment.