Skip to content
Closed
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
24 changes: 23 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ endif()

add_test(NAME test_OFDM_modem_octave_qam16_uncoded
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
echo \"ofdm_tx('test_qam16.raw','qam16c1',3,12,'awgn','bursts',3); ofdm_rx('test_qam16.raw','qam16c1', 'passber', 0.05, 'packetsperburst', 1); quit\" |
echo \"ofdm_tx('test_qam16.raw','qam16c2',1,12,'awgn','bursts',3); ofdm_rx('test_qam16.raw','qam16c2', 'passber', 0.05, 'packetsperburst', 1); quit\" |
DISPLAY=\"\" octave-cli")
set_tests_properties(test_OFDM_modem_octave_qam16_uncoded PROPERTIES PASS_REGULAR_EXPRESSION "Pass")

Expand Down Expand Up @@ -669,6 +669,13 @@ endif()
cd ${CMAKE_CURRENT_BINARY_DIR}/src;
cat test.raw | ./ofdm_demod --mode datac14 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")

# QAM16C2 Octave Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_qam16c2_octave
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/octave;
DISPLAY=\"\" octave-cli -qf --eval 'ofdm_ldpc_tx(\"${CMAKE_CURRENT_BINARY_DIR}/src/test.raw\",\"qam16c2\",1,10,\"awgn\",\"bursts\",2)';
cd ${CMAKE_CURRENT_BINARY_DIR}/src;
cat test.raw | ./ofdm_demod --mode qam16c2 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")

# DATAC4 C Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_datac4_ldpc_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
Expand All @@ -690,6 +697,13 @@ endif()
./ch - - --No -17 |
./ofdm_demod --mode datac14 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")

