a zµYW�#ã@s@ddlZddlZddlTejejZdd„ZGdd„deƒZdS)éN)Ú*cCstdd„|DƒƒS)NcSsg|] }t|ƒ‘qS©)Úord)Ú.0Úxrrú4/usr/lib/python3.9/site-packages/serial/serialcli.pyÚ óz!as_byte_array..)Úsab)ÚstringrrrÚ as_byte_arraysr c@s¢eZdZdZdZdd„Zdd„Zdd„Zed d „ƒZ d#d d „Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zedd„ƒZedd„ƒZedd„ƒZed d!„ƒZd"S)$ÚSerialz)Serial port implementation for .NET/Mono.)é2éKéné†é–éÈi,iXi°ii` iÀi€%iKi–iáiÂc CsÔ|jdurtdƒ‚|jr tdƒ‚ztjj |j¡|_Wn<t yr}z$d|_td|j|fƒ‚WYd}~n d}~00|j dur„d|_ |j dur”d|_ |  ¡|j  ¡d|_|jsº| ¡|jsÈ| ¡| ¡dS)zx Open port with current settings. This may throw a SerialException if the port cannot be opened. Nz.Port must be configured before it can be used.zPort is already open.zcould not open port %s: %sT)Z_portÚSerialExceptionÚis_openÚSystemÚIOÚPortsÚ SerialPortZportstrÚ _port_handleÚ ExceptionÚ _rts_stateÚ _dtr_stateÚ_reconfigure_portZOpenZ_dsrdtrÚ_update_dtr_stateÚ_rtsctsÚ_update_rts_stateÚreset_input_buffer)ÚselfÚmsgrrrÚopens* (   z Serial.openc Cs†|jstdƒ‚|jdur*tjjjj|j_nt |jdƒ|j_|j durXtjjjj|j_ nt |j dƒ|j_ z|j |j_ Wn0ty¨}ztt|ƒƒ‚WYd}~n d}~00|jtkr¾d|j_nJ|jtkrÒd|j_n6|jtkræd|j_n"|jtkrúd|j_ntd|jƒ‚|jtk�r*ttjjjd ƒ|j_n†|jtk�rHtjjjj|j_nh|jtk�rftjjjj|j_nJ|jtk�r„tjjjj |j_n,|jt!k�r¢tjjjj"|j_ntd |jƒ‚|j#t$k�rÎtjjj%j&|j_%nJ|j#t'k�rìtjjj%j(|j_%n,|j#t)k�r tjjj%j*|j_%ntd |j#ƒ‚|j+�r:|j,�r:tjjj-j.|j_-nH|j+�rTtjjj-j/|j_-n.|j,�rntjjj-j0|j_-nttjjj-d ƒ|j_-dS) z,Set communication parameters on opened port.z'Can only operate on a valid port handleNièééééz#Unsupported number of data bits: %rÚNonezUnsupported parity mode: %rz#Unsupported number of stop bits: %r)1rrÚ_timeoutrrrrZInfiniteTimeoutZ ReadTimeoutÚintZ_write_timeoutZ WriteTimeoutZ _baudrateZBaudRateÚIOErrorÚ ValueErrorÚstrZ _bytesizeZFIVEBITSZDataBitsZSIXBITSZ SEVENBITSZ EIGHTBITSZ_parityZ PARITY_NONEÚgetattrZParityZ PARITY_EVENZEvenZ PARITY_ODDZOddZ PARITY_MARKZMarkZ PARITY_SPACEZSpaceZ _stopbitsZ STOPBITS_ONEZStopBitsZOneZSTOPBITS_ONE_POINT_FIVEZ OnePointFiveZ STOPBITS_TWOZTwor Z_xonxoffZ HandshakeZRequestToSendXOnXOffZ RequestToSendZXOnXOff)r#Úerrrr;s\  "                zSerial._reconfigure_portcCsD|jr@|jr:z|j ¡Wntjjjy2Yn0d|_d|_dS)z Close portNF)rrZCloserrrZInvalidOperationException©r#rrrÚcloseƒsz Serial.closecCs|js t‚|jjS)z>Return the number of characters currently in the input buffer.)rÚportNotOpenErrorrZ BytesToReadr2rrrÚ in_waiting‘szSerial.in_waitingécCsT|js t‚tƒ}|rLz| |j ¡¡Wntjy@YqLYq0|d8}qt|ƒS)zÑ Read size bytes from the serial port. If a timeout is set it may return less characters as requested. With no timeout it will block until the requested number of bytes is read. r6) rr4Ú bytearrayÚappendrZReadByterÚTimeoutExceptionÚbytes)r#ÚsizeÚdatarrrÚread˜s  z Serial.readcCsH|js t‚z|j t|ƒdt|ƒ¡Wntjy>t‚Yn0t|ƒS)z-Output the given string over the serial port.r) rr4rZWriter Úlenrr9ZwriteTimeoutError)r#r<rrrÚwrite¬s z Serial.writecCs|js t‚|j ¡dS)z9Clear input buffer, discarding all that is in the buffer.N)rr4rZDiscardInBufferr2rrrr"ºszSerial.reset_input_buffercCs|js t‚|j ¡dS)zs Clear output buffer, aborting the current output and discarding all that is in the buffer. N)rr4rZDiscardOutBufferr2rrrÚreset_output_bufferÀszSerial.reset_output_buffercCs|js t‚t|jƒ|j_dS)zT Set break: Controls TXD. When active, to transmitting is possible. N)rr4ÚboolZ _break_staterZ BreakStater2rrrÚ_update_break_stateÉszSerial._update_break_statecCs|js t‚t|jƒ|j_dS)z)Set terminal status line: Request To SendN)rr4rArrZ RtsEnabler2rrrr!ÑszSerial._update_rts_statecCs|js t‚t|jƒ|j_dS)z-Set terminal status line: Data Terminal ReadyN)rr4rArrZ DtrEnabler2rrrr×szSerial._update_dtr_statecCs|js t‚|jjS)z(Read terminal status line: Clear To Send)rr4rZ CtsHoldingr2rrrÚctsÝsz Serial.ctscCs|js t‚|jjS)z)Read terminal status line: Data Set Ready)rr4rZ DsrHoldingr2rrrÚdsräsz Serial.dsrcCs|js t‚dS)z)Read terminal status line: Ring IndicatorF)rr4r2rrrÚriësz Serial.ricCs|js t‚|jjS)z)Read terminal status line: Carrier Detect)rr4rZ CDHoldingr2rrrÚcdósz Serial.cdN)r6)Ú__name__Ú __module__Ú __qualname__Ú__doc__Z BAUDRATESr%rr3Úpropertyr5r=r?r"r@rBr!rrCrDrErFrrrrr s,H      r ) rZSystem.IO.PortsZserial.serialutilZArrayZByter r Z SerialBaser rrrrÚ s