summaryrefslogtreecommitdiffstats
path: root/src/OutputUHDFeedback.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-12 10:44:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-05-12 10:44:33 +0200
commit201d2cd2e0431a5ea79fb69561c27555f3a03dc1 (patch)
treeb3814f6f91ba6b9594abf7d89f88cf022ab889ae /src/OutputUHDFeedback.cpp
parent5ac10e37d07cfe723ea4b396f08563889dff5a2b (diff)
downloaddabmod-201d2cd2e0431a5ea79fb69561c27555f3a03dc1.tar.gz
dabmod-201d2cd2e0431a5ea79fb69561c27555f3a03dc1.tar.bz2
dabmod-201d2cd2e0431a5ea79fb69561c27555f3a03dc1.zip
Add dpd example script to fetch samples
Diffstat (limited to 'src/OutputUHDFeedback.cpp')
-rw-r--r--src/OutputUHDFeedback.cpp208
1 files changed, 105 insertions, 103 deletions
diff --git a/src/OutputUHDFeedback.cpp b/src/OutputUHDFeedback.cpp
index 8584839..09b73ba 100644
--- a/src/OutputUHDFeedback.cpp
+++ b/src/OutputUHDFeedback.cpp
@@ -38,8 +38,10 @@ DESCRIPTION:
#include <vector>
#include <complex>
+#include <cstring>
#include <uhd/types/stream_cmd.hpp>
#include <sys/socket.h>
+#include <errno.h>
#include <poll.h>
#include "OutputUHDFeedback.h"
#include "Utils.h"
@@ -214,113 +216,113 @@ void OutputUHDFeedback::ServeFeedbackThread()
continue;
}
- while (m_running) {
- uint8_t request_version = 0;
- ssize_t read = recv(client_sock, &request_version, 1, 0);
- if (!read) break; // done reading
- if (read < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client read request version failed";
- }
-
- if (request_version != 1) {
- etiLog.level(info) << "DPD Feedback Server wrong request version";
- break;
- }
-
- uint32_t num_samples = 0;
- read = recv(client_sock, &num_samples, 4, 0);
- if (!read) break; // done reading
- if (read < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client read num samples failed";
- }
-
- // We are ready to issue the request now
- {
- boost::mutex::scoped_lock lock(burstRequest.mutex);
- burstRequest.num_samples = num_samples;
- burstRequest.state = BurstRequestState::SaveTransmitFrame;
-
- lock.unlock();
- }
-
- // Wait for the result to be ready
+ uint8_t request_version = 0;
+ ssize_t read = recv(client_sock, &request_version, 1, 0);
+ if (!read) break; // done reading
+ if (read < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client read request version failed: " << strerror(errno);
+ break;
+ }
+
+ if (request_version != 1) {
+ etiLog.level(info) << "DPD Feedback Server wrong request version";
+ break;
+ }
+
+ uint32_t num_samples = 0;
+ read = recv(client_sock, &num_samples, 4, 0);
+ if (!read) break; // done reading
+ if (read < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client read num samples failed";
+ break;
+ }
+
+ // We are ready to issue the request now
+ {
boost::mutex::scoped_lock lock(burstRequest.mutex);
- while (burstRequest.state != BurstRequestState::Acquired) {
- if (not m_running) break;
- burstRequest.mutex_notification.wait(lock);
- }
+ burstRequest.num_samples = num_samples;
+ burstRequest.state = BurstRequestState::SaveTransmitFrame;
- burstRequest.state = BurstRequestState::None;
lock.unlock();
+ }
+
+ // Wait for the result to be ready
+ boost::mutex::scoped_lock lock(burstRequest.mutex);
+ while (burstRequest.state != BurstRequestState::Acquired) {
+ if (not m_running) break;
+ burstRequest.mutex_notification.wait(lock);
+ }
+
+ burstRequest.state = BurstRequestState::None;
+ lock.unlock();
+
+ if (send(client_sock,
+ &burstRequest.num_samples,
+ sizeof(burstRequest.num_samples),
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send num_samples failed";
+ break;
+ }
+
+ if (send(client_sock,
+ &burstRequest.tx_second,
+ sizeof(burstRequest.tx_second),
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send tx_second failed";
+ break;
+ }
+
+ if (send(client_sock,
+ &burstRequest.tx_pps,
+ sizeof(burstRequest.tx_pps),
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send tx_pps failed";
+ break;
+ }
+
+ const size_t frame_bytes = burstRequest.num_samples * sizeof(complexf);
+
+ assert(burstRequest.tx_samples.size() == frame_bytes);
+ if (send(client_sock,
+ &burstRequest.tx_samples[0],
+ frame_bytes,
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send tx_frame failed";
+ break;
+ }
+
+ if (send(client_sock,
+ &burstRequest.rx_second,
+ sizeof(burstRequest.rx_second),
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send rx_second failed";
+ break;
+ }
+
+ if (send(client_sock,
+ &burstRequest.rx_pps,
+ sizeof(burstRequest.rx_pps),
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send rx_pps failed";
+ break;
+ }
- if (send(client_sock,
- &burstRequest.num_samples,
- sizeof(burstRequest.num_samples),
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send num_samples failed";
- break;
- }
-
- if (send(client_sock,
- &burstRequest.tx_second,
- sizeof(burstRequest.tx_second),
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send tx_second failed";
- break;
- }
-
- if (send(client_sock,
- &burstRequest.tx_pps,
- sizeof(burstRequest.tx_pps),
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send tx_pps failed";
- break;
- }
-
- const size_t frame_bytes = burstRequest.num_samples * sizeof(complexf);
-
- assert(burstRequest.tx_samples.size() == frame_bytes);
- if (send(client_sock,
- &burstRequest.tx_samples[0],
- frame_bytes,
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send tx_frame failed";
- break;
- }
-
- if (send(client_sock,
- &burstRequest.rx_second,
- sizeof(burstRequest.rx_second),
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send rx_second failed";
- break;
- }
-
- if (send(client_sock,
- &burstRequest.rx_pps,
- sizeof(burstRequest.rx_pps),
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send rx_pps failed";
- break;
- }
-
- assert(burstRequest.rx_samples.size() == frame_bytes);
- if (send(client_sock,
- &burstRequest.rx_samples[0],
- frame_bytes,
- 0) < 0) {
- etiLog.level(info) <<
- "DPD Feedback Server Client send rx_frame failed";
- break;
- }
+ assert(burstRequest.rx_samples.size() == frame_bytes);
+ if (send(client_sock,
+ &burstRequest.rx_samples[0],
+ frame_bytes,
+ 0) < 0) {
+ etiLog.level(info) <<
+ "DPD Feedback Server Client send rx_frame failed";
+ break;
}
close(client_sock);