Ejemplo n.º 1
0
 async def ping(self, addr, port: int, timeout: int = None):
     pingmsg = messages.Ping()
     future = self.send_to(pingmsg, addr, port)
     result = None
     if timeout is None:
         result = await future
     else:
         result = await asyncio.wait_for(future, timeout=timeout)
     assert isinstance(result, messages.Pong)
Ejemplo n.º 2
0
    def emit(self):
        if not self.client_connect.ready:
            return self.client_connect.emit()
        else:
            if self.dispatcher.available != 0:
                return messages.Available(self.dispatcher.get_available())

            else:
                return messages.Ping()
Ejemplo n.º 3
0
    def ping(self):
        """
        Send a bunch of pings, and wait for a response to any of them.

        This is a bad way of testing when the arduino is ready
        """
        self._ping_recvd = False
        for i in range(100):
            self._write_message(messages.Ping())
            if self._ping_recvd:
                return
            time.sleep(0.05)

        raise IOError('Never got a response ping')
Ejemplo n.º 4
0
 def Ping(self, num):
     message = messages.Ping(num)
     self.SendMessage(message)