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


Python serial.PARITY_ODD屬性代碼示例

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


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

示例1: establish_serial_connection

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import PARITY_ODD [as 別名]
def establish_serial_connection(port, speed=115200, timeout=10, writeTimeout=10000):
    # Hack for USB connection
    # There must be a way to do it cleaner, but I can't seem to find it
    try:
        temp = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_ODD)
        if sys.platform == 'win32':
            temp.close()
        conn = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_NONE)
        conn.setRTS(False)#needed on mac
        if sys.platform != 'win32':
            temp.close()
        return conn
    except SerialException as e:
        print ("Could not connect to {0} at baudrate {1}\nSerial error: {2}".format(port, str(speed), e))
        return None
    except IOError as e:
        print ("Could not connect to {0} at baudrate {1}\nIO error: {2}".format(port, str(speed), e))
        return None 
開發者ID:TechnoSwiss,項目名稱:MPMD-AutoBedLevel-Cal,代碼行數:20,代碼來源:auto_cal_p5.py

示例2: establishSerialConnection

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import PARITY_ODD [as 別名]
def establishSerialConnection(port, speed=115200, timeout=10, writeTimeout=10000):
        # Hack for USB connection
        # There must be a way to do it cleaner, but I can't seem to find it
        try:
            temp = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_ODD)
            if sys.platform == 'win32':
                temp.close()
            conn = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_NONE)
            conn.setRTS(False) #needed on mac
            if sys.platform != 'win32':
                temp.close()
            return conn
        except SerialException as e:
            print ("Could not connect to {0} at baudrate {1}\nSerial error: {2}".format(port, str(speed), e))
            raise e
        except IOError as e:
            print ("Could not connect to {0} at baudrate {1}\nIO error: {2}".format(port, str(speed), e))
            raise e 
開發者ID:TechnoSwiss,項目名稱:MPMD-AutoBedLevel-Cal,代碼行數:20,代碼來源:auto_cal.py

示例3: getSerialOrNone

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import PARITY_ODD [as 別名]
def getSerialOrNone(portname):
    try:
       return serial.Serial(port=portname,baudrate=115200,parity=serial.PARITY_ODD,stopbits=serial.STOPBITS_TWO,bytesize=serial.SEVENBITS)
    except:
       return None 
開發者ID:utra-robosoccer,項目名稱:soccer-matlab,代碼行數:7,代碼來源:vrhand_vive_tracker.py

示例4: connect

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import PARITY_ODD [as 別名]
def connect(self):
        if self.conn is None:
            self.conn = serial.Serial(port = self.port,
                                      baudrate = 19200,
                                      parity = serial.PARITY_ODD,
                                      stopbits = serial.STOPBITS_ONE,
                                      bytesize = serial.EIGHTBITS,
                                      timeout = 5,
                                      xonxoff = 1)
        elif not self.isConnected():
            self.conn.open() 
開發者ID:atbrask,項目名稱:CMS50Dplus,代碼行數:13,代碼來源:cms50dplus.py


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