Method flush added.

In FTDI driver, flush method is added to be better compatible with Serial from pyserial.
pull/6/head
Quan Lin 2018-11-29 13:45:33 +11:00
rodzic 0d4e0c7199
commit 3e287bbc6e
1 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ Classes:
FtdiSerial(serial.serialutil.SerialBase)
'''
import time
from serial.serialutil import SerialBase, SerialException
from usb4a import usb
@ -163,7 +164,7 @@ class FtdiSerial(SerialBase):
def read(self, data_length=1):
'''Read data from the serial port.
This function should be used in another thread, as it blocks.
This method should be used in another thread, as it blocks.
Parameters:
data_length (int): the length of read buffer(better <= 1024).
@ -230,6 +231,14 @@ class FtdiSerial(SerialBase):
wrote += i
return wrote
def flush(self, flush_time=0.2):
'''Simply wait some time to allow all data to be written.
Parameters:
flush_time (float): time in seconds to wait.
'''
time.sleep(flush_time)
def purgeHwBuffers(self, purgeReadBuffers, purgeWriteBuffers):
'''Set serial port parameters.