This is an example of using HardPy to create a functional test bench.
Note 1. These instructions describe how to use HardPy in Linux. If you want to use it in Windows, change the commands to Windows style.
Note 2. To use this example, you will need python 3.10 or higher and docker to run CouchDB 3.2 or higher.
tests
: test bench using HardPy.database
: config for database deployment.dut_fw
: DUT firmware source code. Can be modified if desired. The assembled firmware is in tests directory.
-
Clone repository.
-
Install
python
environment:$ python -m venv env $ source env/bin/activate $ pip install -r tests/requirements.txt
or, if you prefer conda, install the conda environment:
$ conda env create -f conda.yaml $ conda activate hardpy-sample
-
Install
pyocd
in the current environment:$ pyocd pack update $ pyocd pack install stm32f401retx
-
Run database from
database
folder:$ docker run --name couchdb -p 5984:5984 -e COUCHDB_USER=dev -e COUCHDB_PASSWORD=dev -v ./couchdb.ini:/opt/couchdb/etc/local.ini couchdb:3.3
or run docker compose:
$ docker compose up
-
The database is available at http://127.0.0.1:5984/_utils Login/password:
dev
Run hardpy-panel tests
and check browser:
The Nucleo F401RE devboard is used as the DUT.
Note 3. The address of the DUT is specified in the
conftest.py
file and by default it is/dev/ttyACM0
. If the DUT to be connected is detected at a different address, change it.
Tests:
- Checking the availability of firmware for the board;
- Flashing the devboard;
- Read serial number;
- Check if there is a jumper on the pins (see photo below). If the jumper is present, the LED flashes, the test passes. If there is no jumper, the test fails;
- Read the number of clicks on the User Button and display it in the operator panel interface;