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