# QAM16C2 C Tx, C Rx, burst mode
add_test(NAME test_OFDM_modem_qam16c2_ldpc_burst
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
./ofdm_mod --mode qam16c2 --in /dev/zero --testframes 1 --verbose 1 --ldpc --bursts 10 |
./ch - - --No -30 |
./ofdm_demod --mode qam16c2 --out /dev/null --testframes --ldpc --verbose 2 --packetsperburst 1")

# -------------------------------------------------------------------------
# LDPC
# -------------------------------------------------------------------------
Expand Down Expand Up @@ -1340,6 +1354,13 @@ endif(NOT APPLE)
./freedv_data_raw_rx DATAC14 - binaryOut.bin -v;
diff binaryIn.bin binaryOut.bin")

add_test(NAME test_freedv_data_raw_ofdm_qam16c2_burst_file
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR}/src;
head -c $((1213*10)) </dev/urandom > binaryIn.bin;
./freedv_data_raw_tx qam16c2 binaryIn.bin - --bursts 10 |
./freedv_data_raw_rx qam16c2 - binaryOut.bin -v;
diff binaryIn.bin binaryOut.bin")

# FSK LDPC default 100 bit/s 2FSK, enough noise for several % raw BER to give
# FEC/acquisition a work out, bursts of 1 frame as that stresses acquisition
add_test(NAME test_freedv_data_raw_fsk_ldpc_100
Expand Down Expand Up @@ -1426,6 +1447,7 @@ endif(NOT APPLE)
test_OFDM_modem_datac4_octave
test_OFDM_modem_datac13_octave
test_OFDM_modem_datac14_octave
test_OFDM_modem_qam16c2_octave
test_fsk_lib_4fsk_ldpc
test_OFDM_modem_datac0_compression
PROPERTIES
Expand Down
3 changes: 2 additions & 1 deletion README_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ These modes use an OFDM modem with powerful LDPC codes and are designed for send
| DATAC0 | 500 | 291 | 14 | (256,128) | 0.44 | 70/100 at 0dB | Reverse link ACK packets |
| DATAC1 | 1700 | 980 | 510 | (8192,4096) | 4.18 | 92/100 at 5dB | Forward link data (medium SNR) |
| DATAC3 | 500 | 321 | 126 | (2048,1024) | 3.19 | 74/100 at 0dB | Forward link data (low SNR) |
| DATAC4 | 250 | 87 | 56 | (1472,448) | 5.17 | 90/100 at -4dB | Forward link data (low SNR) |
| DATAC4 | 250 | 87 | 54 | (1472,448) | 5.17 | 90/100 at -4dB | Forward link data (low SNR) |
| DATAC13 | 200 | 64 | 14 | (384,128) | 2.0 | 90/100 at -4dB | Reverse link ACK packets (low SNR) |
| DATAC14 | 250 | 58 | 3 | (112,56) | 0.69 | 90/100 at -2dB | Reverse link ACK packets (low SNR) |
| QAM16C2 | 2100 | 3100 | 1213 | (16200,9720) | 3.2 | 90/100 at 15dB | Forward link data (high SNR) |

Notes:
1. 16 bits (2 bytes) per frame are reserved for a 16 bit CRC, e.g. for `datac3` we have 128 byte frames, and 128-2=126 bytes/frame of payload data.
Expand Down
12 changes: 5 additions & 7 deletions octave/ofdm_lib.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
bad_uw_errors = config.bad_uw_errors;
amp_scale = config.amp_scale;
amp_est_mode = config.amp_est_mode;
EsNo_est_all_symbols = config.EsNo_est_all_symbols;
EsNodB = config.EsNodB;
state_machine = config.state_machine;
edge_pilots = config.edge_pilots;
Expand All @@ -74,10 +73,10 @@
states.Nsampersymbol = states.M+states.Ncp; % number of samples in a single symbol
states.Nsamperframe = Ns*states.Nsampersymbol; % number of samples in a modem frame
states.qam16 = [
1 + j, 1 + j*3, 3 + j, 3 + j*3;
1 - j, 1 - j*3, 3 - j, 3 - j*3;
-1 + j, -1 + j*3, -3 + j, -3 + j*3;
-1 - j, -1 - j*3, -3 - j, -3 - j*3]/3;
1 + j, 1 + j*3, 3 + j, 3 + j*3, ...
1 - j, 1 - j*3, 3 - j, 3 - j*3, ...
-1 + j, -1 + j*3, -3 + j, -3 + j*3, ...
-1 - j, -1 - j*3, -3 - j, -3 - j*3];
rms = sqrt(states.qam16(:)'*states.qam16(:)/16);% set average Es to 1
states.qam16 /= rms;
states.qam16 *= exp(-j*pi/4); % same rotation as QPSK constellation
Expand Down Expand Up @@ -128,7 +127,7 @@
states.uw_ind = [states.uw_ind bps*ind_sym-b]; % bit index
end
end

% how many of the first few frames have UW symbols in them
Nsymsperframe = states.Nbitsperframe/states.bps;
states.Nuwframes = ceil(states.uw_ind_sym(end)/Nsymsperframe);
Expand Down Expand Up @@ -275,7 +274,6 @@

% Es/No (SNR) est states

states.EsNo_est_all_symbols = EsNo_est_all_symbols;
states.clock_offset_est = 0;

% pre-amble for data modes
Expand Down
7 changes: 3 additions & 4 deletions octave/ofdm_mode.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
config.bad_uw_errors = 3;
config.amp_scale = 245E3;
config.amp_est_mode = 0;
config.EsNo_est_all_symbols = 1;
config.EsNodB = 3;
config.state_machine = "voice1";
config.edge_pilots = 1;
Expand Down Expand Up @@ -59,12 +58,12 @@
config.bps=4; config.Ntxtbits = 0; config.Nuwbits = 15*4; config.bad_uw_errors = 5;
config.state_machine = "data";
config.ftwindow_width = 32; config.amp_scale = 132E3;
config.EsNo_est_all_symbols = 0; config.amp_est_mode = 1; config.EsNodB = 10;
config.amp_est_mode = 1; config.EsNodB = 10;
elseif strcmp(mode,"qam16c2")
Ns=5; config.Np=31; Tcp = 0.004; Ts = 0.016; Nc = 33; config.data_mode = "streaming";
config.bps=4; config.Ntxtbits = 0; config.Nuwbits = 42*4; config.bad_uw_errors = 15;
config.bps=4; config.Ntxtbits = 0; config.Nuwbits = 42*4; config.bad_uw_errors = 50;
config.ftwindow_width = 80; config.amp_scale = 135E3; config.state_machine = "data";
config.EsNo_est_all_symbols = 0; config.amp_est_mode = 1; config.EsNodB = 10;
config.amp_est_mode = 1; config.EsNodB = 10;
config.tx_uw = zeros(1,config.Nuwbits = 42*4);
config.tx_uw(1:24) = [1 1 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0];
config.tx_uw(end-24+1:end) = [1 1 0 0 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0];
Expand Down
2 changes: 1 addition & 1 deletion octave/qam16.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function test_qam16_mod_demod(constellation)
for decimal=0:15
tx_bits = zeros(1,4);
for i=1:4
tx_bits(1,5-i) = bitand(bitshift(decimal-1,1-i),1);
tx_bits(1,5-i) = bitand(bitshift(decimal,1-i),1);
end
symbol = qam16_mod(constellation, tx_bits);
rx_bits = qam16_demod(constellation,symbol);
Expand Down
11 changes: 5 additions & 6 deletions src/freedv_2020.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ int freedv_comprx_2020(struct freedv *f, COMP demod_in[]) {

f->sync = 0;

// TODO: should be higher for 2020?
float EsNo = 3.0;
float EsNo = pow(10.0, ofdm->EsNodB / 10);

/* looking for modem sync */

Expand All @@ -249,7 +248,7 @@ int freedv_comprx_2020(struct freedv *f, COMP demod_in[]) {

ofdm_demod(ofdm, rx_bits, demod_in);
ofdm_extract_uw(ofdm, ofdm->rx_np, ofdm->rx_amp, rx_uw);
ofdm_disassemble_qpsk_modem_packet_with_text_amps(
ofdm_disassemble_psk_modem_packet_with_text_amps(
ofdm, ofdm->rx_np, ofdm->rx_amp, payload_syms, payload_amps, txt_bits,
&txt_sym_index);

Expand Down Expand Up @@ -280,14 +279,14 @@ int freedv_comprx_2020(struct freedv *f, COMP demod_in[]) {
uint8_t out_char[coded_bits_per_frame];

if (f->test_frames) {
Nerrs_raw =
count_uncoded_errors(ldpc, &f->ofdm->config, codeword_symbols_de, 0);
Nerrs_raw = count_uncoded_errors(
ldpc, &f->ofdm->config, codeword_symbols_de, codeword_amps_de, 0);
f->total_bit_errors += Nerrs_raw;
f->total_bits += f->ofdm_bitsperframe;
}

symbols_to_llrs(llr, codeword_symbols_de, codeword_amps_de, EsNo,
ofdm->mean_amp, coded_syms_per_frame);
ofdm->mean_amp, ofdm->bps, coded_syms_per_frame);
ldpc_decode_frame(ldpc, &parityCheckCount, &iter, out_char, llr);
if (parityCheckCount != ldpc->NumberParityBits)
rx_status |= FREEDV_RX_BIT_ERRORS;
Expand Down
51 changes: 43 additions & 8 deletions src/freedv_700.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ void freedv_ofdm_data_open(struct freedv *f, struct freedv_advanced *adv) {
if (f->mode == FREEDV_MODE_DATAC4) strcpy(mode, "datac4");
if (f->mode == FREEDV_MODE_DATAC13) strcpy(mode, "datac13");
if (f->mode == FREEDV_MODE_DATAC14) strcpy(mode, "datac14");
if (f->mode == FREEDV_MODE_QAM16C2) strcpy(mode, "qam16c2");
if (f->mode == FREEDV_MODE_DATA_CUSTOM) {
assert(adv != NULL);
assert(adv->config != NULL);
Expand Down Expand Up @@ -447,7 +448,7 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz,
assert((demod_in_is_short == 0) || (demod_in_is_short == 1));

int rx_status = 0;
float EsNo = 3.0; /* further work: estimate this properly from signal */
float EsNo = pow(10.0, ofdm->EsNodB / 10);
f->sync = 0;

/* looking for OFDM modem sync */
Expand Down Expand Up @@ -490,7 +491,7 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz,
/* we have received enough modem frames to complete packet and run LDPC
* decoder */
int txt_sym_index = 0;
ofdm_disassemble_qpsk_modem_packet_with_text_amps(
ofdm_disassemble_psk_modem_packet_with_text_amps(
ofdm, rx_syms, rx_amps, payload_syms, payload_amps, txt_bits,
&txt_sym_index);

Expand All @@ -504,15 +505,48 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz,
float llr[Npayloadbitsperpacket];
uint8_t decoded_codeword[Npayloadbitsperpacket];
symbols_to_llrs(llr, payload_syms_de, payload_amps_de, EsNo,
ofdm->mean_amp, Npayloadsymsperpacket);
ofdm->mean_amp, ofdm->bps, Npayloadsymsperpacket);
ldpc_decode_frame(ldpc, &parityCheckCount, &iter, decoded_codeword, llr);
// iter = run_ldpc_decoder(ldpc, decoded_codeword, llr,
// &parityCheckCount);
memcpy(f->rx_payload_bits, decoded_codeword, Ndatabitsperpacket);

if (strlen(ofdm->data_mode)) {
int crc_ok =
freedv_check_crc16_unpacked(f->rx_payload_bits, Ndatabitsperpacket);
if (!crc_ok && f->verbose) {
int bytes_per_frame = (Ndatabitsperpacket + 7) / 8;
uint8_t rx_bytes[bytes_per_frame];
freedv_pack(rx_bytes, f->rx_payload_bits, Ndatabitsperpacket);
uint16_t rx_crc16 =
((uint16_t)rx_bytes[bytes_per_frame - 2] << 8) |
rx_bytes[bytes_per_frame - 1];
uint16_t calc_crc16 =
freedv_gen_crc16(rx_bytes, bytes_per_frame - 2);
fprintf(stderr,
"OFDM data CRC fail: mode=%s bytes=%d rx_crc=%04x calc_crc=%04x "
"pcc=%d/%d iter=%d euw=%d foff=%4.1f\n",
ofdm->mode, bytes_per_frame, rx_crc16, calc_crc16,
parityCheckCount, ldpc->NumberParityBits, iter, ofdm->uw_errors,
(double)ofdm->foff_est_hz);
if (f->verbose >= 2) {
int n = bytes_per_frame < 16 ? bytes_per_frame : 16;
fprintf(stderr, " payload[0:%d] =", n);
for (int bi = 0; bi < n; bi++) fprintf(stderr, " %02x", rx_bytes[bi]);
fprintf(stderr, "\n");
}
} else if (crc_ok && f->verbose >= 2) {
int bytes_per_frame = (Ndatabitsperpacket + 7) / 8;
uint8_t rx_bytes[bytes_per_frame];
freedv_pack(rx_bytes, f->rx_payload_bits, Ndatabitsperpacket);
fprintf(stderr, "OFDM data OK: mode=%s bytes=%d pcc=%d/%d iter=%d\n",
ofdm->mode, bytes_per_frame, parityCheckCount,
ldpc->NumberParityBits, iter);
int n = bytes_per_frame < 16 ? bytes_per_frame : 16;
fprintf(stderr, " payload[0:%d] =", n);
for (int bi = 0; bi < n; bi++) fprintf(stderr, " %02x", rx_bytes[bi]);
fprintf(stderr, "\n");
}
// we need a valid CRC to declare a data packet valid
if (freedv_check_crc16_unpacked(f->rx_payload_bits, Ndatabitsperpacket))
if (crc_ok)
rx_status |= FREEDV_RX_BITS;
else
rx_status |= FREEDV_RX_BIT_ERRORS;
Expand All @@ -526,8 +560,9 @@ int freedv_comp_short_rx_ofdm(struct freedv *f, void *demod_in_8kHz,

if (f->test_frames) {
/* est uncoded BER from payload bits */
Nerrs_raw = count_uncoded_errors(
ldpc, &f->ofdm->config, payload_syms_de, strlen(ofdm->data_mode));
Nerrs_raw =
count_uncoded_errors(ldpc, &f->ofdm->config, payload_syms_de,
payload_amps_de, strlen(ofdm->data_mode));
f->total_bit_errors += Nerrs_raw;
f->total_bits += Npayloadbitsperpacket;

Expand Down
10 changes: 9 additions & 1 deletion src/freedv_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ struct freedv *freedv_open_advanced(int mode, struct freedv_advanced *adv) {
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, mode)) == false)
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, mode)) == false)
return NULL;

/* set everything to zero just in case */
Expand Down Expand Up @@ -165,6 +166,8 @@ struct freedv *freedv_open_advanced(int mode, struct freedv_advanced *adv) {
freedv_ofdm_data_open(f, NULL);
if (FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, mode))
freedv_ofdm_data_open(f, adv);
if (FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, mode))
freedv_ofdm_data_open(f, NULL);

varicode_decode_init(&f->varicode_dec_states, 1);

Expand Down Expand Up @@ -248,6 +251,7 @@ void freedv_close(struct freedv *freedv) {
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, freedv->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, freedv->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, freedv->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, freedv->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, freedv->mode)) {
FREE(freedv->rx_syms);
FREE(freedv->rx_amps);
Expand Down Expand Up @@ -281,6 +285,7 @@ static int is_ofdm_mode(struct freedv *f) {
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, f->mode);
}

Expand All @@ -291,6 +296,7 @@ static int is_ofdm_data_mode(struct freedv *f) {
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, f->mode);
}

Expand Down Expand Up @@ -483,6 +489,7 @@ void freedv_rawdatacomptx(struct freedv *f, COMP mod_out[],
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, f->mode))
freedv_comptx_ofdm(f, mod_out);

Expand Down Expand Up @@ -1084,6 +1091,7 @@ int freedv_rawdatacomprx(struct freedv *f, unsigned char *packed_payload_bits,
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC4, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC13, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATAC14, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_QAM16C2, f->mode) ||
FDV_MODE_ACTIVE(FREEDV_MODE_DATA_CUSTOM, f->mode))
rx_status = freedv_comp_short_rx_ofdm(f, (void *)demod_in, 0, 1.0f);
if (FDV_MODE_ACTIVE(FREEDV_MODE_FSK_LDPC, f->mode)) {
Expand Down
4 changes: 4 additions & 0 deletions src/freedv_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern "C" {
#define FREEDV_MODE_DATAC13 19
#define FREEDV_MODE_DATAC14 20
#define FREEDV_MODE_DATA_CUSTOM 21
#define FREEDV_MODE_QAM16C2 22

// Sample rates used
#define FREEDV_FS_8000 8000
Expand Down Expand Up @@ -148,6 +149,9 @@ extern "C" {
#if !defined(FREEDV_MODE_DATA_CUSTOM_EN)
#define FREEDV_MODE_DATA_CUSTOM_EN FREEDV_MODE_EN_DEFAULT
#endif
#if !defined(FREEDV_MODE_QAM16C2_EN)
#define FREEDV_MODE_QAM16C2_EN FREEDV_MODE_EN_DEFAULT
#endif

#define FDV_MODE_ACTIVE(mode_name, var) \
((mode_name##_EN) == 0 ? 0 : (var) == mode_name)
Expand Down
2 changes: 2 additions & 0 deletions src/freedv_data_raw_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ int main(int argc, char *argv[]) {
mode = FREEDV_MODE_DATAC13;
if (!strcmp(argv[dx], "DATAC14") || !strcmp(argv[dx], "datac14"))
mode = FREEDV_MODE_DATAC14;
if (!strcmp(argv[dx], "QAM16C2") || !strcmp(argv[dx], "qam16c2"))
mode = FREEDV_MODE_QAM16C2;
if (!strcmp(argv[dx], "CUSTOM") || !strcmp(argv[dx], "custom"))
mode = FREEDV_MODE_DATA_CUSTOM;
if (mode == -1) {
Expand Down
2 changes: 2 additions & 0 deletions src/freedv_data_raw_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ int main(int argc, char *argv[]) {
mode = FREEDV_MODE_DATAC13;
if (!strcmp(argv[dx], "DATAC14") || !strcmp(argv[dx], "datac14"))
mode = FREEDV_MODE_DATAC14;
if (!strcmp(argv[dx], "QAM16C2") || !strcmp(argv[dx], "qam16c2"))
mode = FREEDV_MODE_QAM16C2;
if (!strcmp(argv[dx], "CUSTOM") || !strcmp(argv[dx], "custom"))
mode = FREEDV_MODE_DATA_CUSTOM;
if (mode == -1) {
Expand Down
13 changes: 11 additions & 2 deletions src/freedv_fsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,13 @@ int freedv_rx_fsk_ldpc_data(struct freedv *f, COMP demod_in[]) {
for (int i = 0; i < 8; i++) seq |= f->rx_payload_bits[8 + i] << (7 - i);
}

if (f->fsk_ldpc_state == 1)
if (f->fsk_ldpc_state == 1) {
rx_status |=
FREEDV_RX_SYNC; /* need this set before verbose logging fprintf() */
f->sync = 1;
} else {
f->sync = 0;
}
if (((f->verbose == 1) && (rx_status & FREEDV_RX_BITS)) ||
(f->verbose == 2)) {
fprintf(stderr,
Expand All @@ -628,7 +632,12 @@ int freedv_rx_fsk_ldpc_data(struct freedv *f, COMP demod_in[]) {
}
} else {
/* set RX_SYNC flag even if we don't perform frame processing */
if (f->fsk_ldpc_state == 1) rx_status |= FREEDV_RX_SYNC;
if (f->fsk_ldpc_state == 1) {
rx_status |= FREEDV_RX_SYNC;
f->sync = 1;
} else {
f->sync = 0;
}
}

return rx_status;
Expand Down
Loading