Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/serial/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/serial/serialutil.pyc


uGLc@s5yeeWn3eefk
rAeZdefdYZnXdZedgZedgZedgZ	edgZ
ddd	d
df\ZZZ
ZZdd
df\ZZZddddf\ZZZZide6de6de
6de6de6ZdefdYZdefdYZedZedZdefdYZd efd!YZ e!d"kr1d#d$l"Z"e Z#e"j$j%d%e#j&e"j$j%d&e#j'e"j$j%d'e#j(e"j$j%d(e#j)e"j$j%d)e#j*e"j$j%d*e#nd$S(+t	bytearraycBsGeZdZdZdZdZdZdZdZRS(cCs
dj|S(Nt(tjoin(tself((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__str__scCsddj|S(Ns
bytearray(%r)R(R(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__repr__scCs<t|tr"tj||ntj|t|dS(N(t
isinstancetstrtlisttappendtchr(Rtitem((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR	scCs"x|D]}|j|qW|S(N(R	(Rtothertbyte((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__iadd__s
cCsttj|||S(N(RRt__getslice__(Rtitj((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR#scCs?t|tr%ttj||Sttj||SdS(N(RtsliceRRt__getitem__tord(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR&scCs.t|trt|}ntj||S(N(Rt
basestringRRt__eq__(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR,s(	t__name__t
__module__RRR	RRRR(((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyRs						cCs1t}x|D]}|j|qWt|S(s"convert a sequence to a bytes type(RR	tbytes(tseqtbR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytto_bytes3s	
iii
i
tNtEtOtMtSig?iiiiitNonetEventOddtMarktSpacetSerialExceptioncBseZdZRS(s.Base class for serial port related exceptions.(RRt__doc__(((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR'OstSerialTimeoutExceptioncBseZdZRS(s Write timeouts give an exception(RRR((((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR)Sss
Write timeouts)Attempting to use a port that is not opentFileLikecBseZdZdZdZdZdZdZdZdZ	dedZded	Z
dd
ZddZd
ZddZdZRS(sAn abstract file like class.

    This class implements readline and readlines based on read and
    writelines based on write.
    This class is used to provide the above functions for to Serial
    port objects.

    Note that when the serial port was opened with _NO_ timeout that
    readline blocks until it sees a newline (or the specified size is
    reached) and that readlines would never return and therefore
    refuses to work (it raises an exception in this case)!
    cCs
t|_dS(N(tTruetclosed(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__init__iscCs
t|_dS(N(R+R,(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytcloselscCsy|jWnnXdS(sDestructor.  Calls close().N(R.(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__del__pscCs"x|D]}|j|qWdS(N(twrite(Rtsequencetline((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
writelines|s
cCsdS(sflush of file like objectsN((R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytflushscCs|j}|stn|S(N(treadlinet
StopIteration(RR2((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytnexts	cCs|S(N((R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt__iter__scCst|}t}xdtr{|jd}|rw||7}|||krRPn|dk	rxt||krxPqxqPqWt|S(skread a line which is terminated with end-of-line (eol) character
        ('
' by default) or until timeout.iN(tlenRR+treadR"R(RtsizeteoltleneolR2tc((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR5s		
cCsr|jdkrtdng}xGtrm|jd|}|ri|j||d|krjPqjq'Pq'W|S(sAread a list of lines, until timeout.
        sizehint is ignored.s8Serial port MUST have enabled timeout for this function!R<iN(ttimeoutR"t
ValueErrorR+R5R	(RtsizehintR<tlinesR2((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	readliness	
ccs,x%tr'|j}|sPn|VqWdS(swRead lines, implemented as generator. It will raise StopIteration on
        timeout (empty read). sizehint is ignored.N(R+R5(RRAR2((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
xreadliness
	icCstddS(Nsfile is not seekable(tIOError(Rtpostwhence((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytseekscCstddS(Nsfile is not seekable(RE(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyttellscCstddS(Nsfile is not seekable(RE(Rtn((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyttruncatescCstS(N(tFalse(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytisattysN(RRR(R-R.R/R3R4R7R8R"tLFR5RCRDRHRIRKRM(((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR*[s								t
SerialBasecBseZdZdXZeeeefZe	e
eee
fZeeefZdYd
ee	edYeedYedYdZd Zd!Zd"Zd#Zd$Zd%Zd&Zeeed'd(Zd)Zd*Z ee ed'd+Z!d,Z"d-Z#ee#e"d'd.Z$d/Z%d0Z&ee&e%d'd1Z'd2Z(d3Z)ee)e(d'd4Z*d5Z+d6Z,ee,e+d'd7Z-d8Z.d9Z/ee/e.d'd:Z0d;Z1d<Z2ee2e1d'd=Z3d>Z4d?Z5ee5e4d'd@Z6dYdAZ7dBZ8ee8e7dCZ9dDZ:dEZ;ee;e:d'dFZ<dZZ=dQZ>dRZ?dSZ@dTZAdUZBdVZCdWZDRS([sbSerial port base class. Provides __init__ function and properties to
       get/set port settings.i2iKiniiii,iXiii`	ii%iKiiiiii iii@Bii`ii%&i-ig5i	=cCst|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_d|_
||_||_||_||_||_||_|	|_||_||_|
|_||_|dk	r|jndS(sInitialize comm port object. If a port is given, then the port will be
           opened immediately. Otherwise a Serial port object in closed state
           is returned.N(RLt_isOpenR"t_portt	_baudratet	_bytesizet_parityt	_stopbitst_timeoutt
_writeTimeoutt_xonxofft_rtsctst_dsrdtrt_interCharTimeouttporttbaudratetbytesizetparitytstopbitsR?twriteTimeouttxonxofftrtsctstdsrdtrtinterCharTimeouttopen(RR\R]R^R_R`R?RbRcRaRdRe((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyR-s2																							cCs|jS(sCheck if the port is opened.(RP(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytisOpenscCs&g|jD]}t||f^q
S(N(t	BAUDRATESR(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetSupportedBaudratesscCs&g|jD]}t||f^q
S(N(t	BYTESIZESR(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetSupportedByteSizesscCs&g|jD]}t||f^q
S(N(tSTOPBITSR(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetSupportedStopbitsscCs$g|jD]}t||f^q
S(N(tPARITIEStPARITY_NAMES(RR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetSupportedParitiesscCs|j}|r|jn|dk	rXt|trC||_qa|j||_n	d|_||_|j|_|r|j	ndS(shChange the port. The attribute portstr is set to a string that
           contains the name of the port.N(
RPR.R"RRtportstrtmakeDeviceNameRQtnameRf(RR\twas_open((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetPorts	
		cCs|jS(sGet the current port setting. The value that was passed on init or using
           setPort() is passed back. See also the attribute portstr which contains
           the name of the port as a string.(RQ(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetPort.stdocsPort settingcCsTyt||_Wn$tk
r9td|fnX|jrP|jndS(sChange baud rate. It raises a ValueError if the port is open and the
        baud rate is not possible. If the port is closed, then the value is
        accepted and the exception is raised when the port is opened.sNot a valid baudrate: %rN(tintRRt	TypeErrorR@RPt_reconfigurePort(RR]((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetBaudrate7s
	cCs|jS(s"Get the current baud rate setting.(RR(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetBaudrateBssBaud rate settingcCsH||jkr%td|fn||_|jrD|jndS(sChange byte size.sNot a valid byte size: %rN(RjR@RSRPRz(RR^((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetByteSizeIs
		cCs|jS(s"Get the current byte size setting.(RS(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetByteSizeOssByte size settingcCsH||jkr%td|fn||_|jrD|jndS(sChange parity setting.sNot a valid parity: %rN(RnR@RTRPRz(RR_((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	setParityVs
		cCs|jS(sGet the current parity setting.(RT(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	getParity\ssParity settingcCsH||jkr%td|fn||_|jrD|jndS(sChange stop bits size.sNot a valid stop bit size: %rN(RlR@RURPRz(RR`((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetStopbitscs
		cCs|jS(s"Get the current stop bits setting.(RU(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetStopbitsissStop bits settingcCs|dk	rdy|dWn$tk
r>td|fnX|dkrdtd|fqdn||_|jr|jndS(sChange timeout setting.isNot a valid timeout: %riN(R"RyR@RVRPRz(RR?((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
setTimeoutps
		cCs|jS(s Get the current timeout setting.(RV(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
getTimeout{ssTimeout setting for read()cCs|dk	ra|dkr.td|fny|dWqatk
r]td|qaXn||_|jr|jndS(sChange timeout setting.isNot a valid timeout: %riN(R"R@RyRWRPRz(RR?((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetWriteTimeouts
		cCs|jS(s Get the current timeout setting.(RW(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetWriteTimeoutssTimeout setting for write()cCs#||_|jr|jndS(sChange XON/XOFF setting.N(RXRPRz(RRb((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
setXonXoffs		cCs|jS(s!Get the current XON/XOFF setting.(RX(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt
getXonXoffssXON/XOFF settingcCs#||_|jr|jndS(s$Change RTS/CTS flow control setting.N(RYRPRz(RRc((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	setRtsCtss		cCs|jS(s-Get the current RTS/CTS flow control setting.(RY(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	getRtsCtsssRTS/CTS flow control settingcCs>|dkr|j|_n	||_|jr:|jndS(s#Change DsrDtr flow control setting.N(R"RYRZRPRz(RRd((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	setDsrDtrs
		cCs|jS(s-Get the current DSR/DTR flow control setting.(RZ(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt	getDsrDtrssDSR/DTR flow control settingcCs|dk	r^|dkr+td|ny|dWq^tk
rZtd|q^Xn||_|jr}|jndS(s'Change inter-character timeout setting.isNot a valid timeout: %riN(R"R@RyR[RPRz(RRe((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytsetInterCharTimeouts
		cCs|jS(s0Get the current inter-character timeout setting.(R[(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetInterCharTimeoutss*Inter-character timeout setting for read()R]R^R_R`RbRdRcR?RaRecCs3tg|jD]}|t|d|f^q
S(sQGet current port settings as a dictionary. For use with
        applySettingsDictt_(tdictt	_SETTINGStgetattr(Rtkey((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytgetSettingsDictscCsLxE|jD]:}||t|d|kr
t||||q
q
WdS(sapply stored settings from a dictionary returned from
        getSettingsDict. it's allowed to delete keys from the dictionary. these
        values will simply left unchanged.RN(RRtsetattr(RtdR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytapplySettingsDictsc
CsVd|jjt||j|j|j|j|j|j|j	|j
|j|jfS(sAString representation of the current port settings and its state.s}%s<id=0x%x, open=%s>(port=%r, baudrate=%r, bytesize=%r, parity=%r, stopbits=%r, timeout=%r, xonxoff=%r, rtscts=%r, dsrdtr=%r)(
t	__class__RtidRPRqR]R^R_R`R?RbRcRd(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyRs		cCstS(N(R+(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytreadablescCstS(N(R+(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytwritablescCstS(N(RL(R((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytseekablescCs|jt|}t|}y|||*WnPtk
r}ddl}t||jsh|n|jd|||*nX|S(NiR(R:R9RytarrayR(RRtdataRJterrR((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pytreadintos	(i2iKiniiii,iXiii`	ii%iKiiiiii iii@Bii`ii%&i-ig5i	=N(
sbaudratesbytesizesparitysstopbitssxonxoffsdsrdtrsrtsctsstimeoutswriteTimeoutsinterCharTimeout(ERRR(RhtFIVEBITStSIXBITSt	SEVENBITSt	EIGHTBITSRjtPARITY_NONEtPARITY_EVENt
PARITY_ODDtPARITY_MARKtPARITY_SPACERntSTOPBITS_ONEtSTOPBITS_ONE_POINT_FIVEtSTOPBITS_TWORlR"RLR-RgRiRkRmRpRuRvtpropertyR\R{R|R]R}R~R^RRR_RRR`RRR?RRRaRRRbRRRcRRRdRRReRRRRRRRR(((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyROs#																								
					
				t__main__iNsport name:  %s
sbaud rates: %s
sbyte sizes: %s
sparities:   %s
sstop bits:  %s
s%s
(+RRt	NameErrortAttributeErrorRRRtXONtXOFFtCRRNRRRRRRRRRRRRRoRER'R)twriteTimeoutErrorR@tportNotOpenErrortobjectR*RORtsystststdoutR0RqRiRkRpRm(((s5/usr/lib/python2.7/dist-packages/serial/serialutil.pyt<module>	sF 	$
l@