当前位置: 首页>>代码示例>>Python>>正文


Python serial.PARITY_NONE属性代码示例

本文整理汇总了Python中serial.PARITY_NONE属性的典型用法代码示例。如果您正苦于以下问题:Python serial.PARITY_NONE属性的具体用法?Python serial.PARITY_NONE怎么用?Python serial.PARITY_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在serial的用法示例。


在下文中一共展示了serial.PARITY_NONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def __init__(self, port, baudrate, timeout, fs=False):
        """
        Класс описывающий протокол взаимодействия в устройством.

        :type port: str
        :param port: порт взаимодействия с устройством
        :type baudrate: int
        :param baudrate: скорость взаимодействия с устройством
        :type timeout: float
        :param timeout: время таймаута ответа устройства
        :type fs: bool
        :param fs: признак наличия ФН (фискальный накопитель)
        """

        self.port = port
        self.serial = serial.Serial(
            baudrate=baudrate,
            parity=serial.PARITY_NONE,
            stopbits=serial.STOPBITS_ONE,
            timeout=timeout,
            writeTimeout=timeout
        )
        self.fs = fs
        self.connected = False 
开发者ID:oleg-golovanov,项目名称:pyshtrih,代码行数:26,代码来源:protocol.py

示例2: terminal

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def terminal(port):
    click.echo(click.style('NOTE: This is an early prototype of the terminal.'
                           ' Nothing is guaranteed to work.', bold=True))
    if port == 'default':
        if len(prosflasher.ports.list_com_ports()) == 1:
            port = prosflasher.ports.list_com_ports()[0].device
        elif len(prosflasher.ports.list_com_ports()) > 1:
            click.echo('Multiple ports were found:')
            click.echo(prosflasher.ports.create_port_list())
            port = click.prompt('Select a port to open',
                                type=click.Choice([p.device for p in prosflasher.ports.list_com_ports()]))
        else:
            click.echo('No ports were found.')
            click.get_current_context().abort()
            sys.exit()
    ser = prosflasher.ports.create_serial(port, serial.PARITY_NONE)
    term = proscli.serial_terminal.Terminal(ser)
    signal.signal(signal.SIGINT, term.stop)
    term.start()
    while term.alive:
        time.sleep(0.005)
    term.join()
    ser.close()
    print('Exited successfully')
    sys.exit(0) 
开发者ID:purduesigbots,项目名称:pros-cli2,代码行数:27,代码来源:terminal.py

示例3: test_serialPortDefaultArgs

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def test_serialPortDefaultArgs(self):
        """
        Test correct positional and keyword arguments have been
        passed to the C{serial.Serial} object.
        """
        port = RegularFileSerialPort(self.protocol, self.path, self.reactor)
        # Validate args
        self.assertEqual((self.path,), port._serial.captured_args)
        # Validate kwargs
        kwargs = port._serial.captured_kwargs
        self.assertEqual(9600,                kwargs["baudrate"])
        self.assertEqual(serial.EIGHTBITS,    kwargs["bytesize"])
        self.assertEqual(serial.PARITY_NONE,  kwargs["parity"])
        self.assertEqual(serial.STOPBITS_ONE, kwargs["stopbits"])
        self.assertEqual(0,                   kwargs["xonxoff"])
        self.assertEqual(0,                   kwargs["rtscts"])
        self.assertEqual(None,                kwargs["timeout"])
        port.connectionLost(Failure(Exception("Cleanup"))) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:20,代码来源:test_win32serialport.py

示例4: getCoord

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def getCoord():
	# Start the serial connection
	ser=serial.Serial('/dev/ttyAMA0', 115200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1)
	ser.write("AT+CGNSINF\r")
	while True:
		response = ser.readline()
		if "+CGNSINF: 1," in response:
			# Split the reading by commas and return the parts referencing lat and long
			array = response.split(",")
			lat = array[3]
			print lat
			lon = array[4]
			print lon
			return (lat,lon)


