diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index ea92274f3..2c88841fc 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -21,6 +21,7 @@ #include "INIReader.h" #include "command_event.h" #include "gnss_sdr_make_unique.h" +#include #include #include #include @@ -737,7 +738,8 @@ void labsat23_source::decode_ls3w_register(uint64_t input, std::vector bs(input); - // Reverse, since register are written to file as 64-bit little endian words + // Earlier samples are written in the MSBs of the register. Bit-reverse the register + // for easier indexing. Note this bit-reverses individual samples as well for quant > 1 bit for (std::size_t i = 0; i < 32; ++i) { bool t = bs[i]; @@ -1074,14 +1076,10 @@ int labsat23_source::general_work(int noutput_items, std::size_t output_pointer = 0; for (int i = 0; i < registers_to_read; i++) { - std::array memory_block{}; - binary_input_file.read(memory_block.data(), 8); uint64_t read_register = 0ULL; - for (int k = 7; k >= 0; --k) - { - read_register <<= 8; - read_register |= uint64_t(memory_block[k]); - } + // Labsat3W writes its 64-bit shift register to files in little endian. Read and convert to host endianness. + binary_input_file.read(reinterpret_cast(&read_register), sizeof(read_register)); + boost::endian::little_to_native_inplace(read_register); if (binary_input_file.gcount() == 8) {