Mon May 14 04:48:04 2007

Asterisk developer's documentation


fskmodem.h File Reference

FSK Modem Support. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fsk_data

Defines

#define NCOLA   0x4000
#define PARITY_EVEN   1
#define PARITY_NONE   0
#define PARITY_ODD   2

Functions

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


Detailed Description

FSK Modem Support.

Note:
Includes code and algorithms from the Zapata library.
Todo:
Translate Emiliano Zapata's spanish comments to english, please.

Definition in file fskmodem.h.


Define Documentation

#define NCOLA   0x4000

Definition at line 33 of file fskmodem.h.

Referenced by filtroL().

#define PARITY_EVEN   1

Definition at line 29 of file fskmodem.h.

#define PARITY_NONE   0

Definition at line 28 of file fskmodem.h.

#define PARITY_ODD   2

Definition at line 30 of file fskmodem.h.


Function Documentation

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

Definition at line 204 of file fskmodem.c.

References demodulador(), GET_SAMPLE, and STATE_SEARCH_STARTBIT2.

Referenced by callerid_feed(), callerid_feed_jp(), and tdd_feed().

00208               {
00209          if (demodulador(zap,&x2)) return(-1);
00210          if (x1>0 && x2<0) break;
00211          x1=x2;
00212       }
00213 */
00214 /* this is now the imprecise, losing, but functional code to detect the
00215 beginning of a start bit in the TDD sceanario. It just looks for sufficient
00216 level to maybe, perhaps, guess, maybe that its maybe the beginning of
00217 a start bit, perhaps. This whole thing stinks! */
00218       if (demodulador(fskd,&fskd->x1,GET_SAMPLE)) return(-1);
00219       samples++;
00220       for(;;)
00221          {
00222 search_startbit2:       
00223          if (!*len) {
00224             fskd->state = STATE_SEARCH_STARTBIT2;
00225             return 0;
00226          }
00227          samples++;
00228          if (demodulador(fskd,&fskd->x2,GET_SAMPLE)) return(-1);
00229 #if 0
00230          printf("x2 = %5.5f ", fskd->x2);
00231 #endif         
00232          if (fskd->x2 < -0.5) break; 
00233          }
00234 search_startbit3:       
00235       /* Esperamos 0.5 bits antes de usar DPLL */
00236       i=fskd->spb/2;
00237       if (*len < i) {
00238          fskd->state = STATE_SEARCH_STARTBIT3;
00239          return 0;
00240       }
00241       for(;i;i--) { if (demodulador(fskd,&fskd->x1,GET_SAMPLE)) return(-1); 
00242 #if 0
00243          printf("x1 = %5.5f ", fskd->x1);
00244 #endif         
00245    samples++; }
00246 
00247       /* x1 debe ser negativo (confirmación del bit de start) */
00248 
00249    } while (fskd->x1>0);
00250    fskd->state = STATE_GET_BYTE;
00251 
00252 getbyte:
00253 
00254    /* Need at least 80 samples (for 1200) or
00255       1320 (for 45.5) to be sure we'll have a byte */
00256    if (fskd->nbit < 8) {
00257       if (*len < 1320)
00258          return 0;
00259    } else {
00260       if (*len < 80)
00261          return 0;
00262    }
00263    /* Leemos ahora los bits de datos */
00264    j=fskd->nbit;
00265    for (a=n1=0;j;j--) {
00266       olen = *len;
00267       i=get_bit_raw(fskd, buffer, len);
00268       buffer += (olen - *len);
00269       if (i == -1) return(-1);
00270       if (i) n1++;
00271       a>>=1; a|=i;
00272    }
00273    j=8-fskd->nbit;
00274    a>>=j;
00275 
00276    /* Leemos bit de paridad (si existe) y la comprobamos */
00277    if (fskd->paridad) {
00278       olen = *len;
00279       i=get_bit_raw(fskd, buffer, len); 
00280       buffer += (olen - *len);
00281       if (i == -1) return(-1);
00282       if (i) n1++;
00283       if (fskd->paridad==1) { /* paridad=1 (par) */
00284          if (n1&1) a|=0x100;     /* error */
00285       } else {       /* paridad=2 (impar) */
00286          if (!(n1&1)) a|=0x100;  /* error */
00287       }
00288    }
00289    
00290    /* Leemos bits de STOP. Todos deben ser 1 */
00291    
00292    for (j=fskd->nstop;j;j--) {
00293       r = get_bit_raw(fskd, buffer, len);
00294       if (r == -1) return(-1);
00295       if (!r) a|=0x200;
00296    }
00297 
00298    /* Por fin retornamos  */
00299    /* Bit 8 : Error de paridad */
00300    /* Bit 9 : Error de Framming */
00301 
00302    *outbyte = a;
00303    fskd->state = STATE_SEARCH_STARTBIT;
00304    return 1;
00305 }
00306 }


Generated on Mon May 14 04:48:04 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1