libm2k Module

libm2k.ALWAYS = 0

ALWAYS - Disable analog trigger;

libm2k.ANALOG = 1

ANALOG - Trigger condition specified only by analog trigger (CH1 and CH2)

class libm2k.CALIBRATION_PARAMETERS

Bases: object

Calibration parameters of m2k

property adc_gain_ch_1

ADC calibration gain - channel 1

property adc_gain_ch_2

ADC calibration gain - channel 2

property adc_offset_ch_1

ADC calibration offset - channel 1

property adc_offset_ch_2

ADC calibration offset - channel 2

property dac_a_gain

DAC calibration gain - channel 1

property dac_a_offset

DAC calibration offset - channel 1

property dac_b_gain

DAC calibration gain - channel 2

property dac_b_offset

DAC calibration offset - channel 2

property thisown

The membership flag

libm2k.CHANNEL_1 = 0

CHANNEL_1 - trigger events on analog CHANNEL_1 trigger the AnalogIn interface

libm2k.CHANNEL_2 = 1

CHANNEL_2 - trigger events on analog CHANNEL_2 trigger the AnalogIn interface

class libm2k.CONTEXT_INFO

Bases: object

Additional information about the context

property id_product

Product ID extracted from IIO context

property id_vendor

Vendor ID extracted from IIO context

property manufacturer

Manufacturer extracted from IIO context

property product

Product name extracted from IIO context

property serial

Serial number

property thisown

The membership flag

property uri

IIO context URI

class libm2k.Context(*args, **kwargs)

Bases: object

deinitialize()
getAllDevices()

Retrieve all the available devices :rtype: std::unordered_set< std::string > :return: a list of strings containing all the devices

getAllDmm()

Retrieve all the DMM objects :rtype: std::vector< libm2k::analog::DMM *,std::allocator< libm2k::analog::DMM * > > :return: A list of DMM objects

getAvailableContextAttributes()

Retrieve all the available context attributes :rtype: std::vector< std::string,std::allocator< std::string > > :return: A list of strings containing all the context attributes

getContextAttributeValue(attr)

Retrieve the value of one context attribute :type attr: string :param attr: The name of the required attribute :rtype: string :return: On success, return a string containing the value of the attribute :raises: On error, throw an exception if the attribute is not found

getContextDescription()

Retrieve a detailed context description :rtype: string :return: string containing the current context description

getDMM(*args)

Overload 1:

Retrieve the DMM object at a certain index :type index: int :param index: The index corresponding to the DMM :rtype: DMM :return: On success, a pointer to a DMM object :rtype: DMM :return: On error, nullptr is returned


Overload 2:

Retrieve the DMM object which has the provided name :type name: string :param name: The name corresponding to the DMM :rtype: DMM :return: On success, a pointer to a DMM object :rtype: DMM :return: On error, nullptr is returned

getDmmCount()

Retrieve the number of DMM objects :rtype: int :return: an unsigned int representing the number of DMM objects in the context

getFirmwareVersion()

Retrieve the firmware version of the current context :rtype: string :return: a string containing the firmware version

getIioContext()

Retrieve the iio context :rtype: iio_context :return: A pointer to the iio context

getIioContextVersion()

Get the version of the backend in use :rtype: IIO_CONTEXT_VERSION :return: IIO_CONTEXT_VERSION struct

getSerialNumber()

Retrieve the current context serial number :rtype: string :return: string containing the current context serial number

getUri()

Get the URI of the current context :rtype: string :return: string containing the context URI (ex: “usb:1.2.3”, “ip:192.168.2.1”)

logAllAttributes()

Log all the attributes Notes: The logging system should be enabled

reset()
setTimeout(timeout)

Set a timeout for I/O operations :type timeout: int :param timeout: A positive integer representing the time in milliseconds after which a timeout occurs. A value of 0 is used to specify that no timeout should occur.

property thisown

The membership flag

toGeneric()

Convert the current context to Generic context, if possible :rtype: Generic :return: On success, return the corresponding Generic object :rtype: Generic :return: On error, return a nullptr

toM2k()

Convert the current context to M2k context, if possible :rtype: M2k :return: On success, return the corresponding M2k object :rtype: M2k :return: On error, return a nullptr

class libm2k.ContextBuilder

Bases: object

static contextClose(arg1, deinit=True)
static contextCloseAll()
static contextOpen(*args)

Overload 1:


Overload 2:


Overload 3:

static enableLogging(enable)
static getAllContexts()
static getContextsInfo()
static getVersion()
static m2kOpen(*args)

Overload 1:


Overload 2:


Overload 3:

property thisown

The membership flag

libm2k.ContextBuilder_contextClose(arg1, deinit=True)
libm2k.ContextBuilder_contextCloseAll()
libm2k.ContextBuilder_contextOpen(*args)

Overload 1:


Overload 2:


Overload 3:

libm2k.ContextBuilder_enableLogging(enable)
libm2k.ContextBuilder_getAllContexts()
libm2k.ContextBuilder_getContextsInfo()
libm2k.ContextBuilder_getVersion()
libm2k.ContextBuilder_m2kOpen(*args)

Overload 1:


Overload 2:


Overload 3:

class libm2k.DMM(*args, **kwargs)

Bases: object

getAllChannels()

Retrieve all channels

Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

A list containing the name of all channels

getName()

Retrieve the device’s name

Return type:

string

Returns:

The name of the device

readAll()

Retrieve additional information about all channels

Return type:

std::vector< libm2k::analog::DMM_READING,std::allocator< libm2k::analog::DMM_READING > >

Returns:

A list containing structures for each channel

readChannel(*args)

Overload 1:

Retrieve additional information about the given channel

Parameters:

index (int) – The index corresponding to the channel

Return type:

DMM_READING

Returns:

A structure containing additional information


Overload 2:

Retrieve additional information about the given channel

Parameters:

chn_name (string) – The name corresponding to the channel

Return type:

DMM_READING

Returns:

A structure containing additional information

reset()
property thisown

The membership flag

