evil ass bug

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@260 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2007-06-15 08:16:38 +00:00
parent 3234f987d6
commit 5df3ff7678
6 changed files with 37 additions and 24 deletions

View File

@ -309,30 +309,36 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample)
switch (handle->state) {
case FSK_STATE_DATA:
(*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
{
(*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit);
}
break;
case FSK_STATE_CHANSEIZE:
if (handle->last_bit != handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_CARRIERSIG;
handle->conscutive_state_bits = 0;
{
if (handle->last_bit != handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_CARRIERSIG;
handle->conscutive_state_bits = 0;
}
}
break;
case FSK_STATE_CARRIERSIG:
if (handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_DATA;
handle->conscutive_state_bits = 0;
{
if (handle->current_bit) {
handle->conscutive_state_bits++;
} else {
handle->conscutive_state_bits = 0;
}
if (handle->conscutive_state_bits > 15) {
handle->state = FSK_STATE_DATA;
handle->conscutive_state_bits = 0;
}
}
break;
}

View File

@ -344,6 +344,7 @@ struct zap_channel {
zap_filehandle_t fds[2];
zap_fsk_data_state_t fsk;
uint8_t fsk_buf[80];
uint32_t ring_count;
struct zap_caller_data caller_data;
struct zap_span *span;
struct zap_io_interface *zio;

View File

@ -78,7 +78,7 @@ dsp_uart_handle_t *dsp_uart_create(dsp_uart_attr_t *attr)
handle = malloc(sizeof (*handle));
if (handle) {
memset(handle, 0, sizeof (handle));
memset(handle, 0, sizeof (*handle));
/* fill the attributes member */
memcpy(&handle->attr, attr, sizeof (*attr));
@ -111,8 +111,8 @@ void dsp_uart_bit_handler(void *x, int bit)
handle->data >>= 1;
handle->data |= 0x80 * !!bit;
handle->nbits++;
if (handle->nbits == 8) {
handle->attr.bytehandler(handle->attr.bytehandler_arg, handle->data);
handle->nbits = 0;

View File

@ -426,7 +426,9 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
case ZAP_CHANNEL_STATE_GET_CALLERID:
{
zap_channel_done(chan);
zap_channel_command(chan, ZAP_COMMAND_TRACE_INPUT, "/tmp/wtf.ul");
zap_channel_command(chan, ZAP_COMMAND_ENABLE_CALLERID_DETECT, NULL);
continue;
}
break;
case ZAP_CHANNEL_STATE_RING:
@ -619,7 +621,10 @@ static zap_status_t process_event(zap_span_t *span, zap_event_t *event)
if (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD)) {
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_GET_CALLERID);
event->channel->ring_count = 1;
zap_thread_create_detached(zap_analog_channel_run, event->channel);
} else {
event->channel->ring_count++;
}
}
break;

View File

@ -182,6 +182,8 @@ int zap_fsk_demod_init(zap_fsk_data_state_t *state, int rate, uint8_t *buf, zap_
dsp_fsk_destroy(&state->fsk1200_handle);
}
memset(state, 0, sizeof(*state));
memset(buf, 0, bufsize);
state->buf = buf;
state->bufsize = bufsize;

View File

@ -1408,13 +1408,12 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
if (zap_fsk_demod_feed(&zchan->fsk, sln, slen) != ZAP_SUCCESS) {
uint32_t type, mlen;
char str[128], *sp;
while(zap_fsk_data_parse(&zchan->fsk, &type, &sp, &mlen) == ZAP_SUCCESS) {
*(str+mlen) = '\0';
zap_copy_string(str, sp, ++mlen);
zap_clean_string(str);
zap_log(ZAP_LOG_DEBUG, "FSK: TYPE %s LEN %d VAL [%s]\n", zap_mdmf_type2str(type), mlen-1, str);
zap_log(ZAP_LOG_ERROR, "FSK: TYPE %s LEN %d VAL [%s]\n", zap_mdmf_type2str(type), mlen-1, str);
switch(type) {
case MDMF_DDN: