unitelabs.bus.utils.autodetect

Classes

  • TransportType

    Bases
    enum.Enum

    Attributes

    • Name
      serial
      Type
      Value

      = enum.auto()

      Description

    • Name
      usb
      Type
      Value

      = enum.auto()

      Description

    • Name
      unknown
      Type
      Value

      = enum.auto()

      Description

  • AutoDetector

    This class is used by the `unitelabs.bus.Protocol` to cycle through possible devices until the correct device is found.

    Methods

    • __init__(
        self,
        **kwargs
      ) -> None

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        protocol
        Type
        Protocol
        Default
        Description

        The `unitelabs.bus.Protocol` instance to use.

      • Name
        **kwargs
        Type
        Default
        = {}
        Description

        Kwargs used to initialize the `Protocol` instance, which contains `Transport` init kwargs.

    • get_transport_type(self) -> None

      Infer the type of the transport based on the `protocol._transport_factory` which stores the `TransportFactory` used to initialize the `Protocol`. This allows the differential initialization of new transport instances based on `DeviceInfo`.

    • get_device_manager(self) -> type[DeviceManager]

      Get the correct `DeviceManager` based on the `TransportType`.

      Response

      Type
      type[DeviceManager]
      Description

    • resolve(
        self,
        validation_timeout : float,
        **validation_kwargs
      ) -> None

      User entry-point. Iterates through all available devices until a connection is successfully made, or all available devices have been tested. If no valid connection can be found, calls to `protocol.connection_lost` to pass control back to `protocol`.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        validation_timeout
        Type
        float
        Default
        Description

        How long in seconds to wait for a response from `Protocol.validate`.

      • Name
        **validation_kwargs
        Type
        Default
        = {}
        Description

        kwargs from `Protocol.validate` used to validate the connection.

    • _connect(
        self,
        validation_timeout : float,
      ) -> bool

      Updates the `transport` on the `protocol` and attempts to open said `transport` and validate the connection using `Protocol.validate`.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        validation_timeout
        Type
        float
        Default
        Description

        How long in seconds to wait for a response from `Protocol.validate`.

      • Name
        device
        Type
        DeviceInfo
        Default
        Description

        The device to which we wish to attempt to validate a connection.

      Response

      Type
      bool
      Description

      Whether or not the connection was successfully made and validated.

    • _update_protocol_transport(self, device : DeviceInfo) -> None

      Update the `Protocol`s underlying `Transport` to connect to the given `device`.

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        device
        Type
        DeviceInfo
        Default
        Description

        The `DeviceInfo` of the new device to connect the `Protocol` to.

    Attributes

    • Name
      _transport_type
      Type
      TransportType
      Value

      = None

      Description

    • Name
      protocol
      Type
      Value

      = protocol

      Description

    • Name
      _transport_kwargs
      Type
      Value

      = kwargs

      Description

    • Name
      _device_manager
      Type
      Value

      = None

      Description

    • Name
      _validation_kwargs
      Type
      Value

      = kwargs

      Description

    • Name
      _is_resolving
      Type
      Value

      = False

      Description

    • Name
      logger
      Type
      logging.Logger
      Value

      = None

      Description

    • Name
      device_manager
      Type
      type[DeviceManager]
      Value

      = None

      Description

    • Name
      is_resolving
      Type
      bool
      Value

      = None

      Description

      Whether or not we are currently trying to connect to a device

Copyright © 2024