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


Python serial.STOPBITS_ONE屬性代碼示例

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


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

示例1: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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: open

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [as 別名]
def open(self, port, speed=Constants.serial_default_speed, timeout=Constants.serial_timeout_ms):
        """
        Opens a specified serial port.
        :param port: Serial port name.
        :type port: str.
        :param speed: Baud rate, in bps, to connect to port.
        :type speed: int.
        :param timeout: Sets the general connection timeout.
        :type timeout: float.
        :return: True if the port is available.
        :rtype: bool.
        """
        self._serial.port = port
        self._serial.baudrate = int(speed)
        self._serial.stopbits = serial.STOPBITS_ONE
        self._serial.bytesize = serial.EIGHTBITS
        self._serial.timeout = timeout
        return self._is_port_available(self._serial.port) 
開發者ID:ssepulveda,項目名稱:RTGraph,代碼行數:20,代碼來源:Serial.py

示例3: test_serialPortDefaultArgs

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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 STOPBITS_ONE [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 STOPBITS_ONE [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 STOPBITS_ONE [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: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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

示例8: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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

示例9: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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

示例10: modbus_send_serial

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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

示例11: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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

示例12: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [as 別名]
def __init__(self, protocol, deviceNameOrPortNumber, reactor, 
        baudrate = 9600, bytesize = EIGHTBITS, parity = PARITY_NONE,
        stopbits = STOPBITS_ONE, timeout = 3, xonxoff = 0, rtscts = 0):
        # do NOT use timeout = 0 !!
        self._serial = serial.Serial(deviceNameOrPortNumber, baudrate = baudrate, bytesize = bytesize, parity = parity, stopbits = stopbits, timeout = timeout, xonxoff = xonxoff, rtscts = rtscts)
        javareactor.JConnection.__init__(self, self._serial.sPort, protocol, None)
        self.flushInput()
        self.flushOutput()
        
        self.reactor = reactor
        self.protocol = protocol
        self.protocol.makeConnection(self)
        wb = javareactor.WriteBlocker(self, reactor.q)
        wb.start()
        self.writeBlocker = wb
        javareactor.ReadBlocker(self, reactor.q).start() 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:18,代碼來源:_javaserialport.py

示例13: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [as 別名]
def __init__(self, portnum=None, useByteQueue=False):
        self.ser = None
        try:
            self.ser = serial.Serial(
                port=portnum,
                baudrate=460800,
                bytesize=serial.EIGHTBITS,
                parity=serial.PARITY_NONE,
                stopbits=serial.STOPBITS_ONE,
                timeout=None,  # seconds
                writeTimeout=None,
                rtscts=True
            )

        except Exception as e:
            if self.ser:
                self.ser.close()
            raise

        self.useByteQueue = useByteQueue
        self.byteQueue = collections.deque()

        # if self.ser.name != None:
        # print "UART %s on port %s" % ("open" if self.ser else "closed", self.ser.name) 
開發者ID:yakuza8,項目名稱:peniot,代碼行數:26,代碼來源:UART.py

示例14: __init__

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [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:eliben,項目名稱:code-for-blog,代碼行數:23,代碼來源:com_monitor.py

示例15: SetSamBA

# 需要導入模塊: import serial [as 別名]
# 或者: from serial import STOPBITS_ONE [as 別名]
def SetSamBA(DueSerialPort):
    """ 
    Initial triggering of chip into SAM-BA mode. 
    On the Programming Port there is an ATMEGA16U2 chip, acting as a USB bridge to expose the SAM UART as USB. 
    If the host is connected to the programming port at baud rate 1200, the ATMEGA16U2 will assert the Erase pin and Reset pin of the SAM3X, forcing it to the SAM-BA bootloader mode. 
    The port remains the same number but to access SAM-BA Baud rate must be changed to 115200.
    """
    log.Log("Setting into SAM-BA..." + DueSerialPort)
    
    ser = serial.Serial(port=DueSerialPort,\
                        baudrate=1200,\
                        parity=serial.PARITY_NONE,\
                        stopbits=serial.STOPBITS_ONE,\
                        bytesize=serial.EIGHTBITS,\
                        timeout=2000)       
    
    ser.write("\n")
    time.sleep(3)
    ser.close() 
    
    log.Log("SAM-BA Set.") 
開發者ID:johngrantuk,項目名稱:piupdue,代碼行數:23,代碼來源:piupdue.py


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