class libm2k.DMMReading(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.DMM_READING

Bases: object

The structure of a DMM

property id

Channel’s id

property name

The name of the channel

property thisown

The membership flag

property unit_name

Unit of measurement

property unit_symbol

Unit symbol

property value

The measured value

class libm2k.DMMs(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

libm2k.EXTERNAL = 2

EXTERNAL - Trigger condition specified only by external trigger (TI)

class libm2k.FMCOMMS

Bases: object

property thisown

The membership flag

class libm2k.Generic(*args, **kwargs)

Bases: Context

getAnalogIn(*args)
getAnalogInCount()
getAnalogOut(*args)
getAnalogOutCount()
property thisown

The membership flag

class libm2k.GenericAnalogIn(*args, **kwargs)

Bases: object

enableChannel(index, enable)
getAvailableSampleRates(*args)
getDeviceName()
getIioObjects()
getMaximumSamplerate(*args)
getNbChannels()
getSampleRate(*args)
getSamplesInterleaved(nb_samples)
getSamplesRawInterleaved(nb_samples)
setKernelBuffersCount(count)
setSampleRate(*args)
property thisown

The membership flag

class libm2k.GenericAnalogOut(*args, **kwargs)

Bases: object

enableChannel(chnIdx, enable)
getAvailableSampleRates()
getCyclic(chn)
getName()
getSampleRate(*args)
isChannelEnabled(chnIdx)
push(*args)
pushRaw(*args)
setCyclic(*args)
setSampleRate(*args)
stop()
property thisown

The membership flag

class libm2k.IIO_CONTEXT_VERSION

Bases: object

The version of the backend

property git_tag

git tag

property major

major version

property minor

minor version

property thisown

The membership flag

class libm2k.IIO_OBJECTS

Bases: object

property buffers_rx
property buffers_tx
property channels_in
property channels_out
property context
property devices
property thisown

The membership flag

class libm2k.IioBuffers(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.IioChannels(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.IioDevices(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2k(*args, **kwargs)

Bases: Context

calibrate()
calibrateADC()

Calibrate the ADC

Return type:

boolean

Returns:

On succces, true

Return type:

boolean

Returns:

Otherwise, false

calibrateDAC()

Calibrate the DAC

Return type:

boolean

Returns:

On succces, true

Return type:

boolean

Returns:

Otherwise, false

calibrateFromContext()

Calibrate both ADC and DACs using predefined calibration values located in context :rtype: float :return: The closest temperature found in the lookup table

Notes: Only available from firmware v0.26.

deinitialize()
getAdcCalibrationGain(chn)

Get the calibration gain of the ADC

Parameters:

chn (int) – The index corresponding to a channel

Return type:

float

Returns:

The value of the calibration gain

getAdcCalibrationOffset(chn)

Get the calibration offset of the ADC

Parameters:

chn (int) – The index corresponding to a channel

Return type:

int

Returns:

The value of the calibration offset

getAllAnalogIn()
getAllAnalogOut()
getAnalogIn(*args)

Overload 1:

Retrieve the AnalogIn object

Return type:

M2kAnalogIn

Returns:

On success, a pointer to an AnalogIn object

Return type:

M2kAnalogIn

Returns:

On error, null is returned


Overload 2:

Retrieve the AnalogIn object of a device

Parameters:

dev_name (string) – The name corresponding to a device

Return type:

M2kAnalogIn

Returns:

On success, a pointer to an AnalogIn object

Return type:

M2kAnalogIn

Returns:

If the name does not correspond to any device, null is returned

getAnalogOut()

Retrieve the AnalogOut object

Return type:

M2kAnalogOut

Returns:

On success, a pointer to an AnalogOut object

Return type:

M2kAnalogOut

Returns:

On error, null is returned

getDacCalibrationGain(chn)

Get the calibration gain of the DAC

Parameters:

chn (int) – The index corresponding to a channel

Return type:

float

Returns:

The value of the calibration gain

getDacCalibrationOffset(chn)

Get the calibration offset of the DAC

Parameters:

chn (int) – The index corresponding to a channel

Return type:

int

Returns:

The value of the calibration offset

getDigital()

Retrieve the Digital object

Return type:

M2kDigital

Returns:

On success, a pointer to a Digital object

Raises:

EXC_INVALID_PARAMETER No M2K digital device found

getLUT()

Retrieve the predefined calibration parameter :rtype: std::map< double,std::shared_ptr< libm2k::CALIBRATION_PARAMETERS >,std::less< double >,std::allocator< std::pair< double const,std::shared_ptr< libm2k::CALIBRATION_PARAMETERS > > > > :return: Map <temperature, parameters>

getLed()

Retrieve the state of the led

Return type:

boolean

Returns:

If the led is turned on, true

Return type:

boolean

Returns:

Otherwise, false

getPowerSupply()

Retrieve the PowerSupply object

Return type:

M2kPowerSupply

Returns:

On success, a pointer to a PowerSupply object

Raises:

EXC_INVALID_PARAMETER No M2K power supply

hasContextCalibration()

Check if the calibration based on temperature can be performed :rtype: boolean :return: True if the calibration parameters are available, False otherwise

hasMixedSignal()

Check if the mixed signal acquisition is available on the current firmware version :rtype: boolean :return: True if the mixed signal acquisition is available, false otherwise

isCalibrated()

Check if the board was calibrated :rtype: boolean :return: True if the board was calibrated, False otherwise

reset()
Reset the M2K device to default settings:
  • Reset calibration coefficients

  • Maximum samplerates

  • Set oversampling ratio to 1

  • Set AnalogIn range to low range

  • Set kernel buffers count to 4 (analog/digital and in/out devices)

  • Disable all TX digital channels and enable all RX digital channels

Notes: A calibration is needed afterwards

resetCalibration()
setAdcCalibrationGain(chn, gain)

Set the calibration gain of the ADC :type chn: int :param chn: The index corresponding to a channel :type gain: float :param gain: The calibration gain value Notes: Overrides the calibration coefficients.

Can be reset by running a calibration.

The gain value is currently limited at the (-2,2) range by the hardware.

setAdcCalibrationOffset(chn, offset)

Set the calibration offset of the ADC :type chn: int :param chn: The index corresponding to a channel :type offset: int :param offset: The calibration offset value Notes: Overrides the calibration coefficients.

Can be reset by running a calibration.

setDacCalibrationGain(chn, gain)

Set the calibration gain of the DAC :type chn: int :param chn: The index corresponding to a channel :type gain: float :param gain: The calibration gain value Notes: Overrides the calibration coefficients.

Can be reset by running a calibration.

The gain value is currently limited at the (-2,2) range by the hardware.

setDacCalibrationOffset(chn, offset)

Set the calibration offset of the DAC :type chn: int :param chn: The index corresponding to a channel :type offset: int :param offset: The calibration offset value Notes: Overrides the calibration coefficients.

Can be reset by running a calibration.

setLed(on)

Turn on or off the board’s led

Parameters:

on (boolean) – A boolean value corresponding to the state of the led

Notes: For turning on the led, set the parameter true.

startMixedSignalAcquisition(nb_samples)

Initiate the mixed acquisition :type nb_samples: int :param nb_samples: The number of samples that will be retrieved

Notes: Only available from firmware v0.26.

stopMixedSignalAcquisition()

Stop the mixed acquisition

Notes: Only available from firmware v0.26.

property thisown

The membership flag

class libm2k.M2kAnalogIn(*args, **kwargs)

Bases: object

cancelAcquisition()

Cancel all buffer operations Notes: Should be used to cancel an ongoing acquisition

convertRawToVolts(channel, raw)

Convert the raw value of a sample into volts :type raw: int :param raw:: the raw value of a sample; :type channel: int :param channel:: The index corresponding to the channel; :rtype: float :return: The value of a sample converted into volts;

convertVoltsToRaw(channel, voltage)

Convert the voltage value of a sample into raw

Parameters:
  • voltage (float) – The voltage value of a sample;

  • channel (int) – The index corresponding to the channel;

Return type:

int

Returns:

The value of a sample converted into raw;

enableChannel(chnIdx, enable)

Enable or disable the given channel

Parameters:
  • chnIdx (int) – The index corresponding to the channel

  • enable (boolean) – A boolean value corresponding to the channel’s state

getAvailableRanges()

Retrieve all ranges that are available

Return type:

std::vector< std::pair< std::string,std::pair< double,double > >,std::allocator< std::pair< std::string,std::pair< double,double > > > >

Returns:

A list of pairs containing all available ranges and their name

getAvailableSampleRates()
Return type:

std::vector< double,std::allocator< double > >

Returns:

The list of available samplerates for this device

getChannelName(channel)

Get the channel name for each ADC channel :type channel: int :param channel: - unsigned int representing the index of the channel :rtype: string :return: std::string - name of the channel

getFilterCompensation(samplerate)

Retrieve the filter compensation for the given sample rate

Parameters:

samplerate (float) – A double value representing the sample rate

Return type:

float

Returns:

The value of the filter compensation

getHysteresisRange(chn)

Retrieve the bounds of the analogical trigger’s hysteresis for the given channel

Parameters:

chn (int) – An enumerator corresponding to the channel’s index

Return type:

std::pair< double,double >

Returns:

A pair containing the lower and upper bound

getIioObjects()

Get access to IIO channels, buffers, devices and context. Can be used when debugging directly with libiio. :rtype: IIO_OBJECTS :return: IIO_OBJECTS structure.

getKernelBuffersCount()

Get the number of kernel buffers :rtype: int :return: the number of previously set kernel buffers (saved in this session)

getMaximumSamplerate()

Get the maximum samplerate for the ADC :rtype: float :return: double - the value of the maximum samplerate

getName()

Retrieve the name of the device

Return type:

string

Returns:

The name of the device

getNbChannels()

Retrieve the number of analogical channels

Return type:

int

Returns:

The number of channels

getOversamplingRatio(*args)

Overload 1:

Retrieve the global oversampling ratio

Return type:

int

Returns:

The value of the global ratio


Overload 2:

Retrieve the oversampling ratio for the given channel

Parameters:

chn_idx (int) – The index corresponding to the channel

Return type:

int

Returns:

The ratio value

getRange(channel)

Retrieve the range for the given channel

Parameters:

channel (int) – An enumerator corresponding to the channel’s index

Return type:

int

Returns:

An enumerator corresponding to the range

getRangeLimits(range)

Retrieve the bounds for the given range

Parameters:

range (int) – An enumerator corresponding to the range

Return type:

std::pair< double,double >

Returns:

A pair containing the lower and upper bound

getSampleRate()

Retrieve the global sample rate

Return type:

float

Returns:

The value of the sample rate

getSamples(*args)

Overload 1:

Retrieve a specific number of samples from each channel

Parameters:

nb_samples (int) – The number of samples that will be retrieved

Return type:

std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >

Returns:

A list containing lists of samples for each channel

Notes: The index of the list corresponds to the index of the channel Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.


Overload 2:

Retrieve a specific number of samples from each channel

Parameters:
  • data (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >) –

    • a reference to a vector owned/created by the client

  • nb_samples (int) – The number of samples that will be retrieved

Notes: The vector will be cleaned and then filled with samples The index of the list corresponds to the index of the channel Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getSamplesInterleaved(nb_samples_per_channel)

Retrieve a specific number of samples from each channel

Parameters:

nb_samples_per_channel (int) – The number of samples that will be retrieved

Return type:

float

Returns:

A pointer to the interleaved samples

Notes: Before the acquisition, both channels will be automatically enabled The data array will contain samples from both channels After the acquisition is finished, the channels will return to their initial state Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getSamplesRaw(nb_samples)

Retrieve a specific number of raw samples from each channel

Parameters:

nb_samples (int) – The number of samples that will be retrieved

Return type:

std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >

Returns:

A list containing lists of raw samples for each channel

Notes: The index of the list corresponds to the index of the channel Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getSamplesRawInterleaved(nb_samples_per_channel)

Retrieve a specific number of raw samples from each channel

Parameters:

nb_samples_per_channel (int) – The number of samples that will be retrieved

Return type:

int

Returns:

A pointer to the interleaved raw samples

Notes: Before the acquisition, both channels will be automatically enabled The data array will contain samples from both channels After the acquisition is finished, the channels will return to their initial state Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getScalingFactor(ch)

Retrieve the scaling factor

Parameters:

ch (int) – An enumerator corresponding to the channel’s index

Return type:

float

Returns:

The value of the scaling factor

getTrigger()

Get the hardware trigger handler

Return type:

M2kHardwareTrigger

Returns:

A pointer to the hardware trigger trigger

getValueForRange(range)

Retrieve the numeric value corresponding to the given range

Parameters:

range (int) –

Return type:

float

Returns:

double

getVerticalOffset(channel)
Parameters:

channel (int) – the index of the channel

Return type:

float

Returns:

the value of the offset in Volts

getVoltage(*args)

Overload 1:

Retrieve the average voltage of the given channel

Parameters:

ch (int) – The index corresponding to the channel

Return type:

float

Returns:

The average voltage


Overload 2:

Retrieve the average voltage of the given channel

Parameters:

ch (int) – An enumerator corresponding to the channel’s index

Return type:

float

Returns:

The average voltage


Overload 3:

Retrieve the average voltage for each channel

Return type:

std::vector< double,std::allocator< double > >

Returns:

A list containing the average voltage of each channel

Notes: The index of the voltage corresponds to the channel’s index

getVoltageRaw(*args)

Overload 1:

Retrieve the average raw value of the given channel

Parameters:

ch (int) – The index corresponding to the channel

Return type:

int

Returns:

The average raw value


Overload 2:

Retrieve the average raw value of the given channel

Parameters:

ch (int) – An enumerator corresponding to the channel’s index

Return type:

int

Returns:

The average raw value


Overload 3:

Retrieve the average raw value for each channel

Return type:

std::vector< short,std::allocator< short > >

Returns:

A list containing the average raw value of each channel

Notes: The index of the value corresponds to the channel’s index

isChannelEnabled(chnIdx)

Retrieve the state of the given channel

Parameters:

chnIdx (int) – The index corresponding to the channel

Return type:

boolean

Returns:

True if the channel is enabled

Return type:

boolean

Returns:

False if the channel is disabled

reset()
setKernelBuffersCount(count)

Set the kernel buffers to a specific value :type count: int :param count: the number of kernel buffers

setOversamplingRatio(*args)

Overload 1:

Set the global oversampling ratio

Parameters:

oversampling (int) – Integer value to set the oversampling ratio to

Return type:

int

Returns:

The current value of the global ratio


Overload 2:

Set the oversampling ratio for the given channel

Parameters:
  • chn_idx (int) – The index corresponding to the channel

  • oversampling (int) – Integer value to set the oversampling ratio to

Return type:

int

Returns:

The current ratio value

setRange(*args)

Overload 1:

Set the range for the given channel

Parameters:
  • channel (int) – An enumerator corresponding to the channel’s index

  • range (int) – An enumerator corresponding to a range


Overload 2:

Set the range for the given channel

Parameters:
  • channel (int) – An enumerator corresponding to the channel’s index

  • min (float) – Upper bound

  • max (float) – Lower bound

setSampleRate(samplerate)

Set the global sample rate

Parameters:

samplerate (float) – A double value to set the sample rate to

Return type:

float

Returns:

The value of the global sample rate

setVerticalOffset(channel, vertOffset)

Set the vertical offset, in Volts, of a specific channel :type channel: int :param channel: the index of the channel :type vertOffset: float :param vertOffset: the value of the offset in Volts

startAcquisition(nb_samples)

Create the buffer for both channels and start the acquisition :type nb_samples: int :param nb_samples: size of the buffer in samples for each channel

stopAcquisition()

Destroy the buffer and stop the acquisition

property thisown

The membership flag

class libm2k.M2kAnalogIns(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2kAnalogOut(*args, **kwargs)

Bases: object

cancelBuffer(*args)

Overload 1:

Cancel all buffer operations of enabled channels Notes: Should be used to cancel an ongoing data write.


Overload 2:

Cancel all buffer operations of the given channel :type chn: int :param chn: The index corresponding to the channel Notes: Should be used to cancel an ongoing data write.

convertRawToVolts(channel, raw)

Convert the raw value of a sample into volts :type channel: int :param channel: The index corresponding to the channel :type raw: int :param raw: The raw value of a sample :rtype: float :return: The value of a sample converted into volts

convertVoltsToRaw(channel, voltage)

Convert the volts value of a sample into raw :type channel: int :param channel: The index corresponding to the channel :type voltage: float :param voltage: The volts value of a sample :rtype: int :return: The value of a sample converted into raw

enableChannel(chnIdx, enable)

Enable or disable the given digital channel

Parameters:
  • chnIdx (int) – The index corresponding to the channel

  • enable (boolean) – A boolean value corresponding to the channel’s state

Raises:

EXC_OUT_OF_RANGE No such channel

getAvailableSampleRates(chn)
Parameters:

chn (int) – The index corresponding to the required channel

Return type:

std::vector< double,std::allocator< double > >

Returns:

The list of available samplerates for this device

getBufferRearmOnTrigger()

Retrieve the value of the attribute that controls buffer rearm on trigger Notes: The buffer rearm on trigger is disabled by default. The attribute is shared between both channels. Only available from firmware v0.33. :rtype: boolean :return: A boolean value corresponding to the state of the rearm on trigger.

getChannelName(channel)

Get the channel name for each DAC channel :type channel: int :param channel: - unsigned int representing the index of the channel :rtype: string :return: std::string - name of the channel

getCyclic(chn)

Retrieve the value of the cyclic mode

Parameters:

chn (int) – The index corresponding to the channel

Return type:

boolean

Returns:

A boolean value corresponding to the state of the cyclic mode

getFilterCompensation(samplerate)

Retrieve the filter compensation for the given sample rate

Parameters:

samplerate (float) – A double value representing the sample rate

Return type:

float

Returns:

The value of the filter compensation

getIioObjects()

Get access to IIO channels, buffers, devices and context. Notes: Can be used when debugging directly with libiio. :rtype: IIO_OBJECTS :return: IIO_OBJECTS structure.

getKernelBuffersCount(chnIdx)

Get the number of kernel buffers :type chnIdx: int :param chnIdx: The index corresponding to the channel :rtype: int :return: the number of previously set kernel buffers (saved in this session)

getMaximumSamplerate(chn_idx)

Get the maximum samplerate for the DAC :type chn_idx: int :param chn_idx: - unsigned int representing the index of the channel :rtype: float :return: double - the value of the maximum samplerate

getNbChannels()

Retrieve the number of analogical channels :rtype: int :return: The number of channels

getOversamplingRatio(*args)

Overload 1:

Retrieve the global oversampling ratio :rtype: std::vector< int,std::allocator< int > > :return: The value of the global oversampling ratio


Overload 2:

Retrieve the oversampling ratio for the given channel

Parameters:

chn (int) – The index corresponding to the channel

Return type:

int

Returns:

The oversampling ratio value

getSampleRate(*args)

Overload 1:

Retrieve the sample rate of both DACs :rtype: std::vector< double,std::allocator< double > > :return: A list containing the sample rates


Overload 2:

Retrieve the sample rate for the given channel

Parameters:

chn (int) – The index corresponding to the channel

Return type:

float

Returns:

The value of the sample rate

getScalingFactor(chn)

Retrieve the scaling factor for the given channel

Parameters:

chn (int) – The index corresponding to the channel

Return type:

float

Returns:

The value of the scaling factor

Raises:

EXC_OUT_OF_RANGE No such channel

getSyncedDma(chn=-1)
getSyncedStartDma(chn=-1)
getTrigger()

Get the hardware trigger handler

Return type:

M2kHardwareTrigger

Returns:

A pointer to the hardware trigger

isChannelEnabled(chnIdx)

Check if the given channel is enabled

Parameters:

chnIdx (int) – The index corresponding to the channel

Return type:

boolean

Returns:

A boolean value corresponding to the state of the channel

Raises:

EXC_OUT_OF_RANGE No such channel

isPushDone(chnIdx)

Check if the generation of the signal (only for non-cyclic buffer) is done :type chnIdx: int :param chnIdx: The index corresponding to the channel :rtype: boolean :return: True if the push process is done, false otherwise

Notes: This function takes the number of kernel buffers into consideration. If a new session is started without unplugging the board and the number of kernel buffers was modified in the previous session (default value = 4) a DAC calibration must be performed before calling isPushDone in order to compute the current number of kernel buffers or call again the function setKernelBuffersCount.

Available only in firmware versions newer than 0.23.

push(*args)

Overload 1:

Send the samples to the given channel

Parameters:
  • chnIdx (int) – The index corresponding to the channel

  • data (std::vector< double,std::allocator< double > >) – A list of doubles containing all samples

Notes: Streaming data is possible - required multiple kernel buffers The given channel won’t be synchronized with the other channel Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers) The samples in the buffer can be repeated until the buffer reaches the size requirements :raises: EXC_OUT_OF_RANGE No such channel


Overload 2:

Send samples to channels.

Parameters:

data (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >) – A list containing lists of samples

Notes: The index of each list of samples represents the channel’s index Streaming data is possible - required multiple kernel buffers The given channel won’t be synchronized with the other channel Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers) The samples in the buffer can be repeated until the buffer reaches the size requirements

pushRaw(*args)

Overload 1:

Send the samples to the given channel

Parameters:
  • chnIdx (int) – The index corresponding to the channel

  • data (std::vector< short,std::allocator< short > >) – A list of shorts containing all samples

Notes: Streaming data is possible - required multiple kernel buffers The given channel won’t be synchronized with the other channel Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers) The samples in the buffer can be repeated until the buffer reaches the size requirements :raises: EXC_OUT_OF_RANGE No such channel


Overload 2:

Send samples to channels

Parameters:

data (std::vector< std::vector< short,std::allocator< short > >,std::allocator< std::vector< short,std::allocator< short > > > >) – A list containing lists of samples

Notes: The index of each list of samples represents the channel’s index Streaming data is possible - required multiple kernel buffers The given channel won’t be synchronized with the other channel Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers) The samples in the buffer can be repeated until the buffer reaches the size requirements

pushRawBytes(chnIdx, data, nb_samples)

Send the samples to the given channel

Parameters:
  • chnIdx (int) – The index corresponding to the channel

  • data (int) – A pointer to the raw samples

  • nb_samples (int) – the number of samples

Notes: Streaming data is possible - required multiple kernel buffers The given channel won’t be synchronized with the other channel Due to a hardware limitation, the number of samples per channel must be a multiple of 4 and greater than 16 (non-cyclic buffers) or 1024 (cyclic buffers) The samples in the buffer can be repeated until the buffer reaches the size requirements :raises: EXC_OUT_OF_RANGE No such channel

reset()
setBufferRearmOnTrigger(enable)

Allows sequential output of multiple buffers with each trigger event. :type enable: boolean :param enable: A boolean value that enables or disables the buffer rearm functionality.

Notes: When disabled, all buffers will be sent at once. Opt to concatenate multiple small buffers into a single buffer to avoid timing problems. When enabled, each previously pushed buffer will be sent sequentially with each trigger event. For non-cyclic mode each buffer is sent only once. In cyclic mode:

  • If rearm is disabled, the buffer will be sent continuously.

  • If rearm is enabled, the buffer will be sent once for every trigger event.

Due to hardware limitation, in non-cyclic mode, the channel will idle with the first sample of the next buffer. Only available from firmware v0.33.

setCyclic(*args)

Overload 1:

Enable or disable the cyclic mode for all digital channels

Parameters:

en (boolean) – If true, enable cyclic mode

Raises:

EXC_OUT_OF_RANGE No such channel


Overload 2:

Enable or disable the cyclic mode for all digital channels

Parameters:
  • chn (int) – The index corresponding to the channel

  • en (boolean) – If true, enable cyclic mode

Raises:

EXC_OUT_OF_RANGE No such channel

setKernelBuffersCount(chnIdx, count)

Set the kernel buffers to a specific value :type chnIdx: int :param chnIdx: The index corresponding to the channel :type count: int :param count: the number of kernel buffers

setOversamplingRatio(*args)

Overload 1:

Set the value of the oversampling ratio for each channel

Parameters:

oversampling_ratio (std::vector< int,std::allocator< int > >) – A list containing the ratios for each channel (as integers)

Return type:

std::vector< int,std::allocator< int > >

Returns:

A list containing the oversampling ratio value for each channel


Overload 2:

Set the oversampling ratio for the given channel :type chn: int :param chn: The index corresponding to the channel :type oversampling_ratio: int :param oversampling_ratio: Integer value to set the oversampling ratio to :rtype: int :return: The current oversampling ratio value

setSampleRate(*args)

Overload 1:

Set the sample rate for both channels

Parameters:

samplerates (std::vector< double,std::allocator< double > >) – A list containing the sample rates of each channel

Return type:

std::vector< double,std::allocator< double > >

Returns:

A list containing the previously set sample rates


Overload 2:

Set the sample rate for the given channel

Parameters:
  • chn (int) – The index corresponding to the channel

  • samplerate (float) – A double value to set the sample rate to

Return type:

float

Returns:

The value of the sample rate

setSyncedDma(en, chn=-1)
setSyncedStartDma(en, chn=-1)
setVoltage(chn_idx, volts)

Sets the voltage output of the DAC channel :type chn_idx: int :param chn_idx: - unsigned int representing the index of the channel :type volts: float :param volts: - actual value to be set

Notes: In scenarios where the DMA is not active, such as when an output buffer is destroyed, the DAC will revert to using the raw value set by this function. :rtype: int :return: unsigned short - the corresponding raw value for the given voltage

setVoltageRaw(chn_idx, raw)

Sets the raw output of the DAC channel :type chn_idx: int :param chn_idx: - unsigned int representing the index of the channel :type raw: int :param raw: - actual value to be set

Notes: In scenarios where the DMA is not active, such as when an output buffer is destroyed, the DAC will revert to using the raw value set by this function. :rtype: int :return: unsigned short - the value set in the raw attribute

stop(*args)

Overload 1:

Stop all channels from sending the signals.

Notes: Both DACs will be powered down


Overload 2:

Stop the given channels from sending the signals

Parameters:

chn (int) – The index corresponding to the channel

Notes: The corresponding DAC will be powered down :raises: EXC_OUT_OF_RANGE No such channel

property thisown

The membership flag

class libm2k.M2kAnalogOuts(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2kCalibration(*args, **kwargs)

Bases: object

calibrateADC()
calibrateAll()
calibrateDAC()
cancelCalibration()
getAdcCalibrated()
getAdcGain(channel)
getAdcOffset(channel)
getDacCalibrated()
getDacGain(channel)
getDacOffset(channel)
initialize()
isInitialized()
resetCalibration()
setAdcGain(chn, gain)
setAdcOffset(chn, offset)
setDacGain(chn, gain)
setDacOffset(chn, offset)
property thisown

The membership flag

class libm2k.M2kConditionAnalog(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2kConditionDigital(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2kDigital(*args, **kwargs)

Bases: object

anyChannelEnabled(dir)

Check if there is at least one channel enabled

Parameters:

dir (int) – An enumerator corresponding to the direction of a channel

Return type:

boolean

Returns:

On succces, true

Return type:

boolean

Returns:

Otherwise, false

cancelAcquisition()

Cancel all rx-buffer operations Notes: Should be used to cancel an ongoing acquisition

cancelBufferOut()

Cancel all tx-buffer operations Notes: Should be used to cancel an ongoing data write.

enableAllOut(enable)

Enable or disable all output channels

Parameters:

enable (boolean) – A boolean value corresponding to the channel’s state

Notes: This function affects only the TX channels

enableChannel(*args)

Overload 1:

Enable or disable the given digital channel

Parameters:
  • index (int) – The index corresponding to the channel

  • enable (boolean) – A boolean value corresponding to the channel’s state

Notes: This function affects only the TX channels


Overload 2:

Enable or disable the given digital channel

Parameters:
  • index (int) – An enumerator corresponding to the channel’s index

  • enable (boolean) – A boolean value corresponding to the channel’s state

Notes: This function affects only the TX channels

getCyclic()

Retrieve the value of the cyclic mode

Return type:

boolean

Returns:

A boolean value corresponding to the state of the cyclic mode

getDirection(index)

Retrieve the direction of the given digital channel

Parameters:

index (int) – An enumerator corresponding to the channel’s index

Return type:

int

Returns:

DIO_DIRECTION An enumerator that indicates the direction of a channel

getIioObjects()

Get access to IIO channels, buffers, devices and context. Can be used when debugging directly with libiio. :rtype: IIO_OBJECTS :return: IIO_OBJECTS structure.

getNbChannelsIn()

Retrieve the number of digital input channels

Return type:

int

Returns:

an unsigned int representing the number of digital IN channels

getNbChannelsOut()

Retrieve the number of digital output channels

Return type:

int

Returns:

an unsigned int representing the number of digital OUT channels

getOutputMode(*args)

Overload 1:

Retrieve the output mode for the given digital channel

Parameters:

chn (int) – An enumerator corresponding to the channel’s index

Return type:

int

Returns:

An enumerator corresponding to the output mode


Overload 2:

Retrieve the output mode for the given digital channel

Parameters:

chn (int) – The index corresponding to the channel

Return type:

int

Returns:

An enumerator corresponding to the output mode

getSampleRateIn()

Retrieve the sample rate of all digital input channels :rtype: float :return: The value of the sample rate

getSampleRateOut()

Retrieve the sample rate of all digital output channels

Return type:

float

Returns:

The value of the sample rate

getSamples(*args)

Overload 1:

Retrieve a specific number of samples

Parameters:

nb_samples (int) – The number of samples that will be retrieved

Return type:

std::vector< unsigned short,std::allocator< unsigned short > >

Returns:

A list that contains the samples

Notes: Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.


Overload 2:

Retrieve a specific number of samples :type data: std::vector< unsigned short,std::allocator< unsigned short > > :param data: - a reference to a vector owned/created by the client :type nb_samples: int :param nb_samples: The number of samples that will be retrieved. The vector will be cleaned and then filled with samples. Notes: Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getSamplesP(nb_samples)

Retrieve a specific number of samples :type nb_samples: int :param nb_samples: The number of samples that will be retrieved :rtype: int :return: A pointer to the data Notes: Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

getTrigger()

Get the hardware trigger handler :rtype: M2kHardwareTrigger :return: the trigger object

getValueRaw(*args)

Overload 1:

Retrieve the raw value of the given digital channel

Parameters:

index (int) – An enumerator corresponding to the channel’s index

Return type:

int

Returns:

DIO_LEVEL An enumerator corresponding to the raw value


Overload 2:

Retrieve the raw value of the given digital channel

Parameters:

index (int) – The index corresponding to the channel

Return type:

int

Returns:

DIO_LEVEL An enumerator corresponding to the raw value

isClocksourceExternal()

Get the current clocksource :rtype: boolean :return: True if clocksource is set to external

Notes: Only available from firmware v0.26.

push(data)

Send the samples to all digital channels

Parameters:

data (std::vector< unsigned short,std::allocator< unsigned short > >) – The std vector that contains the samples

Notes: Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

pushBytes(data, nb_samples)

Send the samples to all digital channels

Parameters:
  • data (int) – a pointer to the samples

  • nb_samples (int) – the number of samples

Notes: Due to a hardware limitation, the number of samples must be a multiple of 4 and greater than 16.

reset()
resetRateMux()

Reset the digital rate to default

Notes: Only available from firmware v0.26.

setCyclic(cyclic)

Enable or disable the cyclic mode for all digital channels

Parameters:

cyclic (boolean) – If true, enable cyclic mode

setDirection(*args)

Overload 1:

Set the direction for all digital channels :type mask: int :param mask: A bitmask Notes: Each bit of the mask corresponds to the channel with the same index. The value of the bit represents the channel’s direction. O - input, 1 - output


Overload 2:

Set the direction of the given digital channel :type index: int :param index: The index corresponding to the channel :type dir: int :param dir: An enumerator that indicates the direction of a channel


Overload 3:

Set the direction of the given digital channel :type index: int :param index: The index corresponding to the channel :type dir: boolean :param dir: A boolean value that corresponds to one direction Notes: The boolean value for input direction is false and for output direction is true


Overload 4:

Set the direction of the given digital channel :type index: int :param index: An enumerator corresponding to the channel’s index :type dir: boolean :param dir: A boolean value that corresponds to one direction Notes: The boolean value for input direction is false and for output direction is true


Overload 5:

Set the direction of the given digital channel :type index: int :param index: An enumerator corresponding to the channel’s index :type dir: int :param dir: An enumerator that indicates the direction of a channel

setExternalClocksource(external)

Set the clocksource :type external: boolean :param external: - True to set source to external

  • False to set source to internal

Notes: Only available from firmware v0.26.

setKernelBuffersCountIn(count)

Set the kernel buffers for input to a specific value :type count: int :param count: the number of kernel buffers

setKernelBuffersCountOut(count)

Set the kernel buffers for output to a specific value :type count: int :param count: the number of kernel buffers

setOutputMode(*args)

Overload 1:

Set the output mode for the given digital channel

Parameters:
  • chn (int) – An enumerator corresponding to the channel’s index

  • mode (int) – An enumerator corresponding to the output mode


Overload 2:

Set the output mode for the given digital channel

Parameters:
  • chn (int) – The index corresponding to the channel

  • mode (int) – An enumerator corresponding to the output mode

setRateMux()

Force the digital interface to use the analogical rate

Notes: Only available from firmware v0.26.

setSampleRateIn(samplerate)

Set the sample rate for all digital input channels

Parameters:

samplerate (float) – A double value to set the sample rate to

Return type:

float

Returns:

The current sample rate for all digital input channels

setSampleRateOut(samplerate)

Set the sample rate for all digital output channels

Parameters:

samplerate (float) – A double value to set the sample rate to

Return type:

float

Returns:

The current sample rate for all digital output channels

setValueRaw(*args)

Overload 1:

Set the raw value of a given digital channel

Parameters:
  • index (int) – An enumerator corresponding to the channel’s index

  • level (int) – An enumerator corresponding to the raw value


Overload 2:

Set the raw value of a given digital channel

Parameters:
  • index (int) – The index corresponding to the channel

  • level (int) – An enumerator corresponding to the raw value


Overload 3:

Set the raw value of a given digital channel

Parameters:
  • index (int) – An enumerator corresponding to the channel’s index

  • level (boolean) – A boolean value corresponding to the raw value

startAcquisition(nb_samples)

Create the buffer for all channels and start the acquisition :type nb_samples: int :param nb_samples: size of the buffer in samples

stopAcquisition()

Destroy the buffer and stop the acquisition

stopBufferOut()

Stop all digital channels from sending the signals

property thisown

The membership flag

class libm2k.M2kHardwareTrigger(*args, **kwargs)

Bases: object

getAnalogCondition(chnIdx)

Get the trigger condition for the analog trigger on a specific channel :type chnIdx: int :param chnIdx: the required channel :rtype: int :return: the trigger condition

getAnalogDelay()

Get the analog trigger delay :rtype: int :return: the value of the delay

Notes: the delay can have negative values The negative values are used to place the trigger inside the buffer The value of the delay represents the number of samples in buffer before the triggered sample If the value is 0, the triggered sample will be the first one in the buffer For a buffer of 1000 samples, in order to have the trigger at the middle, you need to set it to -500 The minimum negative value is -8192

the delay can have positive values TBD

getAnalogExternalCondition(chnIdx)
Parameters:

chnIdx (int) – : integer - the index of the required channel

Return type:

int

Returns:

M2K_TRIGGER_CONDITION_DIGITAL

getAnalogExternalOutSelect()

Check which trigger events are forwarded on the TO (trigger out) pin. :rtype: int :return: M2K_TRIGGER_OUT_SELECT :

SELECT_NONE;

SELECT_TRIGGER_IN;

SELECT_DIGITAL_IN;

SELECT_ANALOG_IN;

Notes: Only available from firmware v0.24.

getAnalogHysteresis(chnIdx)

Get the analog hysteresis value for one channel :type chnIdx: int :param chnIdx: the required channel :rtype: float :return: the value of the hysteresis in Volts

getAnalogLevel(chnIdx)

Get the analog trigger level for one channel :type chnIdx: int :param chnIdx: the required channel :rtype: float :return: the analog trigger level in volts

getAnalogLevelRaw(chnIdx)

Get the raw analog trigger level for one channel :type chnIdx: int :param chnIdx: the required channel :rtype: int :return: the raw analog trigger level

getAnalogMode(chnIdx)

Get the mode for the analog trigger on a specific channel :type chnIdx: int :param chnIdx: the required channel :rtype: int :return: the analog trigger mode

getAnalogOutTriggerCondition()

Returns the condition of the AnalogOut trigger event when the source is TI. :rtype: int :return: M2K_TRIGGER_CONDITION_OUT :

NONE_OUT - disabled;

LOW_LEVEL_OUT;

HIGH_LEVEL_OUT;

ANY_EDGE_OUT;

RISING_EDGE_OUT;

FALLING_EDGE_OUT;

Notes: Only available from firmware v0.33.

getAnalogOutTriggerSource()

Returns the source of the AnalogOut trigger event. :rtype: int :return: M2K_TRIGGER_SOURCE_OUT :

TRIGGER_NONE;

TRIGGER_TI;

TRIGGER_ADC;

TRIGGER_LA;

Notes: Only available from firmware v0.33.

getAnalogOutTriggerStatus()

Returns the action that is performed when a trigger event occurs. :rtype: int :return: M2K_TRIGGER_STATUS_ANALOG_OUT :

DISABLED;

START;

STOP;

Notes: Only available from firmware v0.33.

getAnalogSource()

Get the source of the analog trigger :rtype: int :return: analog trigger source (channel1, channel2, etc)

getAnalogSourceChannel()

Get the channel source of the analog trigger :rtype: int :return: analog trigger channel source (channel1, channel2)

getAnalogStreamingFlag()

Get the streaming flag for the analog part :rtype: boolean :return: whether the streaming is enabled (true/false)

getCurrentHwSettings()
getDigitalCondition(*args)

Overload 1:

Get the trigger condition for the digital trigger on a specific channel :type chnIdx: int :param chnIdx: The index of the required channel :rtype: int :return: The trigger condition


Overload 2:

Get the trigger condition for the digital trigger on a specific channel :type chnIdx: int :param chnIdx: An enumerator corresponding to the index of the required channel :rtype: int :return: The trigger condition

getDigitalDelay()

Get the digital trigger delay :rtype: int :return: the value of the digital delay

Notes: the delay can have negative values The negative values are used to place the trigger inside the buffer The value of the delay represents the number of samples in buffer before the triggered sample If the value is 0, the triggered sample will be the first one in the buffer For a buffer of 1000 samples, in order to have the trigger at the middle, you need to set it to -500 The minimum negative value is -8192

the delay can have positive values TBD

getDigitalExternalCondition()
Return type:

int

Returns:

M2K_TRIGGER_CONDITION_DIGITAL

getDigitalMode()

Get the mode for the digital trigger :rtype: int :return: the digital trigger mode (DIO_OR/DIO_AND)

getDigitalSource()

Check which is the source of the DigitalIn interface trigger event. :rtype: int :return: M2K_TRIGGER_SOURCE_DIGITAL :

SRC_TRIGGER_IN;

SRC_ANALOG_IN;

SRC_NONE;

Notes: Only available from firmware v0.24.

getDigitalStreamingFlag()

Get the streaming flag for the digital part :rtype: boolean :return: whether the streaming is enabled (true/false)

hasCrossInstrumentTrigger()
hasExternalTriggerIn()
hasExternalTriggerOut()
reset()
setAnalogCondition(chnIdx, cond)

Set the trigger condition for the analog trigger on a specific channel :type chnIdx: int :param chnIdx: the required channel :type cond: int :param cond: the specific trigger condition

setAnalogDelay(delay)

Set the analog trigger delay :type delay: int :param delay: the value of the analog delay

Notes: the delay can have negative values The negative values are used to place the trigger inside the buffer The value of the delay represents the number of samples in buffer before the triggered sample If the value is 0, the triggered sample will be the first one in the buffer For a buffer of 1000 samples, in order to have the trigger at the middle, you need to set it to -500 The minimum negative value is -8192

the delay can have positive values TBD

setAnalogExternalCondition(chnIdx, cond)
Parameters:
  • chnIdx (int) – : integer - the index of the required channel

  • cond (int) – : M2K_TRIGGER_CONDITION_DIGITAL

setAnalogExternalOutSelect(output_select)

Select what should be redirected on the TO (trigger out) pin.

The options are (none, trigger in, digital in, analog in).

Parameters:

output_select (int) –

: of type M2K_TRIGGER_OUT_SELECT:

SELECT_TRIGGER_IN - forwards trigger events from TI pin(trigger in);

SELECT_DIGITAL_IN - forwards trigger events from DigitalIn interface;

SELECT_ANALOG_IN - forwards trigger events from AnalogIn interface;

SELECT_NONE - no trigger event is forwarded;

Notes: Only available from firmware v0.24.

setAnalogHysteresis(chnIdx, hysteresis)

Set the analog hysteresis value for one channel :type chnIdx: int :param chnIdx: the required channel :type hysteresis: float :param hysteresis: in Volts

setAnalogLevel(chnIdx, v_level)

Set the analog trigger level for one channel :type chnIdx: int :param chnIdx: the required channel :type v_level: float :param v_level: the analog trigger level in volts

setAnalogLevelRaw(chnIdx, level)

Set the raw analog trigger level for one channel :type chnIdx: int :param chnIdx: the required channel :type level: int :param level: the raw analog trigger level

setAnalogMode(chnIdx, mode)

Set the mode for the analog trigger on a specific channel :type chnIdx: int :param chnIdx: the required channel :type mode: int :param mode: the analog trigger mode

setAnalogOutTriggerCondition(condition)

Configures the triggering condition when the source of the AnalogOut trigger event is set to TRIGGER_TI_0. :type condition: int :param condition:: of type M2K_TRIGGER_CONDITION_OUT:

NONE_OUT - disabled;

LOW_LEVEL_OUT;

HIGH_LEVEL_OUT;

ANY_EDGE_OUT;

RISING_EDGE_OUT;

FALLING_EDGE_OUT;

Notes: For the other sources this condition is ignored, the configuration is forwarded by the corresponding interface. Only available from firmware v0.33.

setAnalogOutTriggerSource(src)

Select which interface triggers the AnalogOut. :type src: int :param src:: of type M2K_TRIGGER_SOURCE_OUT:

TRIGGER_NONE - trigger events are disabled;

TRIGGER_TI - trigger events on the TI pin will trigger the AnalogOut interface;

TRIGGER_ADC - trigger events on the AnalogIn interface will trigger the AnalogOut interface;

TRIGGER_LA - trigger events on the DigitalIn interface will trigger the AnalogOut interface;

Notes: Only available from firmware v0.33.

setAnalogOutTriggerStatus(status)

Defines the action to be performed when a trigger event occurs. :type status: int :param status:: of type M2K_TRIGGER_STATUS_ANALOG_OUT:

DISABLED - no action is performed when a trigger event occurs;

START - the AnalogOut interface starts outputting samples;

STOP - the AnalogOut interface stops outputting samples;

Notes: Only available from firmware v0.33.

setAnalogSource(src)

Set the source of the analog trigger :type src: int :param src: analog trigger source (channel1, channel2, etc)

setAnalogSourceChannel(chnIdx)

Set the channel source of the analog trigger :type chnIdx: int :param chnIdx: the index of the channel that should be used

setAnalogStreamingFlag(enable)

Set the streaming flag for the analog part :type enable: boolean :param enable: the streaming

setCalibParameters(chnIdx, scaling, vert_offset)
setDigitalCondition(*args)

Overload 1:

Set the trigger condition for the digital trigger on a specific channel :type chnIdx: int :param chnIdx: The index of the required channel :type cond: int :param cond: the specific trigger condition


Overload 2:

Set the trigger condition for the digital trigger on a specific channel :type chnIdx: int :param chnIdx: An enumerator corresponding to the index of the required channel :type cond: int :param cond: the specific trigger condition

setDigitalDelay(delay)

Set the digital trigger delay :type delay: int :param delay: the value of the digital delay

Notes: the delay can have negative values The negative values are used to place the trigger inside the buffer The value of the delay represents the number of samples in buffer before the triggered sample If the value is 0, the triggered sample will be the first one in the buffer For a buffer of 1000 samples, in order to have the trigger at the middle, you need to set it to -500 The minimum negative value is -8192

the delay can have positive values TBD

setDigitalExternalCondition(cond)
Parameters:

cond (int) – : M2K_TRIGGER_CONDITION_DIGITAL

setDigitalMode(mode)

Set the mode for the digital trigger :type mode: int :param mode: the digital trigger mode (DIO_OR/DIO_AND)

setDigitalSource(external_src)

Select which interface triggers the DigitalIn. :type external_src: int :param external_src:: of type M2K_TRIGGER_SOURCE_DIGITAL:

SRC_TRIGGER_IN - trigger events on the TI(trigger in) pin trigger the DigitalIn interface;

SRC_ANALOG_IN - trigger events on the AnalogIn interface trigger the DigitalIn interface;

SRC_NONE - trigger events on the DigitalIn are conditioned by the internal digital trigger structure;

Notes: Only available from firmware v0.24.

setDigitalStreamingFlag(enable)

Set the streaming flag for the digital part :type enable: boolean :param enable: the streaming

Notes: The digital condition needs to be set before setting the digital streaming flag to true, otherwise after setting the streaming flag to true, a trigger might occur on the old condition.

setHwTriggerSettings(settings)
property thisown

The membership flag

class libm2k.M2kModes(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.M2kPowerSupply(*args, **kwargs)

Bases: object

anyChannelEnabled()

Check if there is at least one enabled channel

Return type:

boolean

Returns:

On succes, true

Return type:

boolean

Returns:

Otherwise, false

enableAll(en)

Enable or disable all channels

Parameters:

en (boolean) – A boolean value corresponding to the state of the channels

enableChannel(chn, en)

Enable or disable the given channel

Parameters:
  • chn (int) – The index corresponding to the channel

  • en (boolean) – A boolean value corresponding to the state of the channel

powerDownDacs(powerdown)
pushChannel(chn, value, calibrated=True)

Set the voltage for the given channel

Parameters:
  • chn (int) – The index corresponding to the channel

  • value (float) – The voltage (up to 5V)

  • calibrated (boolean) – Written values are converted using the calibration coefficients from the IIO context by default; This boolean flag specifies whether the coefficients should be used.

readChannel(chn, calibrated=True)

Retrieve the value of a given channel

Parameters:
  • chn (int) – The index corresponding to the channel

  • calibrated (boolean) – Read values are converted using the calibration coefficients from the IIO context by default; This boolean flag specifies whether the coefficients should be used.

Return type:

float

Returns:

double The voltage transmitted by the given channel

reset()
property thisown

The membership flag

libm2k.NO_SOURCE = 9

NO_SOURCE - block the AnalogIn interface

class libm2k.PairDD(*args)

Bases: object

property first
property second
property thisown

The membership flag

libm2k.SELECT_ANALOG_IN = 3

SELECT_ANALOG_IN - forwards trigger events from AnalogIn interface

libm2k.SELECT_DIGITAL_IN = 4

SELECT_DIGITAL_IN - forwards trigger events from DigitalIn interface

libm2k.SELECT_NONE = 0

SELECT_NONE - no trigger event is forwarded

libm2k.SELECT_TRIGGER_IN = 2

SELECT_TRIGGER_IN - forwards trigger events from TI pin(trigger in)

class libm2k.SETTINGS

Bases: object

Triggering system

property analog_condition

Analogical trigger’s condition

property delay

Trigger’s delay

property digital_condition

Digital trigger’s condition

property hysteresis

Trigger’s hysteresis

property level

Trigger’s level

property mode

Triggering mode

property raw_level

Trigger’s raw level

property thisown

The membership flag

property trigger_source

Triggering source

libm2k.SRC_ANALOG_IN = 1

SRC_ANALOG_IN - trigger events on the AnalogIn interface trigger the DigitalIn interface

libm2k.SRC_DIGITAL_IN = 5

SRC_DIGITAL_IN - trigger events on the DigitalIn interface trigger the AnalogIn interface

libm2k.SRC_DISABLED = 3

SRC_DISABLED - block the DigitalIn interface

libm2k.SRC_NONE = 2

SRC_NONE - trigger events on the DigitalIn are conditioned by the internal digital trigger structure

libm2k.SRC_TRIGGER_IN = 0

SRC_TRIGGER_IN - trigger events on the TI(trigger in) pin trigger the DigitalIn interface

class libm2k.SwigPyIterator(*args, **kwargs)

Bases: object

advance(n)
copy()
decr(n=1)
distance(x)
equal(x)
incr(n=1)
next()
previous()
property thisown

The membership flag

value()
class libm2k.VectorCtxInfo(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorD(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorI(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorPairDD(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorS(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorStr(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorUS(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorVectorD(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorVectorI(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorVectorS(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.VectorVectorUS(*args)

Bases: object

append(x)
assign(n, x)
back()
begin()
capacity()
clear()
empty()
end()
erase(*args)
front()
get_allocator()
insert(*args)
iterator()
pop()
pop_back()
push_back(x)
rbegin()
rend()
reserve(n)
resize(*args)
size()
swap(v)
property thisown

The membership flag

class libm2k.channel

Bases: object

property m_channel

A pointer to an iio_channel structure

property m_direction

The direction of the channel

property thisown

The membership flag

libm2k.contextClose(ctx, deinit=True)

Destroy the given context :type ctx: Context :param ctx: The context to be destroyed :type deinit: boolean :param deinit: If deinit is set to false, running contexts won’t be affected

libm2k.contextCloseAll()

Close all the devices

libm2k.contextOpen(*args)

Overload 1:


Overload 2:


Overload 3:

libm2k.enableLogging(enable)

Enable/disable the logging system :type enable: boolean :param enable: If true enable, otherwise disable

libm2k.getAllContexts()

List all available contexts :rtype: std::vector< std::string,std::allocator< std::string > > :return: A list containing the available contexts

libm2k.getContextsInfo()

List the information about all available contexts :rtype: std::vector< libm2k::CONTEXT_INFO *,std::allocator< libm2k::CONTEXT_INFO * > > :return: A list containing the info about available contexts

libm2k.getVersion()

Get library version :rtype: string :return: a string containing the libm2k version

class libm2k.ini_device_struct

Bases: object

property hw_name
property key_val_pairs
property thisown

The membership flag

libm2k.m2kOpen(*args)

Overload 1:

Open an ADALM2000 based on a given uri :type uri: string :param uri: Describe the location of the context :rtype: M2k :return: M2k object or nullptr if no ADALM2000 was found/available

Notes: the uri can be something similar to: “ip:192.168.2.1” or “usb:1.6.5”


Overload 2:

Open an ADALM2000 based on an existing iio_context and uri :type ctx: iio_context :param ctx: A pointer to an iio_context structure :type uri: string :param uri: Describe the location of the context :rtype: M2k :return: M2k object or nullptr if no ADALM2000 was found/available

Notes: the uri can be something similar to: “ip:192.168.2.1” or “usb:1.6.5”


Overload 3:

Open an ADALM2000 :rtype: M2k :return: M2k object or nullptr if no ADALM2000 was found/available

Notes: this will try to open USB connected devices

class libm2k.m2k_exception(*args, **kwargs)

Bases: object

file()
iioCode()
line()
static make(what)
property thisown

The membership flag

type()
what()
class libm2k.m2k_exception_builder(*args)

Bases: object

build()
file(fileName)
iioCode(code)
line(lineNumber)
property thisown

The membership flag

type(type)
libm2k.m2k_exception_make(what)
libm2k.throw_exception(exception)