Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyc

ó
¹7¬Nc@s¾dZddlZddlmZmZmZddlmZmZddlmZmZm	Z	m
Z
ddlZddlZddl
mZddlmZdeejfd	„ƒYZdS(
sB
Serial port support for Windows.

Requires PySerial and pywin32.
iÿÿÿÿN(tPARITY_NONEtPARITY_EVENt
PARITY_ODD(tSTOPBITS_ONEtSTOPBITS_TWO(tFIVEBITStSIXBITSt	SEVENBITSt	EIGHTBITS(tabstract(tBaseSerialPortt
SerialPortcBs\eZdZdZdeeeddd„Zd„Zd„Z	d„Z
d„Zd	„ZRS(
s@A serial device, acting as a transport, that uses a win32 event.ii€%ic

Cs?|j|d|d|d|d|ddd|d|	ƒ|_|jƒ|jƒ||_||_g|_d|_d|_	d|_
||_tjƒ|_
tjdd	ddƒ|j
_tjƒ|_tjddddƒ|j_|jj|j
j|d
ƒ|jj|jj|dƒ|jj|ƒ|jƒdS(NtbaudratetbytesizetparitytstopbitsttimeouttxonxofftrtsctsiitserialReadEventtserialWriteEvent(t_serialFactorytNonet_serialt
flushInputtflushOutputtreactortprotocoltoutQueuetclosedtclosedNotifiestwriteInProgresst	win32filet
OVERLAPPEDt_overlappedReadt
win32eventtCreateEventthEventt_overlappedWritetaddEventtmakeConnectiont_finishPortSetup(
tselfRtdeviceNameOrPortNumberRRR
RRRR((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyt__init__s*

							cCsOtj|jjƒ\}}tj|jjtjdƒ|jƒ\}|_dS(sn
        Finish setting up the serial port.

        This is a separate method to facilitate testing.
        iN(R tClearCommErrorRthComPorttReadFiletAllocateReadBufferR"tread_buf(R*tflagstcomstattrc((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyR):scCs7tj|jj|jdƒ}|rðt|j| ƒ}tj|jjƒ\}}|jrÝt	j
|jjƒtj|jjtj
|jƒ|jƒ\}}tj|jj|jdƒ}|jj|t|| ƒƒqð|jj|ƒnt	j
|jjƒtj|jjtj
dƒ|jƒ\}|_dS(Nii(R tGetOverlappedResultRR.R"tstrR1R-tcbInQueR#t
ResetEventR%R/R0RtdataReceived(R*tntfirstR2R3R4tbuf((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyRFs 	!cCsN|rJ|jr"|jj|ƒqJd|_tj|jj||jƒndS(Ni(RRtappendR t	WriteFileRR.R&(R*tdata((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pytwrite`s
		cCsTy|jjdƒ}Wntk
r3d|_dSXtj|jj||jƒdS(Ni(	Rtpopt
IndexErrorRR R>RR.R&(R*tdataToWrite((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyRis
	cCs`|jj|jjƒ|jj|jjƒtjj||ƒ|jj	ƒ|j
j|ƒdS(s™
        Called when the serial port disconnects.

        Will call C{connectionLost} on the protocol that is handling the
        serial data.
        N(RtremoveEventR"R%R&R	tFileDescriptortconnectionLostRtcloseR(R*treason((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyRFss

(
t__name__t
__module__t__doc__t	connectedRRRR,R)RR@RRF(((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyRs						
(RKtserialRRRRRRRRRR R#ttwisted.internetR	t
serialportR
RER(((sE/usr/lib/python2.7/dist-packages/twisted/internet/_win32serialport.pyt<module>s"