unitelabs.bus.factories

Packages

Attributes

  • Name
    __all__
    Type
    Value

    = [ "create_serial_connection", "TransportFactory", "create_usb_connection", "open_usb_connection" ]

    Description

Functions

  • create_serial_connection(
      protocol_factory : typing.Callable[..., P],
      port : str,
      baudrate : int,
      **kwargs
    ) -> tuple[Transport, P]

    Create a serial connection with the specified port.

    Parameters

    • Name
      protocol_factory
      Type
      typing.Callable[..., P]
      Default
      Description

      A callable that returns an instance of the protocol to be used.

    • Name
      port
      Type
      str
      Default
      Description

      The port of the serial device.

    • Name
      baudrate
      Type
      int
      Default
      = 9600
      Description

    • Name
      bytesize
      Type
      ByteSize
      Default
      = EIGHTBITS
      Description

    • Name
      parity
      Type
      Parity
      Default
      = NONE
      Description

    • Name
      stopbits
      Type
      StopBits
      Default
      = ONE
      Description

    • Name
      **kwargs
      Type
      Default
      = {}
      Description

      Additional keyword arguments to be passed to the `SerialTransport` constructor.

    Response

    Type
    tuple[Transport, P]
    Description

    A tuple containing the `SerialTransport` instance and the `Protocol` instance.

  • create_usb_connection(
      protocol_factory : typing.Callable[..., P],
      vendor : int,
      product : int,
      **kwargs
    ) -> tuple[Transport, P]

    Create a USB connection with a device based on specified `vendor` and `product` IDs.

    Parameters

    • Name
      protocol_factory
      Type
      typing.Callable[..., P]
      Default
      Description

      A callable that returns an instance of the protocol to be used.

    • Name
      vendor
      Type
      int
      Default
      Description

      The vendor ID of the USB device.

    • Name
      product
      Type
      int
      Default
      Description

      The product ID of the USB device.

    • Name
      **kwargs
      Type
      Default
      = {}
      Description

      Additional keyword arguments to be passed to the `UsbTransport` constructor.

    Response

    Type
    tuple[Transport, P]
    Description

    A tuple containing the `UsbTransport` instance and the protocol instance.

  • open_usb_connection(
      vendor : int,
      product : int,
      **kwargs
    ) -> tuple[asyncio.streams.StreamReader, asyncio.streams.StreamWriter]

    Establish a USB connection with a device based on specified `vendor` and `product` IDs.

    Parameters

    • Name
      vendor
      Type
      int
      Default
      Description

      The vendor ID of the USB device.

    • Name
      product
      Type
      int
      Default
      Description

      The product ID of the USB device.

    • Name
      **kwargs
      Type
      Default
      = {}
      Description

      Additional keyword arguments to be passed to the `UsbTransport` constructor.

    Response

    Type
    tuple[asyncio.streams.StreamReader, asyncio.streams.StreamWriter]
    Description

    A tuple containing the `asyncio.streams.StreamReader` and `asyncio.streams.StreamWriter` instances for the USB connection.

Classes

  • TransportFactory

    Interface representing a factory for creating transports.

    Bases
    typing.Protocol

    Methods

    • __call__(
        self,
        protocol_factory : typing.Callable[..., P],
        **kwargs
      ) -> tuple[Transport, P]

      Parameters

      • Name
        self
        Type
        Default
        Description

      • Name
        protocol_factory
        Type
        typing.Callable[..., P]
        Default
        Description

      • Name
        **kwargs
        Type
        Default
        = {}
        Description

      Response

      Type
      tuple[Transport, P]
      Description

Copyright © 2024