Merged revisions 89042 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89042 | oej | 2007-11-06 19:53:37 +0100 (Tis, 06 Nov 2007) | 2 lines

Bug fixes to tdd support in zaptel. 

........

(Small changes for trunk)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89043 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Olle Johansson 18 years ago
parent 2c582c7cfb
commit 8b917df39b

@ -53,6 +53,7 @@ struct tdd_state {
int pos; int pos;
int modo; int modo;
int mode; int mode;
int charnum;
}; };
static float dr[4], di[4]; static float dr[4], di[4];
@ -67,10 +68,10 @@ static int tdd_decode_baudot(struct tdd_state *tdd,unsigned char data) /* covert
'\n','D','R','J','N','F','C','K', '\n','D','R','J','N','F','C','K',
'T','Z','L','W','H','Y','P','Q', 'T','Z','L','W','H','Y','P','Q',
'O','B','G','^','M','X','V','^' }; 'O','B','G','^','M','X','V','^' };
static char figs[32] = { '<','3','\n','-',' ',',','8','7', static char figs[32] = { '<','3','\n','-',' ','\'','8','7',
'\n','$','4','\'',',','·',':','(', '\n','$','4','\'',',','!',':','(',
'5','+',')','2','·','6','0','1', '5','\"',')','2','=','6','0','1',
'9','7','·','^','.','/','=','^' }; '9','?','+','^','.','/',';','^' };
int d = 0; /* return 0 if not decodeable */ int d = 0; /* return 0 if not decodeable */
switch (data) { switch (data) {
case 0x1f: case 0x1f:
@ -118,7 +119,8 @@ struct tdd_state *tdd_new(void)
tdd->fskd.xi0 = 0; tdd->fskd.xi0 = 0;
tdd->fskd.state = 0; tdd->fskd.state = 0;
tdd->pos = 0; tdd->pos = 0;
tdd->mode = 2; tdd->mode = 0;
tdd->charnum = 0;
fskmodem_init(&tdd->fskd); fskmodem_init(&tdd->fskd);
} else } else
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
@ -187,7 +189,8 @@ int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int len)
tdd->oldlen = 0; tdd->oldlen = 0;
free(obuf); free(obuf);
if (res) { if (res) {
tdd->mode = 2; /* put it in mode where it tdd->mode = 2;
/* put it in mode where it
reliably puts teleprinter in correct shift mode */ reliably puts teleprinter in correct shift mode */
return(c); return(c);
} }
@ -231,7 +234,7 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
} while(0) } while(0)
#define PUT_TDD_BAUD(bit) do { \ #define PUT_TDD_BAUD(bit) do { \
while(scont < tddsb) { \ while (scont < tddsb) { \
PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, bit)); \ PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, bit)); \
scont += 1.0; \ scont += 1.0; \
} \ } \
@ -239,7 +242,7 @@ static inline float tdd_getcarrier(float *cr, float *ci, int bit)
} while(0) } while(0)
#define PUT_TDD_STOP do { \ #define PUT_TDD_STOP do { \
while(scont < (tddsb * 1.5)) { \ while (scont < (tddsb * 1.5)) { \
PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1)); \ PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1)); \
scont += 1.0; \ scont += 1.0; \
} \ } \
@ -266,13 +269,17 @@ int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *str)
/*! Baudot letters */ /*! Baudot letters */
static unsigned char lstr[31] = "\000E\nA SIU\rDRJNFCKTZLWHYPQOBG\000MXV"; static unsigned char lstr[31] = "\000E\nA SIU\rDRJNFCKTZLWHYPQOBG\000MXV";
/*! Baudot figures */ /*! Baudot figures */
static unsigned char fstr[31] = "\0003\n- \00787\r$4',!:(5\")2\0006019?&\000./;"; static unsigned char fstr[31] = "\0003\n- \00787\r$4',!:(5\")2\0006019?+\000./;";
/* Initial carriers (real/imaginary) */ /* Initial carriers (real/imaginary) */
float cr = 1.0; float cr = 1.0;
float ci = 0.0; float ci = 0.0;
float scont = 0.0; float scont = 0.0;
for(x = 0; str[x]; x++) { for(x = 0; str[x]; x++) {
/* Do synch for each 72th character */
if ( (tdd->charnum++) % 72 == 0)
PUT_TDD(tdd->mode ? 27 /* FIGS */ : 31 /* LTRS */);
c = toupper(str[x]); c = toupper(str[x]);
#if 0 #if 0
printf("%c",c); fflush(stdout); printf("%c",c); fflush(stdout);

Loading…
Cancel
Save