Skip to content
Snippets Groups Projects
Commit d142a29d authored by Kristoffer Richardsson's avatar Kristoffer Richardsson
Browse files

#119 Updates to restart system tests

parent eb6be503
Branches
Tags
No related merge requests found
...@@ -43,7 +43,7 @@ class RigSupport: ...@@ -43,7 +43,7 @@ class RigSupport:
] ]
def restart_devices(self, uris): def restart_devices(self, uris):
def send_packets(uris, value): def send_packets(uris, value, description):
for uri in uris: for uri in uris:
devid, channel, datarate, address = RadioDriver.parse_uri(uri) devid, channel, datarate, address = RadioDriver.parse_uri(uri)
radio.set_channel(channel) radio.set_channel(channel)
...@@ -52,17 +52,16 @@ class RigSupport: ...@@ -52,17 +52,16 @@ class RigSupport:
received_packet = False received_packet = False
for i in range(10): 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)) result = radio.send_packet((0xf3, 0xfe, value))
if result.ack is True: if result.ack is True:
received_packet = True received_packet = True
# if i > 0:
# print('Lost packets', i, uri)
break break
time.sleep(0.1)
if not received_packet: if not received_packet:
raise Exception('Failed to restart device') raise Exception('Failed to turn device {}, for {}'.
format(description, uri))
print('Restarting devices') print('Restarting devices')
...@@ -70,8 +69,9 @@ class RigSupport: ...@@ -70,8 +69,9 @@ class RigSupport:
BOOTLOADER_CMD_SYSON = 0x03 BOOTLOADER_CMD_SYSON = 0x03
radio = Crazyradio() radio = Crazyradio()
send_packets(uris, BOOTLOADER_CMD_SYSOFF) send_packets(uris, BOOTLOADER_CMD_SYSOFF, 'off')
time.sleep(0.1) send_packets(uris, BOOTLOADER_CMD_SYSON, 'on')
send_packets(uris, BOOTLOADER_CMD_SYSON)
# Wait for devices to boot
time.sleep(8)
radio.close() radio.close()
time.sleep(5)
...@@ -88,9 +88,20 @@ class TestConnection(unittest.TestCase): ...@@ -88,9 +88,20 @@ class TestConnection(unittest.TestCase):
def test_that_all_devices_are_restarted(self): def test_that_all_devices_are_restarted(self):
# Fixture # Fixture
uris = self.test_rig_support.all_uris
# Test # Test
# Assert # 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): def test_that_the_same_cf_object_can_be_connected_multiple_times(self):
# Fixture # Fixture
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment