Yate
RadioInterface Class Referenceabstract

Generic radio interface. More...

#include <yateradio.h>

Inheritance diagram for RadioInterface:
RefObject DebugEnabler GenObject

Public Types

enum  ErrorCode {
  NoError = 0 , Failure = (1 << 1) , HardwareIOError = (1 << 2) , NotInitialized = (1 << 3) ,
  NotSupported = (1 << 4) , NotCalibrated = (1 << 5) , TooEarly = (1 << 6) , TooLate = (1 << 7) ,
  OutOfRange = (1 << 8) , NotExact = (1 << 9) , DataLost = (1 << 10) , Saturation = (1 << 11) ,
  RFHardwareFail = (1 << 12) , RFHardwareChange = (1 << 13) , EnvironmentalFault = (1 << 14) , InvalidPort = (1 << 15) ,
  Pending = (1 << 16) , Cancelled = (1 << 17) , Timeout = (1 << 18) , HardwareNotAvailable = (1 << 19) ,
  InsufficientSpeed = (1 << 20) , NoAutoRestartMask = HardwareNotAvailable | InsufficientSpeed , FatalErrorMask , ClearErrorMask ,
  LocalErrorMask
}
 
enum  Operation { PendingInitialize = 0 , PendingCount }
 

Public Member Functions

unsigned int pollPending (unsigned int oper, unsigned int waitMs=0)
 
virtual unsigned int getInterface (String &devicePath) const
 
virtual const RadioCapabilitycapabilities () const
 
virtual unsigned int initialize (const NamedList &params=NamedList::empty())=0
 
virtual unsigned int setLoopback (const char *name=0)
 
virtual unsigned int setParams (NamedList &params, bool shareFate=true)=0
 
virtual unsigned int setDataDump (int dir=0, int level=0, const NamedList *params=0)=0
 
virtual unsigned int calibrate ()
 
virtual unsigned int setPorts (unsigned count)=0
 
virtual unsigned int status (int port=-1) const =0
 
virtual void clearErrors ()
 
virtual unsigned int send (uint64_t when, float *samples, unsigned size, float *powerScale=0)=0
 
virtual unsigned int recv (uint64_t &when, float *samples, unsigned &size)=0
 
virtual unsigned int read (uint64_t &when, RadioReadBufs &bufs, unsigned int &skippedBufs)
 
virtual unsigned int getRxTime (uint64_t &when) const =0
 
virtual unsigned int getTxTime (uint64_t &when) const =0
 
virtual unsigned int setFreqOffset (float offs, float *newVal=0)=0
 
virtual unsigned int setSampleRate (uint64_t hz)=0
 
virtual unsigned int getSampleRate (uint64_t &hz) const =0
 
virtual unsigned int setFilter (uint64_t hz)=0
 
virtual unsigned int getFilterWidth (uint64_t &hz) const =0
 
virtual unsigned int setTxFreq (uint64_t hz)=0
 
virtual unsigned int getTxFreq (uint64_t &hz) const =0
 
virtual unsigned int setTxPower (unsigned dBm)=0
 
virtual unsigned int setRxFreq (uint64_t hz)=0
 
virtual unsigned int getRxFreq (uint64_t &hz) const =0
 
virtual unsigned int setTxGain1 (int val, unsigned port)
 
virtual unsigned int setTxGain2 (int val, unsigned port)
 
virtual unsigned int setRxGain1 (int val, unsigned port)
 
virtual unsigned int setRxGain2 (int val, unsigned port)
 
virtual unsigned int setGain (bool tx, int val, unsigned int port, int *newVal=0) const
 
virtual const StringtoString () const
 
virtual void completeDevInfo (NamedList &p, bool full=false, bool retData=false)
 
virtual void setError (NamedList &p, unsigned int code, const char *str=0)
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual void * getObject (const String &name) const
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual const StringtraceId () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- Public Member Functions inherited from DebugEnabler
 DebugEnabler (int level=TelEngine::debugLevel(), bool enabled=true)
 
int debugLevel () const
 
int debugLevel (int level)
 
