blob: 47012a1f018aa1942a4fdf71a6287d23206b07c7 [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
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23/** a 64-bit virtual timestamp for radio data */
24typedef unsigned long long TIMESTAMP;
25
26/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */
27class RadioDevice {
28
29 public:
kurtis.heimerle380af32011-11-26 03:18:55 +000030 /* Available transport bus types */
31 enum busType { USB, NET };
32
kurtis.heimerl965e7572011-11-26 03:16:54 +000033 static RadioDevice *make(double desiredSampleRate, bool skipRx = false);
34
kurtis.heimerldb2aae52011-11-26 03:17:13 +000035 /** Initialize the USRP */
kurtis.heimerl965e7572011-11-26 03:16:54 +000036 virtual bool open()=0;
dburgessb3a0ca42011-10-12 07:44:40 +000037
38 /** Start the USRP */
39 virtual bool start()=0;
40
41 /** Stop the USRP */
42 virtual bool stop()=0;
43
kurtis.heimerle380af32011-11-26 03:18:55 +000044 /** Get the bus type */
45 virtual enum busType getBus()=0;
46
kurtis.heimerldb2aae52011-11-26 03:17:13 +000047 /** Enable thread priority */
48 virtual void setPriority()=0;
49
dburgessb3a0ca42011-10-12 07:44:40 +000050 /**
51 Read samples from the radio.
52 @param buf preallocated buf to contain read result
53 @param len number of samples desired
54 @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough
55 @param timestamp The timestamp of the first samples to be read
56 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
57 @param RSSI The received signal strength of the read result
58 @return The number of samples actually read
59 */
60 virtual int readSamples(short *buf, int len, bool *overrun,
kurtis.heimerl965e7572011-11-26 03:16:54 +000061 TIMESTAMP timestamp = 0xffffffff,
62 bool *underrun = 0,
63 unsigned *RSSI = 0)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000064 /**
65 Write samples to the radio.
66 @param buf Contains the data to be written.
67 @param len number of samples to write.
68 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
69 @param timestamp The timestamp of the first sample of the data buffer.
70 @param isControl Set if data is a control packet, e.g. a ping command
71 @return The number of samples actually written
72 */
73 virtual int writeSamples(short *buf, int len, bool *underrun,
74 TIMESTAMP timestamp,
75 bool isControl=false)=0;
76
77 /** Update the alignment between the read and write timestamps */
78 virtual bool updateAlignment(TIMESTAMP timestamp)=0;
79
80 /** Set the transmitter frequency */
81 virtual bool setTxFreq(double wFreq)=0;
82
83 /** Set the receiver frequency */
84 virtual bool setRxFreq(double wFreq)=0;
85
86 /** Returns the starting write Timestamp*/
87 virtual TIMESTAMP initialWriteTimestamp(void)=0;
88
89 /** Returns the starting read Timestamp*/
90 virtual TIMESTAMP initialReadTimestamp(void)=0;
91
92 /** returns the full-scale transmit amplitude **/
93 virtual double fullScaleInputValue()=0;
94
95 /** returns the full-scale receive amplitude **/
96 virtual double fullScaleOutputValue()=0;
97
98 /** sets the receive chan gain, returns the gain setting **/
99 virtual double setRxGain(double dB)=0;
100
101 /** gets the current receive gain **/
102 virtual double getRxGain(void)=0;
103
104 /** return maximum Rx Gain **/
105 virtual double maxRxGain(void) = 0;
106
107 /** return minimum Rx Gain **/
108 virtual double minRxGain(void) = 0;
109
110 /** sets the transmit chan gain, returns the gain setting **/
111 virtual double setTxGain(double dB)=0;
112
113 /** return maximum Tx Gain **/
114 virtual double maxTxGain(void) = 0;
115
116 /** return minimum Tx Gain **/
117 virtual double minTxGain(void) = 0;
118
119 /** Return internal status values */
120 virtual double getTxFreq()=0;
121 virtual double getRxFreq()=0;
122 virtual double getSampleRate()=0;
123 virtual double numberRead()=0;
124 virtual double numberWritten()=0;
125
126};
127
128#endif