diff options
author | Tom Tsou <tom@tsou.cc> | 2014-11-25 16:06:32 -0800 |
---|---|---|
committer | Tom Tsou <tom@tsou.cc> | 2014-12-15 16:20:15 -0700 |
commit | eb54bddf47e087cf340c8a65b36a03cebd4f174b (patch) | |
tree | d9c41dfef5c514a143c521f7cd138af950a34122 /Transceiver52M/radioInterface.cpp | |
parent | a4d1a4124421473f5f92255e2f3bc44bfa3937ea (diff) |
Transceiver52M: Implement POWEROFF command
Add stop and restart capability through the POWEROFF and POWERON
commands. Calling stop causes receive streaming to cease, and I/O
threads to shutdown leaving only the control handling thread running.
Upon receiving a POWERON command, I/O threads and device streaming are
restarted.
Proper shutdown of the transceiver is now initiated by the destructor,
which calls the stop command internally to wind down and deallocate
threads.
Signed-off-by: Tom Tsou <tom@tsou.cc>
Diffstat (limited to 'Transceiver52M/radioInterface.cpp')
-rw-r--r-- | Transceiver52M/radioInterface.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp index d67b486..369f2ac 100644 --- a/Transceiver52M/radioInterface.cpp +++ b/Transceiver52M/radioInterface.cpp @@ -171,15 +171,20 @@ bool RadioInterface::tuneRx(double freq, size_t chan) return mRadio->setRxFreq(freq, chan); } - -void RadioInterface::start() +bool RadioInterface::start() { - LOG(INFO) << "Starting radio"; + if (mOn) + return true; + + LOG(INFO) << "Starting radio device"; #ifdef USRP1 mAlignRadioServiceLoopThread.start((void * (*)(void*))AlignRadioServiceLoopAdapter, (void*)this); #endif - mRadio->start(); + + if (!mRadio->start()) + return false; + writeTimestamp = mRadio->initialWriteTimestamp(); readTimestamp = mRadio->initialReadTimestamp(); @@ -188,6 +193,23 @@ void RadioInterface::start() mOn = true; LOG(INFO) << "Radio started"; + return true; +} + +/* + * Stop the radio device + * + * This is a pass-through call to the device interface. Because the underlying + * stop command issuance generally doesn't return confirmation on device status, + * this call will only return false if the device is already stopped. + */ +bool RadioInterface::stop() +{ + if (!mOn || !mRadio->stop()) + return false; + + mOn = false; + return true; } #ifdef USRP1 |