bool debugEnabled () const
 
void debugEnabled (bool enable)
 
const char * debugName () const
 
bool debugAt (int level) const
 
bool debugChained () const
 
void debugChain (const DebugEnabler *chain=0)
 
void debugCopy (const DebugEnabler *original=0)
 

Static Public Member Functions

static const char * errorName (int code, const char *defVal=0)
 
static const TokenDicterrorNameDict ()
 
- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Protected Member Functions

 RadioInterface (const char *name)
 
void setPending (unsigned int oper, unsigned int code=Pending)
 
- Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
 
bool resurrect ()
 
virtual void destroyed ()
 
- Protected Member Functions inherited from DebugEnabler
void debugName (const char *name)
 

Protected Attributes

unsigned int m_lastErr
 
unsigned int m_totalErr
 
RadioCapabilitym_radioCaps
 

Detailed Description

Generic radio interface.

Note
Some parameters are quantized by the radio hardware. If the caller requests a parameter value that cannot be matched exactly, the setting method will set the parameter to the best avaiable match and return "NotExact". For such parameters, there is a corresponding readback method to get the actual value used.
If a method does not include a radio port number, then that method applies to all connected ports.
The interface may control multiple radios, with each one appearing as a port. However, in this case,
  • all radios are to be synched on the sample clock
  • all radios are to be of the same hardware type
If the performance of the radio hardware changes, the API indicates this with the RFHardwareChange flag. If this flag appears in a result code, the application should:
  • read a new RadioCapabilties object
  • revisit all of the application-level parameter settings on the radio
  • check the status() method on each port to identify single-port errors

Member Enumeration Documentation

◆ ErrorCode

enum ErrorCode

Error code bit positions in the error code mask.

◆ Operation

enum Operation

Operations Used to handle pending state

Constructor & Destructor Documentation

◆ RadioInterface()

RadioInterface ( const char * name)
protected

Constructor

Parameters
nameInterface name

Member Function Documentation

◆ calibrate()

virtual unsigned int calibrate ( )
inlinevirtual

Run internal calibration procedures and/or load calibration parmameters

Returns
Error code (0 on success)

◆ capabilities()

virtual const RadioCapability * capabilities ( ) const
inlinevirtual

Retrieve radio capabilities

Returns
RadioCapability pointer, 0 if unknown or not implemented

◆ clearErrors()

virtual void clearErrors ( )
inlinevirtual

Clear all error codes that can be cleared. Note the not all codes are clearable, like HW failures for example.

◆ completeDevInfo()

virtual void completeDevInfo ( NamedList & p,
bool full = false,
bool retData = false )
virtual

Complete device info parameters

Parameters
pDestination list
fullPut full device info
retDataTrue to set out pointer in destination, false to add name only

◆ errorName()

static const char * errorName ( int code,
const char * defVal = 0 )
inlinestatic

Retrieve the error string associated with a specific code

Parameters
codeError code
defValOptional default value to retrieve if not found
Returns
Valid TokenDict pointer

References errorNameDict().

◆ errorNameDict()

static const TokenDict * errorNameDict ( )
static

Retrieve the error name dictionary

Returns
Valid TokenDict pointer

Referenced by errorName().

◆ getFilterWidth()

virtual unsigned int getFilterWidth ( uint64_t & hz) const
pure virtual

Get the actual anti-aliasing filter BW

Parameters
hzAnti-aliasing filter value in Hertz
Returns
Error code (0 on success)

◆ getInterface()

virtual unsigned int getInterface ( String & devicePath) const
inlinevirtual

Retrieve the radio device path

Parameters
devicePathDestination buffer
Returns
Error code (0 on success)

◆ getRxFreq()

virtual unsigned int getRxFreq ( uint64_t & hz) const
pure virtual

Readback actual receive frequency

Parameters
hzReceive frequency value
Returns
Error code (0 on success)

◆ getRxTime()

virtual unsigned int getRxTime ( uint64_t & when) const
pure virtual

Get the time of the data currently being received from the radio

Parameters
whenDestination buffer for requested radio time
Returns
Error code (0 on success)

