REST API for A-weighting

It’s ok to enable A-weighting on the application interface but we cannot find corresponding API command on REST API. Please help. Basically, we use it for automated testing in production line. So, all controls are on REST API.

Hi @Chris, there are two APIs for getting an RMS measurement across a specified frequency range. The first is

GET /RmsDbv/{StartFreq}/{EndFreq}

And the second is

GET /RmsDbv/AWeighting/{StartFreq}/{EndFreq}

The second one will apply A Weighting to the RMS measurement while the first one will not.

GET /RmsDbv/{StartFreq}/{EndFreq}
GET /SnrDb/{FundFreq}/{MinFreq}/{MaxFreq}
GET /ThdPct/{FundFreq}/{MaxFreq

Above 3 APIs are ok.

We still have problem with below API:
GET /RmsDbv/AWeighting/{StartFreq}/{EndFreq}

Actually, we see problem with below APIs as well:
GET /Status/Connection
GET /RmsDbv/AWeighting/20/20000
PUT /Settings/SampleRate/48000
PUT /Settings/Window/Rectangle

Attached is the error screen we got.

Above pop up error only happen on Win10 system. If we use Win7, we don’t see this pop up error box but the problematic APIs still not work.

Hi @chris,

I just checked the following APIs in 0.997 with the REST_TEST app and got the following:

GET /Status/Connection returned 0.997 as expected. Can you please check sample app and see if it works for you?

GET /RmsDbv/AWeighting/20/20000 will be enabled for 0.998 this week, thanks for reporting
PUT /Settings/SampleRate/48000 will be enabled for 0.998 this week, thanks for reporting
PUT /Settings/Window/Rectangle will be enabled for 0.998 this week, thanks for reporting

I’d also like to have added the ability to see HTTP debug window to help with REST development and that could give more insight into Win7. Hopefully that makes it in.

Thanks very much for reporting

We tried GET /Status/Version It works.

But we cannot find GET /Status/Connection in REST_TEST app. Please give it a try and see if it really works.

Thanks.

Hi @Chris, release 0.998 was just posted HERE which should address these issues. First, note the REST_TEST has been updated HERE

The new REST_TEST has some added buttons as shown below. These buttons will let you test Windowing, Sample Rate, Connection and Weighting

There is also a console window you can show in the QA40x app with the -C command line option. The console window will appear as a separate window and should mirror the logging file if you have that enabled.

The output from the console makes it easy to see HTTP interaction in real time

Existing settings file loaded
Server started listening on port 9402
Usb Connected
Factory calibration data loaded from flash
---
Time 11:19:05.530
GET	Request:http://localhost:9402/Status/Version
Return: { "SessionId":"0", "Value":"0.998" }
Status: 200 (Elapsed: 5.00 mS)
---
Time 11:19:14.602
GET	Request:http://localhost:9402/Status/Connection
Return: { "SessionId":"0", "Value":"True" }
Status: 200 (Elapsed: 5.00 mS)
---
Time 11:19:20.630
PUT	Request:http://localhost:9402/Settings/Windowing/Rectangle
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 11.00 mS)
---
Time 11:19:22.761
PUT	Request:http://localhost:9402/Settings/Windowing/FlatTop
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 17.00 mS)
---
Time 11:19:25.762
PUT	Request:http://localhost:9402/Settings/SampleRate/192000
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 15.70 mS)
---
Time 11:19:26.383
PUT	Request:http://localhost:9402/Settings/SampleRate/48000
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 9.00 mS)
---
Time 11:19:28.155
PUT	Request:http://localhost:9402/Settings/Weighting/None
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 16.00 mS)
---
Time 11:19:29.83
PUT	Request:http://localhost:9402/Settings/Weighting/AWeighting
Return: { "SessionId":"0" }
Status: 200 (Elapsed: 12.00 mS)

If you have a mal-formed HTTP request, or something that doesn’t make sense, you’ll see it in the console, instead of having to guess what might be wrong:

For example, if you try to compute THD without having done an acquisition first, you’ll see

And the same red highlighting will apply to bad argument too. So, it should help a lot with development.

Note that previously the API indicated that you could make RMS measurement with A-Weighting. That has changed. Now, you will either enable or disable A-Weighting just as you do from the front panel, and the RMS measurement will change based on weighting.

See PUT /Settings/Weighting/{WeightingType}

Also see:

PUT /Settings/SampleRate/{SampleRate}
PUT /Settings/Windowing/{WindowType}

Thanks!

Hi Matt, GET method /Status/Version does not work:
Why?

Thank you.

vers

If you point your browser to http://localhost:9402 do you see the welcome page?

This will debug the QA40x as the source of the problem if you can see that. Furthermore, scroll down the welcome page and see if Status/Version is a supported endpoint with your version of the API.

Also not sure what you are trying to show with the second post “Status/Versions” is not an endpoint.

Thank you for your answer.
localhost:9402 is OK (my version is 1.193)
localhost:9402/Status/Connection is OK
localhost:9402/Status/Version does not work
ans

Hmmm… seems like a bug that has been introduced somewhere between 1.189 and 1.193. I can see the version in both the browser and using curl.

In my Win 2019 server and Ubuntu Linux (mono) GET /Status/Version is OK
:frowning:

In my Win10 (Opera,Firefox,Chrome,curl) nothing…

I send debug console Firefox

So you can access the end point, but when you access with Windows 10 only that end point is not accessible? That’s very odd. It’s like there is a conditional being triggered somewhere.

It seems that this error is mostly likely at the C# level, parsing a string into an integer.

Hi @Jiran, it looks like you are requesting the URL Versions instead of Version

image

Running QA40x version 1.193 on Windows 11, I type this into chrome:

http://localhost:9402/Status/Version

And I get this in response:

{ "SessionId":"0", "Value":"1.193" }

If you run the qa40x app with the -c flag, it will open a console:

C:\Program Files (x86)\QuantAsylum\QA40x>qa40x -c

And then you can see how the app is digesting the web requests. Note the version request succeeded, but then Chrome asked for the favicon.ico to display in the title bar, which failed as expected.

Could you try curl using the console and share what you see there?

Thank you. Solved!!
The problem is in the international format of numbers. English decimal symbol (dot) IS OK. Czech decimal symbol (comma) in international Windows settings provokes an error.

“http: // localhost: 9402/status/versions” was just a typo :frowning:

@matt I think @Jiran has found a localisation bug in the C# backend.

When he has Window set to his (non-English) native language, the version endpoint raises an exception. It appears to be processing a string to an integer but this fails for localisation where they use a comma in place of a decimal point e.g. 1.123 = 1,123, this is quite common in Europe.

@Jiran managed to fix this by changing the default language/number format in his Windows install.