예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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