Skip to main content
Visitor II
February 12, 2021
Solved

Python support for UHF RFID ST25RU3993-HPEV

  • February 12, 2021
  • 13 replies
  • 3732 views

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.

    This topic has been closed for replies.
    Best answer by Cedric Dalban

    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

    13 replies

    ST Employee
    February 12, 2021

    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.

    TNgo.1Author
    Visitor II
    February 12, 2021

    Hi Cedric,

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

    ST Employee
    April 23, 2021

    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

    TNgo.1Author
    Visitor II
    April 23, 2021
    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
    Visitor II
    April 25, 2021

    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.

    ST Employee
    April 26, 2021

    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

    ST Employee
    April 26, 2021

    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.

    Visitor II
    May 1, 2021

    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

    ST Employee
    May 3, 2021

    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.

    ST Employee
    May 3, 2021

    Hello,

    good news !!!

    The STUHFL 3.0.0 has been updated on st.com with the missing makefile.

    As mentioned in previous message, first update libPath and copy all python files to raspberry file system.

    Then generate STUHFL.so on Linux machine (as described in ./Documents/Middleware-ReleaseNote.txt).

    Run python demo on raspberry.

    CAUTION: please ensure python version being used on raspberry is above 3.6.

    best regards,

    Cedric.

    Visitor II
    May 5, 2021

    Hi @Cedric Dalban​ 

    I have generated the *.so file on my raspberry:

    0693W00000ANP31QAH.pngFor loading the libSTUHFL.so, i fixed the path, see picture below:

    0693W00000ANP3fQAH.pngMy python version is 3.7

    I run the python demo by command :  $ sudo python3 STUHFL_demo.py

    it is able to connect to reader, read and write registers.

    but the errors are kicked in after that:

    0693W00000ANP4xQAH.png

    ************************************
    * INVENTORY RUNNER DEMO
    Tuning: ANTENNA_0, Algo: 3
     Freq: 865700, cin:0, clen:0, cout:0
     
    ************************************
    * GEN2 INVENTORY DEMO
    Traceback (most recent call last):
     File "_ctypes/callbacks.c", line 232, in 'calling callback function'
     File "../../../../Middleware/wrapper/python/STUHFL.py", line 2812, in inventoryFinishedCallback
    Tuning: ANTENNA_0, Algo: 3
     Freq: 865700, cin:0, clen:0, cout:0
     
    ************************************
    * GEN2 GENERIC COMMAND DEMO
    AttributeError: 'function' object has no attribute '_ICycleData__StatisticsFromNative'
    Tuning: ANTENNA_0, Algo: 3
     Freq: 865700, cin:0, clen:0, cout:0
    No Tag (4294967289)
     
    ************************************

    the full error log can be found here : https://drive.google.com/file/d/1bcaiQ-A45VlXVX6K6hgSB4BzTj8bt7NE/view?usp=sharing

    Please help us.

    Thanks a lot

    ST Employee
    May 5, 2021

    Hello Vmai,

    looking at your traces:

    LIB:.3.0.0.0

    Board SW:.0.0.0.0

    Board HW:.0.0.0.0

    it seems the communication between the library and the board has simply not been established (even more the read registers should not be all 0x00 ...)

    Indeed, LIB reports 3.0.0.0 means the communication between the wrapper and lib is OK,

    but Board SW/HW versions should be also 3.0.0.0 which would mean communication between lib and board is OK, that is not currently the case (versions are 0.0.0.0).

    For the time being, I don't think Python is involved in the problem, you have a problem establishing connection with your board ...

    Could you please try to run the Linux demo (cf Application-ReleaseNote.txt) which would ensure connections with board is OK ?

    regards,

    Cedric.

    Visitor II
    May 5, 2021

    Hi @Cedric Dalban​

    my connection as below, could you please confirm :

    0693W00000ANS3EQAX.jpg