data types.

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@241 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2007-06-09 16:25:39 +00:00
parent c2f9afc106
commit 8f2661329e
4 changed files with 23 additions and 17 deletions

View File

@ -114,8 +114,9 @@
!strcasecmp(expr, "active") || \
atoi(expr))) ? 1 : 0
#ifndef WIN32
#include <time.h>
#ifndef WIN32
#include <sys/time.h>
#endif
@ -431,7 +432,7 @@ zap_status_t zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
zap_fsk_write_sample_t write_sample_callback,
void *user_data);
int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp);
void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, int ss);
void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss);
zap_status_t zap_fsk_data_parse(zap_fsk_data_state_t *state, zap_size_t *type, char **data, zap_size_t *len);
zap_status_t zap_fsk_demod_feed(zap_fsk_data_state_t *state, int16_t *data, size_t samples);
zap_status_t zap_fsk_demod_destroy(zap_fsk_data_state_t *state);
@ -475,7 +476,7 @@ zap_status_t zap_global_destroy(void);
void zap_global_set_logger(zap_logger_t logger);
void zap_global_set_default_logger(int level);
uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen);
void print_bits(uint8_t *b, int bl, char *buf, int blen, int e, int ss);
void print_bits(uint8_t *b, int bl, char *buf, int blen, int e, uint8_t ss);
ZIO_CODEC_FUNCTION(zio_slin2ulaw);
ZIO_CODEC_FUNCTION(zio_ulaw2slin);
ZIO_CODEC_FUNCTION(zio_slin2alaw);

View File

@ -331,7 +331,12 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
zap_mdmf_type_t mt = MDMF_INVALID;
time(&now);
#ifdef WIN32
_tzset();
_localtime64_s(&tm, &now);
#else
localtime_r(&now, &tm);
#endif
strftime(time_str, sizeof(time_str), "%m%d%H%M", &tm);
zap_fsk_data_init(&fsk_data, databuf, sizeof(databuf));
@ -345,7 +350,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
} else {
mt = MDMF_PHONE_NUM;
}
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) chan->caller_data.cid_num, strlen(chan->caller_data.cid_num));
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) chan->caller_data.cid_num, (uint8_t)strlen(chan->caller_data.cid_num));
if (zap_strlen_zero(chan->caller_data.cid_name)) {
mt = MDMF_NO_NAME;
@ -355,7 +360,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
} else {
mt = MDMF_PHONE_NAME;
}
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) chan->caller_data.cid_name, strlen(chan->caller_data.cid_name));
zap_fsk_data_add_mdmf(&fsk_data, mt, (uint8_t *) chan->caller_data.cid_name, (uint8_t)strlen(chan->caller_data.cid_name));
zap_fsk_data_add_checksum(&fsk_data);
zap_channel_send_fsk_data(chan, &fsk_data, -14);

View File

