You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+86-95Lines changed: 86 additions & 95 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,6 @@
2
2
#tinySA_python
3
3
##AN UNOFFICIAL Python API for the tinySA Device Series
4
4
5
-
#IN PROGRESS! The dev branch is not stable. refer to the main branch for the current stable version of the code
6
-
7
-
8
-
9
5
A Non-GUI Python API for the tinySA series of devices. This repository uses official resources and documentation but is NOT endorsed by the official tinySA product or company. See the[references](#references) section for further reading. See the[official tinySA resources](https://www.tinysa.org/wiki/) for device features.
10
6
11
7
This library covers most documented commands for the tinySA device series, and is planned to include configurable, device-specific commands and memory. The documentation (after the examples) is sorted based on the serial command for the device, with some provided usage examples. While some error checking exists in both the device and the library, it is not exhaustive. It is strongly advised to read the official documentation before attempting to script with your tinySA device. Operating the device experimentally or without referencing the official documents runs the risk of**destroying your device**. See the[tinySA First use page](https://tinysa.org/wiki/pmwiki.php?n=Main.FirstUse) for some setup tips and warnings.
@@ -70,7 +66,10 @@ Improper usage may destroy your device.
70
66
71
67
##Library Usage
72
68
73
-
This library is now avilable via PyPI, local install, or just using the class. We reccomend one of the library install options.
69
+
This library is now available via PyPI, local install, or just using the class. We recommend one of the library install options.
70
+
71
+
Several usage examples are provided in the[Example Implementations](#example-implementations) section, including working with the hardware and plotting results with matplotlib.
`pyQt5` is used with`matplotlib` to draw the figures. It needs to be installed on Linux systems to follow the examples included in tinySA_python, but is not needed on all Windows machines.
145
144
146
145
146
+
###Structure
147
147
148
-
149
-
150
-
151
-
OUT OF DATE - GETTING MAJOR OVERHAUL
152
-
153
-
This library is currently only available as the tinySA class in 'tinySA_python.py' in this repository. It is very much under development and missing some key error checking and handling. HOWEVER, ‘any’ error checking is currently more than the ‘no’ error checking provided by interfacing directly with the device. The code that is included in this repository has been tested on at least one tinySA device and is relatively stable.
154
-
155
-
Several usage examples are provided in the[Example Implementations](#example-implementations) section, including working with the hardware and plotting results with matplotlib.
156
-
157
-
148
+
The`tsapython` library, as it is avilable on PyPI is structured as follows:
158
149
159
150
```python
160
151
@@ -175,13 +166,55 @@ tsapython/
175
166
├── test_basic.py
176
167
├── test_example_workflow.py
177
168
└── test_hardware.py
169
+
```
170
+
171
+
A`docs` repository for the library will be added later in development for stable releases.
178
172
173
+
This library is also part of the`tinySA_python` repository, which includes more extensive documentation and the working development. The GitHub repository is structured as follows:
179
174
175
+
```python
180
176
177
+
tinySA_python/
178
+
├──README
179
+
├── requirements.txt
180
+
├── test_requirements.txt
181
+
├── media/
182
+
│ └──README images, screenshots
183
+
└──tsapython/
184
+
├── .python-version
185
+
├── pyproject.toml
186
+
├──README.md
187
+
├──LICENSE
188
+
├── .gitignore
189
+
├── examples/
190
+
│ ├──__init__.py
191
+
│ ├── identifying_serial_ports.py
192
+
│ ├── plotting_scan.py
193
+
│ ├── plotting_scanraw.py
194
+
│ ├── plotting_waterfall_realtime.py
195
+
│ ├── save_scan_csv.py
196
+
│ ├── using_autoconnect.py
197
+
│ └── using_command_func.py
198
+
├── src/
199
+
│ └── tsapython/
200
+
│ ├──__init__.py
201
+
│ ├── core.py
202
+
│ └── py.typed
203
+
└── tests/
204
+
├──__init__.py
205
+
├── run_all_tests.py
206
+
├── test_basic.py
207
+
├── test_example_workflow.py
208
+
└── test_hardware.py
181
209
182
210
```
183
211
184
-
running tests:
212
+
213
+
###Running Tests
214
+
215
+
Tests should be run from the root`tsapython` directory.
216
+
217
+
```python
185
218
# Run individual test files
186
219
uv run python tests/test_basic.py
187
220
uv run python tests/test_hardware.py
@@ -193,51 +226,8 @@ uv run python tests/run_all_tests.py
193
226
# Or run directly if you have Python in PATH
194
227
python tests/test_basic.py
195
228
python tests/run_all_tests.py
196
-
197
-
198
-
199
-
200
-
201
-
202
-
##Requirements
203
-
204
-
OUT OF DATE - GETTING MAJOR OVERHAUL
205
-
206
-
This project requires numpy, pandas and pyserial.
207
-
208
-
Use 'pip install -r requirements.txt' to install the following dependencies:
209
-
210
-
```python
211
-
pyserial
212
-
numpy
213
-
pandas
214
-
215
-
```
216
-
217
-
The above dependencies are only for the API interfacing of the tinySA_python library. Additional dependencies should be installed if you are following the examples in this README. These can be installed with 'pip install -r test_requirements.txt':
218
-
219
-
```python
220
-
pyserial
221
-
numpy
222
-
pandas
223
-
matplotlib
224
-
pillow
225
-
pyQt5
226
-
```
227
-
228
-
For anyone unfamiliar with using requirements files, or having issues with the libraries, these can also be installed manually in the terminal (we recommend a Python virtual environment) with:
`pyQt5` is used with`matplotlib` to draw the figures. It needs to be installed on Linux systems to follow the examples included in tinySA_python, but is not needed on all Windows machines.
235
-
236
-
237
-
238
-
239
-
240
-
241
231
##Error Handling
242
232
243
233
Some error handling has been implemented for the individual functions in this library, but not for the device configuration. Most functions have a list of acceptable formats for input, which is included in the documentation and the`library_help` function. The`tinySA_help` function will get output from the current version of firmware running on the connected tinySA device.
@@ -258,6 +248,7 @@ Some error checking includes:
258
248
259
249
This library was developed on Windows and has been lightly tested on Linux. The main difference (so far) has been in the permissions for first access of the serial port, but there may be smaller bugs in format that have not been detected yet.
260
250
251
+
261
252
###Finding the Serial Port
262
253
263
254
To start, a serial connection between the tinySA and user PC device must be created. There are several ways to list available serial ports. The library supports some rudimentary autodetection, but if that does not work instructions in this section also support manual detection.
@@ -271,9 +262,8 @@ The tinySA_python currently has some autodetection capabilities, but these are n
271
262
272
263
```python
273
264
274
-
# import tinySA library
275
-
# (NOTE: check library path relative to script path)
276
-
from src.tinySA_pythonimport tinySA
265
+
# import tinySA_python (tsapython) package
266
+
from tsapythonimport tinySA
277
267
278
268
# create a new tinySA object
279
269
tsa= tinySA()
@@ -388,9 +378,8 @@ bytearray(b'deviceid 0\r')
388
378
389
379
```python
390
380
391
-
# import the library class for the tinySA
392
-
# (NOTE: check library path relative to script path)
393
-
from src.tinySA_pythonimport tinySA
381
+
# import tinySA_python (tsapython) package
382
+
from tsapythonimport tinySA
394
383
395
384
# create a new tinySA object
396
385
tsa= tinySA()
@@ -481,9 +470,8 @@ This example shows several types of common data requests:
481
470
482
471
```python
483
472
484
-
# import the library class for the tinySA
485
-
# (NOTE: check library path relative to script path)
486
-
from src.tinySA_pythonimport tinySA
473
+
# import tinySA_python (tsapython) package
474
+
from tsapythonimport tinySA
487
475
488
476
# create a new tinySA object
489
477
tsa= tinySA()
@@ -542,9 +530,9 @@ else:
542
530
543
531
```python
544
532
545
-
# importthe library class for the tinySA
546
-
# (NOTE: check library path relative to script path)
547
-
from src.tinySA_pythonimport tinySA
533
+
# importtinySA_python (tsapython) package
534
+
from tsapythonimport tinySA
535
+
548
536
549
537
# imports FOR THE EXAMPLE
550
538
import numpyas np
@@ -641,9 +629,9 @@ This example works because `data()` returns a trace, which is going to be the sa
641
629
642
630
```python
643
631
644
-
# importtinySA library
645
-
# (NOTE: check library path relative to script path)
646
-
from src.tinySA_pythonimport tinySA
632
+
# importtinySA_python (tsapython) package
633
+
from tsapythonimport tinySA
634
+
647
635
648
636
# import matplotlib FOR THE EXAMPLE
649
637
import matplotlib.pyplotas plt
@@ -715,9 +703,8 @@ This example uses `scan()` to take a data measurement of data that DOES NOT need
715
703
716
704
```python
717
705
718
-
# import tinySA library
719
-
# (NOTE: check library path relative to script path)
720
-
from src.tinySA_pythonimport tinySA
706
+
# import tinySA_python (tsapython) package
707
+
from tsapythonimport tinySA
721
708
722
709
723
710
# imports FOR THE EXAMPLE
@@ -815,9 +802,8 @@ NOTE FOR LINUX USERS: the serial read with SCANRAW is finicky. It's also ONLY wi
815
802
816
803
817
804
```python
818
-
# import tinySA library
819
-
# (NOTE: check library path relative to script path)
820
-
from src.tinySA_pythonimport tinySA
805
+
# import tinySA_python (tsapython) package
806
+
from tsapythonimport tinySA
821
807
822
808
823
809
# imports FOR THE EXAMPLE
@@ -960,9 +946,9 @@ The first part of this example is a static report of the measurements taken over
960
946
961
947
962
948
```python
963
-
# importtinySA library
964
-
# (NOTE: check library path relative to script path)
965
-
from src.tinySA_pythonimport tinySA
949
+
# importtinySA_python (tsapython) package
950
+
from tsapythonimport tinySA
951
+
966
952
967
953
# imports FOR THE EXAMPLE
968
954
import csv
@@ -1138,9 +1124,9 @@ else: # if port found and connected, then complete task(s) and disconnect
1138
1124
The second part of the example is a realtime waterfall plot with peak tracking and a sample of the last reading.
1139
1125
1140
1126
```python
1141
-
# importtinySA library
1142
-
# (NOTE: check library path relative to script path)
1143
-
from src.tinySA_pythonimport tinySA
1127
+
# importtinySA_python (tsapython) package
1128
+
from tsapythonimport tinySA
1129
+
1144
1130
1145
1131
# imports FOR THE EXAMPLE
1146
1132
import numpyas np
@@ -1434,9 +1420,8 @@ if __name__ == "__main__":
1434
1420
1435
1421
```python
1436
1422
1437
-
# import tinySA library
1438
-
# (NOTE: check library path relative to script path)
1439
-
from src.tinySA_pythonimport tinySA
1423
+
# import tinySA_python (tsapython) package
1424
+
from tsapythonimport tinySA
1440
1425
1441
1426
1442
1427
# imports FOR THE EXAMPLE
@@ -1532,9 +1517,8 @@ else: # if port found and connected, then complete task(s) and disconnect
1532
1517
In some cases, this library may not cover all possible command versions, or new features might not be included yet. The tinySA can be accessed directly using the`command()` function. There is NO ERROR CHECKING on this function. It takes the full argument, just as if arguments were entered on the command line.
1533
1518
1534
1519
```python
1535
-
# import tinySA library
1536
-
# (NOTE: check library path relative to script path)
1537
-
from src.tinySA_pythonimport tinySA
1520
+
# import tinySA_python (tsapython) package
1521
+
from tsapythonimport tinySA
1538
1522
1539
1523
1540
1524
# create a new tinySA object
@@ -1656,7 +1640,7 @@ Quick Link Table:
1656
1640
*`get_bulk_data()`
1657
1641
***CLI Wrapper Usage:**
1658
1642
***Notes:**
1659
-
All numbers are binary coded 2 bytes little endian. The pixel data is encoded as 2 bytes per pixel. This is data returned by the device when in AUTO REFRESH mode. NOTE: may need to be paired with acontinious buffer read and dump, which will be tested in the next update
1643
+
All numbers are binary coded 2 bytes little endian. The pixel data is encoded as 2 bytes per pixel. This is data returned by the device when in AUTO REFRESH mode. NOTE: may need to be paired with acontinuous buffer read and dump, which will be tested in the next update
1660
1644
1661
1645
1662
1646
###**calc**
@@ -1806,7 +1790,7 @@ Quick Link Table:
1806
1790
***CLI Wrapper Usage:**
1807
1791
***Notes:**
1808
1792
* NOTE: no frequency checking is done for this function yet.
@@ -2488,7 +2472,7 @@ Marker levels will use the selected unit Marker peak will activate the marker (i
2488
2472
* None, see direct library function calls
2489
2473
* it is also suggested to use the`command()` function to preform more complex actions because this is a complicated command structure
2490
2474
***CLI Wrapper Usage:**
2491
-
***Notes:** For readability, this command was split into multiple functionsintitially rather than using complex alias functions. There is a mismatch of information of commands between versions, so this library uses the documentation returned by the device.
2475
+
***Notes:** For readability, this command was split into multiple functionsinitially rather than using complex alias functions. There is a mismatch of information of commands between versions, so this library uses the documentation returned by the device.
2492
2476
*`select_trace()`: tinySA Ultra has 4 traces to choose from. Other devices may have other numbers of traces.
2493
2477
*`trace_reflevel(...)` : adjusts the reference level of a trace. Levels are specified in dB(m) and can be specified using a floating point notation. E.g. 10 or 2.5[https://tinysa.org/wiki/pmwiki.php?n=Main.USBInterface](https://tinysa.org/wiki/pmwiki.php?n=Main.USBInterface)
2494
2478
@@ -2766,6 +2750,13 @@ This library is updated in spurts. June-August are going to be the most active d