Device controller#

The device controller manages devices that are supported by samna. Methods are provided to list/open/close devices.

The details of the device controller APIs can be find in samna.device.

Note samna only supports devices with USB-C cables which are USB 3.0 capable.

Examples#

There are two ways to open a device.

The first one is to get a DeviceInfo object if you are not sure what boards are connected.

# Get device infos of all unopened devices
deviceInfos = samna.device.get_unopened_devices()

# Print device infos to see what devices are connected
for info in deviceInfos:
    print(info)

# Select the device you want to open, here we want to open the first one
device = samna.device.open_device(deviceInfos[0])

The second way to open a device is using a string of format NAME[:INDEX]. This is helpful if you want to open a specific type of device. The optional index is used to select a specific device if multiple of the same type are connected. Without the index argument, the next available device of this type is opened.

# Here we open the first DynapcnnDevKit
device = samna.device.open_device("DynapcnnDevKit:0")

Please refer to the supported device name column of table in Discover supported devices for the supported device names of the second approach.

Devices can only be opened once on a machine. Devices opened in other processes can not be opened again in this process.

Multiple calls to open a device using the same DeviceInfo or the same name and index string will return the previously opened device. However, multiple calls using the same name without index will not open previously opened devices, but the next available one instead. When no devices are available a runtime error is raised.

Devices can be closed again using the returned device object when opening the device. After the device is closed, all actions on that device are invalid and should not be called.

# Close the device
samna.device.close_device(device)

# Device handle can not be used anymore
# device.get_model()