bionet.utils.misc.SerialBuffer¶
- class bionet.utils.misc.SerialBuffer(get, n=1)¶
Serial buffer class.
This class implements a buffer that automatically replenishes its contents from a specified serial data source when it contains too little data to honor a read request.
Parameters: get : function
Data retrieval function. Must return an empty sequence or None when it can no longer retrieve any data.
n : int
Number of initial entries to load into buffer.
Methods
clear() Empty buffer. read(n=1) Read n elements from buffer. replenish(n=1) Replenish buffer to contain at least n elements. - __init__(get, n=1)¶
Methods
__init__(get[, n]) clear() Remove all elements from the buffer. read([n]) Read a block of data (default length = 1). replenish([n]) Attempt to replenish the buffer such that it contains at least n entries (but do not throw any exception if insufficient data can be obtained).