Colored interleave matrix print in debug mode

pull/61/head
Pieter Robyns 2017-12-20 10:44:45 +01:00
rodzic 9701330772
commit 62c0f6ada7
2 zmienionych plików z 38 dodań i 8 usunięć

Wyświetl plik

@ -25,7 +25,6 @@
#include <string.h>
#include <iomanip>
#define REV_BITS
#define MAC_CRC_SIZE 2u
#define MAX_PWR_QUEUE_SIZE 4
#define SM(value, shift, mask) (((value) << (shift)) & (mask))
@ -33,6 +32,34 @@
namespace gr {
namespace lora {
static std::vector<std::string> term_colors = {
"\e[0m",
"\e[1m\e[91m",
"\e[1m\e[92m",
"\e[1m\e[93m",
"\e[1m\e[94m",
"\e[1m\e[95m",
"\e[1m\e[96m",
"\e[1m\e[97m",
"\e[1m\e[31m",
"\e[1m\e[32m",
"\e[1m\e[33m",
"\e[1m\e[34m",
"\e[1m\e[35m",
"\e[1m\e[36m"
};
/**
* \brief Wrap indices Python-like, i.e. array[wrap_index(-1, array_length)] gets the last element.
*
* \param i
* Index of array
* \param n
* Length of array
*/
inline int32_t wrap_index(int32_t i, int32_t n) {
return ((i % n) + n) % n;
}
/**
* \brief Clamp given value in the given range.
@ -86,7 +113,7 @@ namespace gr {
*/
template <typename T>
inline std::string to_bin(const T v, const uint32_t bitwidth) {
#ifdef REV_BITS
#ifdef LSB_FIRST
const uint64_t maxpow = bitwidth ? (1ull << (bitwidth - 1)) : 0;
uint64_t mask;
@ -340,13 +367,17 @@ namespace gr {
out << "-";
out << std::endl;
for(uint32_t i = 0; i < sf; i++) {
for(uint32_t j = 0; j < cr; j++) {
out << to_bin(v[j], sf)[i];
out << "LSB" << std::endl;
for(int32_t i = sf-1; i >= 0; i--) {
for(int32_t j = 0; j < (int32_t)cr; j++) {
out << term_colors[wrap_index(j-i, (int32_t)sf)+1] << to_bin(v[j], sf)[i] << term_colors[0];
}
out << std::endl;
}
out << "MSB" << std::endl;
for(uint32_t i = 0; i < cr; i++)
out << "-";
out << std::endl;

Wyświetl plik

@ -493,7 +493,7 @@ namespace gr {
const uint32_t word = bin_idx ^ (bin_idx >> 1u);
#ifdef DEBUG
d_debug << gr::lora::to_bin(word, is_header ? d_sf - 2u : d_sf) << " " << bin_idx << std::endl;
d_debug << gr::lora::to_bin(word, is_header ? d_sf - 2u : d_sf) << " " << word << " (bin " << bin_idx << ")" << std::endl;
#endif
d_words.push_back(word);
@ -533,8 +533,8 @@ namespace gr {
}
#ifdef DEBUG
print_interleave_matrix(d_debug, d_words, ppm);
print_vector_bin(d_debug, words_deinterleaved, "D", sizeof(uint8_t) * 8u);
//print_interleave_matrix(d_debug, d_words, ppm);
#endif
// Add to demodulated data
@ -605,7 +605,6 @@ namespace gr {
#ifdef DEBUG
print_vector_bin(d_debug, d_words_deshuffled, "S", sizeof(uint8_t)*8);
d_debug << std::endl;
#endif
// We're done with these words