本文整理汇总了Python中win32file.OVERLAPPED属性的典型用法代码示例。如果您正苦于以下问题:Python win32file.OVERLAPPED属性的具体用法?Python win32file.OVERLAPPED怎么用?Python win32file.OVERLAPPED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32file
的用法示例。
在下文中一共展示了win32file.OVERLAPPED属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def __init__(self, path):
if not isinstance(path, basestring):
raise TypeError("Path argument must be a basestring; instead"
" received %r" % (path,))
self.path = path
self.handle = win32file.CreateFile(
self.path,
0x0001, # FILE_LIST_DIRECTORY
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
None,
win32con.OPEN_EXISTING,
win32con.FILE_FLAG_BACKUP_SEMANTICS | win32con.FILE_FLAG_OVERLAPPED,
None,
)
self.overlapped = win32file.OVERLAPPED()
self.overlapped.hEvent = win32event.CreateEvent(None, True, 0, None)
示例2: __init__
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def __init__(self, deviceName, devicePath, threadName = None):
self.lockObject = threading.Lock()
self.lockObject.acquire()
self.handle = None
self.text = Text
self.deviceName = deviceName
self.devicePath = devicePath
self.abort = False
self.initialized = False
self._overlappedRead = win32file.OVERLAPPED()
self._overlappedRead.hEvent = win32event.CreateEvent(None, 1, 0, None)
self._overlappedWrite = None
self.RawCallback = None
self.ButtonCallback = None
self.ValueCallback = None
self.StopCallback = None
threading.Thread.__init__(self, name = threadName if threadName else self.devicePath)
示例3: Stop
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def Stop(self):
"""
This will be called to stop the thread.
"""
if self.file:
writeOvlap = win32file.OVERLAPPED()
writeOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
msg = "q".encode("ascii")
win32file.WriteFile(self.file, msg, writeOvlap)
win32file.CloseHandle(self.file)
self.file = None
self.keepRunning = False
if self.service:
win32service.CloseServiceHandle(self.service)
#eg.PrintNotice("MCE_Vista: stopping thread")
示例4: Transmit
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def Transmit(self, transmitData):
"""
This will be called to detect available IR Blasters.
"""
if not self.file:
if not self.connecting:
self.Connect()
else:
return False
while self.receiving:
time.sleep(0.05)
writeOvlap = win32file.OVERLAPPED()
writeOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
win32file.WriteFile(self.file, transmitData, writeOvlap)
win32event.WaitForSingleObject(writeOvlap.hEvent, win32event.INFINITE)
return True
示例5: __init__
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def __init__(self, protocol, deviceNameOrPortNumber, reactor,
baudrate = 9600, bytesize = EIGHTBITS, parity = PARITY_NONE,
stopbits = STOPBITS_ONE, xonxoff = 0, rtscts = 0):
self._serial = self._serialFactory(
deviceNameOrPortNumber, baudrate=baudrate, bytesize=bytesize,
parity=parity, stopbits=stopbits, timeout=None,
xonxoff=xonxoff, rtscts=rtscts)
self.flushInput()
self.flushOutput()
self.reactor = reactor
self.protocol = protocol
self.outQueue = []
self.closed = 0
self.closedNotifies = 0
self.writeInProgress = 0
self.protocol = protocol
self._overlappedRead = win32file.OVERLAPPED()
self._overlappedRead.hEvent = win32event.CreateEvent(None, 1, 0, None)
self._overlappedWrite = win32file.OVERLAPPED()
self._overlappedWrite.hEvent = win32event.CreateEvent(None, 0, 0, None)
self.reactor.addEvent(self._overlappedRead.hEvent, self, 'serialReadEvent')
self.reactor.addEvent(self._overlappedWrite.hEvent, self, 'serialWriteEvent')
self.protocol.makeConnection(self)
self._finishPortSetup()
示例6: __init__
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def __init__(self, protocol, deviceNameOrPortNumber, reactor,
baudrate = 9600, bytesize = EIGHTBITS, parity = PARITY_NONE,
stopbits = STOPBITS_ONE, xonxoff = 0, rtscts = 0):
self._serial = serial.Serial(deviceNameOrPortNumber, baudrate=baudrate,
bytesize=bytesize, parity=parity,
stopbits=stopbits, timeout=None,
xonxoff=xonxoff, rtscts=rtscts)
self.flushInput()
self.flushOutput()
self.reactor = reactor
self.protocol = protocol
self.outQueue = []
self.closed = 0
self.closedNotifies = 0
self.writeInProgress = 0
self.protocol = protocol
self._overlappedRead = win32file.OVERLAPPED()
self._overlappedRead.hEvent = win32event.CreateEvent(None, 1, 0, None)
self._overlappedWrite = win32file.OVERLAPPED()
self._overlappedWrite.hEvent = win32event.CreateEvent(None, 0, 0, None)
self.reactor.addEvent(self._overlappedRead.hEvent, self, 'serialReadEvent')
self.reactor.addEvent(self._overlappedWrite.hEvent, self, 'serialWriteEvent')
self.protocol.makeConnection(self)
flags, comstat = win32file.ClearCommError(self._serial.hComPort)
rc, self.read_buf = win32file.ReadFile(self._serial.hComPort,
win32file.AllocateReadBuffer(1),
self._overlappedRead)
示例7: Write
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def Write(self, data, timeout):
if self.handle:
try:
self.lockObject.acquire()
if eg.debugLevel:
print "writing " + str(len(data)) + " bytes to " + self.getName()
if not self._overlappedWrite:
self._overlappedWrite = win32file.OVERLAPPED()
err, n = win32file.WriteFile(self.handle, data, self._overlappedWrite)
if err: #will be ERROR_IO_PENDING:
# Wait for the write to complete.
n = win32file.GetOverlappedResult(self.handle, self._overlappedWrite, 1)
if n != len(data):
raise Exception("could not write full data")
elif n != len(data):
raise Exception("could not write full data")
if timeout: #waits for response from device
win32event.ResetEvent(self._overlappedRead.hEvent)
res = win32event.WaitForSingleObject(self._overlappedRead.hEvent, timeout)
if res == win32event.WAIT_TIMEOUT:
raise Exception("no response from device within timeout")
finally:
self.lockObject.release()
else:
raise Exception("invalid handle")
return
示例8: GetDeviceInfo
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def GetDeviceInfo(self):
"""
This will be called to detect IR device info.
"""
if not self.file:
return None
writeOvlap = win32file.OVERLAPPED()
writeOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
self.deviceInfoEvent = win32event.CreateEvent(None, 0, 0, None)
win32file.WriteFile(self.file, "b".encode("ascii"), writeOvlap)
if win32event.WaitForSingleObject(self.deviceInfoEvent, 250) == win32event.WAIT_OBJECT_0:
return self.deviceInfo
return None
示例9: ChangeReceiveMode
# 需要导入模块: import win32file [as 别名]
# 或者: from win32file import OVERLAPPED [as 别名]
def ChangeReceiveMode(self, mode):
"""
This will be called to detect available IR Blasters.
"""
if not(mode == "l" or mode == "n"):
return False#needs to be normal or learn
if not self.file:
return False
writeOvlap = win32file.OVERLAPPED()
writeOvlap.hEvent = win32event.CreateEvent(None, 0, 0, None)
win32file.WriteFile(self.file, mode, writeOvlap)
win32event.WaitForSingleObject(writeOvlap.hEvent, win32event.INFINITE)
return True