#include <cfg/test.h>
#include <cfg/debug.h>
+#include <cfg/kfile_debug.h>
#include <cpu/byteorder.h>
uint32_t data_written;
Afsk afsk_fd;
AX25Ctx ax25;
+KFileDebug dbg;
int msg_cnt;
-static void message_hook(UNUSED_ARG(struct AX25Msg *, msg))
+static void message_hook(struct AX25Msg *msg)
{
msg_cnt++;
+ ax25_print(&dbg.fd, msg);
}
static FILE *afsk_fileOpen(const char *name)
int afsk_testSetup(void)
{
kdbg_init();
+ kfiledebug_init(&dbg);
fp_adc = afsk_fileOpen("test/afsk_test.au");
#if CPU_AVR
#warning TODO: open the file?
#define DECODE_CALL(buf, addr) \
for (unsigned i = 0; i < sizeof((addr)); i++) \
{ \
- (addr)[i] = *(buf)++ >> 1; \
+ char c = (*(buf)++ >> 1); \
+ (addr)[i] = (c == ' ') ? '\x0' : c; \
}
static void ax25_decode(AX25Ctx *ctx)
kfile_putc(HDLC_FLAG, ctx->ch);
}
+static void print_call(KFile *ch, const AX25Call *call)
+{
+ kfile_printf(ch, "%.6s", call->call);
+ if (call->ssid)
+ kfile_printf(ch, "-%d", call->ssid);
+}
+
+/**
+ * Print a AX25 message in TNC-2 packet monitor format.
+ * \param ch a kfile channel where the message will be printed.
+ * \param msg the message to be printed.
+ */
+void ax25_print(KFile *ch, const AX25Msg *msg)
+{
+ print_call(ch, &msg->src);
+ kfile_putc('>', ch);
+ print_call(ch, &msg->dst);
+
+ #if CONFIG_AX25_RPT_LST
+ for (int i = 0; i < msg->rpt_cnt; i++)
+ {
+ kfile_putc(',', ch);
+ print_call(ch, &msg->rpt_lst[i]);
+ // TODO: add * to the trasmitting digi
+ }
+ #endif
+
+ kfile_printf(ch, ":%.*s\n", msg->len, msg->info);
+}
+
/**
* Init the AX25 protocol decoder.
#define ax25_send(ctx, dst, src, buf, len) ax25_sendVia(ctx, ({static AX25Call __path[]={dst, src}; __path;}), 2, buf, len)
void ax25_init(AX25Ctx *ctx, KFile *channel, ax25_callback_t hook);
+void ax25_print(KFile *ch, const AX25Msg *msg);
+
int ax25_testSetup(void);
int ax25_testTearDown(void);
int ax25_testRun(void);
#include <struct/kfile_mem.h>
#include <cfg/debug.h>
+#include <cfg/kfile_debug.h>
#include <cfg/test.h>
#include <string.h> //strncmp
static AX25Ctx ax25;
static KFileMem mem;
+static KFileDebug dbg;
#define APRS_MSG \
0x3D, 0x34, 0x36, 0x30, 0x33, 0x2E, 0x36, 0x33, \
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);
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);
bertos/net/afsk.c
bertos/net/nmeap/src/nmeap01.c
bertos/net/nmea.c
+ bertos/cfg/kfile_debug.c
"
buildout='/dev/null'