libsmu
1.0.4
Library for interfacing with ADALM1000 devices
|
Generic device class. More...
#include <libsmu.hpp>
Public Member Functions | |
virtual const sl_device_info * | info () const =0 |
Get the descriptor for the device. | |
virtual const sl_channel_info * | channel_info (unsigned channel) const =0 |
Get the descriptor for the specified channel. More... | |
virtual Signal * | signal (unsigned channel, unsigned signal)=0 |
Get the specified signal. More... | |
virtual int | fwver_sem (std::array< unsigned, 3 > &components)=0 |
Get the array of firmware version components (major, minor, patch). Note that this method assumes semantic versioning so versions such as 2.06 will be coerced to 2.6.0, i.e. major=2, minor=6, patch=0. | |
virtual int | set_serial (std::string serial="")=0 |
Set a custom serial number for the device. More... | |
virtual int | set_mode (unsigned channel, unsigned mode, bool restore=true)=0 |
Set the mode of the specified channel. More... | |
virtual int | get_mode (unsigned channel)=0 |
Get the mode of the specified channel. More... | |
virtual ssize_t | read (std::vector< std::array< float, 4 >> &buf, size_t samples, int timeout=0, bool skipsamples=false)=0 |
Get all signal samples from a device. More... | |
virtual int | write (std::vector< float > &buf, unsigned channel, bool cyclic=false)=0 |
Write data to a specified channel of the device. More... | |
virtual void | flush (int channel, bool read=false)=0 |
Flush the read and selected channel write queue for a device. More... | |
int | ctrl_transfer (unsigned bmRequestType, unsigned bRequest, unsigned wValue, unsigned wIndex, unsigned char *data, unsigned wLength, unsigned timeout) |
Perform a raw USB control transfer on the underlying USB device. More... | |
virtual int | samba_mode ()=0 |
Force the device into SAM-BA bootloader mode. More... | |
virtual int | get_default_rate () |
Get the default sample rate. | |
virtual int | sync ()=0 |
Prepare multi-device synchronization. Get current microframe index, set m_sof_start to be time in the future. More... | |
virtual void | lock () |
Lock the device's mutex. This prevents this device's transfers from being processed. Hold only briefly, while modifying signal state. | |
virtual void | unlock () |
Unlock the device's mutex. Allows this device's transfers to be processed. | |
virtual int | write_calibration (const char *cal_file_name) |
Write the device calibration data into the EEPROM. More... | |
virtual int | read_calibration ()=0 |
Read device calibration data from the EEPROM. | |
virtual void | calibration (std::vector< std::vector< float >> *cal)=0 |
Get the device calibration data from the EEPROM. More... | |
virtual int | set_led (unsigned leds)=0 |
Set the leds states for device. More... | |
virtual int | set_adc_mux (unsigned adc_mux)=0 |
set adc mux mode | |
Public Attributes | |
const std::string | m_hwver |
hardware version | |
const std::string | m_fwver |
firmware version | |
const std::string | m_serial |
serial number | |
int | m_overcurrent = 0 |
Session this device is associated with. More... | |
Protected Member Functions | |
Device (Session *s, libusb_device *usb_dev, libusb_device_handle *usb_handle, const char *hw_version, const char *fw_version, const char *serial) | |
Device constructor. | |
virtual int | claim () |
Device claiming and initialization when a session adds this device. More... | |
virtual int | release () |
Device releasing when a session removes this device. More... | |
virtual int | configure (uint32_t sampleRate)=0 |
Configurization and initialization for device sampling. More... | |
virtual int | on ()=0 |
Turn on power supplies and clear sampling state. More... | |
virtual int | off ()=0 |
Stop any current sample writes and stop capturing samples. More... | |
virtual int | run (uint64_t samples)=0 |
Make the device start sampling. More... | |
virtual int | cancel ()=0 |
Cancel all pending libusb transactions. More... | |
Protected Attributes | |
Session *const | m_session |
Session this device is associated with. | |
libusb_device *const | m_usb_dev = NULL |
Underlying libusb device. | |
libusb_device_handle * | m_usb = NULL |
Underlying libusb device handle. | |
uint64_t | m_requested_sampleno = 0 |
Cumulative sample number being handled for input. | |
uint64_t | m_in_sampleno = 0 |
Current sample number being handled for input. | |
uint64_t | m_out_sampleno = 0 |
Current sample number being submitted for output. | |
double | m_write_timeout = 100 |
Amount of time in milliseconds to wait before timing out write operations, defaults to 100 ms and is based on the configured sample rate. | |
std::recursive_mutex | m_state |
Lock for transfer state. | |
Friends | |
class | Session |
Generic device class.
|
pure virtual |
Get the device calibration data from the EEPROM.
cal | A vector of vectors containing calibration values. |
|
protectedpure virtual |
Cancel all pending libusb transactions.
|
pure virtual |
Get the descriptor for the specified channel.
channel | An unsigned integer relating to the requested channel. |
|
inlineprotectedvirtual |
Device claiming and initialization when a session adds this device.
|
protectedpure virtual |
Configurization and initialization for device sampling.
sampleRate | The requested sampling rate for the device. |
int smu::Device::ctrl_transfer | ( | unsigned | bmRequestType, |
unsigned | bRequest, | ||
unsigned | wValue, | ||
unsigned | wIndex, | ||
unsigned char * | data, | ||
unsigned | wLength, | ||
unsigned | timeout | ||
) |
Perform a raw USB control transfer on the underlying USB device.
|
pure virtual |
Flush the read and selected channel write queue for a device.
channel | Channel to flush the write queues for. If -1, skip flushing write queues. |
read | Whether to flush the incoming read queue as well. |
|
pure virtual |
Get the mode of the specified channel.
channel | An unsigned integer relating to the requested channel. |
|
protectedpure virtual |
Stop any current sample writes and stop capturing samples.
|
protectedpure virtual |
Turn on power supplies and clear sampling state.
|
pure virtual |
Get all signal samples from a device.
buf | Buffer object to store sample values into. |
samples | Number of samples to read. |
timeout | Amount of time in milliseconds to wait for samples. |
skipsamples | Whether to skip the queued samples. to be available. If 0 (the default), return immediately. If -1, block indefinitely until the requested number of samples is available. |
std::system_error | of EBUSY if sample overflows have occurred. |
|
inlineprotectedvirtual |
Device releasing when a session removes this device.
|
protectedpure virtual |
Make the device start sampling.
samples | Number of samples to run before stopping. |
std::system_error | of EBUSY if sample underflows/overflows have occurred. |
|
pure virtual |
Force the device into SAM-BA bootloader mode.
|
pure virtual |
Set the leds states for device.
leds | value between [0, 7], each bit of the value represents the state of an LED (1-on 0-off) in this order (RGB or DS3,DS2,DS1 on rev F hardware) |
|
pure virtual |
Set the mode of the specified channel.
channel | An unsigned integer relating to the requested channel. |
mode | An unsigned integer relating to the requested mode. |
restore | Boolean relating to supporting saving the mode being |
|
pure virtual |
Set a custom serial number for the device.
serial | The custom serial number to set, defaults to an empty string that causes the device to reset back to its original serial number. |
|
pure virtual |
Get the specified signal.
channel | An unsigned integer relating to the requested channel. |
signal | An unsigned integer relating to the requested signal. |
|
pure virtual |
Prepare multi-device synchronization. Get current microframe index, set m_sof_start to be time in the future.
|
pure virtual |
Write data to a specified channel of the device.
buf | Buffer of samples to write to the specified channel. |
channel | Channel to write samples to. |
cyclic | Enable cyclic mode (passed buffer is looped over continuously). |
std::system_error | of EBUSY if sample underflows have occurred. |
|
inlinevirtual |
Write the device calibration data into the EEPROM.
cal_file_name | The path to a properly-formatted calibration data file to write to the device. If NULL is passed, calibration is reset to the default setting. |
int smu::Device::m_overcurrent = 0 |
Session this device is associated with.
Overcurrent status for the most recent data request. Is 1 if an overcurrent event occurred in the most recent data request, 0 otherwise.