當前位置: 首頁>>代碼示例>>Python>>正文


Python win32.DTR_CONTROL_ENABLE屬性代碼示例

本文整理匯總了Python中serial.win32.DTR_CONTROL_ENABLE屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32.DTR_CONTROL_ENABLE屬性的具體用法?Python win32.DTR_CONTROL_ENABLE怎麽用?Python win32.DTR_CONTROL_ENABLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在serial.win32的用法示例。


在下文中一共展示了win32.DTR_CONTROL_ENABLE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from serial import win32 [as 別名]
# 或者: from serial.win32 import DTR_CONTROL_ENABLE [as 別名]
def __init__(self, *args, **kwargs):
        self.hComPort = None
        self._overlappedRead = None
        self._overlappedWrite = None
        self._rtsToggle = False

        self._rtsState = win32.RTS_CONTROL_ENABLE
        self._dtrState = win32.DTR_CONTROL_ENABLE


        SerialBase.__init__(self, *args, **kwargs) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:13,代碼來源:serialwin32.py

示例2: setDTR

# 需要導入模塊: from serial import win32 [as 別名]
# 或者: from serial.win32 import DTR_CONTROL_ENABLE [as 別名]
def setDTR(self, level=1):
        """Set terminal status line: Data Terminal Ready"""
        # remember level for reconfigure
        if level:
            self._dtrState = win32.DTR_CONTROL_ENABLE
        else:
            self._dtrState = win32.DTR_CONTROL_DISABLE
        # also apply now if port is open
        if self.hComPort:
            if level:
                win32.EscapeCommFunction(self.hComPort, win32.SETDTR)
            else:
                win32.EscapeCommFunction(self.hComPort, win32.CLRDTR) 
開發者ID:whaleygeek,項目名稱:microbit-gateway,代碼行數:15,代碼來源:serialwin32.py

示例3: setDTR

# 需要導入模塊: from serial import win32 [as 別名]
# 或者: from serial.win32 import DTR_CONTROL_ENABLE [as 別名]
def setDTR(self, level=1):
        """Set terminal status line: Data Terminal Ready"""
        if not self.hComPort: raise portNotOpenError
        if level:
            self._dtrState = win32.DTR_CONTROL_ENABLE
            win32.EscapeCommFunction(self.hComPort, win32.SETDTR)
        else:
            self._dtrState = win32.DTR_CONTROL_DISABLE
            win32.EscapeCommFunction(self.hComPort, win32.CLRDTR) 
開發者ID:respeaker,項目名稱:get_started_with_respeaker,代碼行數:11,代碼來源:serialwin32.py

示例4: open

# 需要導入模塊: from serial import win32 [as 別名]
# 或者: from serial.win32 import DTR_CONTROL_ENABLE [as 別名]
def open(self):
        """Open port with current settings. This may throw a SerialException
           if the port cannot be opened."""
        if self._port is None:
            raise SerialException("Port must be configured before it can be used.")
        if self._isOpen:
            raise SerialException("Port is already open.")
        # the "\\.\COMx" format is required for devices other than COM1-COM8
        # not all versions of windows seem to support this properly
        # so that the first few ports are used with the DOS device name
        port = self.portstr
        try:
            if port.upper().startswith('COM') and int(port[3:]) > 8:
                port = '\\\\.\\' + port
        except ValueError:
            # for like COMnotanumber
            pass
        self.hComPort = win32.CreateFile(port,
               win32.GENERIC_READ | win32.GENERIC_WRITE,
               0, # exclusive access
               None, # no security
               win32.OPEN_EXISTING,
               win32.FILE_ATTRIBUTE_NORMAL | win32.FILE_FLAG_OVERLAPPED,
               0)
        if self.hComPort == win32.INVALID_HANDLE_VALUE:
            self.hComPort = None    # 'cause __del__ is called anyway
            raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError()))

        # Setup a 4k buffer
        win32.SetupComm(self.hComPort, 4096, 4096)

        # Save original timeout values:
        self._orgTimeouts = win32.COMMTIMEOUTS()
        win32.GetCommTimeouts(self.hComPort, ctypes.byref(self._orgTimeouts))

        self._rtsState = win32.RTS_CONTROL_ENABLE
        self._dtrState = win32.DTR_CONTROL_ENABLE

        self._reconfigurePort()

        # Clear buffers:
        # Remove anything that was there
        win32.PurgeComm(self.hComPort,
                            win32.PURGE_TXCLEAR | win32.PURGE_TXABORT |
                            win32.PURGE_RXCLEAR | win32.PURGE_RXABORT)

        self._overlappedRead = win32.OVERLAPPED()
        self._overlappedRead.hEvent = win32.CreateEvent(None, 1, 0, None)
        self._overlappedWrite = win32.OVERLAPPED()
        #~ self._overlappedWrite.hEvent = win32.CreateEvent(None, 1, 0, None)
        self._overlappedWrite.hEvent = win32.CreateEvent(None, 0, 0, None)
        self._isOpen = True 
開發者ID:respeaker,項目名稱:get_started_with_respeaker,代碼行數:54,代碼來源:serialwin32.py


注:本文中的serial.win32.DTR_CONTROL_ENABLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。