Is a Python API available for the QA401?

We have test suites built in Python for competitor’s audio analyzer, but is an API available for the QA401 if we decide to make a switch?

Hi @voltist, there are two APIs into the QA401 hardware. The QAAnalyzer.exe application exposes a dotnet remoting API.That will be hard to implement in Python.

But there’s a headless application (no gui) called the QA401H that runs on Linux/Windows/Mac and can be “driven” by any language that supports a REST interface. And since REST is just a series of calls to load and process web pages, every language can speak to the QA401H box.

In the first link below, you’ll see an example of using Python to make a THD measurement.

The QA401H app doesn’t get the same love and attention that the GUI app does in terms of release frequency–it’s more of a workhorse app designed to sit in a factory doing its thing day in and day out. You get it working once and then don’t touch it unless you need to add tests. In other words, a QA401H install is not something you are upgrading every month like many do on the GUI app. (I just updated the outstanding customer-reported issues for the QA401H app on github HERE)

I’d suggest you try a small sample with Python and the QA401H app and see how it feels. Eventually, the REST interface in the QA401H will replace the dotnet remoting interface in the GUI app too.

I unplugged the QA401 from my USB hub and plugged directly to my pc and now it seems to be working - at least the headless app. See output below

I’m getting connection errors when running the python code

Server started listening on port 9401
The webserver has stopped. Webserver exception: Access is denied.
The webserver may have failed to start listening on the specified port. It may require the application to run with admin privs OR a namespace reservation needs to be made on the port you desire. For example, for port 9401:netsh http add urlacl url=http://*:9401/ user=DOMAIN\userTo check entries, use: netsh http show urlacl
Version: 0.995
Loading FX2 with file 16C04E27.hex [b58731ad] (Match)
Usb re-opened
Loading FPGA File: qa401.bit [eeba84b2] (Match)
FPGA File DateTime: 4/4/2019 11:32 AM

Done loading FPGA
Endpoint: 0x1 Max Packet Size: 64 bytes
Endpoint: 0x81 Max Packet Size: 64 bytes
Endpoint: 0x2 Max Packet Size: 512 bytes
Endpoint: 0x4 Max Packet Size: 512 bytes
Endpoint: 0x86 Max Packet Size: 512 bytes
Endpoint: 0x88 Max Packet Size: 512 bytes
Waiting for HTTP…
From your web browser, go to http://localhost:9401
Press ‘X’ to exit

It looks like the webserver couldn’t start. Usually this is because the QA401H software tries to open port 9401 and it is already open (by the QA401 application) OR because your system won’t allow it.

Assuming you are on windows…to make sure it’s not the former, just ensure sure the QA401 application isn’t running and/or that it’s not stuck in a zombie state in your process list.

To see if your system won’t allow it, go to a cmd line and type

netsh http show urlacl

This lets you see who is allowed to open what ports. There’s a very, very small chance that another app might be using that port. But generally, there won’t be anything and you can add access to that port via:

netsh http add urlacl url=http://*:9401/ user=DOMAIN\user

where DOMAIN\user is changed to what is appropriate for your machine. OR you can run the QA401H app as admin.

More discussion HERE on Stackoverflow. This has been a bit of a hit or miss problem–some machines don’t need the extra permissions added, and some do.

Then, run the QA401H app again and type http://localhost:9401 in a browser and it should open the REST interface as an HTML page.

I am the admin of my pc, and it does not belong to a domain.

OK, so you need to determine your domain and user names. Your domain name on a home machine is the machine name. Type ‘system’ in the search bar and that will bring up the control panel system and security window. There, you can see the computer name–treat that as your domain name. And then type netsh http add urlacl url=http://*:9401/ user=DOMAIN\user into a command prompt (with domain and user adjusted to your identity). And then try to reach via http://localhost:9401 in a browser and see if the webserver returns the expected page.