9. 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.

9.1. Examples

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

9.1.1. Example 1

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

from typhoon.api.device_manager import device_manager

# specify HIL devices serial numbers
hil_device_1 = "604-01-00001"
hil_device_2 = "604-01-00002"
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-01-00002" serial number
device_manager.remove_devices(hil_device_2)

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

Script output:

9.1.2. Example 2

This example illustrates loading an existing setup and connecting it.

from typhoon.api.device_manager import device_manager

# 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=None)

Add devices to active setup.

Parameters:

devices (list) – devices to add.

Returns:

True if device is successfully added to setup, otherwise returns False.

Return type:

status (bool)

add_discovery_ip_addresses(addresses=None)

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 device IP is successfully added to the THCC address store, otherwise returns False.

Return type:

status (bool)

connect_setup()

Connect currently selected HIL setup. Make all devices in the selected setup inaccessible to others.

Returns:

True if all the devices from the setup are available, otherwise returns False.

Return type:

status (bool)

Note

If any of the devices from the setup has a status (busy/not online), the execution of this function will return False

disconnect_setup()

Disconnect currently selected HIL setup. Make all devices in the selected setup accessible to others.

Returns:

True if the disconnection is performed successfully from all devices in the setup, 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)

Format of one dictionary that holds HIL configurations.

Dictionary key

Meaning

Value Type

“device_name”

HIL Device name (device_name1, device_name2)

int value

“static_ip_address”

HIL static IP (192.168.0.1, 192.168.0.2…)

string value

“gateway”

HIL gateway

str value

“force_usb”

(True, False)

bool value

“heartbeat_timeout”

Define time for heartbeat timeout (in secounds)

int value

“usb_init_timeout”

Define time for usb init timeout (in secounds)

int value

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 setup is currently connected, 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=None)

Remove devices from active setup.

Parameters:

devices (list) – devices to remove.

Returns:

True if device is successfully removed from setup, otherwise returns False.

Return type:

status (bool)

remove_discovery_ip_addresses(addresses=None)

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 device IP is successfully removed from the THCC address store, otherwise returns False.

Return type:

status (bool)

set_device_settings(device_serial, settings=None)

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’}

Returns:

True if the passed settings have been successfully written to the device, otherwise returns False.

Return type:

status (bool)

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