Discovery¶
A module that provides methods for discovering brainstem modules over USB and TPCIP.
The discovery module provides an interface for locating BrainStem modules accross multiple transports. It provides a way to find all modules for a give transport as well as specific modules by serial number, or first found. The result of a call to one of the discovery functions is either a list of brainstem.link.Spec objects, or a single brainstem.link.Spec.
The Discovery module allows users to find specific brainstem devices via their serial number, or a list of all devices connected to the host via usb or on the same subnet via TCP/IP. In all cases a Spec object is returned with connection details for the device. In addition do connection details, the BrainStem model is returned. This model is one of a list of BrainStem device model numbers which are accessible via the defs module.
A typical interactive python session finding all connected USB modules might look like the following.
>> import brainstem >> module_list = brainstem.discover.findAllModules(brainstem.link.Spec.USB) >> print [str(s) for s in module_list] [‘Model: 4 LinkType: USB(serial: 0xCB4A3B25, module: 0)’, ‘Model: 13 LinkType: USB(serial: 0x40F5849A, module: 0)’]
For an overview of links, discovery and the Brainstem network see the Acroname BrainStem Reference
- class brainstem.discover.DeviceNode[source]¶
- Python representation of DeviceNode_t (C structure)
hub_serial_number (uint32_t): Serial number of the Acroname hub where the device was found.
hub_port (uint8_t): Port of the Acroname hub where the device was found.
id_vendor (uint16_t): Manufactures Vendor ID of the downstream device.
id_product (uint16_t): Manufactures Product ID of the downstream device.
- speed (enumeration): The devices downstream device speed.
Unknown (0)
Low Speed (1)
Full Speed (2)
High Speed (3)
Super Speed (4)
Super Speed Plus (5)
product_name (string): USB string descriptor.
manufacture (string): USB string descriptor.
serial_number (string): USB string descriptor.
- brainstem.discover.findAllModules(transports, aether_config=<brainstem.link.aEtherConfig object>, buffer_length=128)[source]¶
Return a list of Specs for all modules found on the transports given.
Transports can be presented as a list, and the results would be a list of all modules found for those transports. TCPIP modules take a little longer to find due to the Multicast and gather necessary for finding modules on the local network segment.
- Parameters:
transports (int or list(int)) – A list of transports or a single transport.
- Returns:
A list of the Spec objects for all modules found.
- Return type:
list(Spec)
- brainstem.discover.findFirstModule(transports, aether_config=<brainstem.link.aEtherConfig object>)[source]¶
Return the Spec for the first module found on the given transport.
- Parameters:
transports (int or list(int)) – A list of transports or a single transport.
aether_config (aEtherConfig) – Allows configuration of aEther other than the default.
- Returns:
The connection spec of the first module found on the given transport.
- Return type:
- brainstem.discover.findModule(transports, serial_number, aether_config=<brainstem.link.aEtherConfig object>)[source]¶
Return the Spec for the module with the given serial number.
Transports can be presented as a list. TCPIP modules take a little longer to find due to the Multicast and gather necessary for finding modules on the local network segment.
- Parameters:
transports (int or list(int)) – A list of transports or a single transport.
serial_number (unsigned int) – The module serial_number to look for.
- Returns:
The connection spec for the module whose serial number is given in the args.
- brainstem.discover.getDownstreamDevices(list_length=128)[source]¶
Gets downstream device USB information for all Acroname hubs.
- Parameters:
list_length – The amount of memory to provide for the lower level C call.
- Returns:
Result object containing NO_ERROR and a tuple of DeviceNode’s containing the detected downstream devices:: - aErrParam: Passed in values are not valid (NULL, size, etc). - aErrMemory: No more room in the list. - aErrNotFound: No Acroname devices were found.
- Return type: