diff --git a/public-trunk/Transceiver/Device.h b/public-trunk/Transceiver/Device.h index bc5055d..5a47bb0 100644 --- a/public-trunk/Transceiver/Device.h +++ b/public-trunk/Transceiver/Device.h @@ -85,10 +85,6 @@ public: /** Virtual destructor */ virtual ~Device() { } - - /** Type conversions if necessary */ - static short convertHostDeviceShort(short value); - static short convertDeviceHostShort(short value); }; #endif // _DEVICE_H_ diff --git a/public-trunk/Transceiver/UHDDevice.cpp b/public-trunk/Transceiver/UHDDevice.cpp index e15f0c0..97b9a02 100644 --- a/public-trunk/Transceiver/UHDDevice.cpp +++ b/public-trunk/Transceiver/UHDDevice.cpp @@ -704,17 +704,3 @@ Device *Device::make(double sampleRate, bool skipRx) { return new UHDDevice(sampleRate, skipRx); } - - -short Device::convertHostDeviceShort(short value) -{ - // Type conversion handled internally by UHD - return value; -} - - -short Device::convertDeviceHostShort(short value) -{ - // Type conversion handled internally by UHD - return value; -} diff --git a/public-trunk/Transceiver/USRPDevice.cpp b/public-trunk/Transceiver/USRPDevice.cpp index 2870170..c5e5a34 100644 --- a/public-trunk/Transceiver/USRPDevice.cpp +++ b/public-trunk/Transceiver/USRPDevice.cpp @@ -415,6 +415,13 @@ int USRPDevice::readSamples(short *buf, int len, bool *overrun, dataStart = (bufStart + len) % (currDataSize/2); timeStart = timestamp + len; if (readBuf!=NULL) delete[] readBuf; + + // do IQ swap here + for (int i = 0; i < len; i++) { + short tmp = usrp_to_host_short(buf[2*i]); + buf[2*i] = usrp_to_host_short(buf[2*i+1]); + buf[2*i+1] = tmp; + } return len; @@ -460,7 +467,11 @@ int USRPDevice::writeSamples(short *buf, int len, bool *underrun, { #ifndef SWLOOPBACK if (!m_uTx) return 0; - + + for (int i = 0; i < len*2; i++) { + buf[i] = host_to_usrp_short(buf[i]); + } + int numWritten = 0; unsigned isStart = 1; unsigned RSSI = 0; @@ -550,15 +561,3 @@ Device *Device::make(double desiredSampleRate, bool skipRx) { return new USRPDevice(desiredSampleRate, skipRx); } - - -short Device::convertHostDeviceShort(short value) -{ - return host_to_usrp_short(value); -} - - -short Device::convertDeviceHostShort(short value) -{ - return usrp_to_host_short(value); -} diff --git a/public-trunk/Transceiver/radioInterface.cpp b/public-trunk/Transceiver/radioInterface.cpp index c75e5ba..796bd4e 100644 --- a/public-trunk/Transceiver/radioInterface.cpp +++ b/public-trunk/Transceiver/radioInterface.cpp @@ -80,8 +80,8 @@ short *RadioInterface::USRPifyVector(signalVector &wVector) signalVector::iterator itr = wVector.begin(); short *shortItr = retVector; while (itr < wVector.end()) { - *shortItr++ = usrp->convertHostDeviceShort(itr->real()); - *shortItr++ = usrp->convertHostDeviceShort(itr->imag()); + *shortItr++ = itr->real(); + *shortItr++ = itr->imag(); itr++; } @@ -98,24 +98,8 @@ signalVector *RadioInterface::unUSRPifyVector(short *shortVector, int numSamples signalVector::iterator itr = newVector->begin(); short *shortItr = shortVector; -// This is hideous. -// UHD & !SWLOOPBACK: FLIP_IQ = 0 -// UHD & SWLOOPBACK: FLIP_IQ = 0 -// USRP1 & !SWLOOPBACK: FLIP_IQ = 1 -// USRP1 & SWLOOPBACK: FLIP_IQ = 0 -#ifdef USE_UHD -#define FLIP_IQ 0 -#else -#ifndef SWLOOPBACK -#define FLIP_IQ 1 -#else -#define FLIP_IQ 0 -#endif -#endif - while (itr < newVector->end()) { - *itr++ = Complex(usrp->convertDeviceHostShort(*(shortItr+FLIP_IQ)), - usrp->convertDeviceHostShort(*(shortItr+1-FLIP_IQ))); + *itr++ = Complex(*shortItr, *(shortItr+1)); shortItr += 2; }