1 /* -*- c -*- */ 2 /* 3 * Copyright 2007 - 2011 Dominic Spill, Michael Ossmann 4 * 5 * This file is part of libbtbb 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with libbtbb; see the file COPYING. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #ifdef HAVE_CONFIG_H 24 #include "config.h" 25 #endif 26 27 #include "../bluetooth_packet.h" 28 #include <stdio.h> 29 30 int test_syndromes() { 31 int ret, i; 32 uint64_t syndrome, syncword; 33 ret = 0; 34 35 printf("Testing syndromes\n"); 36 printf("---------------\n"); 37 38 uint64_t input[2] = { 39 /* No errors */ 40 0xcc7b7268ff614e1b, 41 /* Errors */ 42 0xcc7d7268ff614e1b 43 }; 44 45 uint64_t output[2] = { 46 /* No errors */ 47 0, 48 /* Errors */ 49 0x0000000299c6f9b5 50 }; 51 52 for(i = 0; i < 2; i++) { 53 syndrome = gen_syndrome(input[i]); 54 printf("0x%016llx\n", syndrome); 55 if (syndrome == output[i]) { 56 printf("."); 57 } else { 58 printf("F"); 59 ret++; 60 } 61 } 62 63 gen_syndrome_map(); 64 syncword = decode_syncword(0xcc7b7268ff614e1b ^ pn); 65 printf("Syncword 0x%016llx\n", syncword); 66 syncword = decode_syncword(0xcc7b7268ff514e1b ^ pn); 67 printf("Syncword 0x%016llx\n", syncword); 68 69 if (ret > 0) 70 printf("%d errors\n", ret); 71 printf("\n--------------------\n"); 72 printf("Done testing syndrome generation\n"); 73 return ret; 74 } 75 76 int main(int argc, char** argv) { 77 int ret = 0; 78 79 ret += test_syndromes(); 80 81 exit(ret); 82 } 83