^_#xddlmZddlZddlZddlej ej ZdZGdde Z y))absolute_importN)*cPt|Dcgc] }t|c}Scc}w)N)sabord)stringxs 2/usr/lib/python3/dist-packages/serial/serialcli.py as_byte_arrayr s '1A' (('s#ceZdZdZdZdZdZdZedZ ddZ dZ d Z d Z d Zd Zd ZedZedZedZedZy)Serialz)Serial port implementation for .NET/Mono.)2Kni,iXiii` ii%iKiiicv|j td|jr td tjj j |j|_|jd|_ |jd|_ |j|jjd|_|js|j|j s|j#|j%y#t$r'}d|_td|jd|d}~wwxYw)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 z: T)_portSerialExceptionis_openSystemIOPorts SerialPortportstr _port_handle Exception _rts_state _dtr_state_reconfigure_portOpen_dsrdtr_update_dtr_state_rtscts_update_rts_statereset_input_buffer)selfmsgs r openz Serial.opens :: !"RS S <<!"9: : V &  : :4<< HD  ?? ""DO ?? ""DO     ||  " " $||  " " $ !# V $D !$,,PS"TU U Vs8D D8"D33D8c |js td|j>tjj j j|j_n't|jdz|j_|j>tjj j j|j_ n't|jdz|j_ |j|j_ |j"t$k(rd|j_n|j"t(k(rd|j_nb|j"t*k(rd|j_n=|j"t,k(rd|j_ntd|j"z|j.t0k(r?t3tjj j4d |j_n]|j.t6k(r?tjj j4j8|j_n |j.t:k(r>tjj j4j<|j_n|j.t>k(r>tjj j4j@|j_ni|j.tBk(r>tjj j4jD|j_ntd |j.z|jFtHk(r>tjj jJjL|j_%n|jFtNk(r>tjj jJjP|j_%ni|jFtRk(r>tjj jJjT|j_%ntd |jFz|jVrJ|jXr>tjj jZj\|j_-y|jVr>tjj jZj^|j_-y|jXr>tjj jZj`|j_-yt3tjj jZd |j_-y#t$r}tt!|d}~wwxYw) z,Set communication parameters on opened port.z'Can only operate on a valid port handleNiz#Unsupported number of data bits: %rNonezUnsupported parity mode: %rz#Unsupported number of stop bits: %r)1rr_timeoutrrrrInfiniteTimeout ReadTimeoutint_write_timeout WriteTimeout _baudrateBaudRateIOError ValueErrorstr _bytesizeFIVEBITSDataBitsSIXBITS SEVENBITS EIGHTBITS_parity PARITY_NONEgetattrParity PARITY_EVENEven PARITY_ODDOdd PARITY_MARKMark PARITY_SPACESpace _stopbits STOPBITS_ONEStopBitsOneSTOPBITS_ONE_POINT_FIVE OnePointFive STOPBITS_TWOTwor%_xonxoff HandshakeRequestToSendXOnXOff RequestToSendXOnXOff)r(es r r!zSerial._reconfigure_port=s  !"KL L == ,2IIOO,F,F,V,VD   ),/ 0D,ED   )    &-3YY__-G-G-W-WD   *-01D1Dt1K-LD   * %)-D   & >>X %)*D   & ^^w &)*D   & ^^y ()*D   & ^^y ()*D   &BT^^ST T <<; &'.vyy/E/Ev'ND   $ \\[ ('-yy'='='B'BD   $ \\Z ''-yy'='='A'AD   $ \\[ ('-yy'='='B'BD   $ \\\ )'-yy'='='C'CD   $:T\\IJ J >>\ ))/)A)A)E)ED   & ^^6 6)/)A)A)N)ND   & ^^| +)/)A)A)E)ED   &BT^^ST T <Return the number of characters currently in the input buffer.)rPortNotOpenErrorr BytesToReadr_s r in_waitingzSerial.in_waitings&||"$ $  ,,,c|js tt}|r2 |j|jj |dz}|r2t|S#t j$r Yt|SwxYw)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. ) rrb bytearrayappendrReadByterTimeoutExceptionbytes)r(sizedatas r readz Serial.reads ||"$ ${  D--6689  T{ ** T{  s)A B?Bc|js t |jjt |dt |t |S#t j$r tdwxYw)z-Output the given string over the serial port.rz Write timeout) rrbrWriter lenrrkSerialTimeoutException)r(rns r writez Serial.writesh||"$ $ :    # #M$$7CI F4y&& :(9 9 :s /AA1cd|js t|jjy)z9Clear input buffer, discarding all that is in the buffer.N)rrbrDiscardInBufferr_s r r'zSerial.reset_input_buffers$||"$ $ ))+recd|js t|jjy)zs Clear output buffer, aborting the current output and discarding all that is in the buffer. N)rrbrDiscardOutBufferr_s r reset_output_bufferzSerial.reset_output_buffers& ||"$ $ **,recx|js tt|j|j_y)zT Set break: Controls TXD. When active, to transmitting is possible. N)rrbbool _break_stater BreakStater_s r _update_break_statezSerial._update_break_states-||"$ $'+D,=,='>$recx|js tt|j|j_y)z)Set terminal status line: Request To SendN)rrbr{rr RtsEnabler_s r r&zSerial._update_rts_state)||"$ $&*4??&;#recx|js tt|j|j_y)z-Set terminal status line: Data Terminal ReadyN)rrbr{r r DtrEnabler_s r r$zSerial._update_dtr_staterrecZ|js t|jjS)z(Read terminal status line: Clear To Send)rrbr CtsHoldingr_s r ctsz Serial.cts&||"$ $  +++recZ|js t|jjS)z)Read terminal status line: Data Set Ready)rrbr DsrHoldingr_s r dsrz Serial.dsrrrec0|js ty)z)Read terminal status line: Ring IndicatorF)rrbr_s r riz Serial.ris||"$ $recZ|js t|jjS)z)Read terminal status line: Carrier Detect)rrbr CDHoldingr_s r cdz Serial.cds&||"$ $  ***reN)rg)__name__ __module__ __qualname____doc__ BAUDRATESr*r!r`propertyrdrortr'ryr~r&r$rrrrrer r r s34I"rs:'  ll6;;)a+Za+re