aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Transceiver52M/Makefile.am4
-rw-r--r--Transceiver52M/Transceiver.cpp25
-rw-r--r--Transceiver52M/proto_trxd.h28
3 files changed, 46 insertions, 11 deletions
diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index 89ab796..4adf474 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -25,6 +25,7 @@ SUBDIRS = arch device
AM_CPPFLAGS = -Wall $(STD_DEFINES_AND_INCLUDES) -I${srcdir}/arch/common -I${srcdir}/device/common
AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS)
+AM_CFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOVTY_CFLAGS)
rev2dir = $(datadir)/usrp/rev2
rev4dir = $(datadir)/usrp/rev4
@@ -66,7 +67,8 @@ noinst_HEADERS = \
Resampler.h \
ChannelizerBase.h \
Channelizer.h \
- Synthesis.h
+ Synthesis.h \
+ proto_trxd.h
COMMON_LDADD = \
libtransceiver_common.la \
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 0aa4ff5..5441745 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -29,6 +29,9 @@
extern "C" {
#include "osmo_signal.h"
+#include "proto_trxd.h"
+
+#include <osmocom/core/bits.h>
}
#ifdef HAVE_CONFIG_H
@@ -950,22 +953,24 @@ void Transceiver::driveReceiveFIFO(size_t chan)
TOAint = (int) (TOA * 256.0 + 0.5); // round to closest integer
- char burstString[nbits + 10];
- burstString[0] = burstTime.TN();
- for (int i = 0; i < 4; i++)
- burstString[1+i] = (burstTime.FN() >> ((3-i)*8)) & 0x0ff;
- burstString[5] = (int)dBm;
- burstString[6] = (TOAint >> 8) & 0x0ff;
- burstString[7] = TOAint & 0x0ff;
+ char burstString[sizeof(struct trxd_hdr_v0) + nbits + 2];
+ struct trxd_hdr_v0* pkt = (struct trxd_hdr_v0*)burstString;
+ pkt->common.version = 0;
+ pkt->common.reserved = 0;
+ pkt->common.tn = burstTime.TN();
+ osmo_store32be(burstTime.FN(), &pkt->common.fn);
+ pkt->v0.rssi = dBm;
+ osmo_store16be(TOAint, &pkt->v0.toa);
SoftVector::iterator burstItr = rxBurst->begin();
for (unsigned i = 0; i < nbits; i++)
- burstString[8 + i] = (char) round((*burstItr++) * 255.0);
+ pkt->soft_bits[i] = (char) round((*burstItr++) * 255.0);
- burstString[nbits + 9] = '\0';
+ /* +1: Historical reason. There's an uninitizalied byte in there: pkt->soft_bits[bi.nbits] */
+ pkt->soft_bits[nbits + 1] = '\0';
delete rxBurst;
- mDataSockets[chan]->write(burstString, nbits + 10);
+ mDataSockets[chan]->write(burstString, sizeof(struct trxd_hdr_v0) + nbits + 2);
}
void Transceiver::driveTxFIFO()
diff --git a/Transceiver52M/proto_trxd.h b/Transceiver52M/proto_trxd.h
new file mode 100644
index 0000000..9da18db
--- /dev/null
+++ b/Transceiver52M/proto_trxd.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <stdint.h>
+#include <osmocom/core/endian.h>
+
+struct trxd_hdr_common {
+#if OSMO_IS_LITTLE_ENDIAN
+ uint8_t tn:3,
+ reserved:1,
+ version:4;
+#elif OSMO_IS_BIG_ENDIAN
+ uint8_t version:4,
+ reserved:1,
+ tn:3;
+#endif
+ uint32_t fn; /* big endian */
+} __attribute__ ((packed));
+
+struct trxd_hdr_v0_specific {
+ uint8_t rssi;
+ uint16_t toa; /* big endian */
+} __attribute__ ((packed));
+
+struct trxd_hdr_v0 {
+ struct trxd_hdr_common common;
+ struct trxd_hdr_v0_specific v0;
+ uint8_t soft_bits[0];
+} __attribute__ ((packed));