From 66dcf910bd4744d8ced56cb9586aa937a1a2d4c5 Mon Sep 17 00:00:00 2001 From: vg Date: Tue, 7 Jul 2020 16:24:01 +0200 Subject: first commit --- test_serial.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 test_serial.py (limited to 'test_serial.py') 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) -- cgit v1.2.3