Python serial.PARITY_EVEN Examples

The following are 8 code examples of serial.PARITY_EVEN(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module serial , or try the search function .
Example #1
Source File: flasher.py    From pros-cli2 with Mozilla Public License 2.0 7 votes vote down vote up
def get_sys_info(cfg, yes, port):
    if port == 'auto':
        ports = prosflasher.ports.list_com_ports()
        if len(ports) == 0:
            click.echo('No microcontrollers were found. Please plug in a cortex or manually specify a serial port.\n',
                       err=True)
            sys.exit(1)
        port = prosflasher.ports.list_com_ports()[0].device
        if port is not None and yes is False:
            click.confirm('Poll ' + port, default=True, abort=True, prompt_suffix='?')
    if port == 'all':
        port = [p.device for p in prosflasher.ports.list_com_ports()]
        if len(port) == 0:
            click.echo('No microcontrollers were found. Please plug in a cortex or manually specify a serial port.\n',
                       err=True)
            sys.exit(1)
    else:
        port = [port]

    for p in port:
        sys_info = prosflasher.upload.ask_sys_info(prosflasher.ports.create_serial(p, serial.PARITY_EVEN), cfg)
        click.echo(repr(sys_info))

    pass 
Example #2
Source File: biaxe.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def open(self):
    self.ser = serial.Serial(self.port, self.baudrate,
                             serial.EIGHTBITS, serial.PARITY_EVEN,
                             serial.STOPBITS_ONE, self.timeout)
    self.clear_errors()
    self.speed = None 
Example #3
Source File: manager.py    From pyTeliumManager with MIT License 5 votes vote down vote up
def __init__(self,
                 path,
                 baudrate=9600,
                 timeout=1,
                 open_on_create=True,
                 debugging=False):
        super(TeliumNativeSerial, self).__init__(
            path,
            baudrate=baudrate,
            bytesize=SEVENBITS,
            parity=PARITY_EVEN,
            stopbits=STOPBITS_ONE,
            timeout=timeout,
            open_on_create=open_on_create,
            debugging=debugging) 
Example #4
Source File: mitsi.py    From MQMitsi with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def connect(self):
        """ Establish a serial connection to self.port. """
        if self.port:
            self.ser = serial.Serial(
                self.port, 2400, parity=serial.PARITY_EVEN, timeout=0
            )
            self.ser.write(bytearray(self.start_packet.bytes)) 
Example #5
Source File: client.py    From pysunspec with MIT License 5 votes vote down vote up
def open(self):
        """Open the RTU client serial interface.
        """

        try:
            if self.parity == PARITY_EVEN:
                parity = serial.PARITY_EVEN
            else:
                parity = serial.PARITY_NONE

            if self.name != TEST_NAME:
                self.serial = serial.Serial(port = self.name, baudrate=self.baudrate,
                                            bytesize=8, parity=parity,
                                            stopbits=1, xonxoff=0,
                                            timeout=self.timeout, writeTimeout=self.write_timeout)
            else:
                import sunspec.core.test.fake.serial as fake
                self.serial = fake.Serial(port = self.name, baudrate=self.baudrate,
                                          bytesize=8, parity=parity,
                                          stopbits=1, xonxoff=0,
                                          timeout=self.timeout, writeTimeout=self.write_timeout)

        except Exception as e:
            if self.serial is not None:
                self.serial.close()
                self.serial = None
            raise ModbusClientError('Serial init error: %s' % str(e)) 
Example #6
Source File: stm32loader.py    From arminarm with GNU General Public License v2.0 5 votes vote down vote up
def open(self, aport='/dev/ttyAMA0', abaudrate=115200) :
        self.sp = serial.Serial(
            port=aport,
            baudrate=abaudrate,     # baudrate
            bytesize=8,             # number of databits
            parity=serial.PARITY_EVEN,
            stopbits=1,
            xonxoff=0,              # enable software flow control
            rtscts=0,               # disable RTS/CTS flow control
            timeout=5               # set a timeout value, None for waiting forever
        ) 
Example #7
Source File: Heidolph_MR_Hei_Connect.py    From ChemputerSoftware with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, port=None, connect_on_instantiation=False, soft_fail_for_testing=False):
        """
        Initializer of the MRHeiConnect class.

        Args:
            port (str): The port name/number of the hotplate
            connect_on_instantiation (bool): (optional) determines if the connection is established on instantiation of
                the class. Default: Off
            soft_fail_for_testing (bool): (optional) determines if an invalid serial port raises an error or merely logs
                a message. Default: Off
        """
        super().__init__(port, connect_on_instantiation, soft_fail_for_testing)

        # serial settings
        self.baudrate = 9600
        self.bytesize = serial.SEVENBITS
        self.parity = serial.PARITY_EVEN

        # answer patterns
        self.stranswer = re.compile("([0-9A-Z_]+)\r\n")
        self.intanswer = re.compile("([0-9A-Z_]+) (-?\d)\r\n")
        self.floatanswer = re.compile("([0-9A-Z_]+) (\d+\.\d+)\r\n")

        # implemented commands
        self.OLD_PROTOCOL = "PA_OLD"
        self.NEW_PROTOCOL = "PA_NEW"
        self.STATUS = "STATUS"
        self.GET_HOT_PLATE_TEMPERATURE_PV = "IN_PV_3"
        self.SET_TEMPERATURE_SP = "OUT_SP_1"
        self.GET_TEMPERATURE_SP = "IN_SP_1"
        self.START_HEATING = "START_1"
        self.WATCHDOG_ON = "CC_ON"
        self.WATCHDOG_OFF = "CC_OFF" 
