10. Device Manager API

Module: typhoon.api.device_manager

Device Manager API set of functions/methods to manipulate current HIL setup (add or remove devices), create new ones from scratch programmaticaly and connect/disconnect current setup. This is most commonly used for creating scripts for testing and automating repetitive tasks, but its use is not restricted for these use cases only.

10.1. Examples

Following two examples illustrates how you can use Device Manager API.

10.1.1. Example 1

This example illustrates adding/removing device to setup and how to connect/disconnect current setup.


# specify HIL devices serial numbers
hil_device_1 = "604-1010101"
hil_device_2 = "604-2020202"
devices_to_add = [hil_device_1, hil_device_2]
# add devices to setup
device_manager.add_devices_to_setup(devices_to_add)
# connect HIL setup
device_manager.connect_setup()
#
# do something here with 2 connected devices
#
device_manager.disconnect_setup()

# remove device with "604-2020202" serial number
device_manager.remove_devices(hil_device_2)

# connect setup again this time only with device with serial "604-1010101"
device_manager.connect_setup()

Script output:

10.1.2. Example 2

This example illustrates loading an existing setup and connecting it.


# print all detected devices on network
print(device_manager.get_detected_devices())

device_manager.load_setup(file="C:/Users/User/Desktop/test_setup.setup")
# connect HIL setup
device_manager.connect_setup()

# print all devices from setup
print(device_manager.get_setup_devices)

# Check connection status
device_manager.is_setup_connected()

# and disconnect setup
device_manager.disconnect_setup()

Script output:

class DeviceManagerAPI
add_devices_to_setup(devices=[])

Add devices to active setup.

Parameters

devices (list) – devices to add.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

add_discovery_ip_addresses(addresses=[])

Specify addresses where HIL devices are located if auto discovery fails for some reason.

Parameters

addresses (list) – IP addresses where HIL devices are located.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

connect_setup()

Activate current selected HIL setup. Make all devices in the selected setup inaccessible to others.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

disconnect_setup()

Deactivate current selected HIL setup. Make all devices in the selected setup accessible to others.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

get_available_devices()

Get all discovered available devices.

Returns

available devices in JSON representation.

Return type

devices (list)

get_detected_devices()

Get all discovered devices.

Returns

discovered devices in JSON representation.

Return type

devices (list)

get_device_settings(device_serial)

Gets all settings from desired device. :param device_serial: device serial number. :type device_serial: str

Returns

{‘device_name’: ‘hil_name’,
’static_ip_address’: ‘’, ‘netmask’: ‘’,
’gateway’: ‘’, ‘force_usb’: ‘False’,
’heartbeat_timeout’: ‘’, ‘usb_init_timeout’: ‘’,

’ssh_enable’: ‘True’}

Return type

settings (dict)

Note

When an empty string is returned as the value of a setting, it means that the setting has a default value.

get_hil_info()

Returns information about all connected HIL devices.

Returns

list that contains dictionaries where each dictionary holds information about one connected HIL device.

In case there is no connected HIL devices None will be returned.

Return type

list

Format of one dictionary that holds HIL information.

Dictionary key

Meaning

Value Type

“device_id”

HIL Device ID (0, 1, 2…)

int value

“serial_number”

HIL Serial number (00404-00-0001, 00402-00-0001…)

string value

“configuration_id”

HIL Configuration ID (1, 2, 3…)

int value

“product_name”

HIL Product Name (HIL402, HIL602…)

string value

“firmware_release_date”

HIL Firmware Release date (in format Y-M-D)

string value

“calibration_date”

HIL Calibration date (in format Y-M-D). None will be returned if HIL is not calibrated, calibration data is wrong or calibration is not supported on connected HIL)

string value

get_setup_devices()

Get all devices from current HIL setup.

Returns

dicts with information for each devices
{“serial_number”: “some_serial”, “device_name”: “some_device_name”,

”status”: “device_stauts”}.

Return type

devices (list)

get_setup_devices_serials()

Get all devices from current HIL setup.

Returns

serial number of each device from setup.

Return type

devices (list)

is_setup_connected()

Returns current status of active HIL setup.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

load_setup(file='')

Loads HIL setup from file to Control Center.

Parameters

file (str) – Setup description.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

remove_devices_from_setup(devices=[])

Remove devices from active setup.

Parameters

devices (list) – devices to remove.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

remove_discovery_ip_addresses(addresses=[])

Remove previously added addresses where HIL devices are located if auto discovery fails for some reason.

Parameters

addresses (list) – IP addresses which you want to remove.

Returns

True if everything ok, otherwise returns False.

Return type

status (bool)

set_device_settings(device_serial, settings={})

Allows to change all device settings. :param device_serial: serial number of the desired device. :type device_serial: str :param settings: device settings by system key (setting name)

and value (desired values for the previously specified key) settings (dict): {‘device_name’: ‘hil_name’,

‘static_ip_address’: ‘’, ‘netmask’: ‘’,
‘gateway’: ‘’, ‘force_usb’: ‘False’,
‘heartbeat_timeout’: ‘’, ‘usb_init_timeout’: ‘’,

‘ssh_enable’: ‘True’}

Note

When an empty string is passed as a setting value, that setting will be set to the default value.

sync_firmware(device_to_update, configuration_id=None, force=False)

Updates or rollback the firmware of the selected device.

Parameters
  • device_to_update (str) – Serial number of the selected device.

  • configuration_id (int) – sequence number of the configuration.

  • force (boolean) – Force upload even if desired firmware is the same as the one already in HIL device

update_firmware(device_to_update, configuration_id=None, force=False)

Updates the firmware of the selected device.

Parameters
  • device_to_update (str) – Serial number of the selected device.

  • configuration_id (int) – sequence number of the configuration.

  • force (boolean) – Force upload even if desired firmware is the same as the one already in HIL device