Print characters in ASCII range when decoding

pull/120/head
Pieter Robyns 2020-03-22 20:41:38 +01:00
rodzic 0bbd2324c4
commit 77822182a0
2 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -24,6 +24,7 @@
#include <cstdint>
#include <string.h>
#include <iomanip>
#include <sstream>
#define MAC_CRC_SIZE 2u
#define MAX_PWR_QUEUE_SIZE 4
@ -348,11 +349,18 @@ namespace gr {
}
template <typename T>
inline void print_vector_hex(std::ostream& out, const T* v, const uint32_t size, bool endline) {
inline void print_vector_hex(std::ostream& out, const T* v, const uint32_t size, bool endline, bool print_ascii) {
std::stringstream ss;
for (uint32_t i = 0u; i < size; i++) {
out << " " << std::hex << std::setw(2) << std::setfill('0') << (int)v[i];
if (v[i] >= ' ' && v[i] <= '~')
ss << v[i];
}
if (print_ascii)
out << " (" << ss.str() << ")";
if(endline)
out << std::endl;

Wyświetl plik

@ -840,7 +840,7 @@ namespace gr {
if (demodulate(input, true)) {
decode(true);
gr::lora::print_vector_hex(std::cout, &d_decoded[0], d_decoded.size(), false);
gr::lora::print_vector_hex(std::cout, &d_decoded[0], d_decoded.size(), false, false);
memcpy(&d_phdr, &d_decoded[0], sizeof(loraphy_header_t));
if (d_phdr.cr > 4)
d_phdr.cr = 4;
@ -880,7 +880,7 @@ namespace gr {
if (d_payload_symbols <= 0) {
decode(false);
gr::lora::print_vector_hex(std::cout, &d_decoded[0], d_payload_length, true);
gr::lora::print_vector_hex(std::cout, &d_decoded[0], d_payload_length, true, true);
msg_lora_frame();
d_state = gr::lora::DecoderState::DETECT;