plestylib.traffic.serial
========================

.. py:module:: plestylib.traffic.serial


Classes
-------

.. autoapisummary::

   plestylib.traffic.serial.SerialTrafficManager


Module Contents
---------------

.. py:class:: SerialTrafficManager(port, baudrate=9600, timeout=5, write_termination='\r', read_termination='\r\n')

   Bases: :py:obj:`plestylib.traffic.TrafficManager`


   A TrafficManager implementation for managing serial communication.

   This class provides methods to open, close, and communicate with serial devices.

   Initialize the SerialTrafficManager with the given port, baudrate, timeout, and termination characters.

   :param port: The serial port to connect to (e.g., 'COM3' or '/dev/ttyUSB0').
   :type port: str
   :param baudrate: The baud rate for the serial communication. Defaults to 9600.
   :type baudrate: int, optional
   :param timeout: The timeout for serial operations in seconds. Defaults to 5.
   :type timeout: float, optional
   :param write_termination: Termination suffix appended on write.
                             Default is carriage return.
   :type write_termination: str, optional
   :param read_termination: Termination sequence used when reading
                            responses. Default is carriage return plus newline.
   :type read_termination: str, optional


   .. py:attribute:: port


   .. py:attribute:: baudrate
      :value: 9600



   .. py:attribute:: write_termination
      :value: '\r'



   .. py:attribute:: read_termination
      :value: Multiline-String

      .. raw:: html

         <details><summary>Show Value</summary>

      .. code-block:: python

         """
         """

      .. raw:: html

         </details>




   .. py:method:: _open(baudrate: int = None, timeout: float = None, parity: str = None, stopbits: str = None, bytesize: int = None)

      Open the serial connection with the specified parameters.

      :param baudrate: The baud rate for the serial communication. Defaults to the instance's baudrate.
      :type baudrate: int, optional
      :param timeout: The timeout for serial operations in seconds. Defaults to the instance's timeout.
      :type timeout: float, optional
      :param parity: The parity for the serial communication. Must be 'none', 'even', or 'odd'. Defaults to None.
      :type parity: str, optional
      :param stopbits: The stop bits for the serial communication. Must be 'one'. Defaults to None.
      :type stopbits: str, optional
      :param bytesize: The byte size for the serial communication. Must be 8. Defaults to None.
      :type bytesize: int, optional



   .. py:method:: _clear_buffer()

      Clear the input and output buffers of the serial connection.



   .. py:method:: _waite_for_response(timeout=None)

      Wait for a response from the device until the expected termination is received or timeout occurs.



   .. py:method:: _send_command(command: str, timeout=None) -> Any

      Send a command to the device and wait for the response.

      :param command: The command to send to the device.
      :type command: str
      :param timeout: The timeout for waiting for the response. Defaults to the instance's timeout.
      :type timeout: float, optional

      :returns: The response from the device, or False if the command failed or timed out.
      :rtype: Any



   .. py:method:: _close()

      Close the serial connection.



