shepherd-core 2023.12.1__tar.gz → 2024.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/PKG-INFO +49 -33
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/README.md +41 -24
- shepherd_core-2024.4.2/examples/experiment_from_yaml.yaml +30 -0
- shepherd_core-2024.4.2/examples/experiment_generic_var1.py +74 -0
- shepherd_core-2024.4.2/examples/experiment_generic_var2.py +67 -0
- shepherd_core-2024.4.2/examples/experiment_models.py +91 -0
- shepherd_core-2024.4.2/examples/firmware_model.py +49 -0
- shepherd_core-2024.4.2/examples/firmware_modification.py +43 -0
- shepherd_core-2024.4.2/examples/inventory.py +24 -0
- shepherd_core-2024.4.2/examples/uart_decode_waveform.py +32 -0
- shepherd_core-2024.4.2/examples/uart_raw2.csv +15536 -0
- shepherd_core-2024.4.2/examples/vharvester_simulation.py +85 -0
- shepherd_core-2024.4.2/examples/vsource_simulation.py +105 -0
- shepherd_core-2024.4.2/pyproject.toml +113 -0
- shepherd_core-2024.4.2/setup.cfg +4 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/__init__.py +5 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/calibration_hw_def.py +9 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/commons.py +2 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/__init__.py +11 -0
- shepherd_core-2024.4.2/shepherd_core/data_models/base/__init__.py +4 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/cal_measurement.py +18 -6
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/calibration.py +41 -16
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/content.py +20 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/shepherd.py +23 -12
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/timezone.py +5 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/base/wrapper.py +3 -3
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/__init__.py +5 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/_external_fixtures.yaml +32 -16
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/energy_environment.py +7 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/energy_environment_fixture.yaml +3 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/firmware.py +12 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/firmware_datatype.py +7 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/virtual_harvester.py +25 -20
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/virtual_harvester_fixture.yaml +1 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/virtual_source.py +40 -23
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/content/virtual_source_fixture.yaml +1 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/experiment/__init__.py +5 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/experiment/experiment.py +16 -15
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/experiment/observer_features.py +18 -12
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/experiment/target_config.py +11 -7
- shepherd_core-2024.4.2/shepherd_core/data_models/readme.md +88 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/__init__.py +10 -3
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/emulation.py +9 -6
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/firmware_mod.py +4 -2
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/harvest.py +5 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/observer_tasks.py +4 -2
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/programming.py +3 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/task/testbed_tasks.py +10 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/__init__.py +5 -2
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/cape.py +8 -6
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/gpio.py +11 -9
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/mcu.py +10 -10
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/observer.py +10 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/observer_fixture.yaml +23 -22
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/target.py +5 -3
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/target_fixture.yaml +11 -11
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/testbed.py +6 -3
- shepherd_core-2024.4.2/shepherd_core/decoder_waveform/__init__.py +5 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/decoder_waveform/uart.py +44 -25
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/fw_tools/__init__.py +2 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/fw_tools/converter.py +20 -9
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/fw_tools/converter_elf.py +3 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/fw_tools/patcher.py +16 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/fw_tools/validation.py +25 -5
- shepherd_core-2024.4.2/shepherd_core/inventory/__init__.py +115 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/inventory/python.py +4 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/inventory/system.py +13 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/inventory/target.py +4 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/logger.py +5 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/reader.py +44 -26
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/testbed_client/__init__.py +2 -0
- shepherd_core-2024.4.2/shepherd_core/testbed_client/cache_path.py +17 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/testbed_client/client.py +14 -8
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/testbed_client/fixtures.py +30 -11
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/testbed_client/user_model.py +13 -6
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/vsource/__init__.py +2 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/vsource/virtual_converter_model.py +11 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/vsource/virtual_harvester_model.py +8 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/vsource/virtual_source_model.py +10 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/writer.py +28 -20
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core.egg-info/PKG-INFO +50 -34
- shepherd_core-2024.4.2/shepherd_core.egg-info/SOURCES.txt +135 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core.egg-info/requires.txt +2 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core.egg-info/top_level.txt +0 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/conftest.py +1 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_experiment.yaml +1 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_experiment_alternative.yaml +1 -1
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_base_models.py +7 -7
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_content_models.py +19 -19
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_experiment_models.py +13 -12
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_task_models.py +5 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_testbed_models.py +8 -7
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/decoder_waveform/test_decoder.py +1 -1
- shepherd_core-2024.4.2/tests/fw_tools/build_msp.elf +0 -0
- shepherd_core-2024.4.2/tests/fw_tools/build_nrf.elf +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/fw_tools/test_converter.py +12 -12
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/fw_tools/test_patcher.py +5 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/fw_tools/test_validation.py +8 -8
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/test_examples.py +6 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/test_writer.py +7 -7
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/vsource/conftest.py +6 -6
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/vsource/test_converter.py +3 -4
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/vsource/test_harvester.py +5 -5
- shepherd_core-2024.4.2/tests/vsource/test_z.py +6 -0
- shepherd_core-2023.12.1/pyproject.toml +0 -10
- shepherd_core-2023.12.1/setup.cfg +0 -86
- shepherd_core-2023.12.1/shepherd_core/data_models/base/__init__.py +0 -1
- shepherd_core-2023.12.1/shepherd_core/decoder_waveform/__init__.py +0 -3
- shepherd_core-2023.12.1/shepherd_core/inventory/__init__.py +0 -55
- shepherd_core-2023.12.1/shepherd_core.egg-info/SOURCES.txt +0 -126
- shepherd_core-2023.12.1/tests/vsource/test_z.py +0 -5
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/cape_fixture.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/gpio_fixture.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/mcu_fixture.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core/data_models/testbed/testbed_fixture.yaml +0 -0
- /shepherd_core-2023.12.1/shepherd_core/data_models/doc_virtual_source.py → /shepherd_core-2024.4.2/shepherd_core/data_models/virtual_source_doc.txt +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core.egg-info/dependency_links.txt +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/shepherd_core.egg-info/zip-safe +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/conftest.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_cal_data.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_cal_data_faulty.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_cal_meas.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_cal_meas_faulty1.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_cal_meas_faulty2.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_emulator.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_harvester.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_testbed.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/example_config_virtsource.yaml +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_content_fixtures.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_examples.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_task_generation.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/data_models/test_testbed_fixtures.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/decoder_waveform/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/fw_tools/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/fw_tools/conftest.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/inventory/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/inventory/test_inventory.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/test_cal_hw.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/test_logger.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/test_reader.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/testbed_client/__init__.py +0 -0
- {shepherd_core-2023.12.1 → shepherd_core-2024.4.2}/tests/vsource/__init__.py +0 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: shepherd_core
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2024.4.2
|
|
4
4
|
Summary: Programming- and CLI-Interface for the h5-dataformat of the Shepherd-Testbed
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Project-URL: Tracker, https://github.com/orgua/shepherd-datalib/issues
|
|
11
|
-
Project-URL: Source, https://github.com/orgua/shepherd-datalib
|
|
5
|
+
Author-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
6
|
+
Maintainer-email: Ingmar Splitt <ingmar.splitt@tu-dresden.de>
|
|
7
|
+
Project-URL: Documentation, https://github.com/orgua/shepherd-datalib/blob/main/README.md
|
|
8
|
+
Project-URL: Issues, https://github.com/orgua/shepherd-datalib/issues
|
|
9
|
+
Project-URL: Source, https://pypi.org/project/shepherd-core/
|
|
12
10
|
Keywords: testbed,beaglebone,pru,batteryless,energyharvesting,solar
|
|
13
11
|
Platform: unix
|
|
14
12
|
Platform: linux
|
|
@@ -35,12 +33,13 @@ Requires-Dist: numpy
|
|
|
35
33
|
Requires-Dist: pyYAML
|
|
36
34
|
Requires-Dist: chromalog
|
|
37
35
|
Requires-Dist: pydantic[email]>2.0.0
|
|
38
|
-
Requires-Dist: tqdm
|
|
39
36
|
Requires-Dist: scipy
|
|
37
|
+
Requires-Dist: tqdm
|
|
40
38
|
Requires-Dist: intelhex
|
|
41
39
|
Requires-Dist: requests
|
|
42
40
|
Requires-Dist: pyelftools
|
|
43
41
|
Requires-Dist: zstandard
|
|
42
|
+
Requires-Dist: typing-extensions
|
|
44
43
|
Provides-Extra: elf
|
|
45
44
|
Requires-Dist: pwntools-elf-only; extra == "elf"
|
|
46
45
|
Provides-Extra: inventory
|
|
@@ -63,7 +62,7 @@ Requires-Dist: coverage; extra == "test"
|
|
|
63
62
|
[](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
|
|
64
63
|
[](https://github.com/astral-sh/ruff)
|
|
65
64
|
|
|
66
|
-
**Documentation**: <https://orgua.github.io/shepherd
|
|
65
|
+
**Main Documentation**: <https://orgua.github.io/shepherd>
|
|
67
66
|
|
|
68
67
|
**Source Code**: <https://github.com/orgua/shepherd-datalib>
|
|
69
68
|
|
|
@@ -71,53 +70,42 @@ Requires-Dist: coverage; extra == "test"
|
|
|
71
70
|
|
|
72
71
|
---
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
`shepherd-core` is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
|
|
75
74
|
|
|
76
|
-
For postprocessing shepherds .h5-files
|
|
75
|
+
For postprocessing shepherds .h5-files usage of [shepherd_data](https://pypi.org/project/shepherd_data) is recommended.
|
|
77
76
|
|
|
78
77
|
## Features
|
|
79
78
|
|
|
80
79
|
- read and write shepherds hdf5-files
|
|
81
|
-
- create, read, write and convert experiments for the testbed
|
|
80
|
+
- create, read, write and convert experiments for the testbed
|
|
81
|
+
- all required data-models are included
|
|
82
82
|
- simulate the virtual source, including virtual harvesters (and virtual converter as a whole)
|
|
83
|
-
- connect and query the testbed via a webclient (TestbedClient)
|
|
83
|
+
- connect and query the testbed via a webclient (TestbedClient in alpha-stage)
|
|
84
84
|
- offline usage defaults to static demo-fixtures loaded from yaml-files in the model-directories
|
|
85
85
|
- work with target-firmwares
|
|
86
86
|
- embed, modify, verify, convert
|
|
87
87
|
- **Note**: working with ELF-files requires external dependencies, see ``Installation``-Chapter
|
|
88
88
|
- decode waveforms (gpio-state & timestamp) to UART
|
|
89
|
-
- create an inventory (
|
|
89
|
+
- create an inventory (for deployed versions of software, hardware)
|
|
90
90
|
|
|
91
|
-
See [
|
|
91
|
+
See [official documentation](https://orgua.github.io/shepherd) or [example scripts](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased in both. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a [trafficbench](https://github.com/orgua/TrafficBench)-experiment that's used to derive the link-matrix of the testbed-nodes.
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
## Config-Models in Detail
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|---------|--------------|--------------------------------------------|
|
|
97
|
-
| Ubuntu | 3.8 - 3.12 | |
|
|
98
|
-
| Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
|
|
99
|
-
| MacOS | 3.8 - 3.12 | hex-conversion missing |
|
|
95
|
+
These pydantic data-models are used throughout all shepherd interfaces. Users can create an experiment, include their own content and feed it to the testbed.
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
- hex-conversion needs a working and accessible objcopy
|
|
103
|
-
- elf-supports needs
|
|
104
|
-
- ``shepherd-core[elf]`` installs ``pwntools-elf-only``
|
|
105
|
-
- most elf-features also still utilize hex-conversion
|
|
106
|
-
|
|
107
|
-
### Data-Models in Detail
|
|
108
|
-
|
|
109
|
-
- new orchestration ``/data-models`` with focus on remote shepherd-testbed
|
|
97
|
+
- orchestration ``/data-models`` with focus on remote shepherd-testbed
|
|
110
98
|
- classes of sub-models
|
|
111
99
|
- ``/base``: base-classes, configuration and -functionality for all models
|
|
112
100
|
- ``/testbed``: meta-data representation of all testbed-components
|
|
113
|
-
- ``/content``: reusable meta-data for fw, h5 and vsrc-definitions
|
|
101
|
+
- ``/content``: reusable user-defined meta-data for fw, h5 and vsrc-definitions
|
|
114
102
|
- ``/experiment``: configuration-models including sub-systems
|
|
115
103
|
- ``/task``: digestible configs for shepherd-herd or -sheep
|
|
116
104
|
- behavior controlled by ``ShpModel`` and ``content``-model
|
|
117
105
|
- a basic database is available as fixtures through a ``tb_client``
|
|
118
106
|
- fixtures selectable by name & ID
|
|
119
107
|
- fixtures support inheritance
|
|
120
|
-
- models support
|
|
108
|
+
- the models support
|
|
121
109
|
- auto-completion with neutral / sensible values
|
|
122
110
|
- complex and custom datatypes (i.e. PositiveInt, lists-checks on length)
|
|
123
111
|
- checking of inputs and type-casting
|
|
@@ -130,6 +118,20 @@ Notes:
|
|
|
130
118
|
- exposes no internal paths
|
|
131
119
|
- experiments can be transformed to task-sets (``TestbedTasks.from_xp()``)
|
|
132
120
|
|
|
121
|
+
## Compatibility
|
|
122
|
+
|
|
123
|
+
| OS | PyVersion | Comment |
|
|
124
|
+
|---------|--------------|--------------------------------------------|
|
|
125
|
+
| Ubuntu | 3.8 - 3.12 | |
|
|
126
|
+
| Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
|
|
127
|
+
| MacOS | 3.8 - 3.12 | hex-conversion missing |
|
|
128
|
+
|
|
129
|
+
Notes:
|
|
130
|
+
- hex-conversion needs a working and accessible objcopy
|
|
131
|
+
- elf-supports needs
|
|
132
|
+
- ``shepherd-core[elf]`` installs ``pwntools-elf-only``
|
|
133
|
+
- most elf-features also still utilize hex-conversion
|
|
134
|
+
|
|
133
135
|
## Installation
|
|
134
136
|
|
|
135
137
|
The Library is available via PyPI and can be installed with
|
|
@@ -166,3 +168,17 @@ For creating an inventory of the host-system you should install
|
|
|
166
168
|
```shell
|
|
167
169
|
pip install shepherd-core[inventory]
|
|
168
170
|
```
|
|
171
|
+
|
|
172
|
+
## Unittests
|
|
173
|
+
|
|
174
|
+
To run the testbench, follow these steps:
|
|
175
|
+
|
|
176
|
+
1. Navigate your host-shell into the package-folder and
|
|
177
|
+
2. install dependencies
|
|
178
|
+
3. run the testbench (~ 320 tests):
|
|
179
|
+
|
|
180
|
+
```Shell
|
|
181
|
+
cd shepherd-datalib/shepherd_core
|
|
182
|
+
pip3 install ./[tests]
|
|
183
|
+
pytest
|
|
184
|
+
```
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/orgua/shepherd-datalib/actions/workflows/py_unittest.yml)
|
|
6
6
|
[](https://github.com/astral-sh/ruff)
|
|
7
7
|
|
|
8
|
-
**Documentation**: <https://orgua.github.io/shepherd
|
|
8
|
+
**Main Documentation**: <https://orgua.github.io/shepherd>
|
|
9
9
|
|
|
10
10
|
**Source Code**: <https://github.com/orgua/shepherd-datalib>
|
|
11
11
|
|
|
@@ -13,53 +13,42 @@
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
`shepherd-core` is designed as a library and bundles data-models and file-access-routines for the shepherd-testbed, that are used by several codebases.
|
|
17
17
|
|
|
18
|
-
For postprocessing shepherds .h5-files
|
|
18
|
+
For postprocessing shepherds .h5-files usage of [shepherd_data](https://pypi.org/project/shepherd_data) is recommended.
|
|
19
19
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
22
|
- read and write shepherds hdf5-files
|
|
23
|
-
- create, read, write and convert experiments for the testbed
|
|
23
|
+
- create, read, write and convert experiments for the testbed
|
|
24
|
+
- all required data-models are included
|
|
24
25
|
- simulate the virtual source, including virtual harvesters (and virtual converter as a whole)
|
|
25
|
-
- connect and query the testbed via a webclient (TestbedClient)
|
|
26
|
+
- connect and query the testbed via a webclient (TestbedClient in alpha-stage)
|
|
26
27
|
- offline usage defaults to static demo-fixtures loaded from yaml-files in the model-directories
|
|
27
28
|
- work with target-firmwares
|
|
28
29
|
- embed, modify, verify, convert
|
|
29
30
|
- **Note**: working with ELF-files requires external dependencies, see ``Installation``-Chapter
|
|
30
31
|
- decode waveforms (gpio-state & timestamp) to UART
|
|
31
|
-
- create an inventory (
|
|
32
|
+
- create an inventory (for deployed versions of software, hardware)
|
|
32
33
|
|
|
33
|
-
See [
|
|
34
|
+
See [official documentation](https://orgua.github.io/shepherd) or [example scripts](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/examples) for more details and usage. Most functionality is showcased in both. The [extra](https://github.com/orgua/shepherd-datalib/tree/main/shepherd_core/extra)-directory holds data-generators relevant for the testbed. Notably is a [trafficbench](https://github.com/orgua/TrafficBench)-experiment that's used to derive the link-matrix of the testbed-nodes.
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
## Config-Models in Detail
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|---------|--------------|--------------------------------------------|
|
|
39
|
-
| Ubuntu | 3.8 - 3.12 | |
|
|
40
|
-
| Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
|
|
41
|
-
| MacOS | 3.8 - 3.12 | hex-conversion missing |
|
|
42
|
-
|
|
43
|
-
Notes:
|
|
44
|
-
- hex-conversion needs a working and accessible objcopy
|
|
45
|
-
- elf-supports needs
|
|
46
|
-
- ``shepherd-core[elf]`` installs ``pwntools-elf-only``
|
|
47
|
-
- most elf-features also still utilize hex-conversion
|
|
48
|
-
|
|
49
|
-
### Data-Models in Detail
|
|
38
|
+
These pydantic data-models are used throughout all shepherd interfaces. Users can create an experiment, include their own content and feed it to the testbed.
|
|
50
39
|
|
|
51
|
-
-
|
|
40
|
+
- orchestration ``/data-models`` with focus on remote shepherd-testbed
|
|
52
41
|
- classes of sub-models
|
|
53
42
|
- ``/base``: base-classes, configuration and -functionality for all models
|
|
54
43
|
- ``/testbed``: meta-data representation of all testbed-components
|
|
55
|
-
- ``/content``: reusable meta-data for fw, h5 and vsrc-definitions
|
|
44
|
+
- ``/content``: reusable user-defined meta-data for fw, h5 and vsrc-definitions
|
|
56
45
|
- ``/experiment``: configuration-models including sub-systems
|
|
57
46
|
- ``/task``: digestible configs for shepherd-herd or -sheep
|
|
58
47
|
- behavior controlled by ``ShpModel`` and ``content``-model
|
|
59
48
|
- a basic database is available as fixtures through a ``tb_client``
|
|
60
49
|
- fixtures selectable by name & ID
|
|
61
50
|
- fixtures support inheritance
|
|
62
|
-
- models support
|
|
51
|
+
- the models support
|
|
63
52
|
- auto-completion with neutral / sensible values
|
|
64
53
|
- complex and custom datatypes (i.e. PositiveInt, lists-checks on length)
|
|
65
54
|
- checking of inputs and type-casting
|
|
@@ -72,6 +61,20 @@ Notes:
|
|
|
72
61
|
- exposes no internal paths
|
|
73
62
|
- experiments can be transformed to task-sets (``TestbedTasks.from_xp()``)
|
|
74
63
|
|
|
64
|
+
## Compatibility
|
|
65
|
+
|
|
66
|
+
| OS | PyVersion | Comment |
|
|
67
|
+
|---------|--------------|--------------------------------------------|
|
|
68
|
+
| Ubuntu | 3.8 - 3.12 | |
|
|
69
|
+
| Windows | 3.8 - 3.12 | no support for elf and hex-conversions yet |
|
|
70
|
+
| MacOS | 3.8 - 3.12 | hex-conversion missing |
|
|
71
|
+
|
|
72
|
+
Notes:
|
|
73
|
+
- hex-conversion needs a working and accessible objcopy
|
|
74
|
+
- elf-supports needs
|
|
75
|
+
- ``shepherd-core[elf]`` installs ``pwntools-elf-only``
|
|
76
|
+
- most elf-features also still utilize hex-conversion
|
|
77
|
+
|
|
75
78
|
## Installation
|
|
76
79
|
|
|
77
80
|
The Library is available via PyPI and can be installed with
|
|
@@ -108,3 +111,17 @@ For creating an inventory of the host-system you should install
|
|
|
108
111
|
```shell
|
|
109
112
|
pip install shepherd-core[inventory]
|
|
110
113
|
```
|
|
114
|
+
|
|
115
|
+
## Unittests
|
|
116
|
+
|
|
117
|
+
To run the testbench, follow these steps:
|
|
118
|
+
|
|
119
|
+
1. Navigate your host-shell into the package-folder and
|
|
120
|
+
2. install dependencies
|
|
121
|
+
3. run the testbench (~ 320 tests):
|
|
122
|
+
|
|
123
|
+
```Shell
|
|
124
|
+
cd shepherd-datalib/shepherd_core
|
|
125
|
+
pip3 install ./[tests]
|
|
126
|
+
pytest
|
|
127
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
datatype: Experiment
|
|
2
|
+
parameters:
|
|
3
|
+
id: 4567
|
|
4
|
+
name: meaningful Test-Name
|
|
5
|
+
time_start: 2033-03-13 14:15:16
|
|
6
|
+
target_configs:
|
|
7
|
+
- target_IDs: [9, 10, 11]
|
|
8
|
+
custom_IDs: [0, 1, 2]
|
|
9
|
+
energy_env:
|
|
10
|
+
name: SolarSunny
|
|
11
|
+
virtual_source:
|
|
12
|
+
name: diode+capacitor
|
|
13
|
+
firmware1:
|
|
14
|
+
name: nrf52_demo_rf
|
|
15
|
+
- target_IDs:
|
|
16
|
+
- 1
|
|
17
|
+
- 2
|
|
18
|
+
- 3
|
|
19
|
+
- 4
|
|
20
|
+
custom_IDs: [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
|
|
21
|
+
energy_env:
|
|
22
|
+
name: ThermoelectricWashingMachine
|
|
23
|
+
virtual_source:
|
|
24
|
+
name: BQ25570-Schmitt
|
|
25
|
+
harvester:
|
|
26
|
+
name: mppt_bq_thermoelectric
|
|
27
|
+
firmware1:
|
|
28
|
+
name: nrf52_demo_rf
|
|
29
|
+
firmware2:
|
|
30
|
+
name: msp430_deep_sleep
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""How-to for defining an experiment - variant 1.
|
|
2
|
+
|
|
3
|
+
What the code does:
|
|
4
|
+
- recommended approach for missing testbed-client
|
|
5
|
+
- variants
|
|
6
|
+
- var1 - references a server-path for the firmware
|
|
7
|
+
- var2 - embeds local firmware in yaml (elf-support is linux-only)
|
|
8
|
+
- assumption:
|
|
9
|
+
- start ASAP,
|
|
10
|
+
- no custom IDs,
|
|
11
|
+
- static Power-Supply
|
|
12
|
+
- no power-tracing
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from shepherd_core import TestbedClient
|
|
19
|
+
from shepherd_core.data_models import FirmwareDType
|
|
20
|
+
from shepherd_core.data_models import GpioTracing
|
|
21
|
+
from shepherd_core.data_models.content import EnergyEnvironment
|
|
22
|
+
from shepherd_core.data_models.content import Firmware
|
|
23
|
+
from shepherd_core.data_models.experiment import Experiment
|
|
24
|
+
from shepherd_core.data_models.experiment import TargetConfig
|
|
25
|
+
from shepherd_core.data_models.task import TestbedTasks
|
|
26
|
+
from shepherd_core.data_models.testbed import MCU
|
|
27
|
+
|
|
28
|
+
# for online-queries the lib can be connected to the testbed-server
|
|
29
|
+
# NOTE: there are 3 states:
|
|
30
|
+
# - unconnected -> demo-fixture is queried (locally)
|
|
31
|
+
# - connected -> publicly available data is queried online
|
|
32
|
+
# - logged in with token -> also private data is queried online
|
|
33
|
+
tb_client = TestbedClient()
|
|
34
|
+
do_connect = False
|
|
35
|
+
|
|
36
|
+
if do_connect:
|
|
37
|
+
tb_client.connect()
|
|
38
|
+
|
|
39
|
+
xp = Experiment(
|
|
40
|
+
id="4567",
|
|
41
|
+
name="meaningful_TestName",
|
|
42
|
+
# time_start could be "2033-03-13 14:15:16" or "datetime.now() + timedelta(minutes=30)"
|
|
43
|
+
duration=30,
|
|
44
|
+
target_configs=[
|
|
45
|
+
TargetConfig(
|
|
46
|
+
target_IDs=range(7, 13),
|
|
47
|
+
custom_IDs=range(1, 100), # note: longer list is OK
|
|
48
|
+
energy_env=EnergyEnvironment(name="eenv_static_3000mV_50mA_3600s"),
|
|
49
|
+
firmware1=Firmware(
|
|
50
|
+
name="FW_TestXYZ",
|
|
51
|
+
data=Path("/var/shepherd/content/fw/nes_lab/nrf52_demo_rf/build.elf"),
|
|
52
|
+
data_type=FirmwareDType.path_elf,
|
|
53
|
+
data_local=False,
|
|
54
|
+
mcu=MCU(name="nRF52"),
|
|
55
|
+
),
|
|
56
|
+
power_tracing=None,
|
|
57
|
+
gpio_tracing=GpioTracing(
|
|
58
|
+
uart_decode=True, # enables logging uart from userspace
|
|
59
|
+
uart_baudrate=115_200,
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
],
|
|
63
|
+
)
|
|
64
|
+
xp.to_file("experiment_generic_var1.yaml")
|
|
65
|
+
|
|
66
|
+
# Create a tasks-list for the testbed
|
|
67
|
+
tb_tasks = TestbedTasks.from_xp(xp)
|
|
68
|
+
tb_tasks.to_file("experiment_generic_var1_tbt.yaml")
|
|
69
|
+
|
|
70
|
+
# next steps:
|
|
71
|
+
# - copy to server:
|
|
72
|
+
# scp ./experiment_generic_varX_tbt.yaml user@shepherd.cfaed.tu-dresden.de:/var/shepherd/content/
|
|
73
|
+
# - run with herd-tool:
|
|
74
|
+
# shepherd-herd --verbose run --attach /var/shepherd/content/experiment_generic_varX_tbt.yaml
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""How-to for defining an experiment.
|
|
2
|
+
|
|
3
|
+
- recommended approach for missing testbed-client
|
|
4
|
+
- variants
|
|
5
|
+
- var1 - references a server-path for the firmware
|
|
6
|
+
- var2 - embeds local firmware in yaml (elf-support is linux-only)
|
|
7
|
+
- assumption:
|
|
8
|
+
- start ASAP,
|
|
9
|
+
- no custom IDs,
|
|
10
|
+
- static Power-Supply
|
|
11
|
+
- no power-tracing
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from shepherd_core import TestbedClient
|
|
18
|
+
from shepherd_core.data_models import GpioTracing
|
|
19
|
+
from shepherd_core.data_models.content import EnergyEnvironment
|
|
20
|
+
from shepherd_core.data_models.content import Firmware
|
|
21
|
+
from shepherd_core.data_models.experiment import Experiment
|
|
22
|
+
from shepherd_core.data_models.experiment import TargetConfig
|
|
23
|
+
from shepherd_core.data_models.task import TestbedTasks
|
|
24
|
+
|
|
25
|
+
# for online-queries the lib can be connected to the testbed-server
|
|
26
|
+
# NOTE: there are 3 states:
|
|
27
|
+
# - unconnected -> demo-fixture is queried (locally)
|
|
28
|
+
# - connected -> publicly available data is queried online
|
|
29
|
+
# - logged in with token -> also private data is queried online
|
|
30
|
+
tb_client = TestbedClient()
|
|
31
|
+
do_connect = False
|
|
32
|
+
|
|
33
|
+
if do_connect:
|
|
34
|
+
tb_client.connect()
|
|
35
|
+
|
|
36
|
+
xp = Experiment(
|
|
37
|
+
id="4567",
|
|
38
|
+
name="meaningful_TestName",
|
|
39
|
+
# time_start could be "2033-03-13 14:15:16" or "datetime.now() + timedelta(minutes=30)"
|
|
40
|
+
duration=30,
|
|
41
|
+
target_configs=[
|
|
42
|
+
TargetConfig(
|
|
43
|
+
target_IDs=range(7, 13),
|
|
44
|
+
custom_IDs=range(1, 100), # note: longer list is OK
|
|
45
|
+
energy_env=EnergyEnvironment(name="eenv_static_3000mV_50mA_3600s"),
|
|
46
|
+
firmware1=Firmware.from_firmware(
|
|
47
|
+
file=Path("./firmware_nrf.elf").absolute(),
|
|
48
|
+
),
|
|
49
|
+
power_tracing=None,
|
|
50
|
+
gpio_tracing=GpioTracing(
|
|
51
|
+
uart_decode=True, # enables logging uart from userspace
|
|
52
|
+
uart_baudrate=115_200,
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
)
|
|
57
|
+
xp.to_file("experiment_generic_var2.yaml")
|
|
58
|
+
|
|
59
|
+
# Create a tasks-list for the testbed
|
|
60
|
+
tb_tasks = TestbedTasks.from_xp(xp)
|
|
61
|
+
tb_tasks.to_file("experiment_generic_var2_tbt.yaml")
|
|
62
|
+
|
|
63
|
+
# next steps:
|
|
64
|
+
# - copy to server:
|
|
65
|
+
# scp ./experiment_generic_varX_tbt.yaml user@shepherd.cfaed.tu-dresden.de:/var/shepherd/content/
|
|
66
|
+
# - run with herd-tool:
|
|
67
|
+
# shepherd-herd --verbose run --attach /var/shepherd/content/experiment_generic_varX_tbt.yaml
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Shows different ways to define an experiment.
|
|
2
|
+
|
|
3
|
+
How to define an experiment:
|
|
4
|
+
|
|
5
|
+
- within python (shown in this example)
|
|
6
|
+
- object-oriented data-models of
|
|
7
|
+
- experiment
|
|
8
|
+
- TargetConfig -> shared for group of targets
|
|
9
|
+
- virtualSource -> defines energy environment and converters
|
|
10
|
+
- sub-elements reusable
|
|
11
|
+
- scriptable for range of experiments
|
|
12
|
+
- check for plausibility right away
|
|
13
|
+
- as yaml (shown in experiment_from_yaml.yaml)
|
|
14
|
+
- default file-format for storing meta-data (for shepherd)
|
|
15
|
+
- minimal writing
|
|
16
|
+
- easy to copy parts
|
|
17
|
+
- submittable through web-interface
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from shepherd_core import TestbedClient
|
|
22
|
+
from shepherd_core.data_models.content import EnergyEnvironment
|
|
23
|
+
from shepherd_core.data_models.content import Firmware
|
|
24
|
+
from shepherd_core.data_models.content import VirtualHarvesterConfig
|
|
25
|
+
from shepherd_core.data_models.content import VirtualSourceConfig
|
|
26
|
+
from shepherd_core.data_models.experiment import Experiment
|
|
27
|
+
from shepherd_core.data_models.experiment import TargetConfig
|
|
28
|
+
from shepherd_core.data_models.task import TestbedTasks
|
|
29
|
+
|
|
30
|
+
# generate description for all parameters -> base for web-forms
|
|
31
|
+
Experiment.schema_to_file("experiment_schema.yaml")
|
|
32
|
+
|
|
33
|
+
# for online-queries the lib can be connected to the testbed-server
|
|
34
|
+
# NOTE: there are 3 states:
|
|
35
|
+
# - unconnected -> demo-fixture is queried (locally)
|
|
36
|
+
# - connected -> publicly available data is queried online
|
|
37
|
+
# - logged in with token -> also private data is queried online
|
|
38
|
+
tb_client = TestbedClient()
|
|
39
|
+
do_connect = False
|
|
40
|
+
|
|
41
|
+
if do_connect:
|
|
42
|
+
tb_client.connect()
|
|
43
|
+
|
|
44
|
+
# Defining an Experiment in Python
|
|
45
|
+
hrv = VirtualHarvesterConfig(name="mppt_bq_thermoelectric")
|
|
46
|
+
|
|
47
|
+
target_cfgs = [
|
|
48
|
+
# first Instance similar to yaml-syntax
|
|
49
|
+
TargetConfig(
|
|
50
|
+
target_IDs=[9, 10, 11],
|
|
51
|
+
custom_IDs=[0, 1, 2],
|
|
52
|
+
energy_env={"name": "SolarSunny"},
|
|
53
|
+
virtual_source={"name": "diode+capacitor"},
|
|
54
|
+
firmware1={"name": "nrf52_demo_rf"},
|
|
55
|
+
),
|
|
56
|
+
# second Instance fully object-oriented (recommended)
|
|
57
|
+
TargetConfig(
|
|
58
|
+
target_IDs=list(range(1, 5)),
|
|
59
|
+
custom_IDs=list(range(7, 18)), # note: longer list is OK
|
|
60
|
+
energy_env=EnergyEnvironment(name="ThermoelectricWashingMachine"),
|
|
61
|
+
virtual_source=VirtualSourceConfig(name="BQ25570-Schmitt", harvester=hrv),
|
|
62
|
+
firmware1=Firmware(name="nrf52_demo_rf"),
|
|
63
|
+
firmware2=Firmware(name="msp430_deep_sleep"),
|
|
64
|
+
),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
xperi1 = Experiment(
|
|
68
|
+
id="4567",
|
|
69
|
+
name="meaningful Test-Name",
|
|
70
|
+
time_start="2033-03-13 14:15:16", # or: datetime.now() + timedelta(minutes=30)
|
|
71
|
+
target_configs=target_cfgs,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Safe, reload and compare content
|
|
75
|
+
xperi1.to_file("experiment_from_py.yaml", minimal=False)
|
|
76
|
+
xperi2 = Experiment.from_file("experiment_from_py.yaml")
|
|
77
|
+
print(f"xp1 hash: {xperi1.get_hash()}")
|
|
78
|
+
print(f"xp2 hash: {xperi2.get_hash()}")
|
|
79
|
+
|
|
80
|
+
# comparison to same config (in yaml) fails due to internal variables, BUT:
|
|
81
|
+
xperi3 = Experiment.from_file("experiment_from_yaml.yaml")
|
|
82
|
+
print(f"xp3 hash: {xperi3.get_hash()} (won't match)")
|
|
83
|
+
|
|
84
|
+
# Create a tasks-list for the testbed
|
|
85
|
+
tb_tasks2 = TestbedTasks.from_xp(xperi2)
|
|
86
|
+
tb_tasks2.to_file("experiment_tb_tasks.yaml")
|
|
87
|
+
|
|
88
|
+
# Comparison between task-Lists succeed (experiment-comparison failed)
|
|
89
|
+
tb_tasks3 = TestbedTasks.from_xp(xperi3)
|
|
90
|
+
print(f"tasks2 hash: {tb_tasks2.get_hash()}")
|
|
91
|
+
print(f"tasks3 hash: {tb_tasks3.get_hash()}")
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""This example shows ways to embed firmware into the data-model.
|
|
2
|
+
|
|
3
|
+
Note: the new semi-automatic way to generate a data-model needs pwntools installed
|
|
4
|
+
or shepherd-core[elf].
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from shepherd_core import TestbedClient
|
|
10
|
+
from shepherd_core import fw_tools
|
|
11
|
+
from shepherd_core.data_models import Firmware
|
|
12
|
+
from shepherd_core.data_models import FirmwareDType
|
|
13
|
+
|
|
14
|
+
path_elf = Path(__file__).parent.parent / "tests/fw_tools/build_msp.elf"
|
|
15
|
+
|
|
16
|
+
# Option 1 - fully manual
|
|
17
|
+
|
|
18
|
+
fw1 = Firmware(
|
|
19
|
+
name="msp_deep_sleep1",
|
|
20
|
+
data=fw_tools.file_to_base64(path_elf),
|
|
21
|
+
data_type=FirmwareDType.base64_elf,
|
|
22
|
+
mcu={"name": "MSP430FR"},
|
|
23
|
+
owner="example",
|
|
24
|
+
group="test",
|
|
25
|
+
)
|
|
26
|
+
fw1.to_file(Path(__file__).parent / "firmware.yaml")
|
|
27
|
+
|
|
28
|
+
# Option 2 - semi-automatic -> MCU and data-type get derived
|
|
29
|
+
|
|
30
|
+
fw2 = Firmware.from_firmware(
|
|
31
|
+
file=path_elf,
|
|
32
|
+
name="msp_deep_sleep2",
|
|
33
|
+
owner="example",
|
|
34
|
+
group="test",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# store embedded data
|
|
38
|
+
path_elf2 = fw2.extract_firmware(Path(__file__).parent)
|
|
39
|
+
print(f"stored firmware to '{path_elf2.name}'")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# Option 3 - fully automatic (with login) -> owner and group get prefilled
|
|
43
|
+
|
|
44
|
+
tb_client = TestbedClient()
|
|
45
|
+
do_connect = False
|
|
46
|
+
|
|
47
|
+
if do_connect:
|
|
48
|
+
tb_client.connect(token="your_personal_login_token") # noqa: S106
|
|
49
|
+
fw3 = Firmware.from_firmware(file=path_elf, name="msp_deep_sleep3")
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""This example manipulates elf-files and embeds firmware into the data-model.
|
|
2
|
+
|
|
3
|
+
Note: make sure to have installed
|
|
4
|
+
- shepherd-core[elf] via pip
|
|
5
|
+
- build-essential or binutils-$ARCH installed.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import shutil
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from shepherd_core import fw_tools
|
|
12
|
+
from shepherd_core.data_models import Firmware
|
|
13
|
+
from shepherd_core.data_models import FirmwareDType
|
|
14
|
+
|
|
15
|
+
path_src = Path(__file__).parent.parent / "tests/fw_tools/build_msp.elf"
|
|
16
|
+
path_elf = Path(__file__).with_name("firmware_msp.elf")
|
|
17
|
+
|
|
18
|
+
# make local copy to play with
|
|
19
|
+
shutil.copy(path_src, path_elf)
|
|
20
|
+
|
|
21
|
+
print(f"UID old = 0x{fw_tools.read_uid(path_elf):X}")
|
|
22
|
+
fw_tools.modify_uid(path_elf, 0xCAFE)
|
|
23
|
+
print(f"UID new = 0x{fw_tools.read_uid(path_elf):X}")
|
|
24
|
+
|
|
25
|
+
path_hex = fw_tools.elf_to_hex(path_elf)
|
|
26
|
+
|
|
27
|
+
# just PoC - there is an easier way to generate data-model, see other fw-example
|
|
28
|
+
b64 = fw_tools.file_to_base64(path_elf)
|
|
29
|
+
|
|
30
|
+
fw = Firmware(
|
|
31
|
+
name="msp_deep_sleep",
|
|
32
|
+
data=b64,
|
|
33
|
+
data_type=FirmwareDType.base64_elf,
|
|
34
|
+
mcu={"name": "MSP430FR"},
|
|
35
|
+
owner="example",
|
|
36
|
+
group="test",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# for completion also generate hex for nrf
|
|
40
|
+
path_src = Path(__file__).parent.parent / "tests/fw_tools/build_nrf.elf"
|
|
41
|
+
path_elf = Path(__file__).with_name("firmware_nrf.elf")
|
|
42
|
+
shutil.copy(path_src, path_elf)
|
|
43
|
+
fw_tools.elf_to_hex(path_elf)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Shows how to use inventory functionality."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from shepherd_core.inventory import Inventory
|
|
6
|
+
from shepherd_core.inventory import InventoryList
|
|
7
|
+
from shepherd_core.inventory import PythonInventory
|
|
8
|
+
from shepherd_core.inventory import SystemInventory
|
|
9
|
+
from shepherd_core.inventory import TargetInventory
|
|
10
|
+
|
|
11
|
+
pi = PythonInventory.collect()
|
|
12
|
+
print(f"PyInv: {pi}")
|
|
13
|
+
si = SystemInventory.collect()
|
|
14
|
+
print(f"SysInv: {si}")
|
|
15
|
+
ti = TargetInventory.collect()
|
|
16
|
+
print(f"TgtInv: {ti}")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
inv = Inventory.collect()
|
|
20
|
+
print(f"Complete Inventory: {inv}")
|
|
21
|
+
inv.to_file("inventory.yaml", minimal=True, comment="just a test")
|
|
22
|
+
|
|
23
|
+
inl = InventoryList(elements=[inv])
|
|
24
|
+
inl.to_csv(Path(__file__).parent / "inventory.csv")
|