FreeCalypso > hg > sipout-test-utils
comparison test-fsk/modem_rx.c @ 6:ba66d297fe57
test-fsk: first attempt at modem Rx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 04 Mar 2024 23:21:07 -0800 |
parents | |
children | 6d832abad660 |
comparison
equal
deleted
inserted
replaced
5:e80b0051cd92 | 6:ba66d297fe57 |
---|---|
1 /* | |
2 * In this module we implement modem Rx handling, revolving around | |
3 * FSK demodulation via SpanDSP. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <stdint.h> | |
9 #include <stdlib.h> | |
10 #include <string.h> | |
11 #include <strings.h> | |
12 #include <spandsp.h> | |
13 #include "../include/pstn_defs.h" | |
14 | |
15 extern int fsk_mode_rx; | |
16 | |
17 static fsk_rx_state_t *fsk_rx_state; | |
18 | |
19 static void | |
20 byte_rx_func(user_data, byte) | |
21 void *user_data; | |
22 int byte; | |
23 { | |
24 if (byte < 0) { | |
25 printf("Modem state change: %s\n", signal_status_to_str(byte)); | |
26 return; | |
27 } | |
28 printf("Rx byte: 0x%02X\n", byte); | |
29 } | |
30 | |
31 void | |
32 init_modem_rx() | |
33 { | |
34 fsk_rx_state = fsk_rx_init(NULL, &preset_fsk_specs[fsk_mode_rx], | |
35 FSK_FRAME_MODE_FRAMED, byte_rx_func, NULL); | |
36 if (!fsk_rx_state) { | |
37 fprintf(stderr, "error: fsk_rx_init() failed!\n"); | |
38 exit(1); | |
39 } | |
40 } | |
41 | |
42 void | |
43 process_rx_frame(samples) | |
44 int16_t *samples; | |
45 { | |
46 fsk_rx(fsk_rx_state, samples, FRAME_20MS); | |
47 } |