lancero

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: NIST-PD-fallback Imports: 14 Imported by: 0

Documentation

Overview

Package lancero provides an interface to all Lancero scatter-gather DMA character devices, read/write from/to registers of SOPC slaves, wait for SOPC component interrupt events and handle the cyclic mode of SGDMA. Exports object Lancero for general use. Internally, that object works with the lower-level adapter, collector, and lanceroDevice.

Package lancero provides an interface to all Lancero SGDMA character devices, read/write from/to registers of SOPC slaves, wait for SOPC component interrupt events and handle the cyclic mode of SGDMA.

Index

Constants

View Source
const (

	// HardMaxBufSize Longest allowed adapter buffer
	HardMaxBufSize uint32 = 40 * (1 << 20)
)

Variables

This section is empty.

Functions

func EnumerateLanceroDevices

func EnumerateLanceroDevices() (devices []int, err error)

EnumerateLanceroDevices returns a list of lancero device numbers that exist in the devfs. If /dev/lancero_user0 exists, and _control0, _events0, and _sgdma0 all exist and are device files, then 0 is added to the list.

func FindFrameBits

func FindFrameBits(b []byte, offset int) (int, int, int, error)

FindFrameBits (buffer, offset) studies the buffer and returns (q,p,n,err). buffer is the raw data; offset is the byte where frame bits are expected in in the least significant bit. So if the offset is b, frame bits will be expected in buffer[b]&1, buffer[b+4]&1, buffer[b+8]&1, etc.

q index of word with first frame bit following non-frame index p index of word with next frame bit following non-frame index word means 4 bytes: errLerrMfbkLfbkM (L=least signifiant byte, M=most significant byte) n number of consecutive words with frame bit set, starting at q err is nil if q,p,n all found as expected

func OdDashTX

func OdDashTX(b []byte, maxLines int) string

OdDashTX creates output like od -tx4, used for debugging Lancero

func SetLogOutput

func SetLogOutput(w io.Writer)

SetLogOutput calls log.SetOutput from within Lancero

Types

type Lancero

type Lancero struct {
	// contains filtered or unexported fields
}

Lancero is the high-level object used to manipulate all user-space functions of the Lancero device driver.

func NewLancero

func NewLancero(devnum int) (*Lancero, error)

NewLancero generates and returns a new Lancero object and configures it properly. The devnum value is used to select among /dev/lancero_user0, lancero_user1, etc., if there are more than 1 card in the computer. Usually, you'll use 0 here.

func (*Lancero) AvailableBuffer

func (lan *Lancero) AvailableBuffer() ([]byte, time.Time, error)

AvailableBuffer returns a COPY OF the ring buffer segment now ready for reading, plus the best estimate of the time stamp taken immediately after the end of the segment, and any error. Because this returns a COPY, it is encouraged to call ReleaseBytes as soon as the caller is sure how many bytes are to be released, even if the caller is not done using the copy of the data.

func (*Lancero) ChangeRingBuffer

func (lan *Lancero) ChangeRingBuffer(length, threshold int) error

ChangeRingBuffer re-sizes the adapter's ring buffer.

func (*Lancero) Close

func (lan *Lancero) Close() error

Close releases all resources used by this lancero device.

func (*Lancero) CollectorConfigure

func (lan *Lancero) CollectorConfigure(linePeriod, dataDelay int, channelMask uint32,
	frameLength int) error

CollectorConfigure configures the data serialization component.

func (*Lancero) InspectAdapter

func (lan *Lancero) InspectAdapter() uint32

InspectAdapter prints adapter status info and returns the status word.

func (*Lancero) ReleaseBytes

func (lan *Lancero) ReleaseBytes(nBytes int) error

ReleaseBytes instructed the ring buffer adapter to release nBytes bytes for over-writing.

func (*Lancero) StartAdapter

func (lan *Lancero) StartAdapter(waitSeconds, verbosity int) error

StartAdapter starts the ring buffer adapter, waiting up to waitSeconds sec for it to work.

func (*Lancero) StartCollector

func (lan *Lancero) StartCollector(simulate bool) error

StartCollector starts the data serializer.

func (*Lancero) StopAdapter

func (lan *Lancero) StopAdapter() error

StopAdapter stops the ring buffer adapter.

func (*Lancero) StopCollector

func (lan *Lancero) StopCollector() error

StopCollector stops the data serializer.

func (*Lancero) Wait

func (lan *Lancero) Wait() (time.Time, time.Duration, error)

Wait until a the threshold amount of data is available. Return timestamp when ready, duration since last ready, and error.

type Lanceroer

type Lanceroer interface {
	ChangeRingBuffer(int, int) error
	Close() error
	StartAdapter(int, int) error
	StopAdapter() error
	CollectorConfigure(int, int, uint32, int) error
	StartCollector(bool) error
	StopCollector() error
	Wait() (time.Time, time.Duration, error)
	AvailableBuffer() ([]byte, time.Time, error)
	ReleaseBytes(int) error
	InspectAdapter() uint32
}

Lanceroer is the interaface shared by Lancero and NoHardware used to allow testing without lancero hardware

type NoHardware

type NoHardware struct {
	// contains filtered or unexported fields
}

NoHardware is a drop in replacement for Lancero (implements Lanceroer) that requires no hardware. Use it for testing the interface.

func NewNoHardware

func NewNoHardware(ncols int, nrows int, linePeriod int) (*NoHardware, error)

NewNoHardware generates and returns a new Lancero object in test mode, meaning it emulate a lancero without any hardware. Here linePeriod is the equivalent of LSYNC: how many 8 ns clocks per row of readout.

func (*NoHardware) AvailableBuffer

func (lan *NoHardware) AvailableBuffer() ([]byte, time.Time, error)

AvailableBuffer returns some simulated data size matches what you should get in 1 millisecond all entries other than frame bits are zeros

func (*NoHardware) ChangeRingBuffer

func (lan *NoHardware) ChangeRingBuffer(length, threshold int) error

ChangeRingBuffer doesn't error

func (*NoHardware) Close

func (lan *NoHardware) Close() error

Close errors if already closed

func (*NoHardware) CollectorConfigure

func (lan *NoHardware) CollectorConfigure(linePeriod, dataDelay int, channelMask uint32,
	frameLength int) error

CollectorConfigure returns nil

func (*NoHardware) InspectAdapter

func (lan *NoHardware) InspectAdapter() uint32

InspectAdapter does nothing and returns 0

func (*NoHardware) ReleaseBytes

func (lan *NoHardware) ReleaseBytes(nBytes int) error

ReleaseBytes increments bytesReleased

func (*NoHardware) StartAdapter

func (lan *NoHardware) StartAdapter(waitSeconds, verbosity int) error

StartAdapter errors if already started

func (*NoHardware) StartCollector

func (lan *NoHardware) StartCollector(simulate bool) error

StartCollector errors if Collector Already Started

func (*NoHardware) StopAdapter

func (lan *NoHardware) StopAdapter() error

StopAdapter errors if not started

func (*NoHardware) StopCollector

func (lan *NoHardware) StopCollector() error

StopCollector errors if Collector not started

func (NoHardware) String

func (lan NoHardware) String() string

String implements Stringer for NoHardware, aka controls how Println output looks

func (*NoHardware) Wait

func (lan *NoHardware) Wait() (time.Time, time.Duration, error)

Wait sleeps until lastReadTime + minTimeBetweenReads

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL