diff --git a/sys_test/swarm_test_rig/rig_support.py b/sys_test/swarm_test_rig/rig_support.py index f510ada098a03b13f8aa3e5ab6059345338d6070..9fec7a73e9032dde6e1a7c826838cdad26dff4e6 100644 --- a/sys_test/swarm_test_rig/rig_support.py +++ b/sys_test/swarm_test_rig/rig_support.py @@ -43,7 +43,7 @@ class RigSupport: ] def restart_devices(self, uris): - def send_packets(uris, value): + def send_packets(uris, value, description): for uri in uris: devid, channel, datarate, address = RadioDriver.parse_uri(uri) radio.set_channel(channel) @@ -52,17 +52,16 @@ class RigSupport: received_packet = False for i in range(10): - # TODO krri Seems to work better with a pause here, - # investigate why - time.sleep(0.2) result = radio.send_packet((0xf3, 0xfe, value)) if result.ack is True: received_packet = True + # if i > 0: + # print('Lost packets', i, uri) break - time.sleep(0.1) if not received_packet: - raise Exception('Failed to restart device') + raise Exception('Failed to turn device {}, for {}'. + format(description, uri)) print('Restarting devices') @@ -70,8 +69,9 @@ class RigSupport: BOOTLOADER_CMD_SYSON = 0x03 radio = Crazyradio() - send_packets(uris, BOOTLOADER_CMD_SYSOFF) - time.sleep(0.1) - send_packets(uris, BOOTLOADER_CMD_SYSON) + send_packets(uris, BOOTLOADER_CMD_SYSOFF, 'off') + send_packets(uris, BOOTLOADER_CMD_SYSON, 'on') + + # Wait for devices to boot + time.sleep(8) radio.close() - time.sleep(5) diff --git a/sys_test/swarm_test_rig/test_connection.py b/sys_test/swarm_test_rig/test_connection.py index 534862157d2c242db1d276968c024a7453586863..14c4b2117cc9dbeabe6c56563acb9de37810d3bc 100644 --- a/sys_test/swarm_test_rig/test_connection.py +++ b/sys_test/swarm_test_rig/test_connection.py @@ -88,9 +88,20 @@ class TestConnection(unittest.TestCase): def test_that_all_devices_are_restarted(self): # Fixture + uris = self.test_rig_support.all_uris + # Test # Assert - self.test_rig_support.restart_devices(self.test_rig_support.all_uris) + self.test_rig_support.restart_devices(uris) + + def test_that_all_devices_are_restarted_multiple_times(self): + # Fixture + uris = self.test_rig_support.all_uris + + # Test + # Assert + for i in range(10): + self.test_rig_support.restart_devices(uris) def test_that_the_same_cf_object_can_be_connected_multiple_times(self): # Fixture