@ -65,7 +65,7 @@ zap_status_t zap_fsk_data_add_mdmf(zap_fsk_data_state_t *state, zap_mdmf_type_t
{
state->buf[0] = ZAP_CID_TYPE_MDMF;
state->buf[state->bpos++] = type;
state->buf[state->bpos++] = datalen;
state->buf[state->bpos++] = (uint8_t)datalen;
memcpy(&state->buf[state->bpos], data, datalen);
state->bpos += datalen;
return ZAP_SUCCESS;
@ -77,10 +77,10 @@ zap_status_t zap_fsk_data_add_checksum(zap_fsk_data_state_t *state)
uint32_t i;
uint8_t check = 0;
state->buf[1] = state->bpos - 2;
state->buf[1] = (uint8_t)(state->bpos - 2);
for (i = 0; i < state->bpos; i++) {
check += state->buf[i];
check = check + state->buf[i];
}
state->checksum = state->buf[state->bpos] = 256 - check;
@ -219,7 +219,7 @@ int32_t zap_fsk_modulator_generate_carrier_bits(zap_fsk_modulator_t *fsk_trans,
{
uint32_t i = 0;
zap_size_t r = 0;
int bit = 1;
int8_t bit = 1;
for (i = 0; i < bits; i++) {
if ((r = zap_fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) {
@ -239,7 +239,7 @@ void zap_fsk_modulator_generate_chan_sieze(zap_fsk_modulator_t *fsk_trans)
{
uint32_t i = 0;
zap_size_t r = 0;
int bit = 0;
int8_t bit = 0;
for (i = 0; i < fsk_trans->chan_sieze_bits; i++) {
if ((r = zap_fsk_modulator_generate_bit(fsk_trans, bit, fsk_trans->sample_buffer, sizeof(fsk_trans->sample_buffer) / 2))) {
@ -288,13 +288,13 @@ zap_status_t zap_fsk_modulator_init(zap_fsk_modulator_t *fsk_trans,
fsk_trans->modem_type = modem_type;
teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_space, sample_rate, 0);
teletone_dds_state_set_tone(&fsk_trans->dds, fsk_modem_definitions[fsk_trans->modem_type].freq_mark, sample_rate, 1);
fsk_trans->bit_factor = (fsk_modem_definitions[fsk_trans->modem_type].baud_rate * ZAP_FSK_MOD_FACTOR) / (float)sample_rate;
fsk_trans->bit_factor = (uint32_t)((fsk_modem_definitions[fsk_trans->modem_type].baud_rate * ZAP_FSK_MOD_FACTOR) / (float)sample_rate);
fsk_trans->samples_per_bit = (uint32_t) (sample_rate / fsk_modem_definitions[fsk_trans->modem_type].baud_rate);
fsk_trans->est_bytes = ((fsk_data->dlen * 10) + carrier_bits_start + carrier_bits_stop + chan_sieze_bits) * ((fsk_trans->samples_per_bit + 1) * 2);
fsk_trans->est_bytes = (int32_t)(((fsk_data->dlen * 10) + carrier_bits_start + carrier_bits_stop + chan_sieze_bits) * ((fsk_trans->samples_per_bit + 1) * 2));
fsk_trans->bit_accum = 0;
fsk_trans->fsk_data = fsk_data;
teletone_dds_state_set_tx_level(&fsk_trans->dds, db_level);
zap_bitstream_init(&fsk_trans->bs, fsk_trans->fsk_data->buf, fsk_trans->fsk_data->dlen, ZAP_ENDIAN_BIG, 1);
zap_bitstream_init(&fsk_trans->bs, fsk_trans->fsk_data->buf, (uint32_t)fsk_trans->fsk_data->dlen, ZAP_ENDIAN_BIG, 1);
fsk_trans->carrier_bits_start = carrier_bits_start;
fsk_trans->carrier_bits_stop = carrier_bits_stop;
fsk_trans->chan_sieze_bits = chan_sieze_bits;

View File

@ -1486,7 +1486,7 @@ zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t data
{
zap_status_t status = ZAP_FAIL;
zio_codec_t codec_func = NULL;
zap_size_t blen, max = datasize;
zap_size_t blen = 0, max = datasize;
zap_buffer_t *buffer = NULL;
assert(zchan != NULL);
@ -1871,7 +1871,7 @@ uint32_t zap_separate_string(char *buf, char delim, char **array, int arraylen)
return argc;
}
void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, int ss)
void zap_bitstream_init(zap_bitstream_t *bsp, uint8_t *data, uint32_t datalen, zap_endian_t endian, uint8_t ss)
{
memset(bsp, 0, sizeof(*bsp));
bsp->data = data;
@ -1927,7 +1927,7 @@ int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp)
}
} else {
bsp->bit_index += bsp->endian;
bsp->bit_index = bsp->bit_index + bsp->endian;
}
@ -1936,7 +1936,7 @@ int8_t zap_bitstream_get_bit(zap_bitstream_t *bsp)
}
void print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, int ss)
void print_bits(uint8_t *b, int bl, char *buf, int blen, zap_endian_t e, uint8_t ss)
{
zap_bitstream_t bs;
int j = 0, c = 0;