diff options
Diffstat (limited to 'test_serial.py')
-rwxr-xr-x | test_serial.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test_serial.py b/test_serial.py new file mode 100755 index 0000000..cee3f0c --- /dev/null +++ b/test_serial.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import os +import sys +import serial +import base64 +from time import sleep + +ser = serial.Serial('/dev/ttyUSB1', 38400, timeout=0.5, rtscts=0) + +count = 10000 +i = 0 +error_count = 0 +error_size = 0 +size = 0 +while i < 10000 : + i += 1 + #sleep( 5 ) + string = base64.urlsafe_b64encode(os.urandom(10)) + #string = 'abcdefgh' + ser.write(string) + length = len(string) + size += length + print i, "[ ", length, " B ]: ", string + #if ser.read(8) != 'abcdefgh': + if ser.read(length) != string: + error_count += 1 + error_size += length + +print 'error count: %i/%i, error size: %i/%i' % (error_count, count, + error_size, size) + + +sys.exit(0) |