Skip to content

Commit

Permalink
Merge pull request #36 from tmytek/dev/update-tlkcore-v210
Browse files Browse the repository at this point in the history
Dev/update tlkcore v210
  • Loading branch information
alinyo98 authored Jan 14, 2025
2 parents 52a4376 + 558eeec commit 1316489
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* TMYTEK general API for Windows/Linux platform.

# Menu
# Outline

* [Introduction](#introduction)
* [Latest Release & Examples](#latest-release--examples)
Expand Down Expand Up @@ -67,7 +67,7 @@ The **.pyd** format release is for Windows shared library and **.so** format rel

### Python 3

* Install Python *3.6 or 3.8 or 3.10* which mapping with [TLKCore_release](/release), and follow reference user guide of [Getting Started with Python Sample Code](/examples/Python/README.md) to make sure your Python environment first.
* Install Python *3.6 or 3.8 / 3.10 / 3.12* which mapping with [TLKCore_release](/release), and follow reference user guide of [Getting Started with Python Sample Code](/examples/Python/README.md) to make sure your Python environment first.

### Communication environment

Expand Down
20 changes: 17 additions & 3 deletions examples/C_Cpp/examples/tlkcore_fbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ int fpga_conftrol(tlkcore_lib::tlkcore_ptr service, std::string sn)

int set_ud_freq(tlkcore_lib::tlkcore_ptr service)
{
// Here is a example we set freq for ALL UD devices
// PLEASE MODIFY for your purpose
for (std::string sn : ud_list) {
service->set_ud_freq(sn, 24e6, target_freq*1e6, 4e6);
if (service->set_ud_freq(sn, 24e6, target_freq*1e6, 4e6) < 0)
{
return -1;
}
}
return 0;
}
Expand All @@ -146,9 +151,18 @@ int tmy_device_control()

// Please provide the device config file for lib scanning & init
const std::string path = "config/device.conf";
ptr->scan_init_dev(path);
if (ptr->scan_init_dev(path) < 0)
{
printf("[Main] Scan & init device got failed!\r\n");
return -1;
}

set_ud_freq(ptr);
// Set UD example
if (set_ud_freq(ptr) < 0)
{
return -1;
}
// Set BBox example
if (update_beam_config(ptr) < 0)
{
return -1;
Expand Down
82 changes: 61 additions & 21 deletions examples/Python/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# Getting Started with Python Sample Code

* Outline
* [Prerequisites](#prerequisites)
* [Introduction of main.py](#introduction-of-mainpy)
* [Usage](#usage)
* [Basic call flow](#basic-call-flow)
* [startService()](#startservice)
* [testBBox()](#testbbox)
* [testUDBox()](#testudbox)
* [FBS](#fbs)
* [DFU](#dfu)
* [Extra usage](#extra-usage)

## Prerequisites

1. Install Python *3.6 or 3.8 or 3.10*, the version must mapping with [TLKCore_release](/release)
1. Check your Python version
* Windows: `python -V`
* Linux: `python3 -V`
1. Install Python *3.6 or 3.8 / 3.10 / 3.12*, the version MUST mapping with [TLKCore_release](/release)
* Example gives a default libraries for *Python 3.8* ([python-3.8.10 64-bit download Link](https://www.python.org/downloads/release/python-3810))
* Remember to **allow** the option: `Add python.exe to PATH`

Expand All @@ -15,6 +30,18 @@

`pip install -r requirements.txt`

* [Hint-1] Under Ubuntu, please install pip
* `sudo apt-get update`
* `sudo apt install python3-pip`
* [PEP-668](https://peps.python.org/pep-0668/)
* [error: externally-managed-environment](https://askubuntu.com/questions/1465218/pip-error-on-ubuntu-externally-managed-environment-%C3%97-this-environment-is-extern)
* `pip install --break-system-packages --user <username> -r requirements.txt`
* [Hint-2] Under Windows, sometimes you might met the following error: ![cpp_build_tool](/images/Python_cpp_build_tools.png)
* Please install [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version)
* [Hint-3] Python 3.12 user please modify parts of requirements.txt
* psutil==6.1.0
* ft4222==1.10.0

4. Create the new directory named **files** to target directory.

![files](/images/TLKCore_release_files.png)
Expand All @@ -38,6 +65,18 @@ optional arguments:
--root ROOT The root path/directory of for log/ & files/
```

#### example

* Windows

python main.py


* Linux

python3 main.py


### Basic call flow

* main() -> startService() -> testDevice() -> testXXX()
Expand Down Expand Up @@ -143,18 +182,14 @@ BW = 1e5
service.setUDFreq(sn, LO, RF, IF, BW)
```

## Commandline to run

python3 main.py

## FBS

This topic introduces TLKCore how to process FBS (Fast Beam Steering), it loads a readable beam configuration file, then generates a internal data structure, and converts to SPI signals to BBoxOne/Lite.

* TMYBeamConfig
* It comes from *tlkcore.TMYBeamConfig.py* in the downloaded library package with source code.

* Beam configuration file, i.g. [CustomBatchBeams_D2230E058-28.csv](/examples/C_Cpp/examples/config/CustomBatchBeams_D2252E058-28.csv). You can edit/pre-config it via Office-like software or any text editor, **PLEASE RENAME** it for real environment, and passing parameter to TMYBeamConfig()
* Beam configuration file, i.g. [CustomBatchBeams_D2230E058-28.csv](/examples/C_Cpp/examples/config/CustomBatchBeams_D2252E058-28.csv). You can edit/pre-config it via Office-like software or any text editor, please **RENAME** it for real environment, and passing parameter to TMYBeamConfig()
* Basic beam type, there are two basic types, usually we define to CHANNEL CONFIG as default.
* A whole **BEAM config (BeamType=0)**
* beam_db: gain with float type, please DO NOT EXCEED the DR (dynamic range).
Expand All @@ -174,6 +209,26 @@ This topic introduces TLKCore how to process FBS (Fast Beam Steering), it loads
* Default gives **degree 0** for theta, phi ... etc
* Example: TX beam1 will be MAX of DR with degree(0, 0), and TX beam8 just modify ch 9~12 to 1dB
![CustomBatchBeams](/images/CustomBatchBeams.png)
* [Notice] TLKCore generates the Beam_Configuration_{SN}_{Freq}GHz_{AAKitName}.json after fetch CSV file, please remove this json file if your json overrided.

## DFU

Device FW Update, starting from TLKCore v1.2.1, to update Beamform series firmware via TLKCore.

1. Make sure your Python environment installed tftpy package, if not, please `pip install tftpy==0.8.2`
2. Query/download FW image for your BBoxOne/BBoxLite/BBoard/CloverCell device
3. Please disable firewall first to allow tftp protocol transmission
* Windows
* `netsh advfirewall set allprofile state off`
* Ubuntu
* `sudo ufw disable`
* CentOS
* `sudo systemctl stop firewalld`
* macOS
* `sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off`
4. Argument assign image path to main.py

python3 main.py --dfu {IMAGE_PATH}

## Extra usage

Expand Down Expand Up @@ -216,18 +271,3 @@ This topic introduces TLKCore how to process FBS (Fast Beam Steering), it loads

2. Or passing to initDev()
`service.initDev(sn, addr, dev_type)`

4. DFU(Device FW Update), from TLKCore v1.2.1, support to update BBox series firmware via TLKCore now!
1. Query/download FW image for your BBoxOne/BBoxLite/BBoard device
2. Please disable firewall first to allow tftp protocol transmission
* Windows
* `netsh advfirewall set allprofile state off`
* Ubuntu
* `sudo ufw disable`
* CentOS
* `sudo systemctl stop firewalld`
* macOS
* `sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off`
3. Argument assign image path to main.py

python3 main.py --dfu {IMAGE_PATH}
Binary file added images/Python_cpp_build_tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed release/TLKCore_v2.0.0_Linux_Python3.6-64bit.zip
Binary file not shown.
Binary file removed release/TLKCore_v2.0.0_Windows_Python3.10-64bit.zip
Binary file not shown.
Binary file removed release/TLKCore_v2.0.0_Windows_Python3.6-64bit.zip
Binary file not shown.
Binary file removed release/TLKCore_v2.0.0_Windows_Python3.8-64bit.zip
Binary file not shown.
Binary file not shown.
Binary file added release/TLKCore_v2.1.0_Linux_Python3.12-64bit.zip
Binary file not shown.
Binary file not shown.
Binary file added release/TLKCore_v2.1.0_Linux_Python3.8-64bit.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed release/doc/TLKCore Reference Guide v0.1.8.pdf
Binary file not shown.
Binary file not shown.

0 comments on commit 1316489

Please sign in to comment.