SmartWaveAPI package

Module contents

An API for Semify’s SmartWave.

Subpackages

Submodules

SmartWaveAPI.smartwave module

class SmartWaveAPI.smartwave.SmartWave

Bases: object

An instance of a SmartWave device. Keeps track of all available resources.

FPGAClockSpeed: int = 100000000.0
PID: int = 32881
VID: int = 9025
connect(portName: str = None, reset: bool = True, requestInfo: bool = True)

Try to connect to a SmartWave device at the specified port.

Parameters:
  • portName (str) – The name of the port to connect to

  • reset (bool) – Reset the device after connection

  • requestInfo (bool) – Request info from the device after connection

Returns:

Self

Return type:

SmartWave

Raises:
  • ConnectionRefusedError – If no connection could be established with the specified port

  • AttributeError – If the device at the specified port is not a SmartWave device

createI2CConfig(sdaPinName: str | None = None, sclPinName: str | None = None, clockSpeed: int | None = None) I2CConfig

Create an I2C Configuration object.

Parameters:
  • sdaPinName (str) – The name of the pin to use for SDA

  • sclPinName (str) – The name of the pin to use for SCL

  • clockSpeed (int) – The I2C clock speed in Hz

Returns:

An I2C Configuration with the specified settings

Return type:

I2CConfig

disconnect()

Disconnect from the connected device.

getNextAvailableI2CDriver() I2CDriver

Get the next available I2C Driver.

Returns:

An I2C Driver, which has already been marked as in use

Return type:

I2CDriver

Raises:

Exception – If no more I2C Drivers are available on the device

getNextAvailablePin() Pin

Get the next available Pin.

Returns:

A Pin, which has already been marked as in use

Return type:

Pin

Raises:

Exception – If no more Pins are available on the device

getNextAvailableStimulus() Stimulus

Get the next available stimulus.

Returns:

A Stimulus, which has already been marked as in use

Return type:

Stimulus

Raises:

Exception – If no more Stimuli are available on the device

getPin(name: str) Pin

Get a pin by its name.

Parameters:

name (str) – The pin’s name

Returns:

The specified pin, which has already been marked as in use

Return type:

Pin

Raises:
  • AttributeError – If the pin name does not exist on the device

  • Exception – If the pin is already in use

isConnected() bool

Return whether a device connection is currently active.

Returns:

True if the device is connected, False otherwise

readFPGARegister(address: int, blocking: bool = True) int | None

Read directly from a register on the SmartWave’s FPGA.

Parameters:
  • address (int) – The address to read from

  • blocking (bool) – If true, wait for the response from the connected device

Returns:

If blocking == True, return the content of the specified register. Else return None.

Return type:

Union[int, None]

Raises:

Exception – If the blocking mode is requested and another callback for a register read operation is already registered

removeConfig(config: Config)

Remove a config from the device.

Parameters:

Config – the config to remove

Raises:

AttributeError – If the config is not found

requestInfo()

Request the device information from the connected device.

reset()

Reset the configuration of the connected device.

returnI2CDriver(driver: I2CDriver) int

Return an I2C Driver to the list of available I2C Drivers.

Parameters:

driver (I2CDriver) – The I2C driver to return

Returns:

The new number of available I2C Drivers

Return type:

int

returnPin(pin: Pin) int

Return a Pin to the list of available pins.

Parameters:

pin (Pin) – The pin to return

Returns:

The new number of available pins

Return type:

int

returnStimulus(stimulus: Stimulus) int

Return a stimulus to the list of available stimuli.

Parameters:

stimulus (Stimulus) – The stimulus to return

Returns:

The new number of available stimuli

Return type:

int

scanAndConnect(reset: bool = True, requestInfo: bool = True)

Scan all serial ports on the PC and connect to a SmartWave device if one is found.

Parameters:
  • reset (bool) – Reset the device after connection

  • requestInfo (bool) – Request info from the device after connection

Returns:

Self

Return type:

SmartWave

Raises:

ConnectionRefusedError – If no suitable device is found

trigger()

Start or Stop the current configuration on the connected device.

writeFPGARegister(address: int, value: int)

Write directly to a register on the SmartWave’s FPGA.

Parameters:
  • address (int) – The address to write to

  • value (int) – The value to write

writeToDevice(data: bytes, acquireLock: bool = True)

Write bare data to the connected device.

Parameters:

data (bytes) – the data to write

Raises:

Exception – If the serial connection is not active