usrp_client package

Submodules

usrp_client.errors module

exception usrp_client.errors.RemoteUsrpError(actualUsrpMsg: str, usrpName: str = '')

Bases: Exception

__init__(actualUsrpMsg: str, usrpName: str = '') None
exception usrp_client.errors.MultipleRemoteUsrpErrors(errors: List[RemoteUsrpError])

Bases: Exception

__init__(errors: List[RemoteUsrpError]) None

usrp_client.rpc_client module

class usrp_client.rpc_client.UsrpClient(ip: str, port: int)

Bases: _RpcClient

This class is the interface to the UsrpServer running on the USRP device

Under the hood, we communicate with the UsrpServer class which wraps zerorpc. ZeroRPC implements remote procedure call client-server architecture using zeromq as a communication protocol. UsrpClient forwards user calls to the RPC server and serializes them if required.

static create(ip: str, port: int = 5555) UsrpClient

Create a USRP client which is connected to the UsrpServer running at given ip and port

__init__(ip: str, port: int) None

Private constructor. Should not be called. Use UsrpClient.create

configureRfConfig(rfConfig: RfConfig) None

Serialize rfConfig and request configuration on RPC server.

execute(baseTime: float) None

Execute the current configuration at the receiver side.

Set the baseTime on the receiver to the desired value.

Parameters:

baseTime (float) – FPGA time all streaming config time offsets refer to.

getSupportedSamplingRates() ndarray

Queries USRP for the supported sampling rates.

Deprecated! Use getSupportedSampleRates instead.

usrp_client.sanity module

usrp_client.sanity.cmdlineArgs: Namespace
usrp_client.sanity.checkSynchronization(ips: List[str]) bool

Check if the USRPs are reachable and are synchronized to the same clock

Parameters:

ips – List of IP-Adresses of the USRPs to check, where the RPC server needs to run.

Returns:

True if all is reachable and correctly cabled. False otherwise

usrp_client.sanity.checkSingle(ip: str) bool
usrp_client.sanity.checkTrx(ips: List[str]) bool
usrp_client.sanity.parseArgs() Namespace
usrp_client.sanity.main() None

usrp_client.system module

class usrp_client.system.LabeledUsrp(name, ip, port, client)

Bases: tuple

client

Alias for field number 3

ip

Alias for field number 1

name

Alias for field number 0

port

Alias for field number 2

class usrp_client.system.TimedFlag(resetTimeSec: float)

Bases: object

Creates a flag that is reset after a certain time denoted by resetTimeSec.

__init__(resetTimeSec: float) None
set() None

Sets the flag and resets after the specified time.

reset() None

Reset flag.

isSet() bool

Returns the value of the flag.

class usrp_client.system.System(logLevel: int = 20, *, syncSource: str = 'auto')

Bases: object

User interface for accessing multiple USRPs.

This module is the main interface for using the USRP. A system is to be defined to which USRPs can be added. Using the system functions defined in the System class gives you direct access to the USRP configuration etc.

syncThresholdSec = 0.2

In order to verify if the USRPs in the system are properly synchronized, respective FPGA values are queried and compared. If the FPGA times differ more than syncThresholdSec, an exception is thrown that the USRPs are not synchronized. Default value: 0.2s.

baseTimeOffsetSec = 0.5

This value is taken for setting the same base time for all USRPs. For development use mainly. Do not change. Default value: 0.2s.

syncAttempts = 3

Specifies number of synchronization attemps for USRP system.

timeBetweenSyncAttempts = 0.3

Sleep time between two synchronisation attempts in s.

syncTimeOut = 1200.0

Timeout of synchronisation.

__init__(logLevel: int = 20, *, syncSource: str = 'auto') None
newUsrp(ip: str, usrpName: str, *, port: int = 5555) UsrpClient

Create a new USRP and add it to the system.

Parameters:
  • ip (str) – IP of the USRP.

  • port (int) – Port where the Usrp Server is listening

  • usrpName (str) – Identifier of the USRP to be added.

addUsrp(usrpName: str, client: UsrpClient) UsrpClient

Add an existing UsrpClient to the system

Parameters:
  • usrpName (str) – Identifier of the Usrp to be added

  • client (UsrpClient) – Prepared UsrpClient

resetFpgaTimes() None

Reset the time to 0 at all connected USRPs upon the next received PPS

getCurrentFpgaTimes() List[float]

Returns the timestamps the connected USRPs consider in their FPGAs.

configureTx(usrpName: str, txStreamingConfig: TxStreamingConfig) None

Configure transmitter streaming.

Use this function to configure the transmission streaming of your desired USRP.

Parameters:
  • usrpName (str) – Identifier of USRP.

  • txStreamingConfig (TxStreamingConfig) – Desired configuration.

configureRx(usrpName: str, rxStreamingConfig: RxStreamingConfig) None

Configure receiver streaming.

