Support CRs 1 and 3

pull/21/head
Pieter Robyns 2016-09-27 17:38:18 +02:00
rodzic 02ddbd728c
commit 41e4d98bf9
4 zmienionych plików z 49 dodań i 13 usunięć

Wyświetl plik

@ -432,8 +432,8 @@ namespace gr {
words_deinterleaved.push_back(d);
}
//print_vector(words_deinterleaved, "D", sizeof(uint8_t)*8);
std::reverse(words_deinterleaved.begin(),words_deinterleaved.end());
print_vector(words_deinterleaved, "D", sizeof(uint8_t)*8);
// Add to demodulated data
for(int i = 0; i < words_deinterleaved.size(); i++) {
@ -451,7 +451,14 @@ namespace gr {
if(is_header) {
prng = prng_header;
} else {
prng = prng_payload;
if(d_cr == 4)
prng = prng_payload;
else if(d_cr == 3)
prng = prng_payload_cr7;
else if(d_cr == 1)
prng = prng_payload_cr5;
else
prng = prng_payload;
}
deshuffle(shuffle_pattern);
@ -470,7 +477,7 @@ namespace gr {
if(!is_header)
std::cout << result.str() << std::endl;
else
std::cout << result.str();
std::cout << result.str();
return 0;
}
@ -491,6 +498,7 @@ namespace gr {
}
//print_vector(d_words_deshuffled, "S", sizeof(uint8_t)*8);
print_vector_raw(d_words_deshuffled, sizeof(uint8_t)*8);
// We're done with these words
d_demodulated.clear();
@ -505,7 +513,7 @@ namespace gr {
d_words_dewhitened.push_back(xor_b);
}
//print_vector(d_words_dewhitened, "W", sizeof(uint8_t)*8);
print_vector(d_words_dewhitened, "W", sizeof(uint8_t)*8);
d_words_deshuffled.clear();
}
@ -524,7 +532,7 @@ namespace gr {
d_words_dewhitened.clear();
return;*/
} else if(d_cr == 3) {
fs = LIQUID_FEC_HAMMING74;
fs = LIQUID_FEC_HAMMING84;
} else if(d_cr == 2) {
fs = LIQUID_FEC_HAMMING128;
} else if(d_cr == 1) { // TODO: Temporary, since Liquid doesn't support 4/5 Hamming so we need to implement it ourselves / extend Liquid.
@ -631,15 +639,15 @@ namespace gr {
return 4;
break;
}
case 0x0b: {
case 0x07: {
return 3;
break;
}
case 0x0c: {
case 0x05: {
return 2;
break;
}
case 0x08: {
case 0x03: {
return 1;
break;
}
@ -712,7 +720,7 @@ namespace gr {
nibble_reverse(decoded, 1); // TODO: Why?
d_payload_length = decoded[0];
d_cr = lookup_cr(decoded[2]);
d_cr = lookup_cr(decoded[1]);
int symbols_per_block = d_cr + 4;
int bits_needed = ((d_payload_length * 8) + 16) * (symbols_per_block / 4);

Wyświetl plik

@ -10,6 +10,14 @@ namespace gr {
const uint8_t prng_payload[] = {
0xdf, 0xef, 0xb0, 0xf7, 0x9e, 0xfd, 0xc6, 0xdf, 0x10, 0xfb, 0x43, 0x34, 0xa8, 0x5f, 0xf2, 0x97, 0x62, 0x8, 0xf8, 0x49, 0xbe, 0x8a, 0xa4, 0xd6, 0x16, 0xe6, 0x85, 0x39, 0x6b, 0xef, 0xe5, 0xbc, 0xb3, 0x1c, 0x14, 0xa7, 0x3d, 0x4f, 0x91, 0x61, 0x85, 0x72, 0x20, 0x45, 0x4, 0x25, 0x80, 0x1b, 0x41, 0xa7, 0x5b, 0x4, 0xa2, 0x80, 0x9b, 0x41, 0xa7, 0x10, 0x4f, 0x43, 0x61, 0xa8, 0x39, 0xb9, 0xa4, 0x83, 0x16, 0xcb, 0x85, 0xa0, 0x6b, 0x68, 0xae, 0xbc, 0x19, 0x1c, 0x8d, 0xa7, 0xba, 0x4f, 0xda, 0x2a, 0x64, 0xd8, 0x58, 0xdc, 0xb0, 0xa2, 0x9e, 0xd0, 0xc6, 0x46, 0x10, 0x7c, 0x8, 0x34, 0x2, 0x5f, 0x6b, 0x97, 0xe5, 0x8, 0xb3, 0x2, 0x5f, 0x20, 0xdc, 0x4f, 0xa2, 0x61, 0x9b, 0x72, 0xec, 0xe, 0xae, 0xc4, 0x19, 0xa8, 0x8d, 0xb9, 0xf1, 0xc8, 0x3b, 0x2a, 0x57, 0xd8, 0x46, 0xdc, 0x7c, 0xe9, 0x34, 0x31, 0x5f, 0x75, 0xdc, 0x62, 0xa2, 0xf8, 0x9b, 0xf5, 0xa7, 0xe, 0x4,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 0xe, 0x28, 0xc4, 0x52, 0xa8, 0x26, 0xf2, 0x22, 0x62, 0x16, 0xb2, 0xce, 0x5e, 0x8a, 0x96, 0xd6, 0x8, 0xe6, 0x48, 0x72, 0xc0, 0xe, 0x7c, 0x8e, 0x7e, 0x2, 0xbe, 0x6a, 0xa4, 0xe4, 0x5c, 0xf8, 0x64, 0xbe, 0x12, 0xee, 0x50, 0xbc, 0xe6, 0x56, 0x38, 0x46, 0xee, 0x36, 0xbc, 0xd4, 0x56, 0x26, 0xc, 0x68, 0xd6, 0xf6, 0xe6, 0xb6, 0x38, 0x74, 0xa4, 0x28, 0x5c, 0x52, 0x2e, 0x26, 0xb8, 0x68, 0x82, 0xbc, 0xca, 0x56, 0xea, 0x4c, 0x88, 0x9c, 0x8e, 0x6, 0x2, 0xa, 0x6a, 0xba, 0xe4, 0x90, 0xb2, 0x84, 0x14, 0x20, 0x76, 0x4e, 0x3a, 0x60, 0x9c, 0x72, 0xa6, 0x44, 0x4e, 0x6e, 0x60, 0x30, 0x38, 0xbe, 0xee, 0x82, 0xb8, 0xca, 0x1c, 0xa2, 0xec, 0x68, 0xd4, 0xf6, 0xfc, 0x3e, 0xf6, 0x7e, 0x2c, 0xd8, 0xc4, 0x6c, 0xe2, 0xb8
};
const uint8_t prng_payload_cr5[] = {
0x54, 0x64, 0x38, 0x7c, 0x14, 0x74, 0x4c, 0x54, 0x10, 0x70, 0x40, 0x3c, 0x28, 0x54, 0x70, 0x1c, 0x68, 0x8, 0x78, 0x48, 0x34, 0x8, 0x2c, 0x54, 0x1c, 0x6c, 0xc, 0x38, 0x68, 0x64, 0x64, 0x34, 0x30, 0x14, 0x1c, 0x2c, 0x34, 0x4c, 0x10, 0x60, 0xc, 0x70, 0x20, 0x4c, 0x4, 0x2c, 0x0, 0x18, 0x40, 0x2c, 0x58, 0x4, 0x20, 0x0, 0x18, 0x40, 0x2c, 0x10, 0x4c, 0x40, 0x60, 0x28, 0x38, 0x38, 0x2c, 0x8, 0x1c, 0x48, 0xc, 0x20, 0x68, 0x68, 0x2c, 0x34, 0x18, 0x14, 0x4, 0x2c, 0x38, 0x4c, 0x58, 0x28, 0x6c, 0x58, 0x58, 0x54, 0x38, 0x20, 0x14, 0x50, 0x4c, 0x4c, 0x10, 0x7c, 0x8, 0x3c, 0x0, 0x54, 0x68, 0x1c, 0x64, 0x8, 0x30, 0x0, 0x54, 0x20, 0x54, 0x4c, 0x20, 0x60, 0x18, 0x70, 0x64, 0x4, 0x2c, 0x4c, 0x18, 0x28, 0x4, 0x38, 0x70, 0x40, 0x38, 0x28, 0x5c, 0x58, 0x4c, 0x54, 0x7c, 0x68, 0x3c, 0x30, 0x54, 0x7c, 0x54, 0x68, 0x20, 0x78, 0x18, 0x7c, 0x2c, 0x14, 0x4, 0x4c, 0x0, 0x28, 0x8, 0x38, 0x38, 0x8, 0x58, 0x0, 0x24, 0x40, 0x70, 0x58, 0x68, 0x20, 0x30, 0x50, 0x1c, 0x4, 0x7c, 0x54, 0x38, 0x6c, 0x5c, 0x70, 0x4, 0x4c, 0x54, 0x64, 0x6c, 0x30, 0x70, 0x7c, 0x4, 0x20, 0x4c, 0x50, 0x28, 0x2c, 0x70, 0x20, 0x68, 0x1c, 0x30, 0x44, 0x54, 0x8, 0x1c, 0x54, 0x8, 0x6c, 0x48, 0x70, 0x40, 0x4, 0x7c, 0x4, 0x74, 0x0, 0x34, 0x68, 0x2c, 0x64, 0x54, 0x78, 0x6c, 0x34, 0x10, 0x64, 0x58, 0x34, 0x6c, 0x5c, 0x38, 0x4c, 0x64, 0x34, 0x34, 0x5c, 0x5c, 0x2c, 0x4, 0x68, 0x54, 0x7c, 0x6c, 0x3c, 0x38, 0x7c, 0x2c, 0x20, 0x54, 0x50, 0x24, 0x2c, 0x38, 0x68, 0x8, 0x34, 0x48, 0x5c, 0x68, 0x4, 0x8, 0x1c, 0x4, 0xc, 0x0, 0x8, 0x68, 0x38, 0x64, 0x10, 0x30, 0xc, 0x1c, 0x20, 0x7c, 0x4c, 0x38, 0x60, 0x14, 0x70, 0x2c, 0x4c, 0x4c, 0x64, 0x60, 0x30, 0x38, 0x34, 0x64, 0x8, 0x34, 0x48, 0x14, 0x20, 0x64, 0x68, 0x64, 0x7c, 0x78, 0x3c, 0x7c, 0x34, 0x4, 0x40, 0x4c, 0x60, 0x60, 0x38, 0x10, 0x2c, 0x10, 0x1c, 0xc, 0x44, 0x8, 0x40, 0x38, 0x34, 0x58, 0x14, 0x6c, 0x4c, 0x10, 0x58, 0x58, 0x20, 0x24, 0x50, 0x58, 0x4c, 0x54, 0x34, 0x20, 0x5c, 0x18, 0x64, 0x2c, 0x8, 0x4c, 0x4c, 0x28, 0x28, 0x10, 0x38, 0x34, 0x8, 0x10, 0x48, 0x44, 0x68, 0x8, 0x40, 0x54, 0x2c, 0x24, 0x18, 0x10, 0x64, 0x34, 0x2c, 0x10, 0x50, 0x44, 0x64, 0x40, 0x40, 0x7c, 0x2c, 0x3c, 0x18, 0x1c, 0x64, 0x7c, 0x64, 0x70, 0x78, 0x3c, 0x7c, 0x3c, 0x4c, 0x68, 0x44, 0x38, 0x78, 0x54, 0x5c, 0x74, 0x58, 0x78, 0x6c, 0x74, 0x70, 0x14, 0x4, 0x38, 0x7c, 0x50, 0x60, 0x2c, 0x58, 0x28, 0x40, 0x78, 0x3c, 0x7c, 0x1c, 0x14, 0x7c, 0x8, 0x70, 0x5c, 0x78, 0x64, 0x14, 0x8, 0x60, 0x68, 0x34, 0x60, 0x1c, 0x50, 0x14, 0x0, 0x10, 0x4c, 0x40, 0x20
};
}
}

Wyświetl plik

@ -33,6 +33,14 @@ namespace gr {
std::cout << std::endl << std::flush;
}
template <typename T>
inline void print_vector_raw(std::vector<T>& v, int element_len_bits) {
for(int i = 0; i < v.size(); i++) {
std::cout << to_bin(v[i], element_len_bits);
}
std::cout << std::flush;
}
bool check_parity(std::string word, bool even) {
int count = 0;
@ -47,16 +55,27 @@ namespace gr {
return (((count+1) % 2) == 0);
}
// TODO: Crappy implementation! Fix
void fec_extract_data_only(uint8_t* in_data, uint32_t len, uint8_t* indices, uint8_t n, uint8_t* out_data) {
for(uint32_t i = 0; i < len; i++) {
uint8_t d = 0;
uint8_t index = 0;
for(uint32_t i = 1; i < len; i+=2) {
uint8_t d1 = 0;
for(uint32_t j = 0; j < n; j++) {
uint8_t power = pow(2, indices[j]);
if((in_data[i-1] & power) > 0) {
d1 += pow(2, j);
}
}
uint8_t d2 = 0;
for(uint32_t j = 0; j < n; j++) {
uint8_t power = pow(2, indices[j]);
if((in_data[i] & power) > 0) {
d += power;
d2 += pow(2, j);
}
}
out_data[i] = d;
out_data[index] = (d1 << 4) | d1;
index++;
}
}

Wyświetl plik

@ -66,6 +66,7 @@ class lora_receiver(gr.hier_block2):
self.connect((resampler, 0), (channelizer, 0))
if realtime:
self.connect((channelizer, 0), (self.c_decoder, 0))
self.connect((resampler, 0), (self.c_decoder, 1))
else:
self.connect((channelizer, 0), (qdemod, 0))
self.connect((channelizer, 0), (decoder, 1))