def exchange(self, msg_send): # Call when transmit-receive required. msg_rx = ToMaster() if self.sendbuf(msg_send): if self.await_message(msg_rx): self.stop_listening() return msg_rx.unpack() self.stop_listening() return None # Timeout
def test_slave(): s = radio_fast.Slave(slave_config) send_msg = ToMaster() while True: result = s.exchange(send_msg) # Wait for master if result is not None: print(result.i0) else: print('Timeout') send_msg.i0 += 1
async def slave(): # power control done in main.py s = rf.Slave(v2_config) # Slave runs on V2 PCB (with SD card) send_msg = ToMaster() while True: await asyncio.sleep(0) result = s.exchange(send_msg) # Wait for master if result is not None: print(result.i0) else: print('Timeout') send_msg.i0 += 1
def ts(): from micropower import PowerController power_controller = PowerController(pin_active_high='Y12', pin_active_low='Y11') power_controller.power_up() s = rf.Slave(v1_config) send_msg = ToMaster() while True: result = s.exchange(send_msg) # Wait for master if result is not None: print(result.i0) else: print('Timeout') send_msg.i0 += 1
def slave(lcd): yield Roundrobin() s = rf.Slave(testbox_config) # Slave on testbox send_msg = ToMaster() while True: while True: start = pyb.millis() result = s.exchange(send_msg, block=False) t = pyb.elapsed_millis(start) yield Roundrobin() if result is None: # Timeout break if result: # Success break if result is None: lcd[0] = 'Timeout' elif result: lcd[0] = str(result.i0) lcd[1] = 't = {}mS'.format(t) yield Roundrobin() send_msg.i0 += 1