def exchange(self, msg_send, block = True): if block: # Blocking read returns message on success, while not self.any(): # None on timeout pass else: # Nonblocking read returns message on success, if not self.any(): # None on timeout, False on no data return False msg_rx = FromMaster() if self.await_message(msg_rx): self.sendbuf(msg_send) # Sometimes returns False when it has actually worked. return msg_rx.unpack() # In this instance don't discard received data. return None # Timeout
def exchange(self, msg_send, block = True): if block: # Blocking read returns message on success, while not self.any(): # None on timeout pass else: # Nonblocking read returns message on success, if not self.any(): # None on timeout, False on no data return False msg_rx = FromMaster() if self.await_message(msg_rx): if self.sendbuf(msg_send): return msg_rx.unpack() return None # Timeout
def exchange(self, msg_send, block=True): if block: # Blocking read returns message on success, while not self.any(): # None on timeout pass else: # Nonblocking read returns message on success, if not self.any(): # None on timeout, False on no data return False msg_rx = FromMaster() if self.await_message(msg_rx): if self.sendbuf(msg_send): return msg_rx.unpack() return None # Timeout