diff options
author | vg <vgm+dev@devys.org> | 2020-07-07 16:24:01 +0200 |
---|---|---|
committer | vg <vgm+dev@devys.org> | 2020-07-07 16:24:01 +0200 |
commit | 66dcf910bd4744d8ced56cb9586aa937a1a2d4c5 (patch) | |
tree | df4dca1ae4af1e5df0be0d1f4f2cd0d54751f8e8 /test_serial.py | |
download | hic-master.tar.gz hic-master.tar.bz2 hic-master.zip |
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) |