Skip to content

Commit

Permalink
dsssframe64: ensuring callback was invoked in synchronizer
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Mar 18, 2024
1 parent afa0d80 commit 8d75f50
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/framing/tests/dsssframe64_autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@
#include "autotest/autotest.h"
#include "liquid.h"

// AUTOTEST : test simple recovery of frame in noise
// static callback function
static int framing_autotest_callback(
unsigned char * _header,
int _header_valid,
unsigned char * _payload,
unsigned int _payload_len,
int _payload_valid,
framesyncstats_s _stats,
void * _context)
{
printf("*** callback invoked (%s) ***\n", _payload_valid ? "pass" : "FAIL");
unsigned int * secret = (unsigned int*) _context;
*secret = 0x01234567;
return 0;
}

void autotest_dsssframe64sync()
{
// create objects
unsigned int context = 0;
dsssframe64gen fg = dsssframe64gen_create();
dsssframe64sync fs = dsssframe64sync_create(NULL, NULL);
dsssframe64sync fs = dsssframe64sync_create(framing_autotest_callback, (void*)&context);

// generate the frame
unsigned int frame_len = dsssframe64gen_get_frame_len(fg);
Expand All @@ -47,6 +63,9 @@ void autotest_dsssframe64sync()
// try to receive the frame
dsssframe64sync_execute(fs, frame, frame_len);

// ensure callback was invoked
CONTEND_EQUALITY(context, 0x01234567);

// parse statistics
framedatastats_s stats = dsssframe64sync_get_framedatastats(fs);
CONTEND_EQUALITY(stats.num_frames_detected, 1);
Expand Down

0 comments on commit 8d75f50

Please sign in to comment.