(self, rs=False, cs=1000, ds=1000, cd=0)
Open the serial connection.
Open the serial connection.
Open the serial connection .
def _open_serial(self, rs=False, cs=1000, ds=1000, cd=0):
        """Open the serial connection."""
        with safe_io(error.DEVICE_TIMEOUT):
            self._check_open()
        # handshake - report as timeout if it fails
        # by default, RTS is up, DTR down
        # RTS can be suppressed, DTR only accessible through machine ports
        # https://lbpe.wikispaces.com/AccessingSerialPort
        if not rs:
            with safe_io(error.DEVICE_TIMEOUT):
                self._serial.rts = True
        now = datetime.datetime.now()
        timeout_cts = now + datetime.timedelta(microseconds=cs)
        timeout_dsr = now + datetime.timedelta(microseconds=ds)
        timeout_cd = now + datetime.timedelta(microseconds=cd)
        with safe_io(error.DEVICE_TIMEOUT):
            have_cts, have_dsr, have_cd = self._serial.cts, self._serial.dsr, self._serial.cd
        while ((now < timeout_cts and not have_cts) and
                (now < timeout_dsr and not have_dsr) and
                (now < timeout_cd and not have_cd)):
            now = datetime.datetime.now()
            with safe_io(error.DEVICE_TIMEOUT):
                have_cts = have_cts and self._serial.cts
                have_dsr = have_dsr and self._serial.dsr
                have_cts = have_cd and self._serial.cd
            # give CPU some time off
            self._queues.wait()
        # only check for status if timeouts are set > 0
        # http://www.electro-tech-online.com/threads/qbasic-serial-port-control.19286/
        # https://measurementsensors.honeywell.com/ProductDocuments/Instruments/008-0385-00.pdf
        if ((cs > 0 and not have_cts) or
                (ds > 0 and not have_dsr) or
                (cd > 0 and not have_cd)):
            raise error.BASICError(error.DEVICE_TIMEOUT)
def _open_serial ( self , rs = False , cs = 1000 , ds = 1000 , cd = 0 ) : with safe_io ( error . DEVICE_TIMEOUT ) : self . _check_open ( ) # handshake - report as timeout if it fails # by default, RTS is up, DTR down # RTS can be suppressed, DTR only accessible through machine ports # https://lbpe.wikispaces.com/AccessingSerialPort if not rs : with safe_io ( error . DEVICE_TIMEOUT ) : self . _serial . rts = True now = datetime . datetime . now ( ) timeout_cts = now + datetime . timedelta ( microseconds = cs ) timeout_dsr = now + datetime . timedelta ( microseconds = ds ) timeout_cd = now + datetime . timedelta ( microseconds = cd ) with safe_io ( error . DEVICE_TIMEOUT ) : have_cts , have_dsr , have_cd = self . _serial . cts , self . _serial . dsr , self . _serial . cd while ( ( now < timeout_cts and not have_cts ) and ( now < timeout_dsr and not have_dsr ) and ( now < timeout_cd and not have_cd ) ) : now = datetime . datetime . now ( ) with safe_io ( error . DEVICE_TIMEOUT ) : have_cts = have_cts and self . _serial . cts have_dsr = have_dsr and self . _serial . dsr have_cts = have_cd and self . _serial . cd # give CPU some time off self . _queues . wait ( ) # only check for status if timeouts are set > 0 # http://www.electro-tech-online.com/threads/qbasic-serial-port-control.19286/ # https://measurementsensors.honeywell.com/ProductDocuments/Instruments/008-0385-00.pdf if ( ( cs > 0 and not have_cts ) or ( ds > 0 and not have_dsr ) or ( cd > 0 and not have_cd ) ) : raise error . BASICError ( error . DEVICE_TIMEOUT )