X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fafsk_test.c;h=cd434084f83da2caf36817761260dece8e0b5a9e;hb=83ea7ed8da72ed69c0ef12589a921694987504fa;hp=d835d628d8263f7ff4238eed091dd902b0496dcc;hpb=83341ac21b1a3ec29c962bc168b801eb888c90ad;p=bertos.git diff --git a/bertos/net/afsk_test.c b/bertos/net/afsk_test.c index d835d628..cd434084 100644 --- a/bertos/net/afsk_test.c +++ b/bertos/net/afsk_test.c @@ -51,6 +51,7 @@ #include #include +#include #include @@ -61,16 +62,15 @@ FILE *fp_adc; FILE *fp_dac; uint32_t data_size; uint32_t data_written; -bool afsk_tx_test; Afsk afsk_fd; AX25Ctx ax25; - -int8_t afsk_adc_val; +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) @@ -129,6 +129,7 @@ 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? @@ -146,8 +147,7 @@ int afsk_testSetup(void) ASSERT(fwrite(snd_header, 1, sizeof(snd_header), fp_dac) == sizeof(snd_header)); timer_init(); - afsk_init(&afsk_fd); - afsk_fd.fd.error = kfile_genericClose; + afsk_init(&afsk_fd, 0 ,0); ax25_init(&ax25, &afsk_fd.fd, message_hook); return 0; } @@ -171,8 +171,7 @@ int afsk_testRun(void) int c; while ((c = fgetc(fp_adc)) != EOF) { - afsk_adc_val = (int8_t)c; - afsk_adc_isr(); + afsk_adc_isr(&afsk_fd, (int8_t)c); ax25_poll(&ax25); } @@ -185,9 +184,13 @@ int afsk_testRun(void) ax25_send(&ax25, AX25_CALL("abcdef", 0), AX25_CALL("123456", 1), buf, sizeof(buf)); - while (afsk_tx_test) - afsk_dac_isr(); - + do + { + int8_t val = afsk_dac_isr(&afsk_fd) - 128; + ASSERT(fwrite(&val, 1, sizeof(val), fp_dac) == sizeof(val)); + data_written++; + } + while (afsk_fd.sending); #define SND_DATASIZE_OFF 8 #if CPU_AVR @@ -204,8 +207,7 @@ int afsk_testRun(void) while ((c = fgetc(fp_adc)) != EOF) { - afsk_adc_val = (int8_t)c; - afsk_adc_isr(); + afsk_adc_isr(&afsk_fd, (int8_t)c); ax25_poll(&ax25); }