How do I prevent duplicate scans when using the WaveAnalyzer 1500S API?

Downloading measurement data is achieved via the  data API command:

http://<​ip>/wanl/data/text

If you have ever retrieved scans using this command, you may have noticed that  successive calls can return duplicates of the same scan. This is because calls to this command do not trigger a new WaveAnalyzer scan; the WaveAnalyzer scans continuously. Instead it simply retrieves the measurement data of the most recently completed scan.

In case this command is called too quickly, it is certainly possible to receive the same scan many times if the instrument has not had time to complete its next scan.

while not a problem for most use cases, duplicate scans can become troublesome when performing some operations where many consecutive unique scans are needed e.g. scan averaging.

Scan Management using Scan ID

Duplicate scans can be avoided by tracking the scan ID. Each scan has an associated Scan ID and since duplicate scans have the same ID, they can be discarded.

The scan id is best retrieved using the scan/info command:

http://<​ip>/wanl/scan/info

This command returns a JSON string containing information about the current scan. Here is an example output:

{"center":193738808,"port":"Normal","scanid":9440866,"span":5277283,"startfreq":191100167,"stopfreq":196377450}

The following flowchart is a useful guide to avoid duplicate scans:

Scan ID Algorithm
Scan ID Algorithm

 

Please rate this article