Use this function to configure the receiving of your desired USRP.

Parameters:
  • usrpName (str) – Identifier of USRP.

  • rxStreamingConfig (RxStreamingConfig) – Desired configuration.

getRfConfigs() Dict[str, RfConfig]

Returns actual Radio Frontend configurations of the USRPs in the system.

Returns:

Dict-keys denote the identifier/name of the USRPs. Values are the Radio Frontend configurations.

Return type:

Dict[str, RfConfig]

synchronizeUsrps() None

Let all USRPs synchronize upon the PPS signal

synchronisationValid() bool

Returns true if synchronisation of the USRPs is valid.

execute() None

Executes all streaming configurations.

Samples are buffered, timeouts are calculated, Usrps are synchronized…

collect() Dict[str, List[MimoSignal]]

Collects the samples at each USRP.

This is a blocking call. In the streaming configurations, the user defined when to send and receive the samples at which USRP. This method waits until all the samples are received (hence blocking) and returns them.

Returns:

Dictionary containing the samples received. The key represents the usrp identifier.

Return type:

Dict[str, List[MimoSignal]]

getSupportedSamplingRates(usrpName: str) ndarray

Returns supported sampling rates.

Parameters:

usrpName (str) – Identifier of USRP to be queried.

Returns:

Array of supported sampling rates.

Return type:

np.ndarray

Module contents

class usrp_client.UsrpClient(ip: str, port: int)

Bases: _RpcClient

This class is the interface to the UsrpServer running on the USRP device

Under the hood, we communicate with the UsrpServer class which wraps zerorpc. ZeroRPC implements remote procedure call client-server architecture using zeromq as a communication protocol. UsrpClient forwards user calls to the RPC server and serializes them if required.

static create(ip: str, port: int = 5555) UsrpClient

Create a USRP client which is connected to the UsrpServer running at given ip and port

__init__(ip: str, port: int) None

Private constructor. Should not be called. Use UsrpClient.create

configureRfConfig(rfConfig: RfConfig) None

Serialize rfConfig and request configuration on RPC server.

execute(baseTime: float) None

Execute the current configuration at the receiver side.

Set the baseTime on the receiver to the desired value.

Parameters:

baseTime (float) – FPGA time all streaming config time offsets refer to.

getSupportedSamplingRates() ndarray

Queries USRP for the supported sampling rates.

Deprecated! Use getSupportedSampleRates instead.

class usrp_client.System(logLevel: int = 20, *, syncSource: str = 'auto')

Bases: object

User interface for accessing multiple USRPs.

This module is the main interface for using the USRP. A system is to be defined to which USRPs can be added. Using the system functions defined in the System class gives you direct access to the USRP configuration etc.

syncThresholdSec = 0.2

In order to verify if the USRPs in the system are properly synchronized, respective FPGA values are queried and compared. If the FPGA times differ more than syncThresholdSec, an exception is thrown that the USRPs are not synchronized. Default value: 0.2s.

baseTimeOffsetSec = 0.5

This value is taken for setting the same base time for all USRPs. For development use mainly. Do not change. Default value: 0.2s.

syncAttempts = 3

Specifies number of synchronization attemps for USRP system.

timeBetweenSyncAttempts = 0.3

Sleep time between two synchronisation attempts in s.

syncTimeOut = 1200.0

Timeout of synchronisation.

__init__(logLevel: int = 20, *, syncSource: str = 'auto') None
newUsrp(ip: str, usrpName: str, *, port: int = 5555) UsrpClient

Create a new USRP and add it to the system.

Parameters:
  • ip (str) – IP of the USRP.

  • port (int) – Port where the Usrp Server is listening

  • usrpName (str) – Identifier of the USRP to be added.

addUsrp(usrpName: str, client: UsrpClient) UsrpClient

Add an existing UsrpClient to the system

Parameters:
  • usrpName (str) – Identifier of the Usrp to be added

  • client (UsrpClient) – Prepared UsrpClient

resetFpgaTimes() None

Reset the time to 0 at all connected USRPs upon the next received PPS

getCurrentFpgaTimes() List[float]

Returns the timestamps the connected USRPs consider in their FPGAs.

configureTx(usrpName: str, txStreamingConfig: TxStreamingConfig) None

Configure transmitter streaming.

Use this function to configure the transmission streaming of your desired USRP.

Parameters:
  • usrpName (str) – Identifier of USRP.

  • txStreamingConfig (TxStreamingConfig) – Desired configuration.

configureRx(usrpName: str, rxStreamingConfig: RxStreamingConfig) None

Configure receiver streaming.

Use this function to configure the receiving of your desired USRP.

Parameters:
  • usrpName (str) – Identifier of USRP.

  • rxStreamingConfig (RxStreamingConfig) – Desired configuration.

getRfConfigs() Dict[str, RfConfig]

Returns actual Radio Frontend configurations of the USRPs in the system.

Returns:

