From e1ea128f747bb65924e5a7f5061b1632c496719f Mon Sep 17 00:00:00 2001 From: Mictronics Date: Thu, 8 Mar 2018 20:15:11 +0100 Subject: [PATCH 1/4] Line endings. --- player/plutoplayer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/player/plutoplayer.c b/player/plutoplayer.c index 9422851..4c7dc8b 100644 --- a/player/plutoplayer.c +++ b/player/plutoplayer.c @@ -25,8 +25,8 @@ struct stream_cfg { static void usage() { fprintf(stderr, "Usage: plutoplayer [options]\n" " -t Transmit data from file (required)\n" - " -a Set TX attenuation [dB] (default -20.0)" - " -b Set RF bandwidth [MHz] (default 5.0)"); + " -a Set TX attenuation [dB] (default -20.0)\n" + " -b Set RF bandwidth [MHz] (default 5.0)\n"); return; } From 09a37982486832e9e8a60bb3528448a3f963a43d Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 17 Mar 2018 09:49:57 +0100 Subject: [PATCH 2/4] Add options for URI and ntwork context. Bufix usage output. --- player/plutoplayer.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/player/plutoplayer.c b/player/plutoplayer.c index 4c7dc8b..a5ba4b7 100644 --- a/player/plutoplayer.c +++ b/player/plutoplayer.c @@ -26,7 +26,9 @@ static void usage() { fprintf(stderr, "Usage: plutoplayer [options]\n" " -t Transmit data from file (required)\n" " -a Set TX attenuation [dB] (default -20.0)\n" - " -b Set RF bandwidth [MHz] (default 5.0)\n"); + " -b Set RF bandwidth [MHz] (default 5.0)\n" + " -u ADALM-Pluto URI\n" + " -n ADALM-Pluto network IP or hostname (default pluto.local)\n"); return; } @@ -58,7 +60,8 @@ int main(int argc, char** argv) { const char* path = NULL; struct stream_cfg txcfg; FILE *fp = NULL; - enum state {INIT, READ_FILE, PAD_TRAILING, DONE}; + const char *uri = NULL; + const char *ip = NULL; // TX stream default config txcfg.bw_hz = MHZ(3.0); // 3.0 MHz RF bandwidth @@ -74,7 +77,7 @@ int main(int argc, char** argv) { struct iio_channel *tx0_q = NULL; struct iio_buffer *tx_buffer = NULL; - while ((opt = getopt(argc, argv, "t:a:b:")) != EOF) { + while ((opt = getopt(argc, argv, "t:a:b:n:u:")) != EOF) { switch (opt) { case 't': path = optarg; @@ -89,6 +92,12 @@ int main(int argc, char** argv) { if(txcfg.bw_hz > MHZ(5.0)) txcfg.bw_hz = MHZ(5.0); if(txcfg.bw_hz < MHZ(1.0)) txcfg.bw_hz = MHZ(1.0); break; + case 'u': + uri = optarg; + break; + case 'n': + ip = optarg; + break; default: printf("Unknown argument '-%c %s'\n", opt, optarg); usage(); @@ -118,7 +127,13 @@ int main(int argc, char** argv) { printf("* Acquiring IIO context\n"); ctx = iio_create_default_context(); if (ctx == NULL) { - ctx = iio_create_network_context("pluto.local"); + if(ip != NULL) { + ctx = iio_create_network_context(ip); + } else if (uri != NULL) { + ctx = iio_create_context_from_uri(uri); + } else { + ctx = iio_create_network_context("pluto.local"); + } } if (ctx == NULL) { @@ -214,7 +229,7 @@ int main(int argc, char** argv) { ntx = iio_buffer_push(tx_buffer); if (ntx < 0) { printf("Error pushing buf %d\n", (int) ntx); - goto error_exit; + break; } } printf("Done.\n"); From 2155fc5216e30d1d866250d46eecdeb983767bb5 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Wed, 21 Mar 2018 15:50:52 +0100 Subject: [PATCH 3/4] Remove double code. --- player/plutoplayer.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/player/plutoplayer.c b/player/plutoplayer.c index f1f0b60..c5c1f15 100644 --- a/player/plutoplayer.c +++ b/player/plutoplayer.c @@ -186,10 +186,6 @@ int main(int argc, char** argv) { iio_channel_attr_write_longlong( iio_device_find_channel(phydev, "altvoltage1", true) , "frequency", txcfg.lo_hz); // Set TX LO frequency - - iio_channel_attr_write_longlong( - iio_device_find_channel(phydev, "altvoltage1", true) - , "frequency", txcfg.lo_hz); // Set TX LO frequency printf("* Initializing streaming channels\n"); tx0_i = iio_device_find_channel(tx, "voltage0", true); From d5484fe778f2bc494d6f8f34d5088921925632b7 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Wed, 21 Mar 2018 20:08:34 +0100 Subject: [PATCH 4/4] Fix sample pointer size and reading correct from file. --- player/plutoplayer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/player/plutoplayer.c b/player/plutoplayer.c index c5c1f15..d3cb99b 100644 --- a/player/plutoplayer.c +++ b/player/plutoplayer.c @@ -215,12 +215,12 @@ int main(int argc, char** argv) { , "powerdown", false); // Turn ON TX LO int32_t ntx = 0; - char *ptx_buffer = (char *)iio_buffer_start(tx_buffer); - + short *ptx_buffer = (short *)iio_buffer_start(tx_buffer); + printf("* Transmit starts...\n"); // Keep writing samples while there is more data to send and no failures have occurred. while (!feof(fp) && !stop) { - fread(ptx_buffer, 1, BUFFER_SIZE,fp); + fread(ptx_buffer, sizeof(short), BUFFER_SIZE / sizeof(short),fp); // Schedule TX buffer ntx = iio_buffer_push(tx_buffer); if (ntx < 0) {