summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-12 20:05:57 -0700
committerJosh Blum <josh@joshknows.com>2011-11-03 20:37:12 -0700
commit522bc87d9f61668f3d22e067c39a98e5f33fc6c5 (patch)
tree414d3dcd86710aba39a44649872ce709d1662d8f
parent9369259177e5517e2b0e775804224c5467e14eab (diff)
downloaduhd-522bc87d9f61668f3d22e067c39a98e5f33fc6c5.tar.gz
uhd-522bc87d9f61668f3d22e067c39a98e5f33fc6c5.tar.bz2
uhd-522bc87d9f61668f3d22e067c39a98e5f33fc6c5.zip
uhd: fixed 8sc item32 converter on head/tail cases
-rw-r--r--host/examples/rx_timed_samples.cpp2
-rw-r--r--host/lib/convert/gen_convert_general.py24
2 files changed, 11 insertions, 15 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 0851593cd..143bceb03 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -98,7 +98,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
while(num_acc_samps < total_num_samps){
//receive a single packet
size_t num_rx_samps = rx_stream->recv(
- &buff.front(), buff.size(), md, timeout
+ &buff.front(), buff.size(), md, timeout, true
);
//use a small timeout for subsequent packets
diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py
index 43e1f9967..9a1135b0b 100644
--- a/host/lib/convert/gen_convert_general.py
+++ b/host/lib/convert/gen_convert_general.py
@@ -51,27 +51,23 @@ DECLARE_CONVERTER(sc8_item32_$(end), 1, $(cpu_type), 1, PRIORITY_GENERAL){
const item32_t *input = reinterpret_cast<const item32_t *>(size_t(inputs[0]) & ~0x3);
$(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]);
$(cpu_type)_t dummy;
+ size_t num_samps = nsamps;
- const bool head_case = ((size_t(inputs[0]) & 0x3) != 0);
- const bool tail_case = ((nsamps & 0x1) == 0)? head_case : not head_case;
- const size_t num_pairs = (head_case? nsamps-1 : nsamps)/2;
- size_t i = 0, j = 0;
-
- //special head case, probably from a partial recv
- if (head_case){
- const item32_t item0 = $(to_host)(input[i++]);
- item32_sc8_to_$(cpu_type)(item0, dummy, output[j++], scale_factor);
+ if ((size_t(inputs[0]) & 0x3) != 0){
+ const item32_t item0 = $(to_host)(*input++);
+ item32_sc8_to_$(cpu_type)(item0, dummy, *output++, scale_factor);
+ num_samps--;
}
- for (; i < num_pairs; i++, j+=2){
+ const size_t num_pairs = num_samps/2;
+ for (size_t i = 0, j = 0; i < num_pairs; i++, j+=2){
const item32_t item_i = $(to_host)(input[i]);
item32_sc8_to_$(cpu_type)(item_i, output[j], output[j+1], scale_factor);
}
- //special tail case, finished on an odd number
- if (tail_case){
- const item32_t item_i = $(to_host)(input[i]);
- item32_sc8_to_$(cpu_type)(item_i, output[j], dummy, scale_factor);
+ if (num_samps != num_pairs*2){
+ const item32_t item_n = $(to_host)(input[num_pairs]);
+ item32_sc8_to_$(cpu_type)(item_n, output[num_samps-1], dummy, scale_factor);
}
}
"""