Dict-keys denote the identifier/name of the USRPs. Values are the Radio Frontend configurations.

Return type:

Dict[str, RfConfig]

synchronizeUsrps() None

Let all USRPs synchronize upon the PPS signal

synchronisationValid() bool

Returns true if synchronisation of the USRPs is valid.

execute() None

Executes all streaming configurations.

Samples are buffered, timeouts are calculated, Usrps are synchronized…

collect() Dict[str, List[MimoSignal]]

Collects the samples at each USRP.

This is a blocking call. In the streaming configurations, the user defined when to send and receive the samples at which USRP. This method waits until all the samples are received (hence blocking) and returns them.

Returns:

Dictionary containing the samples received. The key represents the usrp identifier.

Return type:

Dict[str, List[MimoSignal]]

getSupportedSamplingRates(usrpName: str) ndarray

Returns supported sampling rates.

Parameters:

usrpName (str) – Identifier of USRP to be queried.

Returns:

Array of supported sampling rates.

Return type:

np.ndarray

class usrp_client.MimoSignal(signals: List[numpy.ndarray] = <factory>)

Bases: object

signals: List[ndarray]

Each List item corresponds to one antenna frame.

serialize() List[Tuple[List, List]]
static deserialize(serialized: List[Tuple[List, List]]) MimoSignal
__init__(signals: ~typing.List[~numpy.ndarray] = <factory>) None
class usrp_client.TxStreamingConfig(sendTimeOffset: float = 0.0, samples: uhd_wrapper.utils.config.MimoSignal = <factory>, numRepetitions: int = 1)

Bases: object

__init__(sendTimeOffset: float = 0.0, samples: ~uhd_wrapper.utils.config.MimoSignal = <factory>, numRepetitions: int = 1) None
sendTimeOffset: float = 0.0

Offset in seconds from the basetime System.execute().

samples: MimoSignal
numRepetitions: int = 1

Determines how often the signal should be repeated before exiting. If not equal 1, the signal length must be aligned to the word size. Otherwise an error is raised.

class usrp_client.RxStreamingConfig(receiveTimeOffset: float = 0.0, numSamples: int = 0, numRepetitions: int = 1, repetitionPeriod: int = 0, antennaPort: str = '')

Bases: DataClassJsonMixin

receiveTimeOffset: float = 0.0
numSamples: int = 0
numRepetitions: int = 1
repetitionPeriod: int = 0
antennaPort: str = ''
__init__(receiveTimeOffset: float = 0.0, numSamples: int = 0, numRepetitions: int = 1, repetitionPeriod: int = 0, antennaPort: str = '') None
class usrp_client.RfConfig(txAnalogFilterBw: float = 0.0, rxAnalogFilterBw: float = 0.0, txSamplingRate: float = 0.0, rxSamplingRate: float = 0.0, txGain: float = 0.0, rxGain: float = 0.0, txCarrierFrequency: float = 0.0, rxCarrierFrequency: float = 0.0, noTxStreams: int = 1, noRxStreams: int = 1, txAntennaMapping: ~typing.List[int] = <factory>, rxAntennaMapping: ~typing.List[int] = <factory>)

Bases: DataClassJsonMixin

Describes the RF configuration of the USRP. In particular, carrier frequency, sampling rate, TX/RX gains are contained in this structure. Moreover, the stream to antenna mapping is described in the elements txAntennaMapping and rxAntennaMapping.

txAnalogFilterBw: float = 0.0
rxAnalogFilterBw: float = 0.0
txSamplingRate: float = 0.0
rxSamplingRate: float = 0.0
txGain: float = 0.0
rxGain: float = 0.0
txCarrierFrequency: float = 0.0
rxCarrierFrequency: float = 0.0
noTxStreams: int = 1
noRxStreams: int = 1
txAntennaMapping: List[int]

Describes the mapping from a TX stream to an according TX antenna. If not empty, contains a list which describes the stream mapping. The nth element of the list identifies the antenna index (zero-based) where the nth stream is transmitted from.

If empty, uses a default mapping (i.e. first stream is mapped to first antenna, second stream to second antenna and so on), i.e. [0, 1, 2, …, noTxStreams-1].

rxAntennaMapping: List[int]

Describes the mapping from an RX antenna to the RX streams. Consider the txAntennaMapping for a description of the format.

serialize() str
static deserialize(value: str) RfConfig
__init__(txAnalogFilterBw: float = 0.0, rxAnalogFilterBw: float = 0.0, txSamplingRate: float = 0.0, rxSamplingRate: float = 0.0, txGain: float = 0.0, rxGain: float = 0.0, txCarrierFrequency: float = 0.0, rxCarrierFrequency: float = 0.0, noTxStreams: int = 1, noRxStreams: int = 1, txAntennaMapping: ~typing.List[int] = <factory>, rxAntennaMapping: ~typing.List[int] = <factory>) None