
    Vh                     d    d Z ddlmZmZmZ ddlmZmZ ddlm	Z	  G d de	ej                        Zy)z
Serial Port Protocol
    )	EIGHTBITSPARITY_NONESTOPBITS_ONE)abstractfdesc)BaseSerialPortc                   B    e Zd ZdZdZdeeedddfdZd Z	d Z
d Zd	 Zy
)
SerialPortz>
    A select()able serial device, acting as a transport.
       i%  r   c           
      2   t         j                  j                  | |       | j                  |||||||	|
      | _        || _        | j                          | j                          || _        | j                  j                  |        | j                          y )N)baudratebytesizeparitystopbitstimeoutxonxoffrtscts)r   FileDescriptor__init___serialFactory_serialreactor
flushInputflushOutputprotocolmakeConnectionstartReading)selfr   deviceNameOrPortNumberr   r   r   r   r   r   r   r   s              Q/home/dcms/DCMS/lib/python3.12/site-packages/twisted/internet/_posixserialport.pyr   zSerialPort.__init__   s     	((w7**" + 	
  $$T*    c                 .    | j                   j                  S )N)r   fdr   s    r    filenozSerialPort.fileno8   s    ||r!   c                 J    t        j                  | j                         |      S )z7
        Write some data to the serial device.
        )r   	writeToFDr%   )r   datas     r    writeSomeDatazSerialPort.writeSomeData;   s     t{{}d33r!   c                 r    t        j                  | j                         | j                  j                        S )z:
        Some data's readable from serial device.
        )r   
readFromFDr%   r   dataReceivedr$   s    r    doReadzSerialPort.doReadA   s'     t}}/I/IJJr!   c                     t         j                  j                  | |       | j                  j	                          | j
                  j                  |       y)z
        Called when the serial port disconnects.

        Will call C{connectionLost} on the protocol that is handling the
        serial data.
        N)r   r   connectionLostr   closer   )r   reasons     r    r/   zSerialPort.connectionLostG   s<     	..tV<$$V,r!   N)__name__
__module____qualname____doc__	connectedr   r   r   r   r%   r)   r-   r/    r!   r    r
   r
      s?     I >4K	-r!   r
   N)r5   serialr   r   r   twisted.internetr   r   twisted.internet.serialportr   r   r
   r7   r!   r    <module>r;      s,   
 8 7 , 6>-!8!8 >-r!   