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