ME405 Library  Version 0.38
Python library in support of ME405 class
cqueue.py File Reference

This file contains documentation and a test program for the custom C queues used in the ME405 library. More...

Classes

class  cqueue.FloatQueue
 A fast, pre-allocated queue of floats for MicroPython. More...
 
class  cqueue.IntQueue
 A fast, pre-allocated queue of integers for MicroPython. More...
 
class  cqueue.ByteQueue
 A fast, pre-allocated queue of characters for MicroPython. More...
 

Functions

def cqueue.main ()
 Run a test by creating queues, putting numbers into the queues, getting the numbers back out, and checking for consistency. More...
 

Variables

int cqueue.TEST_SIZE = 3000
 The number of times to call put() for each queue.
 
int cqueue.NUM_QUEUE_SIZE = 2000
 The number of elements in each queue which we create and test.
 
int cqueue.BYTE_QUEUE_SIZE = 20
 The number of characters in the test byte queue.
 
int cqueue.BYTE_T_SIZE = 94
 The number of times we try to put something into the byte queue. More...
 
int cqueue.NUM_RUNS = 25
 The number of times we repeat the whole test.
 
dictionary cqueue.overall
 The results of running tests repeatedly. More...
 
 cqueue.end
 
 cqueue.booq = cqueue.ByteQueue(10)
 

Detailed Description

This file contains documentation and a test program for the custom C queues used in the ME405 library.

These queues are faster than regular Python based queues and don't allocate memory.

The code in this file is not the source code which makes the C queues work. That code is written in C as the file cqueues.c and compiled into the MicroPython image used in the ME405 course.

Author
JR Ridgely
Date
2022-Feb-24 JRR Original file

It is intended for educational use only, but its use is not limited thereto. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ main()

def cqueue.main ( )

Run a test by creating queues, putting numbers into the queues, getting the numbers back out, and checking for consistency.

While we're at it, keep track of the time it took to put things into the queues, as this can be important if putting data into a queue within an interrupt callback.

Variable Documentation

◆ BYTE_T_SIZE

int cqueue.BYTE_T_SIZE = 94

The number of times we try to put something into the byte queue.

It's kept somewhat small so we're putting in printable ASCII characters

◆ overall

dictionary cqueue.overall
Initial value:
1 = {"Int Sum" : 0,
2  "Int Max" : 0,
3  "Float Sum" : 0,
4  "Float Max" : 0,
5  "Byte Sum" : 0,
6  "Byte Max" : 0
7  }

The results of running tests repeatedly.