FSK Modulator/Demodulator.
More...
#include "asterisk.h"
#include <stdio.h>
#include "asterisk/fskmodem.h"
Go to the source code of this file.
|
#define | BWLIST {75,800} |
|
#define | FLIST {1400,1800,1200,2200,1300,2100} |
|
#define | GET_SAMPLE get_sample(&buffer, len) |
|
#define | NBW 2 |
|
#define | NF 6 |
|
#define | STATE_GET_BYTE 3 |
|
#define | STATE_SEARCH_STARTBIT 0 |
|
#define | STATE_SEARCH_STARTBIT2 1 |
|
#define | STATE_SEARCH_STARTBIT3 2 |
|
|
static int | demodulator (fsk_data *fskd, float *retval, float x) |
|
static float | filterL (fsk_data *fskd, float in) |
|
static float | filterM (fsk_data *fskd, float in) |
|
static float | filterS (fsk_data *fskd, float in) |
|
int | fsk_serial (fsk_data *fskd, short *buffer, int *len, int *outbyte) |
| Retrieve a serial byte into outbyte. Buffer is a pointer into a series of shorts and len records the number of bytes in the buffer. len will be overwritten with the number of bytes left that were not consumed. More...
|
|
static int | get_bit_raw (fsk_data *fskd, short *buffer, int *len) |
|
static float | get_sample (short **buffer, int *len) |
|
|
static double | coef_in [NF][NBW][8] |
| Coefficients for input filters Coefficients table, generated by program "mkfilter" mkfilter is part of the zapatatelephony.org distribution Format: coef[IDX_FREC][IDX_BW][IDX_COEF] IDX_COEF = 0 => 1/GAIN IDX_COEF = 1-6 => Coefficientes y[n].
|
|
static double | coef_out [NBW][8] |
| Coefficients for output filter Coefficients table, generated by program "mkfilter" Format: coef[IDX_BW][IDX_COEF] IDX_COEF = 0 => 1/GAIN IDX_COEF = 1-6 => Coefficientes y[n]. More...
|
|
FSK Modulator/Demodulator.
- Author
- Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
- Includes code and algorithms from the Zapata library.
Definition in file fskmodem_float.c.
static float filterL |
( |
fsk_data * |
fskd, |
|
|
float |
in |
|
) |
| |
|
inlinestatic |
Low-pass filter for demodulated data
Definition at line 147 of file fskmodem_float.c.
References fsk_data::bw, coef_out, fsk_data::flp, and fsk_data::flyv.
154 fskd->flxv[(fskd->
flp + 6) & 7] = in * (*pc++);
156 s = (fskd->flxv[fskd->
flp] + fskd->flxv[(fskd->
flp+6)&7]) +
157 6 * (fskd->flxv[(fskd->
flp+1)&7] + fskd->flxv[(fskd->
flp+5)&7]) +
158 15 * (fskd->flxv[(fskd->
flp+2)&7] + fskd->flxv[(fskd->
flp+4)&7]) +
159 20 * fskd->flxv[(fskd->
flp+3)&7];
161 for (i = 0,j = fskd->
flp;i<6;i++,j++)
162 s += fskd->
flyv[j&7]*(*pc++);
static double coef_out[NBW][8]
Coefficients for output filter Coefficients table, generated by program "mkfilter" Format: coef[IDX_B...
static float filterM |
( |
fsk_data * |
fskd, |
|
|
float |
in |
|
) |
| |
|
inlinestatic |
Band-pass filter for MARK frequency
Definition at line 109 of file fskmodem_float.c.
References fsk_data::bw, coef_in, fsk_data::f_mark_idx, fsk_data::fmp, and fsk_data::fmyv.
116 fskd->fmxv[(fskd->
fmp+6)&7] = in*(*pc++);
118 s = (fskd->fmxv[(fskd->
fmp + 6) & 7] - fskd->fmxv[fskd->
fmp]) + 3 * (fskd->fmxv[(fskd->
fmp + 2) & 7] - fskd->fmxv[(fskd->
fmp + 4) & 7]);
119 for (i = 0, j = fskd->
fmp; i < 6; i++, j++)
120 s += fskd->
fmyv[j&7]*(*pc++);
static double coef_in[NF][NBW][8]
Coefficients for input filters Coefficients table, generated by program "mkfilter" mkfilter is part o...
static float filterS |
( |
fsk_data * |
fskd, |
|
|
float |
in |
|
) |
| |
|
inlinestatic |
Band-pass filter for SPACE frequency
Definition at line 128 of file fskmodem_float.c.
References fsk_data::bw, coef_in, fsk_data::f_space_idx, fsk_data::fsp, and fsk_data::fsyv.
135 fskd->fsxv[(fskd->
fsp+6)&7] = in*(*pc++);
137 s = (fskd->fsxv[(fskd->
fsp + 6) & 7] - fskd->fsxv[fskd->
fsp]) + 3 * (fskd->fsxv[(fskd->
fsp + 2) & 7] - fskd->fsxv[(fskd->
fsp + 4) & 7]);
138 for (i = 0, j = fskd->
fsp; i < 6; i++, j++)
139 s += fskd->
fsyv[j&7]*(*pc++);
static double coef_in[NF][NBW][8]
Coefficients for input filters Coefficients table, generated by program "mkfilter" mkfilter is part o...
int fsk_serial |
( |
fsk_data * |
fskd, |
|
|
short * |
buffer, |
|
|
int * |
len, |
|
|
int * |
outbyte |
|
) |
| |
Retrieve a serial byte into outbyte. Buffer is a pointer into a series of shorts and len records the number of bytes in the buffer. len will be overwritten with the number of bytes left that were not consumed.
- Return values
-
0 | Still looking for something... |
1 | An output byte was received and stored in outbyte |
-1 | An error occured in the transmission He must be called with at least 80 bytes of buffer. |
Definition at line 224 of file fskmodem_float.c.
References ast_frame::len, fsk_data::nbit, fsk_data::nstop, fsk_data::parity, ast_frame::samples, and fsk_data::spb.
231 switch (fskd->state) {
233 case STATE_SEARCH_STARTBIT2:
234 goto search_startbit2;
235 case STATE_SEARCH_STARTBIT3:
236 goto search_startbit3;
258 if (demodulator(fskd, &fskd->x1, GET_SAMPLE))
264 fskd->state = STATE_SEARCH_STARTBIT2;
268 if (demodulator(fskd, &fskd->x2, GET_SAMPLE))
271 printf(
"x2 = %5.5f ", fskd->x2);
280 fskd->state = STATE_SEARCH_STARTBIT3;
284 if (demodulator(fskd, &fskd->x1, GET_SAMPLE))
287 printf(
"x1 = %5.5f ", fskd->x1);
294 }
while (fskd->x1 > 0);
295 fskd->state = STATE_GET_BYTE;
301 if (fskd->
nbit < 8) {
310 for (a = n1 = 0; j; j--) {
312 i = get_bit_raw(fskd, buffer, len);
313 buffer += (olen - *len);
327 i = get_bit_raw(fskd, buffer, len);
328 buffer += (olen - *len);
344 for (j = fskd->
nstop;j;j--) {
345 r = get_bit_raw(fskd, buffer, len);
357 fskd->state = STATE_SEARCH_STARTBIT;
Initial value:= {
{ 1.3868644653e-08,-6.3283665042e-01,4.0895057217e+00,-1.1020074592e+01,1.5850766191e+01,-1.2835109292e+01,5.5477477340e+00,0.0000000000e+00, },
{ 3.1262119724e-03,-7.8390522307e-03,8.5209627801e-02,-4.0804129163e-01,1.1157139955e+00,-1.8767603680e+00,1.8916395224e+00,0.0000000000e+00, },
}
Coefficients for output filter Coefficients table, generated by program "mkfilter" Format: coef[IDX_BW][IDX_COEF] IDX_COEF = 0 => 1/GAIN IDX_COEF = 1-6 => Coefficientes y[n].
Definition at line 102 of file fskmodem_float.c.
Referenced by filterL().