◆ getSampleRate()

virtual unsigned int getSampleRate ( uint64_t & hz) const
pure virtual

Get the actual sample rate

Parameters
hzSample rate value in Hertz
Returns
Error code (0 on success)

◆ getTxFreq()

virtual unsigned int getTxFreq ( uint64_t & hz) const
pure virtual

Readback actual transmit frequency

Parameters
hzTransmit frequency value
Returns
Error code (0 on success)

◆ getTxTime()

virtual unsigned int getTxTime ( uint64_t & when) const
pure virtual

Get the time of the the data currently being sent to the radio

Parameters
whenDestination buffer for requested radio time
Returns
Error code (0 on success)

◆ initialize()

virtual unsigned int initialize ( const NamedList & params = NamedList::empty())
pure virtual

Initialize the radio interface. Any attempt to transmit or receive prior to this operation will return NotInitialized.

Parameters
paramsOptional parameters list
Returns
Error code (0 on success)

References NamedList::empty().

◆ pollPending()

unsigned int pollPending ( unsigned int oper,
unsigned int waitMs = 0 )

Poll for a pending operation

Parameters
operOperation to check
waitMsOptional time (in milliseconds) to wait for operation completion
Returns
Error code (0 on success)

◆ read()

virtual unsigned int read ( uint64_t & when,
RadioReadBufs & bufs,
unsigned int & skippedBufs )
virtual

Receive the next available samples and associated timestamp. Compensate timestamp difference. Copy any valid data in the future to auxiliary buffers. Adjust the timestamp (no need for the caller to do it). Handles buffer rotation also. All sample counters (length/offset) are expected in sample periods.

Parameters
whenInput: current timestamp. Output: next read data timestamp
bufsBuffers to use
skippedBufsThe number of skipped full buffers
Returns
Error code (0 on success)

◆ recv()

virtual unsigned int recv ( uint64_t & when,
float * samples,
unsigned & size )
pure virtual

Receive the next available samples and associated timestamp. All ports are received together in interleaved format. e.g: I0 Q0 I1 Q1 I2 Q2 I0 Q0 I1 Q1 I2 Q2, etc for a 3-port system. The method will wait for proper timestamp (to be at least requested timestamp). The caller must increase the timestamp after succesfull read. The method may return less then requested size.

Parameters
whenInput: current timestamp. Output: read data timestamp
samplesDestination buffer (array of 2 * size * ports floats, interleaved IQ)
sizeInput: requested number of samples. Output: actual number of read samples
Returns
Error code (0 on success)

◆ send()

virtual unsigned int send ( uint64_t when,
float * samples,
unsigned size,
float * powerScale = 0 )
pure virtual

Send a frame of complex samples at a given time, interleaved IQ format. If there are gaps in the sample stream, the RadioInterface must zero-fill. All ports are sent together in interleaved format; example: I0 Q0 I1 Q1 I2 Q2 I0 Q0 I1 Q1 I2 Q2, etc for a 3-port system Block until the send is complete. Return TooEarly if the blocking time would be too long. Return TooLate if any of the block is in the past.

Parameters
whenTime to schedule the transmission
samplesData to send (array of 2 * size * ports floats, interleaved IQ)
sizeThe number of sample periods in the samples array
powerScaleOptional pointer to power scale value
Returns
Error code (0 on success)

◆ setDataDump()

virtual unsigned int setDataDump ( int dir = 0,
int level = 0,
const NamedList * params = 0 )
pure virtual

Update (set/reset) interface data dump

Parameters
dirDirection to update. 0: both, negative: RX only, positive: TX only
levelDump level to update. 0: both, negative: interface level (data sent/received by the upper layer), positive: device level (data sent to or read from radio device)
paramsOptional parameters
Returns
Error code (0 on success)

◆ setError()

virtual void setError ( NamedList & p,
unsigned int code,
const char * str = 0 )
virtual

Fill (set) error related parameters

Parameters
pDestination list
codeError code
strOptional error string (not error name)

◆ setFilter()

virtual unsigned int setFilter ( uint64_t hz)
pure virtual

