cancel
Showing results for 
Search instead for 
Did you mean: 

Python support for UHF RFID ST25RU3993-HPEV

TNgo.1
Associate II

Currently I am working on a project that uses the UHF RFID evaluation board ST25RU3993-HPEV, which is controlled by STM32L476RG.

For my project, I want to use Raspberry Pi to communicate with the evaluation board, so the use of Python is required. However, the Python code, according to ST, is still under development.

So I am wondering how I can approach this or if anyone has worked on this before? Appreciate all your kind support.

1 ACCEPTED SOLUTION

Accepted Solutions
Cedric Dalban
ST Employee

Hello TNgo,

Good news !!!

The release v3.0.0 providing among other features the C#, Python and Java wrappers has been released on st.com:

The README.htm provided with the release lists all documentation related to this release among which FW & wrappers details, Native & wrapper demos description, API changes between 2.3.0 & 3.0.0 summary ...

Enjoy,

best regards,

Cedric

View solution in original post

17 REPLIES 17
Cedric Dalban
ST Employee

Hello TNgo,

The Python wrapper development (as well as the C# wrapper) has been finalized and will be delivered in the next release that is planned in the coming weeks.

For your information, the release will also be provided with linux makefiles for application and MW (STUHFL clib), this will surely ease your integration.

best regards,

Cedric.

Hi Cedric,

Thank you for your reply. Looking forward to the release!

Cedric Dalban
ST Employee

Hello TNgo,

Good news !!!

The release v3.0.0 providing among other features the C#, Python and Java wrappers has been released on st.com:

The README.htm provided with the release lists all documentation related to this release among which FW & wrappers details, Native & wrapper demos description, API changes between 2.3.0 & 3.0.0 summary ...

Enjoy,

best regards,

Cedric

Hi Cedric,
That’s fantastic news. Our team will get our hands on it right away. Thank you for your kind support.
If any technical inquiries, can we reach out to you through the forum?
Best regards,
Ngo Tung
Vmai.1
Associate II

Hi @Cedric Dalban​ 

I have downloaded the SDK according to your links above.

On my Window machine, I connect the RFID ST25RU3993-HPEV Dev Kit to my computer.

Base on the README.htm. I open the STUHFL_demo.py in PyCharm.

Run the python code, i running into the problems like picture:

0693W00000AMRy7QAH.pngThe error log as below :

C:\Users\vietmq\AppData\Local\Programs\Python\Python38\python.exe "C:/Users/vietmq/Downloads/en.STSW-ST25RU-SDK/ST25RU3993 STUHFL SDK package v3-0-0-0/Applications/STUHFL_demo_wrapper/STUHFL_demo_py/STUHFL_demo_py/STUHFL_demo.py"
Welcome to the ST-UHF-L demo 
STUHFL version
Traceback (most recent call last):
  File "C:/Users/vietmq/Downloads/en.STSW-ST25RU-SDK/ST25RU3993 STUHFL SDK package v3-0-0-0/Applications/STUHFL_demo_wrapper/STUHFL_demo_py/STUHFL_demo_py/STUHFL_demo.py", line 60, in <module>
    ret = STUHFL.Connect(port)
  File "..\..\..\..\Middleware\wrapper\python\STUHFL.py", line 160, in Connect
  File "..\..\..\..\Middleware\wrapper\python\STUHFL_native.py", line 523, in Connect
    lib = loadSTUHFL_DLL()
  File "..\..\..\..\Middleware\wrapper\python\STUHFL_native.py", line 507, in loadSTUHFL_DLL
    return cdll.LoadLibrary(libPath)
  File "C:\Users\vietmq\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "C:\Users\vietmq\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\vietmq\Downloads\en.STSW-ST25RU-SDK\ST25RU3993 STUHFL SDK package v3-0-0-0\Applications\STUHFL_demo_wrapper\STUHFL_demo_py\STUHFL_demo_py\Debug\x64\STUHFL.dll' (or one of its dependencies). Try using the full path with constructor syntax.
 
Process finished with exit code 1

It is asking for .dll lib file.

but in the SDK, the .dll lib file is located under : en.STSW-ST25RU-SDK\ST25RU3993 STUHFL SDK package v3-0-0-0\Middleware\wrapper\python\Debug\x64

 0693W00000AMRyCQAX.png 

should i change the library path in the python code or what should i do in this case ?

Great thanks for your support.

best regards,

Viet.

Cedric Dalban
ST Employee

Hello Vmai,

The DLL is supposed to be found by the MW thanks to the code in STUHFL_demo.py dealing with os.path (lines 27-43) + the function loadSTUHFL_DLL() in STUHFL_native.py.

So the current location of DLL (...\Middleware\wrapper\python\Debug\x64) is OK,

now remains to understand why in your environment the DLL is not reached:

FileNotFoundError: Could not find module 'C:\Users\vietmq\Downloads\en.STSW-ST25RU-SDK\ST25RU3993 STUHFL SDK package v3-0-0-0\Applications\STUHFL_demo_wrapper\STUHFL_demo_py\STUHFL_demo_py\Debug\x64\STUHFL.dll' (or one of its dependencies). Try using the full path with constructor syntax.

...\Applications\STUHFL_demo_wrapper\STUHFL_demo_py\STUHFL_demo_py\Debug\x64\STUHFL.dll is definitely not the path where the dll is supposed to be found !!!

Could you first instrument the function loadSTUHFL_DLL() with the following code at least to ensure the DLL path is taken into account: 

  for path in os.environ["PATH"].split(";"):

    print("path: {}".format(path))

you should have the following path listed:

path: ...\ST25RU3993 STUHFL SDK package v3-0-0-0\Applications\STUHFL_demo_wrapper\STUHFL_demo_py\STUHFL_demo_py\..\..\..\..\Middleware\wrapper\python

If not, something went wrong with your system path update.

As a workaround and until the root cause is found, could you copy the DLL in a location where your application is able to reach it ?

regards,

Cedric

Cedric Dalban
ST Employee

Hi Vmai,

Another point, looking at your traces it seems the dll is eventually found (indeed cdll.LoadLibrary(libPath) is called after the check if os.path.isfile(path + "\\" + libPath):)

but has a problem to load, so could you check the bitness (32/64 bits) your system is using ?

Indeed, we provided with the release package only the 64 bits debug dll

but if your system is 32 bits only you will have to build the equivalent dll for 32 bits support.

If your system is still 32 bits, could you then try to rebuild the dll ?

Please have a look to Application-STUHFL_demo_py.chm for further details on how to (re)build the dlls.

regards,

Cedric.

Vmai.1
Associate II

Hi @Cedric Dalban​ 

Thanks for your support.

I have modified a bit in python code :

def loadSTUHFL_DLL():
    # Checks DLL exists and is reachable
    for path in os.environ["PATH"].split(";"):
        if os.path.isfile(path + "\\" + libPath):
            print("aaaaaa:: " + path + "\\" + libPath)
            #return cdll.LoadLibrary(libPath)
            return cdll.LoadLibrary(path + "\\" + libPath)
 
    print("""
***************************** CAUTION *****************************************
Cannot open STUHFL DLL:
{}
 
Please ensure STUHFL DLL has been generated before using STUHFL Python wrapper
*******************************************************************************
""".format(libPath))
    sys.exit()
    return None

I returned "return cdll.LoadLibrary(path + "\\" + libPath)"

with this modify, the python code work well in my window computer.

ANOTHER QUESTION :

I would like to execute the python code on Linux (for example Raspi).

But it seems that it is not able to load dll file on Linux environment, please correct me if i am wrong.

So how to execute python code on Linux environment ?

Thanks.

Viet

Cedric Dalban
ST Employee

Hello Vmai,

That is a really good news you eventually had your python demo working.

Concerning the Linux environment, it is quite simple.

First, you have to update libPath with appropriate path and extension .so

libPath = "<path_to_shared_object>STUHFL.so"

Second, I just realized a Linux makefile was supposed to be delivered in .../Middleware/lib

unfortunately we forgot to add it to the package.

We will have to generate a release v3.0.1 to fix this miss.

I'll come back to you soon.

Sorry again for this.

best regards,

Cedric.