libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
rb_file.py File Reference

Example: fetch ADC samples in a ring buffer and save to file. More...

Go to the source code of this file.

Variables

 rb_file.libc = CDLL("libc.so.6")
 For file operations.
 
int rb_file.tSamp = 123401
 The number of samples in the files (per step).
 
int rb_file.tmr = 20000
 The sampling rate in ns (20000 -> 50 kHz).
 
int rb_file.NoStep = 3
 The number of active steps (must match setStep calls and mask).
 
int rb_file.NoFile = 2
 The number of files to write.
 
string rb_file.NamFil = "output.%u"
 The output file names format.
 
 rb_file.io = pruio_new(PRUIO_DEF_ACTIVE, 0, 0, 0)
 Create a ctypes pointer to the pruio structure.
 
 rb_file.IO = io.contents
 The pointer dereferencing, using contents member.
 
int rb_file.mask = 0b111 << 9
 The active steps (9 to 11)
 
int rb_file.tInd = tSamp * NoStep
 The maximum total index.
 
tuple rb_file.half = ((IO.ESize >> 2) // NoStep) * NoStep
 Index half ring buffer.
 
tuple rb_file.samp = (half << 1) // NoStep
 The number of samples (per step)
 
 rb_file.p0 = IO.Adc.contents.Value
 A pointer to the start of the ring buffer.
 
 rb_file.p1 = cast(byref(p0.contents, (half << 1)), POINTER(c_ushort))
 Pointer to middle of the ring buffer.
 
string rb_file.fName = NamFil % n
 The file name.
 
 rb_file.oFile = libc.fopen(fName, "wb")
 The output file descriptor.
 
int rb_file.i = 0
 Start index.
 
int rb_file.rest = tInd + half - i
 The bites left in ring buffer.
 
int rb_file.iEnd = p0 else rest + half
 Last index in buffer.
 

Detailed Description

Example: fetch ADC samples in a ring buffer and save to file.

This file contains an example on how to use the ring buffer mode of libpruio. A fixed step mask of AIN-0, AIN-1 and AIN-2 get configured for maximum speed, sampled in to the ring buffer and from there saved as raw data to some files. Find a functional description in section rb_file.

Licence: GPLv3, Copyright 2017-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net

Run by: python rb_file.py

Since
0.6.0

Definition in file rb_file.py.