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