Example #8
Source File: IKA_RV10.py    From ChemputerSoftware with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, port=None, device_name=None, connect_on_instantiation=False, soft_fail_for_testing=False):
        """
        Initializer of the IKARV10 class
        :param str port: The port name/number of the rotavap (remember under Windows: COM15 -> port 14)
        :param str device_name: A descriptive name for the device, used mainly in debug prints.
        :param bool connect_on_instantiation: (optional) determines if the connection is established on instantiation of
            the class. Default: Off
        """
        super().__init__(port, device_name, soft_fail_for_testing)

        # serial settings
        self.baudrate = 9600
        self.bytesize = serial.SEVENBITS
        self.parity = serial.PARITY_EVEN

        self.write_delay = 0.1
        self.read_delay = 0.1

        # answer patterns
        self.stranswer = re.compile("([0-9A-Z_]+)\r\n")
        self.intanswer = re.compile("(\d+) (\d)\r\n")
        self.floatanswer = re.compile("(\d+\.\d+) (\d)\r\n")

        # DOCUMENTED COMMANDS for easier maintenance
        self.GET_ROTATION_PV = "IN_PV_4"
        self.GET_ROTATION_SP = "IN_SP_4"
        self.SET_ROTATION_SP = "OUT_SP_4"  # 20-280 RPM
        self.GET_TEMP_PV = "IN_PV_2"
        self.GET_TEMP_SP = "IN_SP_2"
        self.SET_TEMP_SP = "OUT_SP_2"  # 0-180°C, max. T is safety temperature minus 10°C, T>90°C switches to oil mode
        self.GET_SAFETY_TEMP_SP = "IN_SP_2"
        self.SET_SAFETY_TEMP_SP = "OUT_SP_2"
        self.START_TEMP = "START_2"
        self.STOP_TEMP = "STOP_2"
        self.START_ROTATION = "START_4"
        self.STOP_ROTATION = "STOP_4"
        self.RESET = "RESET"
        self.GET_NAME = "IN_NAME"
        self.SET_NAME = "OUT_NAME"
        self.GET_SOFTWARE_VERSION = "IN_SOFTWARE"
        self.SET_INTERVAL_SP = "OUT_SP_60"  # 1-60s, "0" switches mode off
        self.SET_TIMER_SP = "OUT_SP_61"  # 1-199min, "0" switches mode off
        self.LIFT_UP = "OUT_SP_62 1"
        self.LIFT_DOWN = "OUT_SP_63 1"

        self.MAX_RPM = 280

        self.MAX_RETRIES = 10

        self.heating_on = Event()  # communicator for switching the keepalive on or off

        self.launch_command_handler()

        if connect_on_instantiation:
            self.open_connection()