Skip to content

Commit

Permalink
Merge pull request #35 from tmytek/hotfix/matlab_example
Browse files Browse the repository at this point in the history
Hotfix for MATLAB example
  • Loading branch information
alinyo98 authored Aug 2, 2024
2 parents 1737df9 + 9911ed7 commit e720214
Show file tree
Hide file tree
Showing 13 changed files with 424 additions and 23 deletions.
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

* TMYTEK general API for Windows/Linux platform.

# Menu

* [Introduction](#introduction)
* [Latest Release & Examples](#latest-release--examples)
* [Prerequisites](#prerequisites)
* [Troubleshooting](#troubleshooting)

## Introduction

**TLKCore** is a core service which inside the TMXLAB KIT(TLK/[WEB-TLK](https://web-tlk.tmytek.com/)), it integrates Python built libraries which developing mmWave( n257 / n258 / n260 / n261 ) **beamforming** and **beam steering** applications on **BBox 5G Series(mmwave beamformer)** and **UDBox 5G Series(mmwave Up-down frequency converter)** and other standard products developed by TMYTEK.
Expand All @@ -22,19 +29,39 @@ The **.pyd** format release is for Windows shared library and **.so** format rel
* TMYCommService is maintaining physical communications for all devices, it usually not handled directly by developer.
* TMYUtils defines all data structure for return data, let developer more easier to know current status of processed function.
* **TMYPublic** is a open source code, it defines all data structure which developer might used, e.g. RFMode(TX/RX), RetCode(OK/ERROR/...), UDState...etc.
* (Optional) **TMYBeamConfig** is option solution for FBS (fast beam steering), it aims to parse assigned csv file to a dict structure and check beam configuration, please reference [FBS](/examples//Python/README.md#FBS)
* (Optional) **TMYBeamConfig** is option solution for FBS (fast beam steering), it aims to parse assigned csv file to a dict structure and check beam configuration, please reference [FBS](/examples/Python/README.md#FBS)
* All files/function under tmydev/ are all operating logic of standard products
* db/ used for WEB-TLK, developer could ignore it.

![architecture](/images/TLKCore_architecture.png)

##### Latest Release & Reference Guide
## Latest Release & Examples

* [[Download Link](/release)]

* Supported languages

![support](/images/support_languages.png)
* [[Doc for function reference](/release/doc/)]

* [[Example code for supported languages](/examples/)]

<!-- [![support](/images/support_languages.png)](/examples/) -->

<p style="display:flex;justify-content:space-between;align-items:center">
<a href="/examples/C_Cpp">
<img src="/images/Logo_Cpp.png" alt="Image 1" width="100" height="100"/>
</a>
<a href="/examples/CSharp">
<img src="/images/Logo_CSharp.png" alt="Image 1" width="100" height="100"/>
</a>
<a href="/examples/LabVIEW">
<img src="/images/Logo_LabVIEW.svg" alt="Image 1" width="140" height="100"/>
</a>
<a href="/examples/MATLAB">
<img src="/images/Logo_MATLAB.png" alt="Image 1" width="170" height="100"/>
</a>
<a href="/examples/Python">
<img src="/images/Logo_Python.png" alt="Image 1" width="110" height="100"/>
</a>
</p>

## Prerequisites

Expand All @@ -48,7 +75,7 @@ Host PC can communicate with TMYTEK product through physical connection as the f

#### Ethernet/RJ-45

* DHCP - Put devide and host PC in the LAN.
* DHCP - Put the device and host PC in the LAN.
* Static IP - Configure your network environment to IP: **192.168.100**.xxx, and Subnet Mask Bits <= `/24`, likes: 255.255.255.0

![network](/images/Network.png)
Expand Down
2 changes: 1 addition & 1 deletion examples/C_Cpp/lib_tlkcore_cpp/src/tlkcore_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class tlkcore_lib_impl : public tlkcore_lib
}
auto config = devs.attr("get")(sn);
if (config == Py_None) { // equals Python: if config is None:
cout << "[TLKCore] Not found: " << sn << endl;
cout << "[TLKCore] Not found: " << sn << "in the config file" << endl;
return -1;
}
// cout << config << endl;
Expand Down
6 changes: 5 additions & 1 deletion examples/MATLAB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ P.S. The following example executes *MATLAB R2021b & Pyhton 3.8 64bit* on Window
![MATLAB_copy](/images/MATLAB_copy.png)

2. Double-click TLKCoreExample.m to launch MATLAB process.
3. Press **Run** to execute.
3. Modify to your Python version

![MATLAB_ver](/images/MATLAB_Python_version.png)

4. Press **Run** to execute.
38 changes: 24 additions & 14 deletions examples/MATLAB/TLKCoreExample.m
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
% Setup your Python execution version for MATLAB interface engine (just
% Setup your Python execution version for MATLAB interface engine (just
% execute it once after MATLAB started), assign the version name to Windows
% registry (Windows Only) or set the full path

terminate(pyenv)
pe = pyenv;
if pe.Status == "NotLoaded"
disp("Set to out")
disp(" ----- Calling pyenv to check Python environment, and it's NotLoaded -> Start loading(OutOfProcess) -----")

% PLEASE MODIFY TO YOUR PYTHON VERSION (3.8/3.10/...) HERE
pyenv(ExecutionMode="OutOfProcess")%, "Version", "3.8")
end
py.list % Call a Python function to load interpreter
disp(" ----- Calling a simple Pytohn function: py.list to load Python interpreter -----")
py.list
disp(" ----- Calling pyenv to check Python environment -----")
pyenv

% Setup TLKCore lib path
pylibfolder = '.\lib';
if count(py.sys.path, pylibfolder) == 0
insert(py.sys.path, int64(0), pylibfolder);
end
disp(" ----- Calling py.sys.path to get Python execute sequence -----")
py.sys.path

% Create instance
tlkcore = py.TLKCoreService.TLKCoreService;
% Create instance, it finds TLKCoreService class under pylibfolder
tlkcore = py.tlkcore.TLKCoreService.TLKCoreService;
disp("TLKCore version: " + tlkcore.version)

% Exevute scan devices
% Scan devices via your main.py calls "scanDevices" function
scan_list = py.main.wrapper("scanDevices");
disp("Scan result:")
disp(scan_list)

% Display system information then init each device to control
Expand All @@ -42,7 +50,7 @@
% Initial device
ret = py.main.wrapper("initDev", SN);
disp(ret)

% Simple query test
disp(py.main.wrapper("querySN", SN))
disp(py.main.wrapper("queryFWVer", SN))
Expand All @@ -64,17 +72,19 @@
% Remember to de-int device to free memory
py.main.wrapper("DeInitDev", SN)
end
disp(" ----- Terminate pyenv -----")
terminate(pyenv)

function testBBox(SN)
disp("Test BBox")

% Load basic enums
tmy_public = py.importlib.import_module('TMYPublic');
tmy_public = py.importlib.import_module('tlkcore.TMYPublic');
RFMode = tmy_public.RFMode;

% Set TX, 28GHz here, please modify for your purpose, and make sure
% related tables exist
% Set TX & 28GHz here as example,
% please modify for your purpose,
% and make sure related tables exist.
mode = RFMode.TX;
py.main.wrapper("setRFMode", SN, mode)
py.main.wrapper("setOperatingFreq", SN, 28)
Expand All @@ -87,7 +97,7 @@ function testBBox(SN)
aakit_pat = "4x4";
aakitList = py.main.wrapper("getAAKitList", SN, mode);
disp(aakitList)
if length(aakitList) == 0
if isempty(aakitList)
warning("PhiA mode")
end
% Check each aakit_name in aakitList meets the seaching pattern
Expand All @@ -114,7 +124,7 @@ function testUDBox(SN)
disp("Test UDBox")

% Load basic enums
tmy_public = py.importlib.import_module('TMYPublic');
tmy_public = py.importlib.import_module('tlkcore.TMYPublic');
UDState = tmy_public.UDState;

state = py.main.wrapper("getUDState", SN, UDState.PLO_LOCK);
Expand All @@ -127,7 +137,7 @@ function testUDBox(SN)
disp(py.main.wrapper("setUDState", SN, int32(0), UDState.CH1))
input("Wait for ch1 off")
disp(py.main.wrapper("setUDState", SN, int32(1), UDState.CH1))

disp(py.main.wrapper("setUDState", SN, int32(1), UDState.OUT_10M))
disp(py.main.wrapper("setUDState", SN, int32(1), UDState.OUT_100M))
disp(py.main.wrapper("setUDState", SN, int32(1), UDState.PWR_5V))
Expand All @@ -138,4 +148,4 @@ function testUDBox(SN)
disp(py.main.wrapper("getHarmonic", SN, 24e6, 28e6, 4e6, 100000))

disp(py.main.wrapper("setUDFreq", SN, 24e6, 28e6, 4e6, 100000))
end
end
2 changes: 1 addition & 1 deletion examples/Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ This topic introduces TLKCore how to process FBS (Fast Beam Steering), it loads

![scanned](/images/scanned.png)

2. Direct connect v
2. Direct connect
1. Via typing:

python3 main.py --dc D2230E013-28 192.168.100.121 9
Expand Down
Binary file added images/Logo_CSharp.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 added images/Logo_Cpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
360 changes: 360 additions & 0 deletions images/Logo_LabVIEW.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Logo_MATLAB.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 added images/Logo_Python.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 added images/MATLAB_Python_version.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 modified images/Network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.

0 comments on commit e720214

Please sign in to comment.