class thinkrf.devices.WSA4000

Interface for WSA4000

connect() must be called before other methods are used.


This command selects and queries the active antenna port.

Parameters:number – 1 or 2 to set; None to query
Returns:active antenna port
capture(spp, ppb)

This command will start the single block capture and the return of ppb packets of spp samples each. The data within a single block capture trace is continuous from one packet to the other, but not necessary between successive block capture commands issued.

  • spp – the number of samples in a packet
  • ppb – the number of packets in a capture

connect to a wsa

Parameters:host – the hostname or IP to connect to

This command sets or queries the rate of decimation of samples in a trace capture. This decimation method consists of cascaded integrator-comb (CIC) filters and at every value number of samples, one sample is captured. The supported rate is 4 - 1023. When the rate is set to 0, no decimation is performed on the trace capture.

Parameters:value (int) – new decimation value (0 or 4 - 1023); None to query
Returns:the decimation value

close a connection to a wsa


Check if the VRT stream has closed.

Returns:True if no more data, False if more data

Flush capture memory of sweep captures.


Flush capture memory of sweep captures.


This command sets or queries the tuned center frequency of the WSA.

Parameters:freq (int) – the new center frequency in Hz (0 - 10 GHz); None to query
Returns:the frequency in Hz

This command sets or queries the frequency shift value.

Parameters:freq (int) – the new frequency shift in Hz (0 - 125 MHz); None to query
Returns:the amount of frequency shift

This command sets or queries RFE quantized gain configuration. The RF front end (RFE) of the WSA4000 consists of multiple quantized gain stages. The gain corresponding to each user-selectable setting has been pre-calculated for either optimal sensitivity or linearity. The parameter defines the total quantized gain of the RFE.

Parameters:gain – ‘high’, ‘medium’, ‘low’ or ‘vlow’ to set; None to query
Returns:the RF gain value

Check if there is VRT data to read.

Returns:True if there is a packet to read, False if not

Check if we have permission to read data.

Returns:True if allowed to read, False if not

Returns the WSA4000’s identification information string.

Returns:“<Manufacturer>,<Model>,<Serial number>,<Firmware version>”

This command sets or queries variable IF gain stages of the RFE. The gain has a range of -10 to 34 dB. This stage of the gain is additive with the primary gain stages of the LNA that are described in gain().

Parameters:gain – float between -10 and 34 to set; None to query
Returns:the ifgain in dB

This command queries the lock status of the RF VCO (Voltage Control Oscillator) in the Radio Front End (RFE) or the lock status of the PLL reference clock in the digital card.

Parameters:modulestr – ‘vco’ for rf lock status, ‘clkref’ for mobo lock status
Returns:True if locked

This command sets or queries the RFE preselect filter selection.

Parameters:enable – True or False to set; None to query
Returns:the RFE preselect filter selection state

Raw read of VRT socket data from the WSA.

Parameters:num – the number of bytes to read

Read a single VRT packet from the WSA.

See thinkrf.vrt.Stream.read_packet().


Aquire exclusive permission to read data from the WSA.

Returns:True if allowed to read, False if not

Resets the WSA4000 to its default settings. It does not affect the registers or queues associated with the IEEE mandated commands.


Send a SCPI command and wait for the response.

This is the lowest-level interface provided. Please see the Programmer’s Guide for information about the commands available.

Parameters:cmd (str) – the command to send
Returns:the response back from the box if any

Send a SCPI command.

This is the lowest-level interface provided. Please see the Programmer’s Guide for information about the commands available.

Parameters:cmd (str) – the command to send

Add an entry to the sweep list

Parameters:entry (thinkrf.config.SweepEntry) – the sweep entry to add

Remove all entries from the sweep list.


Read an entry from the sweep list.

Parameters:index – the index of the entry to read
Returns:sweep entry
Return type:thinkrf.config.SweepEntry

Start the sweep engine.


Stop the sweep engine.


This command sets or queries the type of trigger event. Setting the trigger type to “NONE” is equivalent to disabling the trigger execution; setting to any other type will enable the trigger engine.

Parameters:settings (thinkrf.config.TriggerSettings) – the new trigger settings; None to query
Returns:the trigger settings


class thinkrf.config.SweepEntry(fstart=2400000000, fstop=2400000000, fstep=100000000, fshift=0, decimation=0, antenna=1, gain='vlow', ifgain=0, spp=1024, ppb=1, trigtype='none', level_fstart=50000000, level_fstop=10000000000, level_amplitude=-100)

Sweep entry for thinkrf.devices.WSA4000.sweep_add()

  • fstart – starting frequency in Hz
  • fstop – ending frequency in Hz
  • shift – the frequency shift in Hz
  • decimation – the decimation value (0 or 4 - 1023)
  • antenna – the antenna (1 or 2)
  • gain – the RF gain value (‘high’, ‘medium’, ‘low’ or ‘vlow’)
  • ifgain – the IF gain in dB (-10 - 34)
  • spp – samples per packet
  • ppb – packets per block
  • trigtype – trigger type (‘none’ or ‘level’)
  • level_fstart – level trigger starting frequency in Hz
  • level_fstop – level trigger ending frequency in Hz
  • level_amplitude – level trigger minimum in dBm
class thinkrf.config.TriggerSettings(trigtype='NONE', fstart=None, fstop=None, amplitude=None)

Trigger settings for thinkrf.devices.WSA4000.trigger().

  • trigtype – “LEVEL” or “NONE” to disable
  • fstart – starting frequency in Hz
  • fstop – ending frequency in Hz
  • amplitude – minumum level for trigger in dBm
exception thinkrf.config.TriggerSettingsError


class thinkrf.vrt.ContextPacket(pkt_type, word, socket)

A Context Packet received from thinkrf.vrt.Stream.read_packet()


a dict containing field names and values from the packet

Parameters:ptype – “Receiver”, “Digitizer” or None for any packet type
Returns:True if this packet matches the type passed
class thinkrf.vrt.DataPacket(word, socket)

A Data Packet received from thinkrf.vrt.Stream.read_packet()


a thinkrf.vrt.IQData object containing the packet data

class thinkrf.vrt.IQData(binary_data)

Data Packet values as a lazy collection of (I, Q) tuples read from binary_data.

This object behaves as an immutable python sequence, e.g. you may do any of the following:

points = len(iq_data)

i_and_q = iq_data[5]

for i, q in iq_data:
    print i, q

Return a numpy array of I, Q values for this data similar to:

array([[ -44,    8],
       [ -40,   60],
       [ -12,   92],
       [-132,   -8],
       [-124,   56],
       [ -44,   80]], dtype=int16)
exception thinkrf.vrt.InvalidDataReceived
class thinkrf.vrt.Stream(socket)

A VRT Packet Stream interface wrapping socket.

Returns:True if there is data waiting on socket.

Read a complete packet from socket and return either a thinkrf.vrt.ContextPacket or a thinkrf.vrt.DataPacket.


thinkrf.util.read_data_and_reflevel(dut, points=1024)

Wait for and capture a data packet and a reference level packet.

Returns:(data_pkt, reflevel_pkt)
thinkrf.util.socketread(socket, count, flags=None)

Retry socket read until count data received, like reading from a file.


thinkrf.numpy_util.compute_fft(dut, data_pkt, reflevel_pkt)

Return an array of dBm values by computing the FFT of the passed data and reference level.


This function uses only dut.ADC_DYNAMIC_RANGE, and reflevel_pkt[‘reflevel’].

Returns:numpy array of dBm values as floats

Project Versions

Table Of Contents

Previous topic

ThinkRF Device API

Next topic

Basic Examples

This Page