blob: f10da3e7cde5ea5675011b0f74f69f03087fedcf [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.heimerl965e7572011-11-26 03:16:54 +000030 static RadioDevice *make(double desiredSampleRate, bool skipRx = false);
31
kurtis.heimerldb2aae52011-11-26 03:17:13 +000032 /** Initialize the USRP */
kurtis.heimerl965e7572011-11-26 03:16:54 +000033 virtual bool open()=0;
dburgessb3a0ca42011-10-12 07:44:40 +000034
35 /** Start the USRP */
36 virtual bool start()=0;
37
38 /** Stop the USRP */
39 virtual bool stop()=0;
40
kurtis.heimerldb2aae52011-11-26 03:17:13 +000041 /** Enable thread priority */
42 virtual void setPriority()=0;
43
dburgessb3a0ca42011-10-12 07:44:40 +000044 /**
45 Read samples from the radio.
46 @param buf preallocated buf to contain read result
47 @param len number of samples desired
48 @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough
49 @param timestamp The timestamp of the first samples to be read
50 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
51 @param RSSI The received signal strength of the read result
52 @return The number of samples actually read
53 */
54 virtual int readSamples(short *buf, int len, bool *overrun,
kurtis.heimerl965e7572011-11-26 03:16:54 +000055 TIMESTAMP timestamp = 0xffffffff,
56 bool *underrun = 0,
57 unsigned *RSSI = 0)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000058 /**
59 Write samples to the radio.
60 @param buf Contains the data to be written.
61 @param len number of samples to write.
62 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
63 @param timestamp The timestamp of the first sample of the data buffer.
64 @param isControl Set if data is a control packet, e.g. a ping command
65 @return The number of samples actually written
66 */
67 virtual int writeSamples(short *buf, int len, bool *underrun,
68 TIMESTAMP timestamp,
69 bool isControl=false)=0;
70
71 /** Update the alignment between the read and write timestamps */
72 virtual bool updateAlignment(TIMESTAMP timestamp)=0;
73
74 /** Set the transmitter frequency */
75 virtual bool setTxFreq(double wFreq)=0;
76
77 /** Set the receiver frequency */
78 virtual bool setRxFreq(double wFreq)=0;
79
80 /** Returns the starting write Timestamp*/
81 virtual TIMESTAMP initialWriteTimestamp(void)=0;
82
83 /** Returns the starting read Timestamp*/
84 virtual TIMESTAMP initialReadTimestamp(void)=0;
85
86 /** returns the full-scale transmit amplitude **/
87 virtual double fullScaleInputValue()=0;
88
89 /** returns the full-scale receive amplitude **/
90 virtual double fullScaleOutputValue()=0;
91
92 /** sets the receive chan gain, returns the gain setting **/
93 virtual double setRxGain(double dB)=0;
94
95 /** gets the current receive gain **/
96 virtual double getRxGain(void)=0;
97
98 /** return maximum Rx Gain **/
99 virtual double maxRxGain(void) = 0;
100
101 /** return minimum Rx Gain **/
102 virtual double minRxGain(void) = 0;
103
104 /** sets the transmit chan gain, returns the gain setting **/
105 virtual double setTxGain(double dB)=0;
106
107 /** return maximum Tx Gain **/
108 virtual double maxTxGain(void) = 0;
109
110 /** return minimum Tx Gain **/
111 virtual double minTxGain(void) = 0;
112
113 /** Return internal status values */
114 virtual double getTxFreq()=0;
115 virtual double getRxFreq()=0;
116 virtual double getSampleRate()=0;
117 virtual double numberRead()=0;
118 virtual double numberWritten()=0;
119
120};
121
122#endif