Ejemplo n.º 1
0
 def __init__(self, comms_address, baudrate=115200):
     secondary_address = usb_utils.get_serial_number_from_path(
         comms_address)
     super(JlinkSerialComms,
           self).__init__(comms_address=comms_address,
                          secondary_address=secondary_address,
                          baudrate=baudrate)
Ejemplo n.º 2
0
def _usb_serial_number_from_serial_port_path(
    address: str, detect_logger: logging.Logger,
    create_switchboard_func: Callable[..., switchboard_base.SwitchboardBase]
) -> str:
    """Gets serial number from serial port path."""
    del create_switchboard_func  # Unused

    serial_number = usb_utils.get_serial_number_from_path(address)
    detect_logger.info("_usb_serial_number_from_serial_port_path response: "
                       f"{serial_number}")
    return serial_number
    def get_detection_info(self) -> Tuple[Dict[str, str], Dict[str, str]]:
        """Gets the persistent and optional attributes of a device during setup.

    Returns:
      Dictionary of persistent attributes and dictionary of
      optional attributes.
    """
        persistent_dict = self.props["persistent_identifiers"]
        address = persistent_dict["console_port_name"]
        persistent_dict["serial_number"] = (
            usb_utils.get_serial_number_from_path(address))
        persistent_dict["model"] = "PROTO"
        return persistent_dict, {}
Ejemplo n.º 4
0
    def get_detection_info(self):
        """Gets the persistent and optional attributes of a Cambrionix.

    Returns:
      tuple: (Dict of persistent attributes, dict of optional attributes)

    Raises:
      DeviceError: if device model is not supported.

    Notes:
      persistent: model,
                  hub_port_name,
                  console_port_name,
                  total_ports,
                  ftdi_serial_number,
                  serial_number

      optional:   empty dict
    """
        persistent_dict = self.props["persistent_identifiers"]
        persistent_dict["model"] = self._get_system_hardware()
        if persistent_dict["model"] not in usb_config.CAMBRIONIX_PORT_MAP:
            raise errors.DeviceError(
                "Model {} not supported. Supported models: {}".format(
                    persistent_dict["model"],
                    ",".join(usb_config.CAMBRIONIX_PORT_MAP.keys())))
        persistent_dict["hub_port_name"] = self.communication_address
        persistent_dict["console_port_name"] = self.communication_address
        persistent_dict["total_ports"] = self.total_ports
        persistent_dict[
            "ftdi_serial_number"] = usb_utils.get_serial_number_from_path(
                self.communication_address)

        # Cambrionix does not have a separate serial number from the one shown
        # in the /dev/serial/by-id/... name.
        persistent_dict["serial_number"] = self.props[
            "persistent_identifiers"]["ftdi_serial_number"]

        self.props["options"] = {}

        return persistent_dict, self.props["options"]
Ejemplo n.º 5
0
 def __init__(self, comms_address: str, baudrate: int = 115200) -> None:
     super().__init__(comms_address)
     self.secondary_address = usb_utils.get_serial_number_from_path(
         comms_address)
     self.baudrate = baudrate