aboutsummaryrefslogtreecommitdiff
path: root/src/freedv_data_raw_rx.c
diff options
context:
space:
mode:
authordrowe67 <[email protected]>2024-05-11 08:13:44 +0930
committerGitHub <[email protected]>2024-05-11 08:13:44 +0930
commit3d69c8d0639059851e60c0ddf882f86bf2fba380 (patch)
tree56372a673925be032aaaa8670b684a678c1ac22a /src/freedv_data_raw_rx.c
parent6930e3c26a9d8f4f2baf5f2b8145a7216ab71d02 (diff)
parentf004b51451fe78b8f289c8a553acad06f2768d9e (diff)
Merge pull request #46 from drowe67/dr-freedata-001
FreeDATA Feature Request 001 - FreeDV API support for custom OFDM raw data modes
Diffstat (limited to 'src/freedv_data_raw_rx.c')
-rw-r--r--src/freedv_data_raw_rx.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/freedv_data_raw_rx.c b/src/freedv_data_raw_rx.c
index 0353ae5..435648d 100644
--- a/src/freedv_data_raw_rx.c
+++ b/src/freedv_data_raw_rx.c
@@ -39,6 +39,7 @@
#include "ldpc_codes.h"
#include "modem_stats.h"
#include "octave.h"
+#include "ofdm_internal.h"
/* other processes can end this program using signals */
@@ -216,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], "CUSTOM") || !strcmp(argv[dx], "custom"))
+ mode = FREEDV_MODE_DATA_CUSTOM;
if (mode == -1) {
fprintf(stderr, "Error in mode: %s\n", argv[dx]);
exit(1);
@@ -248,6 +251,23 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Setting estimator limits to %d to %d Hz.\n", fsk_lower,
fsk_upper);
fsk_set_freq_est_limits(fsk, fsk_lower, fsk_upper);
+ } else if (mode == FREEDV_MODE_DATA_CUSTOM) {
+ // demonstrate custom OFDM raw data modes
+ struct OFDM_CONFIG ofdm_config;
+ ofdm_init_mode("datac14", &ofdm_config);
+ // modify datac14 to have 3 carriers instead of 4, which means
+ // we have to tweak Np, and the number of unique word bits
+ ofdm_config.nc = 3;
+ ofdm_config.np = 6;
+ ofdm_config.nuwbits = 48;
+ ofdm_config.bad_uw_errors = 18;
+ uint8_t uw[] = {1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1,
+ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0};
+ memcpy(ofdm_config.tx_uw, uw, sizeof(uw));
+ memcpy(&ofdm_config.tx_uw[ofdm_config.nuwbits - sizeof(uw)], uw,
+ sizeof(uw));
+ adv.config = (void *)&ofdm_config;
+ freedv = freedv_open_advanced(mode, &adv);
} else {
freedv = freedv_open(mode);
}
@@ -264,8 +284,8 @@ int main(int argc, char *argv[]) {
fsk->Ndft);
}
- /* for streaming bytes it's much easier use the modes that have a multiple of
- * 8 payload bits/frame */
+ /* for streaming bytes it's much easier use the modes that have a multiple
+ * of 8 payload bits/frame */
assert((freedv_get_bits_per_modem_frame(freedv) % 8) == 0);
int bytes_per_modem_frame = freedv_get_bits_per_modem_frame(freedv) / 8;
// last two bytes used for CRC