Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tensile/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__
tensile-venv
tock
libtock-rs
libtock-c
ot-central-controller.hex
41 changes: 28 additions & 13 deletions tensile/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,34 @@ def flash_board(self):

self.log_info(f"[FLASHING -- COMPLETE] {self.board_serial_no}.")

# Build libtock-c app.
self.log_info(f"[BUILDING] libtock-c app {self.app_name}...")
self.log_info(sh.make("-C", self.libtock_path, _err_to_out=True))
self.log_info(f"[BUILDING -- COMPLETE] {self.app_name}.")

# Flash libtock-c app to board.
self.log_info(f"[FLASHING] libtock-c app {self.app_name} to: {self.board_serial_no}...")
self.log_info(sh.tockloader(
"install",
f"{self.libtock_path}/build/{self.app_name}.tab",
"--jlink-serial-number",
self.board_serial_no,
_err_to_out=True))
# Build libtock app.

# Building / Flashing is different depending on if libtock-c/rs.
if "libtock-rs" in self.libtock_path:
self.log_info(f"[BUILDING] libtock-rs app {self.app_name}...")
self.log_info(sh.make("-C", "libtock-rs", "nrf52840", f"EXAMPLE={self.app_name}", _err_to_out=True))
# Flash libtock app to board.
self.log_info(f"[FLASHING] libtock-rs app {self.app_name} to: {self.board_serial_no}...")
self.log_info(sh.tockloader(
"install",
f"libtock-rs/target/nrf52840/thumbv7em-none-eabi/release/examples/{self.app_name}.tab",
"--jlink-serial-number",
self.board_serial_no,
_err_to_out=True))

else:
self.log_info(f"[BUILDING] libtock-c app {self.app_name}...")
self.log_info(sh.make("-C", self.libtock_path, _err_to_out=True))

# Flash libtock app to board.
self.log_info(f"[FLASHING] libtock-c app {self.app_name} to: {self.board_serial_no}...")
self.log_info(sh.tockloader(
"install",
f"{self.libtock_path}/build/{self.app_name}.tab",
"--jlink-serial-number",
self.board_serial_no,
_err_to_out=True))

self.log_info(f"[FLASHING -- COMPLETE] {self.app_name}.")


Expand Down
52 changes: 49 additions & 3 deletions tensile/ieee802154_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from board import Board

def radio_rx_test(boards, test_duration_sec=10):
def libtock_c_radio_rx_test(boards, test_duration_sec=10):
# We require 2 boards for this test.
# TODO: Better handling/reporting of case w/o at least 2 boards.
if len(boards) < 2:
Expand Down Expand Up @@ -58,7 +58,7 @@ def radio_rx_test(boards, test_duration_sec=10):
raise Exception("FAILED: radio_rx test -- {} out of {} packets transmitted successfully. \
Dump of received packets:\n {}".format(success_passed, TOTAL_PACKETS, test_rx_results))

def radio_tx_raw_test(boards, test_duration_sec=10):
def libtock_c_radio_tx_raw_test(boards, test_duration_sec=10):
# We require 2 boards for this test.
# TODO: Better handling/reporting of case w/o at least 2 boards.
if len(boards) < 2:
Expand Down Expand Up @@ -115,7 +115,7 @@ def radio_tx_raw_test(boards, test_duration_sec=10):
raise Exception("FAILED: radio_tx_raw test -- {} out of {} packets transmitted successfully. Dump of \
received packets: \n {}".format(success_passed, TOTAL_PACKETS, test_rx_results))

def radio_tx_test(boards, test_duration_sec=10):
def libtock_c_radio_tx_test(boards, test_duration_sec=10):
# Create board objects for each device.
board = Board(boards[0],
"tock/boards/nordic/nrf52840dk",
Expand All @@ -142,3 +142,49 @@ def radio_tx_test(boards, test_duration_sec=10):
board.log_info("PASSED: radio_tx test")
else:
raise Exception("FAILED: radio_tx test -- {} out of {} packets transmitted successfully.".format(success_passed, TOTAL_PACKETS))


# Test libtock-rs `ieee802154_tx_raw` and `ieee802154_rx_raw` apps.
def libtock_rs_radio_raw_test(boards, test_duration_sec=10):
# We require 2 boards for this test.
# TODO: Better handling/reporting of case w/o at least 2 boards.
if len(boards) < 2:
raise Exception("Error: [Inadequate resources] - radio_rxtx test requires at least two available boards.")

# Create board objects for tx device.
board_tx = Board(boards[0],
"tock/boards/tutorials/nrf52840dk-thread-tutorial",
"libtock-rs/ieee802154_tx_raw.rs",
"ieee802154_tx_raw",
"tock/target/thumbv7em-none-eabi/release/nrf52840dk-thread-tutorial.bin")

# Create board object for rx device.
board_rx = Board(boards[2],
"tock/boards/nordic/nrf52840dk",
"libtock-rs/ieee802154_rx_raw.rs",
"ieee802154_rx_raw",
"tock/target/thumbv7em-none-eabi/release/nrf52840dk-thread-tutorial.bin")

# Setup boards for test.
board_tx.prep_test()
board_rx.prep_test()

# Run tests.
board_tx.run_test(1)
test_rx_results = board_rx.run_test(test_duration_sec)

# The standard TX test transmits a packet every 1s.
success_passed = 0
TOTAL_PACKETS = test_duration_sec

index = 0
for item in test_rx_results:
if "Received frame with body of len 15:" in item:
success_passed += 1

# Check if 50% of packets were transmitted successfully.
if success_passed / TOTAL_PACKETS >= 0.50:
board_rx.log_info("PASSED: radio_rx test")
else:
raise Exception("FAILED: radio_rx test -- {} out of {} packets transmitted successfully. \
Dump of received packets:\n {}".format(success_passed, TOTAL_PACKETS, test_rx_results))
13 changes: 9 additions & 4 deletions tensile/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pynrfjprog import LowLevel
from ieee802154_tests import radio_tx_test, radio_rx_test, radio_tx_raw_test
from ieee802154_tests import libtock_c_radio_rx_test, libtock_c_radio_tx_raw_test, libtock_c_radio_tx_test, libtock_rs_radio_raw_test
from openthread_tests import openthread_hello_test

if __name__ == '__main__':
Expand All @@ -9,9 +9,14 @@
available_devices = nrfjprog_api.enum_emu_snr()
print(available_devices)
nrfjprog_api.close()
radio_tx_test(available_devices)
radio_rx_test(available_devices, 60)
radio_tx_raw_test(available_devices, 60)

# libtock-c tests #
libtock_c_radio_tx_test(available_devices)
libtock_c_radio_rx_test(available_devices, 60)
libtock_c_radio_tx_raw_test(available_devices, 60)
openthread_hello_test(available_devices)

# libtock-rs tests #
libtock_rs_radio_raw_test(available_devices, 60)

print("===SUCCESSFULLY PASSED ALL TESTS===")
6 changes: 1 addition & 5 deletions tensile/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@ source tensile-venv/bin/activate
# Install needed python dependencies.
pip install -r requirements.txt

# NOTE: The testing scripts expect these repos to be in the same directory as main.py.
# Clone libtock-c / tock / tockloader (need to clone tockloader from my repo temporarily
# until the tockloader jlink-selector branch is merged).

if [ ! -f ot-central-controller.hex ]; then
wget https://book.tockos.org/assets/temperature-sensor/ot-central-controller.hex
fi

git clone https://github.com/tock/tock.git
git clone https://github.com/tock/libtock-c.git

git clone https://github.com/tock/libtock-rs.git

Loading