blob: cee3f0cb8d7f850b6a25c33f4b568ffdcec82a0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)
|