ó EIRTc@s^ddlTddlZddlZddlZiejd6ejd6ejd6ejd6ZdZ de fd „ƒYZ yddl Z Wn*e k r´d e efd „ƒYZnXd e e jfd „ƒYZed krZddlZedƒZejjdeƒejjdƒejdƒejƒejjdejdƒƒejƒndS(iÿÿÿÿ(t*Ntdebugtinfotwarningterrorit SocketSerialcBsÅeZdZd&Zd„Zd„Zd„Zd„Zd„Zd„Z dd„Z d„Z d„Z d„Z dd„Zed„Zed „Zed!„Zd"„Zd#„Zd$„Zd%„ZRS('s-Serial port implementation for plain sockets.i2iKini†i–iÈi,iXi°ii` iÀi€%iKi–iáiÂcCsd|_|jdkr'tdƒ‚n|jr?tdƒ‚ny;tjtjtjƒ|_|jj |j |j ƒƒWn5t k r±}d|_td|j |fƒ‚nX|jj tƒ|jƒt|_|jsû|jtƒ|jtƒn|jƒ|jƒdS(sjOpen port with current settings. This may throw a SerialException if the port cannot be opened.s.Port must be configured before it can be used.sPort is already open.sCould not open port %s: %sN(tNonetloggert_porttSerialExceptiont_isOpentsockettAF_INETt SOCK_STREAMt_sockettconnecttfromURLtportstrt Exceptiont settimeoutt POLL_TIMEOUTt_reconfigurePorttTruet_rtsctstsetRTStsetDTRt flushInputt flushOutput(tselftmsg((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytopen)s&         cCs>|jdkrtdƒ‚n|jr:|jjdƒndS(siSet communication parameters on opened port. for the socket:// protocol all settings are ignored!sCan only operate on open portss!ignored port configuration changeN(RRR RR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyREs cCsi|jre|jrLy$|jjtjƒ|jjƒWnnXd|_nt|_tj dƒndS(s Close portg333333Ó?N( R RtshutdownR t SHUT_RDWRtcloseRtFalsettimetsleep(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyR!Ms    cCstdƒ‚dS(Ns2there is no sensible way to turn numbers into URLs(R (Rtport((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytmakeDeviceName\scCsu|jƒjdƒr"|d}ny#d|krõ|jddƒ\}}x©|jdƒD]•}d|kr†|jddƒ\}}nd}|dkrÛtjƒtjdƒ|_|jjt |ƒ|jj dƒqYt d |fƒ‚qYWn|jd dƒ\}}t |ƒ}d |ko0d knsDt d ƒ‚nWn#t k rj}t d|ƒ‚nX||fS(s(extract host and port from an URL strings socket://i t/it=tloggingspySerial.socketsenabled loggingsunknown option: %rt:iisport not in range 0...65535sRexpected a string in the form "[rfc2217://]:[/option[/option...]]": %sN(tlowert startswithtsplitRR)t basicConfigt getLoggerRtsetLevelt LOGGER_LEVELSRt ValueErrortintR (RturltoptionstoptiontvaluethostR%te((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyR_s,      cCs2|jst‚n|jr.|jjdƒndS(s>Return the number of characters currently in the input buffer.s&WARNING: inWaiting returns dummy valuei(R tportNotOpenErrorRR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyt inWaiting~s   icCs|jst‚ntƒ}|jdk r@tjƒ|j}nd}xÆt|ƒ|kr|dksytjƒ|kryStjƒ}|jj|t|ƒƒ}tjƒ|}|rÊ|j |ƒnPWqIt j k råqIqIt j k r }t d|ƒ‚qIXqIWt|ƒS(sÀ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.sconnection failed (%s)N(R R:t bytearrayt_timeoutRR#tlenRtrecvtextendR ttimeoutRR tbytes(RtsizetdataRAtttblocktdurationR9((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytread†s&  3 cCs_|jst‚ny|jjt|ƒƒWn&tjk rT}td|ƒ‚nXt|ƒS(sœOutput the given string over the serial port. Can block if the connection is blocked. May raise SerialException if the connection is closed.ssocket connection failed: %s( R R:Rtsendalltto_bytesR RR R>(RRDR9((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytwrite¥s cCs2|jst‚n|jr.|jjdƒndS(s9Clear input buffer, discarding all that is in the buffer.signored flushInputN(R R:RR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyR±s  cCs2|jst‚n|jr.|jjdƒndS(sbClear output buffer, aborting the current output and discarding all that is in the buffer.signored flushOutputN(R R:RR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyR·s  gÐ?cCs9|jst‚n|jr5|jjd|fƒndS(sPSend break condition. Timed, returns to idle state after given duration.signored sendBreak(%r)N(R R:RR(RRG((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyt sendBreak¾s  cCs9|jst‚n|jr5|jjd|fƒndS(sJSet break: Controls TXD. When active, to transmitting is possible.signored setBreak(%r)N(R R:RR(Rtlevel((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytsetBreakÅs  cCs9|jst‚n|jr5|jjd|fƒndS(s)Set terminal status line: Request To Sendsignored setRTS(%r)N(R R:RR(RRM((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyRÌs  cCs9|jst‚n|jr5|jjd|fƒndS(s-Set terminal status line: Data Terminal Readysignored setDTR(%r)N(R R:RR(RRM((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyRÒs  cCs2|jst‚n|jr.|jjdƒntS(s(Read terminal status line: Clear To Sendsreturning dummy for getCTS()(R R:RRR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytgetCTSØs   cCs2|jst‚n|jr.|jjdƒntS(s)Read terminal status line: Data Set Readysreturning dummy for getDSR()(R R:RRR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytgetDSRßs   cCs2|jst‚n|jr.|jjdƒntS(s)Read terminal status line: Ring Indicatorsreturning dummy for getRI()(R R:RRR"(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytgetRIæs   cCs2|jst‚n|jr.|jjdƒntS(s)Read terminal status line: Carrier Detectsreturning dummy for getCD()(R R:RRR(R((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pytgetCDís   (i2iKini†i–iÈi,iXi°ii` iÀi€%iKi–iáiÂ(t__name__t __module__t__doc__t BAUDRATESRRR!R&RR;RHRKRRRLRRNRRRORPRQRR(((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyR#s*                tSerialcBseZRS((RSRT(((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyRWÿscBseZRS((RSRT(((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyRWst__main__ssocket://localhost:7000s%s s write... shello s read: %s i(tserial.serialutilR#R R)tDEBUGtINFOtWARNINGtERRORR1Rt SerialBaseRtiot ImportErrortFileLikeRWt RawIOBaseRStsystststdoutRKtflushRHR!(((sN/opt/freeware/lib/python2.7/site-packages/serial/urlhandler/protocol_socket.pyts0        Ø