X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Ftest%2Fao_fec_test.c;h=cbced6ae31435fb870ee8c599c02d88f9d564d5a;hb=refs%2Fheads%2Fmaster;hp=216a4b79667dd42302b7751675669c9bea33c6fd;hpb=b89d37d357273b97050c00d7fe12022e32799fa8;p=fw%2Faltos diff --git a/src/test/ao_fec_test.c b/src/test/ao_fec_test.c index 216a4b79..7c4e6f0e 100644 --- a/src/test/ao_fec_test.c +++ b/src/test/ao_fec_test.c @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -302,8 +303,31 @@ ao_real_packet(void) return ok; } +int +ao_hello_packet(void) +{ + uint8_t message[5] = "hello"; + uint8_t encode[ENCODE_LEN(sizeof(message))]; + int encode_len; + uint8_t transmit[EXPAND_LEN(sizeof(message))]; + uint8_t decode[DECODE_LEN(sizeof(message))]; + int transmit_len; + int decode_ok; + + printf("Hello packet test:\n"); + ao_fec_dump_bytes(message, sizeof(message), "Message"); + encode_len = ao_fec_encode(message, sizeof(message), encode); + ao_fec_dump_bytes(encode, encode_len, "Encode"); + transmit_len = ao_expand(encode, encode_len, transmit); + ao_fec_dump_bytes(transmit, transmit_len, "Transmit"); + decode_ok = ao_fec_decode(transmit, transmit_len, decode, sizeof(message) + 2, NULL); + ao_fec_dump_bytes(decode, sizeof(message) + 2, "Receive"); + printf("Hello result: %s\n", decode_ok ? "success" : "fail"); + return decode_ok; +} + #define EXPECT_DECODE_FAIL 0 -#define EXPECT_CRC_MISMATCH 6386 +#define EXPECT_CRC_MISMATCH 6304 #define EXPECT_DATA_MISMATCH 0 #define NOISE_AMOUNT 0x50 @@ -335,6 +359,9 @@ main(int argc, char **argv) if (!ao_real_packet()) errors++; + if (!ao_hello_packet()) + errors++; + srandom(0); for (trial = 0; trial < 100000; trial++) {