aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-11-13 11:00:21 -0800
committerAlexander Chemeris <Alexander.Chemeris@gmail.com>2015-11-13 11:00:21 -0800
commit9155d8da94ebcac24bf234b237d049bb3a5def15 (patch)
treec3e7607d36d5c26f1e22e9ba7e808d32b06b0418
parent8b8e7ecf8a1365759b410cfb764b9ee94972bb2d (diff)
transceiver: Add an option to stream raw samples instead of demodulated softbits.
-rw-r--r--Transceiver52M/Transceiver.cpp78
-rw-r--r--Transceiver52M/Transceiver.h18
-rw-r--r--Transceiver52M/osmo-trx.cpp15
3 files changed, 84 insertions, 27 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index ddb191e..7dbb7bb 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -145,11 +145,13 @@ Transceiver::Transceiver(int wBasePort,
size_t wSPS, size_t wChans,
GSM::Time wTransmitLatency,
RadioInterface *wRadioInterface,
- double wRssiOffset)
+ double wRssiOffset,
+ bool wExternalDemod)
: mBasePort(wBasePort), mAddr(wTRXAddress),
mClockSocket(wBasePort, wTRXAddress, mBasePort + 100),
mTransmitLatency(wTransmitLatency), mRadioInterface(wRadioInterface),
rssiOffset(wRssiOffset),
+ mExternalDemod(wExternalDemod),
mSPSTx(wSPS), mSPSRx(1), mChans(wChans), mOn(false),
mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelay(0), mWriteBurstToDiskMask(0)
{
@@ -876,7 +878,6 @@ void Transceiver::driveReceiveFIFO(size_t chan)
{
radioVector *radio_burst = NULL;
signalVector *burst = NULL;
- SoftVector *rxBurst = NULL;
double burst_power; // sqr(amp)
double RSSI; // in dBFS
double dBm; // in dBm
@@ -884,6 +885,8 @@ void Transceiver::driveReceiveFIFO(size_t chan)
double noise; // noise level in dBFS
GSM::Time burstTime;
CorrType burstType;
+ char burstString[3000];
+ int pktLen;
/* Blocking FIFO read */
radio_burst = mReceiveFIFO[chan]->read();
@@ -924,29 +927,33 @@ void Transceiver::driveReceiveFIFO(size_t chan)
RSSI = dB2(rxFullScale / burst_power);
dBm = RSSI+rssiOffset;
- /* Pre-process and demodulate radio vector */
- rxBurst = demodSignalVector(burst, burstType, TOA);
- if (!rxBurst)
- return;
+ if (!mExternalDemod) {
+ /* Pre-process and demodulate radio vector */
+ SoftVector *rxBurst = demodSignalVector(burst, burstType, TOA);
+ if (!rxBurst)
+ return;
- LOG(DEBUG) << std::fixed << std::right
- << " time: " << burstTime
- << " RSSI: " << std::setw(5) << std::setprecision(1) << RSSI << "dBFS/" << std::setw(6) << -dBm << "dBm"
- << " noise: " << std::setw(5) << std::setprecision(1) << noise << "dBFS/" << std::setw(6) << -(noise+rssiOffset) << "dBm"
- << " TOA: " << std::setw(5) << std::setprecision(2) << TOA
- << " bits: " << *rxBurst;
+ LOG(DEBUG) << std::fixed << std::right
+ << " time: " << burstTime
+ << " RSSI: " << std::setw(5) << std::setprecision(1) << RSSI << "dBFS/" << std::setw(6) << -dBm << "dBm"
+ << " noise: " << std::setw(5) << std::setprecision(1) << noise << "dBFS/" << std::setw(6) << -(noise+rssiOffset) << "dBm"
+ << " TOA: " << std::setw(5) << std::setprecision(2) << TOA
+ << " bits: " << *rxBurst;
- char burstString[gSlotLen+10];
- formatDemodPacket(burstTime, dBm, TOA, rxBurst, burstString);
- delete rxBurst;
+ pktLen = formatDemodPacket(burstTime, dBm, TOA, rxBurst, burstString);
+ delete rxBurst;
+ } else {
+ /* Send radio vector as is */
+ pktLen = formatRawPacket(burstTime, dBm, TOA, burstType, mTSC, burst, burstString);
+ }
- mDataSockets[chan]->write(burstString,gSlotLen+10);
+ mDataSockets[chan]->write(burstString, pktLen);
delete burst;
}
-void Transceiver::formatDemodPacket(GSM::Time burstTime, double dBm, double TOA,
- SoftVector *rxBurst, char *burstString)
+int Transceiver::formatCommonPacketHeader(GSM::Time burstTime, double dBm, double TOA,
+ char *burstString)
{
int TOAint; // in 1/256 symbols
TOAint = (int) (TOA * 256.0 + 0.5); // round to closest integer
@@ -957,12 +964,43 @@ void Transceiver::formatDemodPacket(GSM::Time burstTime, double dBm, double TOA,
burstString[5] = (int)dBm;
burstString[6] = (TOAint >> 8) & 0x0ff;
burstString[7] = TOAint & 0x0ff;
+
+ return 8;
+}
+
+int Transceiver::formatDemodPacket(GSM::Time burstTime, double dBm, double TOA,
+ SoftVector *rxBurst, char *burstString)
+{
+ int headerSize = formatCommonPacketHeader(burstTime, dBm, TOA, burstString);
SoftVector::iterator burstItr = rxBurst->begin();
for (unsigned int i = 0; i < gSlotLen; i++) {
- burstString[8+i] =(char) round((*burstItr++)*255.0);
+ burstString[headerSize+i] =(char) round((*burstItr++)*255.0);
}
- burstString[gSlotLen+9] = '\0';
+ burstString[gSlotLen+headerSize+1] = '\0';
+
+ return gSlotLen+headerSize+2;
+}
+
+int Transceiver::formatRawPacket(GSM::Time burstTime, double dBm, double TOA,
+ CorrType burstType, unsigned tsc,
+ signalVector *rxBurst, char *burstString)
+{
+ int headerSize = formatCommonPacketHeader(burstTime, dBm, TOA, burstString);
+ burstString[headerSize++] = burstType;
+ burstString[headerSize++] = tsc;
+ burstString[headerSize++] = 0; // alignment
+ burstString[headerSize++] = 0; // alignment
+
+ signalVector::iterator burstItr = rxBurst->begin();
+ float *signalItr = (float*)(&burstString[headerSize]);
+
+ for (unsigned int i = 0; i < gSlotLen; i++, burstItr++) {
+ signalItr[2*i] = (*burstItr).real();
+ signalItr[2*i+1] = (*burstItr).imag();
+ }
+
+ return headerSize + 2*gSlotLen*sizeof(float);
}
void Transceiver::driveTxFIFO()
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index d8cdaee..a75ba4e 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -87,7 +87,8 @@ public:
size_t wSPS, size_t chans,
GSM::Time wTransmitLatency,
RadioInterface *wRadioInterface,
- double wRssiOffset);
+ double wRssiOffset,
+ bool wExternalDemod);
/** Destructor */
~Transceiver();
@@ -170,6 +171,8 @@ private:
double rssiOffset; ///< RSSI to dBm conversion offset
+ bool mExternalDemod; ///< Should we internal or external demod
+
/** modulate and add a burst to the transmit queue */
void addRadioVector(size_t chan, BitVector &bits,
int RSSI, GSM::Time &wTime);
@@ -236,9 +239,18 @@ protected:
/** drive demodulation of GSM bursts */
void driveReceiveFIFO(size_t chan);
+ /** format a common header for packets with sent over the network */
+ int formatCommonPacketHeader(GSM::Time burstTime, double dBm, double TOA,
+ char *burstString);
+
/** format a packet of soft-bits to be sent over the network */
- void formatDemodPacket(GSM::Time burstTime, double dBm, double TOA,
- SoftVector *rxBurst, char *burstString);
+ int formatDemodPacket(GSM::Time burstTime, double dBm, double TOA,
+ SoftVector *rxBurst, char *burstString);
+
+ /** format a packet of raw samples to be sent over the network */
+ int formatRawPacket(GSM::Time burstTime, double dBm, double TOA,
+ CorrType burstType, unsigned tsc,
+ signalVector *rxBurst, char *burstString);
/** drive transmission of GSM bursts */
void driveTxFIFO();
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 7b9fd7c..caffe20 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -72,6 +72,7 @@ struct trx_config {
double offset;
double rssi_offset;
bool swap_channels;
+ bool external_demod;
};
ConfigurationTable gConfig;
@@ -189,6 +190,7 @@ bool trx_setup_config(struct trx_config *config)
ost << " Tuning offset........... " << config->offset << std::endl;
ost << " RSSI to dBm offset...... " << config->rssi_offset << std::endl;
ost << " Swap channels........... " << config->swap_channels << std::endl;
+ ost << " External demodulator.... " << config->external_demod << std::endl;
std::cout << ost << std::endl;
return true;
@@ -244,7 +246,7 @@ Transceiver *makeTransceiver(struct trx_config *config, RadioInterface *radio)
VectorFIFO *fifo;
trx = new Transceiver(config->port, config->addr.c_str(), config->sps,
- config->chans, GSM::Time(3,0), radio, config->rssi_offset);
+ config->chans, GSM::Time(3,0), radio, config->rssi_offset, config->external_demod);
if (!trx->init(config->filler, config->rtsc)) {
LOG(ALERT) << "Failed to initialize transceiver";
delete trx;
@@ -298,8 +300,9 @@ static void print_help()
" -o Set baseband frequency offset (default=auto)\n"
" -r Random burst test mode with TSC\n"
" -R RSSI to dBm offset in dB (default=0)\n"
- " -S Swap channels (UmTRX only)\n",
- "EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
+ " -S Swap channels (UmTRX only)\n"
+ " -e External demodulator - stream raw samples instead of soft bits (default=internal)\n",
+ "EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
}
static void handle_options(int argc, char **argv, struct trx_config *config)
@@ -316,8 +319,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
config->offset = 0.0;
config->rssi_offset = 0.0;
config->swap_channels = false;
+ config->external_demod = false;
- while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:R:S")) != -1) {
+ while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:R:Se")) != -1) {
switch (option) {
case 'h':
print_help();
@@ -363,6 +367,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
case 'S':
config->swap_channels = true;
break;
+ case 'e':
+ config->external_demod = true;
+ break;
default:
print_help();
exit(0);