Added CRC checking
This commit is contained in:
parent
ccc80ff9e3
commit
7818b0f5e0
2 changed files with 15 additions and 13 deletions
4
Makefile
4
Makefile
|
@ -13,10 +13,10 @@ run_tests: test
|
||||||
gen_ft8: gen_ft8.o ft8/constants.o ft8/text.o ft8/pack_v2.o ft8/encode_v2.o common/wave.o
|
gen_ft8: gen_ft8.o ft8/constants.o ft8/text.o ft8/pack_v2.o ft8/encode_v2.o common/wave.o
|
||||||
$(CXX) $(LDFLAGS) -o $@ $^
|
$(CXX) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
test: test.o ft8/v1/encode.o ft8/v1/pack.o ft8/v1/unpack.o ft8/pack_v2.o ft8/encode_v2.o ft8/text.o ft8/constants.o
|
test: test.o ft8/v1/encode.o ft8/v1/pack.o ft8/v1/unpack.o ft8/pack_v2.o ft8/encode_v2.o ft8/text.o ft8/constants.o fft/kiss_fftr.o fft/kiss_fft.o
|
||||||
$(CXX) $(LDFLAGS) -o $@ $^
|
$(CXX) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
decode_ft8: decode_ft8.o fft/kiss_fftr.o fft/kiss_fft.o ft8/decode.o ft8/ldpc.o ft8/unpack_v2.o ft8/text.o ft8/constants.o common/wave.o
|
decode_ft8: decode_ft8.o fft/kiss_fftr.o fft/kiss_fft.o ft8/decode.o ft8/encode_v2.o ft8/ldpc.o ft8/unpack_v2.o ft8/text.o ft8/constants.o common/wave.o
|
||||||
$(CXX) $(LDFLAGS) -o $@ $^
|
$(CXX) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "ft8/ldpc.h"
|
#include "ft8/ldpc.h"
|
||||||
#include "ft8/decode.h"
|
#include "ft8/decode.h"
|
||||||
#include "ft8/constants.h"
|
#include "ft8/constants.h"
|
||||||
|
#include "ft8/encode_v2.h"
|
||||||
|
|
||||||
#include "common/wave.h"
|
#include "common/wave.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
|
@ -202,23 +203,24 @@ int main(int argc, char **argv) {
|
||||||
//ldpc_decode(log174, kLDPC_iterations, plain, &n_errors);
|
//ldpc_decode(log174, kLDPC_iterations, plain, &n_errors);
|
||||||
|
|
||||||
if (n_errors > 0) {
|
if (n_errors > 0) {
|
||||||
//printf("ldpc_decode() = %d\n", n_errors);
|
LOG(LOG_DEBUG, "ldpc_decode() = %d (%.0f Hz)\n", n_errors, freq_hz);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract payload + CRC (first FT8_K bits)
|
// Extract payload + CRC (first FT8_K bits)
|
||||||
uint8_t a91[12];
|
uint8_t a91[FT8_K_BYTES];
|
||||||
pack_bits(plain, FT8_K, a91);
|
pack_bits(plain, FT8_K, a91);
|
||||||
|
|
||||||
// TODO: check CRC
|
// Extract CRC and check it
|
||||||
|
uint16_t chksum = ((a91[9] & 0x07) << 11) | (a91[10] << 3) | (a91[11] >> 5);
|
||||||
// printf("%03d: score = %d freq = %.1f time = %.2f\n", idx,
|
a91[9] &= 0xF8;
|
||||||
// cand.score, freq_hz, time_sec);
|
a91[10] = 0;
|
||||||
// print_tones(kGray_map, log174);
|
a91[11] = 0;
|
||||||
// for (int i = 0; i < 12; ++i) {
|
uint16_t chksum2 = ft8_v2::ft8_crc(a91, 96 - 14);
|
||||||
// printf("%02x ", a91[i]);
|
if (chksum != chksum2) {
|
||||||
// }
|
LOG(LOG_DEBUG, "Checksum: message = %04x, CRC = %04x\n", chksum, chksum2);
|
||||||
// printf("\n");
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
char message[kMax_message_length];
|
char message[kMax_message_length];
|
||||||
unpack77(a91, message);
|
unpack77(a91, message);
|
||||||
|
|
Loading…
Reference in a new issue