X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25_test.c;h=f801c2f2488c7b84cf5d69a73122fea758825b00;hb=8ad8e5d325736480a881a7f30bd757f96b87376e;hp=b4e0e73e1329133aeb4271eec65fde8c2a802441;hpb=6ea89e0647ea241ed2393a53cccb0d8ba01be48e;p=bertos.git diff --git a/bertos/net/ax25_test.c b/bertos/net/ax25_test.c index b4e0e73e..f801c2f2 100644 --- a/bertos/net/ax25_test.c +++ b/bertos/net/ax25_test.c @@ -32,48 +32,65 @@ * * \brief AX25 test. * - * \version $Id$ * \author Francesco Sacchi */ #include "ax25.h" -#include #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); ASSERT(msg->pid == AX25_PID_NOLAYER3); ASSERT(msg->len == 30); - ASSERT(strncmp((char *)msg->info, "=4603.63N/01431.26E-Op. Andrej", 30) == 0); + ASSERT(strncmp((const char *)msg->info, "=4603.63N/01431.26E-Op. Andrej", 30) == 0); } 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; } @@ -86,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; }