Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fsk #3

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/qdetector_cccf_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char*argv[])
float phi = 0.5f; // carrier phase offset
float SNRdB = 20.0f; // signal-to-noise ratio [dB]
float threshold = 0.5f; // detection threshold
float range = 0.05f; // carrier offset search range [radians/sample]
float range = 0.3f; // carrier offset search range [radians/sample]

int dopt;
while ((dopt = getopt(argc,argv,"hn:k:m:b:F:T:S:t:r:")) != EOF) {
Expand Down
71 changes: 71 additions & 0 deletions include/liquid.h
Original file line number Diff line number Diff line change
Expand Up @@ -4929,6 +4929,77 @@ void dsssframesync_debug_enable(dsssframesync _q);
void dsssframesync_debug_disable(dsssframesync _q);
void dsssframesync_debug_print(dsssframesync _q, const char * _filename);

//
// FSK frame generator
//

typedef struct {
unsigned int check;
unsigned int fec0;
unsigned int fec1;
unsigned int bits_per_symbol;
unsigned int samples_per_symbol;
} fskframegenprops_s;

typedef struct fskframegen_s * fskframegen;

fskframegen fskframegen_create(fskframegenprops_s * _props,
float _bandwidth);
void fskframegen_destroy(fskframegen _q);
void fskframegen_reset(fskframegen _q);
int fskframegen_is_assembled(fskframegen _q);
void fskframegen_getprops(fskframegen _q, fskframegenprops_s * _props);
int fskframegen_setprops(fskframegen _q, fskframegenprops_s * _props);
void fskframegen_set_header_len(fskframegen _q, unsigned int _len);
int fskframegen_set_header_props(fskframegen _q,
fskframegenprops_s * _props);
unsigned int fskframegen_getframelen(fskframegen _q);

// assemble a frame from an array of data
// _q : frame generator object
// _header : frame header
// _payload : payload data [size: _payload_len x 1]
// _payload_len : payload data length
void fskframegen_assemble(fskframegen _q,
const unsigned char * _header,
const unsigned char * _payload,
unsigned int _payload_len);

int fskframegen_write_samples(fskframegen _q,
liquid_float_complex * _buffer,
unsigned int _buffer_len);


//
// FSK frame synchronizer
//

typedef struct fskframesync_s * fskframesync;

fskframesync fskframesync_create(framesync_callback _callback, void * _userdata);
void fskframesync_destroy(fskframesync _q);
void fskframesync_print(fskframesync _q);
void fskframesync_reset(fskframesync _q);
int fskframesync_is_frame_open(fskframesync _q);
void fskframesync_set_bandwidth(fskframesync _q, float _bw);
void fskframesync_set_header_len(fskframesync _q,
unsigned int _len);
void fskframesync_decode_header_soft(fskframesync _q,
int _soft);
void fskframesync_decode_payload_soft(fskframesync _q,
int _soft);
int fskframesync_set_header_props(fskframesync _q,
fskframegenprops_s * _props);
void fskframesync_execute(fskframesync _q,
liquid_float_complex * _x,
unsigned int _n);
void fskframesync_reset_framedatastats(fskframesync _q);
framedatastats_s fskframesync_get_framedatastats (fskframesync _q);

void fskframesync_debug_enable(fskframesync _q);
void fskframesync_debug_disable(fskframesync _q);
void fskframesync_debug_print(fskframesync _q, const char * _filename);

//
// OFDM flexframe generator
//
Expand Down
53 changes: 53 additions & 0 deletions include/liquid.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,22 @@ void bpacketsync_reconfig(bpacketsync _q);
#define DSSSFRAME_H_FEC0 (LIQUID_FEC_GOLAY2412)
#define DSSSFRAME_H_FEC1 (LIQUID_FEC_NONE)


//
// fskframe
//

#define FSKFRAME_PROTOCOL (107 + PACKETIZER_VERSION)
#define FSKFRAME_PRE_K (150)
#define FSKFRAME_H_USER_DEFAULT (8)
#define FSKFRAME_H_DEC (6)
#define FSKFRAME_H_CRC (LIQUID_CRC_32)
#define FSKFRAME_H_FEC0 (LIQUID_FEC_GOLAY2412)
#define FSKFRAME_H_FEC1 (LIQUID_FEC_NONE)
#define FSKFRAME_H_BITS_PER_SYMBOL (1)
#define FSKFRAME_H_SAMPLES_PER_SYMBOL (4)


//
// MODULE : math
//
Expand Down Expand Up @@ -1878,5 +1894,42 @@ extern unsigned int liquid_c_leading_zeros[256];

// byte reversal and manipulation
extern const unsigned char liquid_reverse_byte_gentab[256];

typedef struct symbolreader_s * symbolreader;

symbolreader symbolreader_create();

void symbolreader_reset(symbolreader _r,
const unsigned char * _src,
unsigned int _src_len);

void symbolreader_destroy(symbolreader _r);

int symbolreader_read(symbolreader _r,
unsigned int _len,
unsigned int * _out);

unsigned int symbolreader_length(symbolreader _r);


typedef struct symbolwriter_s * symbolwriter;

symbolwriter symbolwriter_create();

void symbolwriter_reset(symbolwriter _w,
unsigned int _len);

void symbolwriter_destroy(symbolwriter _w);

int symbolwriter_write(symbolwriter _w,
unsigned int _len,
unsigned int _symbol);

// caller must not access this pointer after destroy()
const unsigned char * symbolwriter_bytes(symbolwriter _w);

// in bits
unsigned int symbolwriter_length(symbolwriter _w);

#endif // __LIQUID_INTERNAL_H__

10 changes: 8 additions & 2 deletions makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ RANLIB := @RANLIB@
INCLUDE_CFLAGS = $(addprefix -I,$(include_dirs))
CONFIG_CFLAGS = @CFLAGS@ @DEBUG_MSG_OPTION@ @ARCH_OPTION@
CPPFLAGS = @CPPFLAGS@ $(INCLUDE_CFLAGS)
CFLAGS = $(CONFIG_CFLAGS) -Wall -fPIC
LDFLAGS = @LDFLAGS@
CFLAGS = $(CONFIG_CFLAGS) -Wall -fPIC -fsanitize=address
LDFLAGS = @LDFLAGS@ -fsanitize=address
LIBS = @LIBS@
PATHSEP = /

Expand Down Expand Up @@ -599,6 +599,8 @@ framing_objects := \
src/framing/src/framesync64.o \
src/framing/src/flexframegen.o \
src/framing/src/flexframesync.o \
src/framing/src/fskframegen.o \
src/framing/src/fskframesync.o \
src/framing/src/gmskframegen.o \
src/framing/src/gmskframesync.o \
src/framing/src/msourcecf.o \
Expand Down Expand Up @@ -630,6 +632,8 @@ src/framing/src/framegen64.o : %.o : %.c $(include_headers)
src/framing/src/framesync64.o : %.o : %.c $(include_headers)
src/framing/src/flexframegen.o : %.o : %.c $(include_headers)
src/framing/src/flexframesync.o : %.o : %.c $(include_headers)
src/framing/src/fskframegen.o : %.o : %.c $(include_headers)
src/framing/src/fskframesync.o : %.o : %.c $(include_headers)
src/framing/src/msourcecf.o : %.o : %.c $(include_headers) src/framing/src/msource.c
src/framing/src/ofdmflexframegen.o : %.o : %.c $(include_headers)
src/framing/src/ofdmflexframesync.o : %.o : %.c $(include_headers)
Expand Down Expand Up @@ -1434,6 +1438,7 @@ example_programs := \
examples/flexframesync_reconfig_example \
examples/framesync64_example \
examples/freqmodem_example \
examples/fskframesync_example \
examples/fskmodem_example \
examples/fskmodem_waterfall_example \
examples/gasearch_example \
Expand Down Expand Up @@ -1485,6 +1490,7 @@ example_programs := \
examples/polyfit_lagrange_example \
examples/poly_findroots_example \
examples/qdetector_cccf_example \
examples/qdetector_hell \
examples/qpacketmodem_performance_example \
examples/qpacketmodem_example \
examples/qpilotsync_example \
Expand Down
6 changes: 4 additions & 2 deletions src/framing/src/dsssframesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct dsssframesync_s {
synth_crcf payload_synth;

int header_soft;
flexframegenprops_s header_props;
dsssframegenprops_s header_props;
liquid_float_complex * header_spread;
unsigned int header_spread_len;
qpacketmodem header_decoder;
Expand Down Expand Up @@ -386,7 +386,7 @@ void dsssframesync_execute_rxpreamble(dsssframesync _q, liquid_float_complex _x)
}

// save output in p/n symbols buffer
unsigned int delay = _q->k * _q->m; // delay from matched filter
unsigned int delay = 2 * _q->m; // delay from matched filter
if (_q->preamble_counter >= delay) {
unsigned int index = _q->preamble_counter - delay;
_q->preamble_rx[index] = mf_out;
Expand Down Expand Up @@ -554,6 +554,8 @@ void dsssframesync_execute_rxpayload(dsssframesync _q, liquid_float_complex _x)
_q->framesyncstats.fec0 = qpacketmodem_get_fec0(_q->payload_decoder);
_q->framesyncstats.fec1 = qpacketmodem_get_fec1(_q->payload_decoder);

// XXX set all framesyncstats

if (_q->callback != NULL) {
_q->callback(_q->header_dec,
_q->header_valid,
Expand Down
Loading