blob: e5cdde8b9e82191f5da8b33bf6cd74d5bd042ecd [file] [log] [blame]
dburgessb3a0ca42011-10-12 07:44:40 +00001/*
2* Copyright 2008 Free Software Foundation, Inc.
3*
4* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion.
5*
6* This use of this software may be subject to additional restrictions.
7* See the LEGAL file in the main directory for details.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13*/
14
15#ifndef __RADIO_DEVICE_H__
16#define __RADIO_DEVICE_H__
17
ttsouf60dafa2012-10-22 00:07:14 +000018#include <string>
dburgessb3a0ca42011-10-12 07:44:40 +000019
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24/** a 64-bit virtual timestamp for radio data */
25typedef unsigned long long TIMESTAMP;
26
27/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */
28class RadioDevice {
29
30 public:
kurtis.heimerle380af32011-11-26 03:18:55 +000031 /* Available transport bus types */
Thomas Tsou02d88d12013-04-05 15:36:30 -040032 enum TxWindowType { TX_WINDOW_USRP1, TX_WINDOW_FIXED };
kurtis.heimerle380af32011-11-26 03:18:55 +000033
kurtis.heimerl965e7572011-11-26 03:16:54 +000034 static RadioDevice *make(double desiredSampleRate, bool skipRx = false);
35
kurtis.heimerldb2aae52011-11-26 03:17:13 +000036 /** Initialize the USRP */
ttsouf60dafa2012-10-22 00:07:14 +000037 virtual bool open(const std::string &args)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000038
39 /** Start the USRP */
40 virtual bool start()=0;
41
42 /** Stop the USRP */
43 virtual bool stop()=0;
44
Thomas Tsou02d88d12013-04-05 15:36:30 -040045 /** Get the Tx window type */
46 virtual enum TxWindowType getWindowType()=0;
kurtis.heimerle380af32011-11-26 03:18:55 +000047
kurtis.heimerldb2aae52011-11-26 03:17:13 +000048 /** Enable thread priority */
49 virtual void setPriority()=0;
50
dburgessb3a0ca42011-10-12 07:44:40 +000051 /**
52 Read samples from the radio.
53 @param buf preallocated buf to contain read result
54 @param len number of samples desired
55 @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough
56 @param timestamp The timestamp of the first samples to be read
57 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
58 @param RSSI The received signal strength of the read result
59 @return The number of samples actually read
60 */
61 virtual int readSamples(short *buf, int len, bool *overrun,
kurtis.heimerl965e7572011-11-26 03:16:54 +000062 TIMESTAMP timestamp = 0xffffffff,
63 bool *underrun = 0,
64 unsigned *RSSI = 0)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000065 /**
66 Write samples to the radio.
67 @param buf Contains the data to be written.
68 @param len number of samples to write.
69 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
70 @param timestamp The timestamp of the first sample of the data buffer.
71 @param isControl Set if data is a control packet, e.g. a ping command
72 @return The number of samples actually written
73 */
74 virtual int writeSamples(short *buf, int len, bool *underrun,
75 TIMESTAMP timestamp,
76 bool isControl=false)=0;
77
78 /** Update the alignment between the read and write timestamps */
79 virtual bool updateAlignment(TIMESTAMP timestamp)=0;
80
81 /** Set the transmitter frequency */
82 virtual bool setTxFreq(double wFreq)=0;
83
84 /** Set the receiver frequency */
85 virtual bool setRxFreq(double wFreq)=0;
86
87 /** Returns the starting write Timestamp*/
88 virtual TIMESTAMP initialWriteTimestamp(void)=0;
89
90 /** Returns the starting read Timestamp*/
91 virtual TIMESTAMP initialReadTimestamp(void)=0;
92
93 /** returns the full-scale transmit amplitude **/
94 virtual double fullScaleInputValue()=0;
95
96 /** returns the full-scale receive amplitude **/
97 virtual double fullScaleOutputValue()=0;
98
99 /** sets the receive chan gain, returns the gain setting **/
100 virtual double setRxGain(double dB)=0;
101
102 /** gets the current receive gain **/
103 virtual double getRxGain(void)=0;
104
105 /** return maximum Rx Gain **/
106 virtual double maxRxGain(void) = 0;
107
108 /** return minimum Rx Gain **/
109 virtual double minRxGain(void) = 0;
110
111 /** sets the transmit chan gain, returns the gain setting **/
112 virtual double setTxGain(double dB)=0;
113
114 /** return maximum Tx Gain **/
115 virtual double maxTxGain(void) = 0;
116
117 /** return minimum Tx Gain **/
118 virtual double minTxGain(void) = 0;
119
120 /** Return internal status values */
121 virtual double getTxFreq()=0;
122 virtual double getRxFreq()=0;
123 virtual double getSampleRate()=0;
124 virtual double numberRead()=0;
125 virtual double numberWritten()=0;
126
127};
128
129#endif