Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""This module provides Python bindings for the Discovery API of DGILib."""
"""Python bindings for DGILib Discovery.
DGILib is a Dynamic-Link Library (DLL) to help software applications communicate with Data Gateway Interface (DGI) devices. See the Data Gateway Interface user guide for further details. DGILib handles the low-level USB communication and adds a level of buffering for minimizing the chance of overflows.
TODO? 2.1.1. initialize_status_change_notification Initializes the system necessary for using the status change notification callback mechanisms. A handle will be created to keep track of the registered callbacks. This function must always be called before registering and unregistering notification callbacks. Function definition void initialize_status_change_notification(uint32_t* handlep) Parameters handlep Pointer to a variable that will hold the handle 2.1.2. uninitialize_status_change_notification Uninitializes the status change notification callback mechanisms. This function must be called when shutting down to clean up memory allocations. Function definition void uninitialize_status_change_notification(uint32_t handle) Parameters handle Handle to uninitialize 2.1.3. register_for_device_status_change_notifications Registers provided function pointer with the device status change mechanism. Whenever there is a change (device connected or disconnected) the callback will be executed. Note that it is not allowed to connect to a device in the context of the callback function. The callback function has the following definition: typedef void (*DeviceStatusChangedCallBack)(char* device_name, char* device_serial, BOOL connected) Function definition void register_for_device_status_change_notifications(uint32_t handle, DeviceStatusChangedCallBack deviceStatusChangedCallBack) Parameters handle Handle to change notification mechanisms deviceStatusChangedCallBack Function pointer that will be called when the devices change 2.1.4. unregister_for_device_status_change_notifications Unregisters previously registered function pointer from the device status change mechanism. Function definition void unregister_for_device_status_change_notifications(uint32_t handle, DeviceStatusChangedCallBack deviceStatusChangedCallBack) Parameters handle Handle to change notification mechanisms deviceStatusChangedCallBack Function pointer that will be removed
"""
"""`discover`.
Triggers a scan to find available devices in the system. The result will be immediately available through the `get_device_count`, `get_device_name` and `get_device_serial` functions.
`void discover(void)` """
"""`get_device_count`.
Returns the number of devices detected.
`int get_device_count(void)`
:return: The number of devices detected :rtype: int """
"""`get_device_name`.
Gets the name of a detected device.
`int get_device_name(int index, char* name)`
+------------+------------+ | Parameter | Description | +============+============+ | *index* | Index of device ranges from 0 to `get_device_count` - 1 | | *name* | Pointer to buffer where name of device can be stored. 100 or more bytes must be allocated | +------------+------------+
:param index: Index of device ranges from 0 to `get_device_count` - 1 :type index: int :return: The name of a detected device :rtype: str :raises: :exc:`DeviceReturnError` """ raise DeviceReturnError(f"get_device_name returned: {res}")
"""`get_device_serial`.
Gets the serial number of a detected device.
`int get_device_serial(int index, char* sn)`
+------------+------------+ | Parameter | Description | +============+============+ | *index* | Index of device ranges from 0 to `get_device_count` - 1 | | *sn* | Pointer to buffer where the serial number of the device can be stored. 100 or more bytes must be allocated. This is used when connecting to a device | +------------+------------+
:param index: Index of device ranges from 0 to `get_device_count` - 1 :type index: int :return: The serial number of a detected device :rtype: str :raises: :exc:`DeviceReturnError` """ raise DeviceReturnError(f"get_device_serial returned: {res}")
"""`is_msd_mode`.
EDBG devices can be set to a mass storage mode where the DGI is unavailable. In such cases the device is still detected by DGILib, but it won't be possible to directly connect to it. This command is used to check if the device is in such a mode.
A non-zero return value indicates that the mode must be changed by `set_mode` before proceeding.
`int is_msd_mode(char* sn)`
+------------+------------+ | Parameter | Description | +============+============+ | *sn* | Serial number of the device to check | +------------+------------+
:param device_sn: Serial number of the device to check (defaults to self.device_sn) :type device_sn: str or None :return: A non-zero return value indicates that the mode must be changed by `set_mode` before proceeding. :rtype: int """
"""`set_mode`.
This function is used to temporarily set the EDBG to a specified mode.
`int set_mode(char* sn, int nmbed)`
+------------+------------+ | Parameter | Description | +============+============+ | *sn* | Serial number of the device to set | | *nmbed* | 0 - Set to mbed mode. 1 - Set to DGI mode | +------------+------------+
:param device_sn: Serial number of the device to set :type device_sn: str :param nmbed: 0 - Set to mbed mode. 1 - Set to DGI mode (defaults to DGI mode) :type nmbed: int :raises: :exc:`DeviceReturnError` """ if self.verbose: print(f"\t{res} set_mode {nmbed}") if res: raise DeviceReturnError(f"set_mode returned: {res}") |