aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CommonLibs/Makefile.am1
-rw-r--r--CommonLibs/osmo_signal.h35
-rw-r--r--Transceiver52M/Transceiver.cpp23
-rw-r--r--Transceiver52M/Transceiver.h5
-rw-r--r--Transceiver52M/osmo-trx.cpp17
5 files changed, 79 insertions, 2 deletions
diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am
index 2332acb..3173397 100644
--- a/CommonLibs/Makefile.am
+++ b/CommonLibs/Makefile.am
@@ -49,4 +49,5 @@ noinst_HEADERS = \
Logger.h \
trx_vty.h \
debug.h \
+ osmo_signal.h \
config_defs.h
diff --git a/CommonLibs/osmo_signal.h b/CommonLibs/osmo_signal.h
new file mode 100644
index 0000000..00b8097
--- /dev/null
+++ b/CommonLibs/osmo_signal.h
@@ -0,0 +1,35 @@
+/* Generic signalling/notification infrastructure */
+/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * Author: Pau Espin Pedrol <pespin@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+#include <osmocom/core/signal.h>
+
+/* Signalling subsystems */
+enum signal_subsystems {
+ SS_TRANSC,
+};
+
+/* SS_TRANSC signals */
+enum SS_TRANSC {
+ S_TRANSC_STOP_REQUIRED, /* Transceiver fatal error, it should be stopped */
+};
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index a1ebb30..cdfd79d 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -27,6 +27,10 @@
#include "Transceiver.h"
#include <Logger.h>
+extern "C" {
+#include "osmo_signal.h"
+}
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -115,7 +119,7 @@ Transceiver::Transceiver(int wBasePort,
: mBasePort(wBasePort), mLocalAddr(TRXAddress), mRemoteAddr(GSMcoreAddress),
mClockSocket(TRXAddress, wBasePort, GSMcoreAddress, wBasePort + 100),
mTransmitLatency(wTransmitLatency), mRadioInterface(wRadioInterface),
- rssiOffset(wRssiOffset),
+ rssiOffset(wRssiOffset), sig_cbfn(NULL),
mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans), mEdge(false), mOn(false), mForceClockInterface(false),
mTxFreq(0.0), mRxFreq(0.0), mTSC(0), mMaxExpectedDelayAB(0), mMaxExpectedDelayNB(0),
mWriteBurstToDiskMask(0)
@@ -219,6 +223,17 @@ bool Transceiver::init(FillerType filler, size_t rtsc, unsigned rach_delay, bool
return true;
}
+void Transceiver::setSignalHandler(osmo_signal_cbfn cbfn)
+{
+ if (this->sig_cbfn)
+ osmo_signal_unregister_handler(SS_TRANSC, this->sig_cbfn, NULL);
+
+ if (cbfn) {
+ this->sig_cbfn = cbfn;
+ osmo_signal_register_handler(SS_TRANSC, this->sig_cbfn, NULL);
+ }
+}
+
/*
* Start the transceiver
*
@@ -885,8 +900,12 @@ bool Transceiver::driveTxPriorityQueue(size_t chan)
void Transceiver::driveReceiveRadio()
{
- if (!mRadioInterface->driveReceiveRadio()) {
+ int rc = mRadioInterface->driveReceiveRadio();
+ if (rc == 0) {
usleep(100000);
+ } else if (rc < 0) {
+ LOG(FATAL) << "radio Interface receive failed, requesting stop.";
+ osmo_signal_dispatch(SS_TRANSC, S_TRANSC_STOP_REQUIRED, this);
} else if (mForceClockInterface || mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) {
mForceClockInterface = false;
writeClockInterface();
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index f9b54f0..e250adc 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -31,6 +31,7 @@
#include <sys/socket.h>
extern "C" {
+#include <osmocom/core/signal.h>
#include "config_defs.h"
}
@@ -128,6 +129,8 @@ public:
/** accessor for number of channels */
size_t numChans() const { return mChans; };
+ void setSignalHandler(osmo_signal_cbfn cbfn);
+
/** Codes for channel combinations */
typedef enum {
FILL, ///< Channel is transmitted, but unused
@@ -177,6 +180,8 @@ private:
double rssiOffset; ///< RSSI to dBm conversion offset
+ osmo_signal_cbfn *sig_cbfn; ///< Registered Signal Handler to announce events.
+
/** modulate and add a burst to the transmit queue */
void addRadioVector(size_t chan, BitVector &bits,
int RSSI, GSM::Time &wTime);
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 1c40fcf..d01a4cf 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -55,6 +55,7 @@ extern "C" {
#include "convert.h"
#include "trx_vty.h"
#include "debug.h"
+#include "osmo_signal.h"
}
#define DEFAULT_CONFIG_FILE "osmo-trx.cfg"
@@ -112,6 +113,20 @@ RadioInterface *makeRadioInterface(struct trx_ctx *trx,
return radio;
}
+/* Callback function to be called every time we receive a signal from TRANSC */
+static int transc_sig_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ switch (signal) {
+ case S_TRANSC_STOP_REQUIRED:
+ gshutdown = true;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
/* Create transceiver core
* The multi-threaded modem core operates at multiples of the GSM rate of
* 270.8333 ksps and consists of GSM specific modulation, demodulation,
@@ -132,6 +147,8 @@ int makeTransceiver(struct trx_ctx *trx, RadioInterface *radio)
return -1;
}
+ transceiver->setSignalHandler(transc_sig_cb);
+
for (size_t i = 0; i < trx->cfg.num_chans; i++) {
fifo = radio->receiveFIFO(i);
if (fifo && transceiver->receiveFIFO(fifo, i))