Set the anti-aliasing filter BW

Parameters
hzAnti-aliasing filter value in Hertz
Returns
Error code (0 on success)

◆ setFreqOffset()

virtual unsigned int setFreqOffset ( float offs,
float * newVal = 0 )
pure virtual

Set the frequency offset

Parameters
offsFrequency offset to set
newValOptional pointer to value set by interface (requested value may be adjusted to fit specific device value)
Returns
Error code (0 on success)

◆ setGain()

virtual unsigned int setGain ( bool tx,
int val,
unsigned int port,
int * newVal = 0 ) const
inlinevirtual

Automatic tx/rx gain setting Set post mixer value. Return a value to be used by upper layer

Parameters
txDirection
valValue to set
portPort to use
newValOptional pointer to value to use for calculation by the upper layer
Returns
Error code (0 on success)

◆ setLoopback()

virtual unsigned int setLoopback ( const char * name = 0)
inlinevirtual

Set radio loopback

Parameters
nameLoopback name (NULL for none)
Returns
Error code (0 on success)

◆ setParams()

virtual unsigned int setParams ( NamedList & params,
bool shareFate = true )
pure virtual

Set multiple interface parameters. Each command must start with 'cmd:' to allow the code to detect unhandled commands. Command sub-params should not start with the prefix

Parameters
paramsParameters list
shareFateTrue to indicate all parameters share the fate (return on first error, except for Pending), false to process all
Returns
Error code (0 on success). Failed command(s) will be set in the list with cmd_name.code=error_code

◆ setPending()

void setPending ( unsigned int oper,
unsigned int code = Pending )
inlineprotected

Set pending state

Parameters
operOperation to set
codeStatus code

◆ setPorts()

virtual unsigned int setPorts ( unsigned count)
pure virtual

Set the number of ports to be used

Parameters
countThe number of ports to be used
Returns
Error code (0 on success)

◆ setRxFreq()

virtual unsigned int setRxFreq ( uint64_t hz)
pure virtual

Set the receive frequency in Hz

Parameters
hzReceive frequency value
Returns
Error code (0 on success)

◆ setRxGain1()

virtual unsigned int setRxGain1 ( int val,
unsigned port )
inlinevirtual

Set the receive pre-mixer gain in dB wrt max

Returns
Error code (0 on success)

◆ setRxGain2()

virtual unsigned int setRxGain2 ( int val,
unsigned port )
inlinevirtual

Set the receive post-mixer gain in dB wrt max

Returns
Error code (0 on success)

◆ setSampleRate()

virtual unsigned int setSampleRate ( uint64_t hz)
pure virtual

Set the sample rate

Parameters
hzSample rate value in Hertz
Returns
Error code (0 on success)

◆ setTxFreq()

virtual unsigned int setTxFreq ( uint64_t hz)
pure virtual

Set the transmit frequency in Hz

Parameters
hzTransmit frequency value
Returns
Error code (0 on success)

◆ setTxGain1()

virtual unsigned int setTxGain1 ( int val,
unsigned port )
inlinevirtual

Set the transmit pre-mixer gain in dB wrt max

Returns
Error code (0 on success)

◆ setTxGain2()

virtual unsigned int setTxGain2 ( int val,
unsigned port )
inlinevirtual

Set the transmit post-mixer gain in dB wrt max

Returns
Error code (0 on success)

◆ setTxPower()

virtual unsigned int setTxPower ( unsigned dBm)
pure virtual

Set the output power in dBm. This is power per active port, compensating for internal gain differences.

Parameters
dBmThe output power to set
Returns
Error code (0 on success)

◆ status()

virtual unsigned int status ( int port = -1) const
pure virtual

Return any persistent error codes. ("Persistent" means a condition of the radio interface itself, as opposed to a status code related to a specific method call)

Parameters
portPort number to check, or -1 for all ports OR'd together
Returns
Error(s) mask

◆ toString()

virtual const String & toString ( ) const
virtual

Retrieve the interface name

Returns
Interface name

Reimplemented from GenObject.


The documentation for this class was generated from the following file: