Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

fskmodem.c File Reference

#include <asterisk/fskmodem.h>
#include <stdio.h>
#include "coef_in.h"
#include "coef_out.h"

Include dependency graph for fskmodem.c:

Include dependency graph

Go to the source code of this file.

Defines

#define NBW   2
#define BWLIST   {75,800}
#define NF   4
#define FLIST   {1400,1800,1200,2200}
#define STATE_SEARCH_STARTBIT   0
#define STATE_SEARCH_STARTBIT2   1
#define STATE_SEARCH_STARTBIT3   2
#define STATE_GET_BYTE   3
#define GET_SAMPLE   get_sample(&buffer, len)

Functions

int fsk_serie (fsk_data *fskd, short *buffer, int *len, int *outbyte)


Define Documentation

#define BWLIST   {75,800}
 

Definition at line 22 of file fskmodem.c.

#define FLIST   {1400,1800,1200,2200}
 

Definition at line 24 of file fskmodem.c.

#define GET_SAMPLE   get_sample(&buffer, len)
 

Definition at line 40 of file fskmodem.c.

Referenced by fsk_serie().

#define NBW   2
 

Definition at line 21 of file fskmodem.c.

#define NF   4
 

Definition at line 23 of file fskmodem.c.

#define STATE_GET_BYTE   3
 

Definition at line 29 of file fskmodem.c.

#define STATE_SEARCH_STARTBIT   0
 

Definition at line 26 of file fskmodem.c.

#define STATE_SEARCH_STARTBIT2   1
 

Definition at line 27 of file fskmodem.c.

Referenced by fsk_serie().

#define STATE_SEARCH_STARTBIT3   2
 

Definition at line 28 of file fskmodem.c.

Referenced by fsk_serie().


Function Documentation

int fsk_serie fsk_data fskd,
short *  buffer,
int *  len,
int *  outbyte
 

Definition at line 183 of file fskmodem.c.

References GET_SAMPLE, fsk_data::spb, fsk_data::state, STATE_SEARCH_STARTBIT2, STATE_SEARCH_STARTBIT3, fsk_data::x1, and fsk_data::x2.

Referenced by callerid_feed(), and tdd_feed().

00184 { 00185 /* this was jesus's nice, reasonable, working (at least with RTTY) code 00186 to look for the beginning of the start bit. Unfortunately, since TTY/TDD's 00187 just start sending a start bit with nothing preceding it at the beginning 00188 of a transmission (what a LOSING design), we cant do it this elegantly */ 00189 /* 00190 if (demodulador(zap,&x1)) return(-1); 00191 for(;;) { 00192 if (demodulador(zap,&x2)) return(-1); 00193 if (x1>0 && x2<0) break; 00194 x1=x2; 00195 } 00196 */ 00197 /* this is now the imprecise, losing, but functional code to detect the 00198 beginning of a start bit in the TDD sceanario. It just looks for sufficient 00199 level to maybe, perhaps, guess, maybe that its maybe the beginning of 00200 a start bit, perhaps. This whole thing stinks! */ 00201 if (demodulador(fskd,&fskd->x1,GET_SAMPLE)) return(-1); 00202 samples++; 00203 for(;;) 00204 { 00205 search_startbit2: 00206 if (!*len) { 00207 fskd->state = STATE_SEARCH_STARTBIT2; 00208 return 0; 00209 } 00210 samples++; 00211 if (demodulador(fskd,&fskd->x2,GET_SAMPLE)) return(-1); 00212 #if 0 00213 printf("x2 = %5.5f ", fskd->x2); 00214 #endif 00215 if (fskd->x2 < -0.5) break; 00216 } 00217 search_startbit3: 00218 /* Esperamos 0.5 bits antes de usar DPLL */ 00219 i=fskd->spb/2; 00220 if (*len < i) { 00221 fskd->state = STATE_SEARCH_STARTBIT3; 00222 return 0; 00223 } 00224 for(;i;i--) { if (demodulador(fskd,&fskd->x1,GET_SAMPLE)) return(-1); 00225 #if 0 00226 printf("x1 = %5.5f ", fskd->x1); 00227 #endif 00228 samples++; } 00229 00230 /* x1 debe ser negativo (confirmación del bit de start) */ 00231 00232 } while (fskd->x1>0); 00233 fskd->state = STATE_GET_BYTE; 00234 00235 getbyte: 00236 00237 /* Need at least 80 samples (for 1200) or 00238 1320 (for 45.5) to be sure we'll have a byte */ 00239 if (fskd->nbit < 8) { 00240 if (*len < 1320) 00241 return 0; 00242 } else { 00243 if (*len < 80) 00244 return 0; 00245 } 00246 /* Leemos ahora los bits de datos */ 00247 j=fskd->nbit; 00248 for (a=n1=0;j;j--) { 00249 olen = *len; 00250 i=get_bit_raw(fskd, buffer, len); 00251 buffer += (olen - *len); 00252 if (i == -1) return(-1); 00253 if (i) n1++; 00254 a>>=1; a|=i; 00255 } 00256 j=8-fskd->nbit; 00257 a>>=j; 00258 00259 /* Leemos bit de paridad (si existe) y la comprobamos */ 00260 if (fskd->paridad) { 00261 olen = *len; 00262 i=get_bit_raw(fskd, buffer, len); 00263 buffer += (olen - *len); 00264 if (i == -1) return(-1); 00265 if (i) n1++; 00266 if (fskd->paridad==1) { /* paridad=1 (par) */ 00267 if (n1&1) a|=0x100; /* error */ 00268 } else { /* paridad=2 (impar) */ 00269 if (!(n1&1)) a|=0x100; /* error */ 00270 } 00271 } 00272 00273 /* Leemos bits de STOP. Todos deben ser 1 */ 00274 00275 for (j=fskd->nstop;j;j--) { 00276 r = get_bit_raw(fskd, buffer, len); 00277 if (r == -1) return(-1); 00278 if (!r) a|=0x200; 00279 } 00280 00281 /* Por fin retornamos */ 00282 /* Bit 8 : Error de paridad */ 00283 /* Bit 9 : Error de Framming */ 00284 00285 *outbyte = a; 00286 fskd->state = STATE_SEARCH_STARTBIT; 00287 return 1; 00288 } 00289 }


Generated on Sat Jun 12 16:41:35 2004 for Asterisk by doxygen 1.3.7