Help with Python API

  • 7 Replies
  • 2304 Views
Help with Python API
« on: November 13, 2024, 11:12:48 PM »
I am attempting to do a simple capture with the Python API.  I connected AWG1 to CH1 outside the scope and confirmed I can create and capture waveforms with the GUI.  However, when I run test.py I just read =-137 for all readings on CH1.  See output bellow.  I am wondering if the Python API is reading from the correct register for the capture?  Or maybe I need to change other hardware settings?

Using 2.4.0-rc2

----------------------------------------------------------------
ScopeFun API activated
API version: 2.4.0
Checking USB connection... connected
FX3 firmware ID: b'SSSSSSSSSSSSSS'
Checking FPGA status... configured
Configuring hardware control registers... OK
Capturing 3 frame(s), 10000 samples...
Frame 1:
USB transfer OK: 41984 Bytes received
10000 samples received
Frame 2:
USB transfer OK: 41984 Bytes received
10000 samples received
Frame 3:
USB transfer OK: 41984 Bytes received
10000 samples received
Decoding received frame data... (40960 bytes)
Ch1: [-137 -137 -137 ... -137 -137 -137]
Ch2: [477 477 477 ... 477 477 477]
Dig: [3549 3549 3549 ... 3549 3549 3549]

*

Dejan

  • *****
  • 150
    • View Profile
Re: Help with Python API
« Reply #1 on: November 14, 2024, 08:35:48 PM »
It look's like there is a bug in API versions 2.4.0-rc1/rc2 for Windows. I'm looking into this...
Could you try with Python API version v2.4.0-beta  or stable release v2.3.4?

Re: Help with Python API
« Reply #2 on: November 14, 2024, 10:53:47 PM »
I tried both 2.4.0-beta and stable release 2.3.4, bit I think I am now getting an unrelated issue where even the GUI crashes.  In the Windows Event log, I get the following:

Faulting application name: scopefun.exe, version: 0.0.0.0, time stamp: 0x6523c621
Faulting module name: msvcrt.dll, version: 7.0.22621.2506, time stamp: 0x657b2709
Exception code: 0xc0000005
Fault offset: 0x0000000000062071
Faulting process id: 0x0x47E8
Faulting application start time: 0x0x1DB36DE52DE0446
Faulting application path: C:\Users\dzimmanck\ScopeFun 2.3.4\scopefun.exe
Faulting module path: C:\WINDOWS\System32\msvcrt.dll
Report Id: 81b70961-7c16-4e37-a376-9a6663714db8
Faulting package full name:
Faulting package-relative application ID:

*

Dejan

  • *****
  • 150
    • View Profile
Re: Help with Python API
« Reply #3 on: November 14, 2024, 11:13:57 PM »
You can use the latest (2.4.0-RC2) version for the GUI application (scopefun.exe).

Just the Python API (.pyd file) can be downgraded (download this file from the links provided and replace the existing .pyd file in the script folder.

I'm still checking the problem with latest API and will let you know when I have more info.
« Last Edit: November 14, 2024, 11:22:11 PM by Dejan »

Re: Help with Python API
« Reply #4 on: November 14, 2024, 11:29:48 PM »
OK, I switched laptops and have the application working again.  I get the same capture behavior with 2.4.0-beta.

Decoding received frame data... (40960 bytes)
Ch1: [-137 -137 -137 ... -137 -137 -137]
Ch2: [477 477 477 ... 477 477 477]
Dig: [3549 3549 3549 ... 3549 3549 3549]

Re: Help with Python API
« Reply #5 on: November 15, 2024, 01:05:58 AM »
I have also observed the same behavior on 2.3.0

*

Dejan

  • *****
  • 150
    • View Profile
Re: Help with Python API
« Reply #6 on: November 16, 2024, 08:29:45 PM »
The problem with Python API in Windows should be solved now.

The problem was apparently related to the 'pybind11' library (which enables C++ types in Python). After updating pybind11 library to the latest version, I was able to receive correct data in Python API.

Please download new software version 2.4.0 and let me know if you still have any issue. Alternatively, you can only download scopefun module for Windows and place it in the script folder, overwriting previus version.
« Last Edit: November 16, 2024, 08:32:02 PM by Dejan »

Re: Help with Python API
« Reply #7 on: November 18, 2024, 06:26:11 PM »
Works now.  Thanks Dejan!

I want to create a more Pythonic wrapper around the pyd files that gets released on PyPi. Dejan, may have some additional questions on the API.  I will try to figure out as much as I can through code inspection.

-Donny