# Start the program by opening the cellular connection and creating a bucket for our data 
开发者ID:initialstate,项目名称:fona-pi-zero,代码行数:19,代码来源:fonagps.py

示例5: setup_serial

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def setup_serial(ser, port, lock):
    """Setup all parameters for the serial communication"""
    try:
        with lock:
            ser.baudrate = 4800
            ser.port = port
            ser.bytesize = serial.EIGHTBITS
            ser.stopbits = serial.STOPBITS_ONE
            ser.parity = serial.PARITY_NONE
            ser.timeout = 0.1  # Read timeout in seconds
            ser.write_timeout = 0.1  # Write timeout in seconds
    except Exception as e:
        helper.show_error("Problem initializing serial port " + port + ".\n\n"
                          "Exception:\n" + str(e) + "\n\n"
                          "The application will now exit.")
        sys.exit(0) 
开发者ID:akej74,项目名称:grid-control,代码行数:18,代码来源:grid.py

示例6: initializeUartPort

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def initializeUartPort(
        portName,
        baudrate = 57600,
        bytesize = serial.EIGHTBITS,
        parity   = serial.PARITY_NONE,
        stopbits = serial.STOPBITS_ONE,
        timeout  = 0
    ):

    port = serial.Serial()

    #tuning port object
    port.port         = portName
    port.baudrate     = baudrate
    port.bytesize     = bytesize
    port.parity       = parity
    port.stopbits     = stopbits
    port.timeout      = timeout

    return port 
开发者ID:JFF-Bohdan,项目名称:sim-module,代码行数:22,代码来源:test_shared.py

