Exemplo n.º 1
0
    def connect(self):
        """Connects to the roaster and creates communication thread."""
        port = utils.find_device('1A86:5523')
        self._ser = serial.Serial(port=port,
                                  baudrate=9600,
                                  bytesize=8,
                                  parity='N',
                                  stopbits=1.5,
                                  timeout=.25,
                                  xonxoff=False,
                                  rtscts=False,
                                  dsrdtr=False)

        self._initialize()

        self.comm_process = mp.Process(target=self.comm)
        self.comm_process.start()
        self.time_process = mp.Process(target=self.timer)
        self.time_process.start()
Exemplo n.º 2
0
    def connect(self):
        """Connects to the roaster and creates communication thread."""
        port = utils.find_device('1A86:5523')
        self._ser = serial.Serial(
            port=port,
            baudrate=9600,
            bytesize=8,
            parity='N',
            stopbits=1.5,
            timeout=.25,
            xonxoff=False,
            rtscts=False,
            dsrdtr=False)

        self._initialize()

        self.comm_process = mp.Process(target=self.comm)
        self.comm_process.start()
        self.time_process= mp.Process(target=self.timer)
        self.time_process.start()
Exemplo n.º 3
0
    def _connect(self):
        """Do not call this directly - call auto_connect() or connect(),
        which will call _connect() for you.

        Connects to the roaster and creates communication thread.
        Raises a RoasterLokkupError exception if the hardware is not found.
        """
        # the following call raises a RoasterLookupException when the device
        # is not found. It is
        port = utils.find_device('1A86:5523')
        # on some systems, after the device port is added to the device list,
        # it can take up to 20 seconds after USB insertion for
        # the port to become available... (!)
        # let's put a safety timeout in here as a precaution
        wait_timeout = time.time() + 40.0  # should be PLENTY of time!
        # let's update the _connect_state while we're at it...
        self._connect_state.value = self.CS_CONNECTING
        connect_success = False
        while time.time() < wait_timeout:
            try:
                self._ser = serial.Serial(
                    port=port,
                    baudrate=9600,
                    bytesize=8,
                    parity='N',
                    stopbits=1.5,
                    timeout=0.25,
                    xonxoff=False,
                    rtscts=False,
                    dsrdtr=False)
                connect_success = True
                break
            except serial.SerialException:
                time.sleep(0.5)
        if not connect_success:
            # timeout on attempts
            raise exceptions.RoasterLookupError

        self._initialize()
Exemplo n.º 4
0
 def test_find_device_with_device_unavailable(self, mock_comports):
     with self.assertRaises(exceptions.RoasterLookupError):
         utils.find_device('1234:5678')
Exemplo n.º 5
0
 def test_find_device_with_device_available(self, mock_comports):
     device_path = utils.find_device('1A86:5523')
     self.assertEqual(device_path, '/dev/tty2')
Exemplo n.º 6
0
 def test_find_device_with_device_unavailable(self, mock_comports):
     with self.assertRaises(exceptions.RoasterLookupError):
         utils.find_device('1234:5678')
Exemplo n.º 7
0
 def test_find_device_with_device_available(self, mock_comports):
     device_path = utils.find_device('1A86:5523')
     self.assertEqual(device_path, '/dev/tty2')