REST API and UTF8 Formatting

I’m having trouble getting a working Frequency Response Mask test using the REST API. Currently I am setting my settings (FFT, sample rate, attenuator) then setting the settings for the Chirp Gen, selecting it as the output source, muting right, starting an acquisition, and then running a mask test on the acquired data. Even though the manual tests pass I cannot get a test to pass through the REST API. One problem may be the UTF-8 formatting which I’ve put below.

‘c%3a%5cUsers%5cUsername%5cOneDrive%5cDocuments%5cQuantAsylum%5cQA40x%5cUserMasks%5cTest_12db.mask’

C:\Users\Username\OneDrive\Documents\QuantAsylum\QA40x\UserMasks\Test_12db.mask

I’ve also tried with changing %5c / to %2f . Do other symbols like _ and . also need encoding?

If anyone has an idea of what I may need to change to select this mask correctly, or if it may be another problem with how I’ve set up the test then let me know.

What is the REST API endpoint you are hitting with this data and how are you sending the request? Maybe some one else can try and replicate what you are doing.

What is this .mask file? It seems you are trying to send the file location to the analyser? Rather than sending the path I think you might need to encode the data because the analyser will not be able to access that path.

Hi @Isaac, are you manually encoding to UTF-8? Or using an existing language library? The former is probably very tricky.

Have you tried curl? Also, if you launch QA40x with -L and/or -C you’ll see a lot more info about failed REST commands.

Yes I am manually encoding it, but I probably should look into libraries for that. It’s a pretty simple bit of python code, but it looks like this.

AmplitudeDbv = -12
WindowSec = 0.0
SmoothingDenominator = 0
RightAsReference = ‘false’
file_location = ‘C%3a%2fUsers%2fisaac%2fOneDrive%2fDocuments%2fQuantAsylum%2fQA40x%2fUserMasks%2fTest_12db.mask’
#frequency responce mask
requests.put(‘http://localhost:9402/Settings/BufferSize/65536’)
requests.put(‘http://localhost:9402/Settings/Input/Max/6’)
requests.put(‘http://localhost:9402/Settings/SampleRate/96000’)
requests.put(f’http://localhost:9402//Settings/ExpoChirpGen/{AmplitudeDbv}/{WindowSec}/{SmoothingDenominator}/{RightAsReference}‘)
requests.put(‘http://localhost:9402/Settings/OutputSource/ExpoChirp’)
requests.put(‘http://localhost:9402/Settings/Muting/MuteRight’)
requests.post(‘http://localhost:9402/Acquisition’)
result = requests.get(f’http://localhost:9402/MaskTest/{file_location}/True/False’)
print(result.json())

I’m not familiar with curl. Also how would you go about launching QA40X with -L or -C? I am running on windows, so maybe there’s an equivalent there? It would be nice to know if its finding the mask correctly and failing the test, or if it just failed to find the mask and is returning false. To clarify the requests works, but I have yet to get it to return True for fitting the mask.

Hi @Isaac,

Inside file explorer, navigate to the install location of the QA40x app (usually C:\Program Files (x86)\QuantAsylum\QA40x

Type cmd in the path area of file explorer (up near the top) and this will launch a cmd window. Do a dir to make sure you can see the app, and then type qa40x.exe -C to launch the app with a console.

You can also navigate to the shortcut for the QA40x app (the shortcut you click on to normally launch the app) and then copy that and add the -C there too. I have three different shortcuts I’ve added to the QA40x app. The first runs normally, the second runs with the 384ksps test mode, the third runs with a console and the 4th runs with logging.

image

Thank you the console mode was a lifesaver. I’ve used it to verify my tests are working as expected, and its helped me catch some syntax errors as well. Using a library for encoding also helped, though I did get it working with manual encoding at one point.

Hi @Isaac, great to hear! It’s not needed often, but when it is needed, it’s a big help for sure!