Go to the source code of this file.
Defines | |
#define | TDD_BYTES_PER_CHAR 2700 |
Typedefs | |
typedef tdd_state | TDDSTATE |
Functions | |
int | ast_tdd_gen_ecdisa (unsigned char *outbuf, int len) |
int | tdd_feed (struct tdd_state *tdd, unsigned char *ubuf, int samples) |
void | tdd_free (struct tdd_state *tdd) |
int | tdd_generate (struct tdd_state *tdd, unsigned char *buf, const char *string) |
void | tdd_init (void) |
tdd_state * | tdd_new (void) |
Definition in file tdd.h.
|
Definition at line 27 of file tdd.h. Referenced by zt_sendtext(). |
|
|
|
Definition at line 115 of file tdd.c. References ecdisa, and tdd_state::pos. Referenced by zt_setoption(). 00116 { 00117 int pos = 0; 00118 int cnt; 00119 while(len) { 00120 cnt = len; 00121 if (cnt > sizeof(ecdisa)) 00122 cnt = sizeof(ecdisa); 00123 memcpy(outbuf + pos, ecdisa, cnt); 00124 pos += cnt; 00125 len -= cnt; 00126 } 00127 return 0; 00128 }
|
|
Definition at line 130 of file tdd.c. References ast_log(), AST_MULAW, free, fsk_serie(), tdd_state::fskd, LOG_ERROR, LOG_NOTICE, LOG_WARNING, malloc, tdd_state::oldlen, tdd_state::oldstuff, and tdd_decode_baudot(). Referenced by zt_read(). 00131 { 00132 int mylen = len; 00133 int olen; 00134 int b = 'X'; 00135 int res; 00136 int c,x; 00137 short *buf = malloc(2 * len + tdd->oldlen); 00138 short *obuf = buf; 00139 if (!buf) { 00140 ast_log(LOG_WARNING, "Out of memory\n"); 00141 return -1; 00142 } 00143 memset(buf, 0, 2 * len + tdd->oldlen); 00144 memcpy(buf, tdd->oldstuff, tdd->oldlen); 00145 mylen += tdd->oldlen/2; 00146 for (x=0;x<len;x++) 00147 buf[x+tdd->oldlen/2] = AST_MULAW(ubuf[x]); 00148 c = res = 0; 00149 while(mylen >= 1320) { /* has to have enough to work on */ 00150 olen = mylen; 00151 res = fsk_serie(&tdd->fskd, buf, &mylen, &b); 00152 if (mylen < 0) { 00153 ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d) (olen was %d)\n", mylen,olen); 00154 free(obuf); 00155 return -1; 00156 } 00157 buf += (olen - mylen); 00158 if (res < 0) { 00159 ast_log(LOG_NOTICE, "fsk_serie failed\n"); 00160 free(obuf); 00161 return -1; 00162 } 00163 if (res == 1) { 00164 /* Ignore invalid bytes */ 00165 if (b > 0x7f) 00166 continue; 00167 c = tdd_decode_baudot(tdd,b); 00168 if ((c < 1) || (c > 126)) continue; /* if not valid */ 00169 break; 00170 } 00171 } 00172 if (mylen) { 00173 memcpy(tdd->oldstuff, buf, mylen * 2); 00174 tdd->oldlen = mylen * 2; 00175 } else 00176 tdd->oldlen = 0; 00177 free(obuf); 00178 if (res) { 00179 tdd->mode = 2; /* put it in mode where it 00180 reliably puts teleprinter in correct shift mode */ 00181 return(c); 00182 } 00183 return 0; 00184 }
|
|
Definition at line 186 of file tdd.c. References free. Referenced by zt_setoption(). 00187 { 00188 free(tdd); 00189 }
|
|
Definition at line 250 of file tdd.c. References PUT_TDD. 00251 { 00252 int bytes=0; 00253 int i,x; 00254 char c; 00255 static unsigned char lstr[31] = "\000E\nA SIU\rDRJNFCKTZLWHYPQOBG\000MXV"; 00256 static unsigned char fstr[31] = "\0003\n- \00787\r$4',!:(5\")2\0006019?&\000./;"; 00257 /* Initial carriers (real/imaginary) */ 00258 float cr = 1.0; 00259 float ci = 0.0; 00260 float scont = 0.0; 00261 00262 for(x = 0; str[x]; x++) { 00263 c = toupper(str[x]); 00264 #if 0 00265 printf("%c",c); fflush(stdout); 00266 #endif 00267 if (c == 0) /* send null */ 00268 { 00269 PUT_TDD(0); 00270 continue; 00271 } 00272 if (c == '\r') /* send c/r */ 00273 { 00274 PUT_TDD(8); 00275 continue; 00276 } 00277 if (c == '\n') /* send c/r and l/f */ 00278 { 00279 PUT_TDD(8); 00280 PUT_TDD(2); 00281 continue; 00282 } 00283 if (c == ' ') /* send space */ 00284 { 00285 PUT_TDD(4); 00286 continue; 00287 } 00288 for(i = 0; i < 31; i++) 00289 { 00290 if (lstr[i] == c) break; 00291 } 00292 if (i < 31) /* if we found it */ 00293 { 00294 if (tdd->mode) /* if in figs mode, change it */ 00295 { 00296 PUT_TDD(31); /* Send LTRS */ 00297 tdd->mode = 0; 00298 } 00299 PUT_TDD(i); 00300 continue; 00301 } 00302 for(i = 0; i < 31; i++) 00303 { 00304 if (fstr[i] == c) break; 00305 } 00306 if (i < 31) /* if we found it */ 00307 { 00308 if (tdd->mode != 1) /* if in ltrs mode, change it */ 00309 { 00310 PUT_TDD(27); /* send FIGS */ 00311 tdd->mode = 1; 00312 } 00313 PUT_TDD(i); /* send byte */ 00314 continue; 00315 } 00316 } 00317 return bytes; 00318 }
|
|
Initializes the TDD system. Mostly stuff for inverse FFT Definition at line 81 of file tdd.c. References TDD_MARK, and TDD_SPACE. 00082 { 00083 /* Initialize stuff for inverse FFT */ 00084 dr[0] = cos(TDD_SPACE * 2.0 * M_PI / 8000.0); 00085 di[0] = sin(TDD_SPACE * 2.0 * M_PI / 8000.0); 00086 dr[1] = cos(TDD_MARK * 2.0 * M_PI / 8000.0); 00087 di[1] = sin(TDD_MARK * 2.0 * M_PI / 8000.0); 00088 }
|
|
This function returns a malloc'd instance of the tdd_state data structure. Returns a pointer to a malloc'd tdd_state structure, or NULL on error. Definition at line 90 of file tdd.c. References ast_log(), LOG_WARNING, and malloc. Referenced by zt_setoption(). 00091 { 00092 struct tdd_state *tdd; 00093 tdd = malloc(sizeof(struct tdd_state)); 00094 if (tdd) { 00095 memset(tdd, 0, sizeof(struct tdd_state)); 00096 tdd->fskd.spb = 176; /* 45.5 baud */ 00097 tdd->fskd.hdlc = 0; /* Async */ 00098 tdd->fskd.nbit = 5; /* 5 bits */ 00099 tdd->fskd.nstop = 1.5; /* 1.5 stop bits */ 00100 tdd->fskd.paridad = 0; /* No parity */ 00101 tdd->fskd.bw=0; /* Filter 75 Hz */ 00102 tdd->fskd.f_mark_idx = 0; /* 1400 Hz */ 00103 tdd->fskd.f_space_idx = 1; /* 1800 Hz */ 00104 tdd->fskd.pcola = 0; /* No clue */ 00105 tdd->fskd.cont = 0; /* Digital PLL reset */ 00106 tdd->fskd.x0 = 0.0; 00107 tdd->fskd.state = 0; 00108 tdd->pos = 0; 00109 tdd->mode = 2; 00110 } else 00111 ast_log(LOG_WARNING, "Out of memory\n"); 00112 return tdd; 00113 }
|