示例7: establish_serial_connection

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [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

示例8: establishSerialConnection

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [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

示例9: modbus_rtu_client

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def modbus_rtu_client(name=None, baudrate=None, parity=None):

    global modbus_rtu_clients

    client = modbus_rtu_clients.get(name)
    if client is not None:
        if baudrate is not None and client.baudrate != baudrate:
            raise ModbusClientError('Modbus client baudrate mismatch')
        if parity is not None and client.parity != parity:
            raise ModbusClientError('Modbus client parity mismatch')
    else:
        if baudrate is None:
            baudrate = 9600
        if parity is None:
            parity = PARITY_NONE

        client = ModbusClientRTU(name, baudrate, parity)
        modbus_rtu_clients[name] = client

    return client 
开发者ID:sunspec,项目名称:pysunspec,代码行数:22,代码来源:client.py

示例10: __init__

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def __init__(self, devfile="/dev/ttyS0", baudrate=9600, bytesize=8, timeout=1,
                 parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,
                 xonxoff=False, dsrdtr=True, codepage="cp858", *args, **kwargs):
        """
        @param devfile  : Device file under dev filesystem
        @param baudrate : Baud rate for serial transmission
        @param bytesize : Serial buffer size
        @param timeout  : Read/Write timeout
        """
        escpos.Escpos.__init__(self, *args, **kwargs)
        self.devfile = devfile
        self.baudrate = baudrate
        self.bytesize = bytesize
        self.timeout = timeout
        self.parity = parity
        self.stopbits = stopbits
        self.xonxoff = xonxoff
        self.dsrdtr = dsrdtr
        self.codepage = codepage 
开发者ID:paxapos,项目名称:fiscalberry,代码行数:21,代码来源:ReceiptSerialDriver.py

示例11: __init__

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def __init__(self, devfile="/dev/ttyS0", baudrate=9600, bytesize=8, timeout=1,
                 parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,
                 xonxoff=False, dsrdtr=True, *args, **kwargs):
        """

        :param devfile:  Device file under dev filesystem
        :param baudrate: Baud rate for serial transmission
        :param bytesize: Serial buffer size
        :param timeout:  Read/Write timeout
        :param parity:   Parity checking
        :param stopbits: Number of stop bits
        :param xonxoff:  Software flow control
        :param dsrdtr:   Hardware flow control (False to enable RTS/CTS)
        """
        Escpos.__init__(self, *args, **kwargs)
        self.devfile = devfile
        self.baudrate = baudrate
        self.bytesize = bytesize
        self.timeout = timeout
        self.parity = parity
        self.stopbits = stopbits
        self.xonxoff = xonxoff
        self.dsrdtr = dsrdtr

        self.open() 
开发者ID:python-escpos,项目名称:python-escpos,代码行数:27,代码来源:printer.py

示例12: __init__

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def __init__(   self, 
                    data_q, error_q, 
                    port_num,
                    port_baud,
                    port_stopbits = serial.STOPBITS_ONE,
                    port_parity   = serial.PARITY_NONE,
                    port_timeout  = 0.01):
        threading.Thread.__init__(self)
        
        self.serial_port = None
        self.serial_arg  = dict( port      = port_num,
                                 baudrate  = port_baud,
                                 stopbits  = port_stopbits,
                                 parity    = port_parity,
                                 timeout   = port_timeout)

        self.data_q   = data_q
        self.error_q  = error_q
        
        self.alive    = threading.Event()
        self.alive.set()
    #------------------------------------------------------ 
开发者ID:mba7,项目名称:SerialPort-RealTime-Data-Plotter,代码行数:24,代码来源:com_monitor.py

示例13: modbus_send_serial

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def modbus_send_serial(data, properties):
    modbus_data = pickle.dumps(data)
    data_length = len(modbus_data)
    encoded_data = base64.b64encode(modbus_data)
    data_size = sys.getsizeof(encoded_data)
    log.debug('Data size : %s' % data_size)

    ser = serial.Serial(
        port='/dev/ttyAMA0',
        baudrate = 57600,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=0.5
        )

    ser.write(encoded_data)
    log.debug(encoded_data) 
开发者ID:wavestone-cdt,项目名称:dyode,代码行数:20,代码来源:modbus.py

示例14: init

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def init(self):
        super(SiUart, self).init()
        self._init.setdefault('board_id', None)
        self._init.setdefault('avoid_download', False)
        if self._init['board_id'] and int(self._init['board_id']) >= 0:
            self._ser = serial.Serial()
            if 'port' in self._init.keys():
                self._ser.setPort(self._init['port'])
            if 'baudrate' in self._init.keys():
                self._ser.setBaudrate(self._init['baudrate'])
            if 'parity' in self._init.keys() and self._init["parity"] == 0:
                self._ser.setParity(serial.PARITY_NONE)
            if 'stopbits' in self._init.keys():
                self._ser.setStopbits(self._init['stopbits'])
            if 'bytesize' in self._init.keys():
                self._ser.setByteSize(self._init['bytesize'])
            if 'timeout' in self._init.keys():
                self._ser.setTimeout(self._init['timeout'])

            self._ser.open()
            if not self._ser.isOpen():
                raise IOError("Port at %s not open" % self._ser.port)
        else:
            logger.info('Found board') 
开发者ID:SiLab-Bonn,项目名称:basil,代码行数:26,代码来源:SiUart.py

示例15: __init__

# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_NONE [as 别名]
def __init__(self, port, verbose=False):
        threading.Thread.__init__(self)

        self._on = True
        self.verbose = verbose
        self.lock = threading.Lock()
        self.ser = serial.Serial(port,
                                 baudrate=115200,
                                 parity=serial.PARITY_NONE,
                                 stopbits=serial.STOPBITS_ONE,
                                 bytesize=serial.EIGHTBITS)
        is_open = self.ser.isOpen()
        if self.verbose:
            print('pydobot: %s open' % self.ser.name if is_open else 'failed to open serial port')

        self._set_queued_cmd_start_exec()
        self._set_queued_cmd_clear()
        self._set_ptp_joint_params(200, 200, 200, 200, 200, 200, 200, 200)
        self._set_ptp_coordinate_params(velocity=200, acceleration=200)
        self._set_ptp_jump_params(10, 200)
        self._set_ptp_common_params(velocity=100, acceleration=100)
        self._get_pose() 
开发者ID:luismesas,项目名称:pydobot,代码行数:24,代码来源:dobot.py


注:本文中的serial.PARITY_NONE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。