X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25_test.c;h=f801c2f2488c7b84cf5d69a73122fea758825b00;hb=05bb26937d55b1b2ddc58e089cb8880708b3e526;hp=31a7ed36722af351548100c432344d12e65ed620;hpb=babce1b7210691909e160c9cc2f653875bbf556b;p=bertos.git diff --git a/bertos/net/ax25_test.c b/bertos/net/ax25_test.c index 31a7ed36..f801c2f2 100644 --- a/bertos/net/ax25_test.c +++ b/bertos/net/ax25_test.c @@ -32,7 +32,6 @@ * * \brief AX25 test. * - * \version $Id$ * \author Francesco Sacchi */ @@ -41,26 +40,43 @@ #include #include +#include #include #include //strncmp static AX25Ctx ax25; static KFileMem mem; +static KFileDebug dbg; + +#define APRS_MSG \ + 0x3D, 0x34, 0x36, 0x30, 0x33, 0x2E, 0x36, 0x33, \ + 0x4E, 0x2F, 0x30, 0x31, 0x34, 0x33, 0x31, 0x2E, \ + 0x32, 0x36, 0x45, 0x2D, 0x4F, 0x70, 0x2E, 0x20, \ + 0x41, 0x6E, 0x64, 0x72, 0x65, 0x6A uint8_t aprs_packet[] = { HDLC_FLAG, - 0x82, 0xA0, 0xA4, 0xA6, 0x40, 0x40, 0xE0, 0xA6, 0x6A, 0x6E, 0x98, 0x9C, 0x40, 0x61, 0x03, 0xF0, - 0x3D, 0x34, 0x36, 0x30, 0x33, 0x2E, 0x36, 0x33, 0x4E, 0x2F, 0x30, 0x31, 0x34, 0x33, 0x31, 0x2E, - 0x32, 0x36, 0x45, 0x2D, 0x4F, 0x70, 0x2E, 0x20, 0x41, 0x6E, 0x64, 0x72, 0x65, 0x6A, 0x40, 0x65, + 0x82, 0xA0, 0xA4, 0xA6, 0x40, 0x40, 0xE0, /* dst */ + 0xA6, 0x6A, 0x6E, 0x98, 0x9C, 0x40, 0x61, /* src */ + 0x03, /* ctrl */ + 0xF0, /* pid */ + APRS_MSG, /* payload */ + 0x40, 0x65, /* CRC */ HDLC_FLAG, }; +uint8_t buf[] = { APRS_MSG }; +KFileMem mem1; +uint8_t aprs_packet_check[256]; + + static void msg_callback(AX25Msg *msg) { - ASSERT(strncmp(msg->dst.call, "APRS ", 6) == 0); - ASSERT(strncmp(msg->src.call, "S57LN ", 6) == 0); + ax25_print(&dbg.fd, msg); + ASSERT(strncmp(msg->dst.call, "APRS\x0\x0", 6) == 0); + ASSERT(strncmp(msg->src.call, "S57LN\x0", 6) == 0); ASSERT(msg->src.ssid == 0); ASSERT(msg->dst.ssid == 0); ASSERT(msg->ctrl == AX25_CTRL_UI); @@ -72,7 +88,9 @@ static void msg_callback(AX25Msg *msg) int ax25_testSetup(void) { kdbg_init(); + kfiledebug_init(&dbg); kfilemem_init(&mem, aprs_packet, sizeof(aprs_packet)); + kfilemem_init(&mem1, aprs_packet_check, sizeof(aprs_packet_check)); ax25_init(&ax25, &mem.fd, msg_callback); return 0; } @@ -85,6 +103,9 @@ int ax25_testTearDown(void) int ax25_testRun(void) { ax25_poll(&ax25); + ax25_init(&ax25, &mem1.fd, NULL); + ax25_send(&ax25, AX25_CALL("aprs", 0x70), AX25_CALL("s57ln", 0x30), buf, sizeof(buf)); + ASSERT(memcmp(aprs_packet, aprs_packet_check, sizeof(aprs_packet)) == 0); return 0; }