当前位置: 首页>>代码示例>>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;未经允许,请勿转载。