T.31 now has basically functional T.38 mode - needs more testing, though

Various modules which lacked routines to get at the sub-structures now
have them.
The tests have been tweaked so they only access internals where essential.
This commit is contained in:
Steve Underwood 2013-01-01 23:07:55 +08:00
parent 8859eb0b23
commit c6c03827b8
99 changed files with 2662 additions and 1274 deletions

View File

@ -52,14 +52,10 @@ EXTRA_DIST = autogen.sh \
if COND_DOC
MAYBE_DOC=doc
endif
if COND_TESTDATA
MAYBE_TESTDATA=test-data
endif
if COND_TESTS
MAYBE_TESTDATA=test-data
MAYBE_TESTS=spandsp-sim tests
MAYBE_TESTS=spandsp-sim test-data tests
endif
SUBDIRS = src $(MAYBE_DOC) $(MAYBE_TESTDATA) $(MAYBE_TESTS)
SUBDIRS = src $(MAYBE_DOC) $(MAYBE_TESTS)
DIST_SUBDIRS = src doc test-data spandsp-sim tests

View File

@ -31,6 +31,7 @@ m4_include(m4/ax_fixed_point_machine.m4)
m4_include(m4/ax_misaligned_access_fails.m4)
m4_include(m4/ax_c99_features.m4)
m4_include(m4/ax_check_export_capability.m4)
m4_include(m4/ax_check_arm_neon.m4)
AC_CONFIG_SRCDIR([src/tone_generate.c])
AC_CONFIG_AUX_DIR([config])
@ -124,7 +125,6 @@ AC_TYPE_SIGNAL
AC_ARG_ENABLE(doc, [ --enable-doc Build the documentation])
AC_ARG_ENABLE(tests, [ --enable-tests Build the test programs])
AC_ARG_ENABLE(test_data, [ --enable-test-data Build TIFF test files for some ITU test images])
AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support])
AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support])
AC_ARG_ENABLE(sse2, [ --enable-sse2 Enable SSE2 support])
@ -135,6 +135,7 @@ AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support])
AC_ARG_ENABLE(sse4a, [ --enable-sse4a Enable SSE4A support])
AC_ARG_ENABLE(sse5, [ --enable-sse5 Enable SSE5 support])
AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support])
AC_ARG_ENABLE(neon, [ --enable-neon Enable NEON support])
AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
# The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp
AC_ARG_ENABLE(builtin_tiff,
@ -199,7 +200,7 @@ AC_CHECK_HEADERS([fenv.h])
AC_CHECK_HEADERS([fftw3.h], , [AC_CHECK_HEADERS([fftw.h])])
AC_CHECK_HEADERS([pcap.h])
AC_CHECK_HEADERS([pthread.h])
if test "${build}" = "${host}"
if test "${build}" == "${host}"
then
AC_CHECK_HEADERS([X11/X.h])
fi
@ -243,7 +244,7 @@ AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H])
AC_LANG([C])
if test "${build}" = "${host}"
if test "${build}" == "${host}"
then
case "${host}" in
x86_64-*)
@ -264,7 +265,7 @@ SPANDSP_SUPPORT_T43="#undef SPANDSP_SUPPORT_T43"
SPANDSP_SUPPORT_V34="#undef SPANDSP_SUPPORT_V34"
AC_CHECK_LIB([m], [cos])
# Some platforms still seem to lack the basic single precision trig and power related function.
# Some platforms still seem to lack the basic single precision trig and power related functions.
AC_SEARCH_LIBS([sinf], [m], AC_DEFINE([HAVE_SINF], [1], [Define to 1 if you have the sinf() function.]))
AC_SEARCH_LIBS([cosf], [m], AC_DEFINE([HAVE_COSF], [1], [Define to 1 if you have the cosf() function.]))
AC_SEARCH_LIBS([tanf], [m], AC_DEFINE([HAVE_TANF], [1], [Define to 1 if you have the tanf() function.]))
@ -312,13 +313,12 @@ if test -n "$enable_tests" ; then
AC_LANG([C])
fi
saved_CFLAGS="$CFLAGS"
AX_CHECK_EXPORT_CAPABILITY([$host],
[AC_DEFINE([SPANDSP_USE_EXPORT_CAPABILITY], [1], [Use the library symbol export capability of the compiler])
SPANDSP_USE_EXPORT_CAPABILITY="#define SPANDSP_USE_EXPORT_CAPABILITY 1"],
[SPANDSP_USE_EXPORT_CAPABILITY="#undef SPANDSP_USE_EXPORT_CAPABILITY"])
saved_CFLAGS="$CFLAGS"
AC_CACHE_CHECK([whether compiler supports -Wunused-but-set-variable], [ac_cv_gcc_unused_but_set_variable], [
CFLAGS="$CFLAGS -Wunused-but-set-variable"
AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_unused_but_set_variable=yes],[ac_cv_gcc_unused_but_set_variable=no])
@ -326,18 +326,17 @@ AC_TRY_COMPILE([],[return 0;],[ac_cv_gcc_unused_but_set_variable=yes],[ac_cv_gcc
AC_MSG_RESULT($ac_cv_gcc_unused_but_set_variable)
CFLAGS="$saved_CFLAGS"
case "${ax_cv_c_compiler_vendor}" in
gnu)
COMP_VENDOR_CFLAGS="-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS"
if test x"$ac_cv_gcc_unused_but_set_variable" = xyes; then
if test x"$ac_cv_gcc_unused_but_set_variable" = xyes ; then
COMP_VENDOR_CFLAGS="-Wunused-but-set-variable $COMP_VENDOR_CFLAGS"
fi
AX_CHECK_ARM_NEON([$host],
[AC_DEFINE([SPANDSP_USE_ARM_NEON], [1], [Use the ARM NEON instruction set])])
if test "$enable_neon" = "yes" ; then
COMP_VENDOR_CFLAGS="-mfpu=neon $COMP_VENDOR_CFLAGS"
fi
if test "$enable_avx" = "yes" ; then
COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
fi
@ -399,12 +398,9 @@ sun)
;;
intel)
COMP_VENDOR_CFLAGS="-std=c99 -D_POSIX_C_SOURCE=2 -D_GNU_SOURCE=1 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes $COMP_VENDOR_CFLAGS"
if test x"$ac_cv_gcc_unused_but_set_variable" = xyes; then
if test x"$ac_cv_gcc_unused_but_set_variable" = xyes ; then
COMP_VENDOR_CFLAGS="-Wunused-but-set-variable $COMP_VENDOR_CFLAGS"
fi
if test "$enable_avx" = "yes" ; then
COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
fi
@ -459,49 +455,57 @@ AX_MISALIGNED_ACCESS_FAILS([$host],
SPANDSP_MISALIGNED_ACCESS_FAILS="#define SPANDSP_MISALIGNED_ACCESS_FAILS 1"],
[SPANDSP_MISALIGNED_ACCESS_FAILS="#undef SPANDSP_MISALIGNED_ACCESS_FAILS"])
if test "$enable_avx" = "yes" ; then
AC_DEFINE([SPANDSP_USE_AVX], [1], [Use the AVX instruction set (i386 and x86_64 only).])
enable_sse5"yes"
fi
if test "$enable_sse5" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).])
enable_sse4a="yes"
fi
if test "$enable_sse4a" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4A], [1], [Use the SSE4A instruction set (i386 and x86_64 only).])
enable_sse4_2="yes"
fi
if test "$enable_sse4_2" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
enable_sse4_1="yes"
fi
if test "$enable_sse4_1" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
enable_ssse3="yes"
fi
if test "$enable_ssse3" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSSE3], [1], [Use the SSSE3 instruction set (i386 and x86_64 only).])
enable_sse3="yes"
fi
if test "$enable_sse3" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
enable_sse2="yes"
fi
if test "$enable_sse2" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
enable_sse="yes"
fi
if test "$enable_sse" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
enable_mmx="yes"
fi
if test "$enable_mmx" = "yes" ; then
AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
fi
case "${host}" in
armv7[bl] | armv7-*)
if test "$enable_neon" = "yes" ; then
AC_DEFINE([SPANDSP_USE_ARM_NEON], [1], [Use the NEON instruction set (ARMV7 only).])
fi
;;
x86_64-* | i386-* | i686-*)
if test "$enable_avx" = "yes" ; then
AC_DEFINE([SPANDSP_USE_AVX], [1], [Use the AVX instruction set (i386 and x86_64 only).])
enable_sse5="yes"
fi
if test "$enable_sse5" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).])
enable_sse4a="yes"
fi
if test "$enable_sse4a" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4A], [1], [Use the SSE4A instruction set (i386 and x86_64 only).])
enable_sse4_2="yes"
fi
if test "$enable_sse4_2" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
enable_sse4_1="yes"
fi
if test "$enable_sse4_1" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
enable_ssse3="yes"
fi
if test "$enable_ssse3" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSSE3], [1], [Use the SSSE3 instruction set (i386 and x86_64 only).])
enable_sse3="yes"
fi
if test "$enable_sse3" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
enable_sse2="yes"
fi
if test "$enable_sse2" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
enable_sse="yes"
fi
if test "$enable_sse" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
enable_mmx="yes"
fi
if test "$enable_mmx" = "yes" ; then
AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
fi
;;
esac
AM_CONDITIONAL([COND_DOC], [test "$enable_doc" = yes])
AM_CONDITIONAL([COND_TESTS], [test "$enable_tests" = yes])
AM_CONDITIONAL([COND_TESTDATA], [test "$enable_test_data" = yes])
AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes])
AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes])
AM_CONDITIONAL([COND_SSE2], [test "$enable_sse2" = yes])
@ -512,6 +516,7 @@ AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes])
AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes])
AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes])
AM_CONDITIONAL([COND_AVX], [test "$enable_avx" = yes])
AM_CONDITIONAL([COND_NEON], [test "$enable_neon" = yes])
if test "$enable_builtin_tiff" = "yes" ; then
abs_tiffdir="`cd $srcdir/../tiff-4.0.2/ && pwd`"
@ -532,15 +537,17 @@ else
AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LIBS="-ltiff"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libtiff-devel package?)"), -lm)
fi
if test "$ac_cv_header_tif_dir_h" = "yes" ; then
AC_DEFINE([SPANDSP_SUPPORT_TIFF_FX], [1], [Support TIFF/FX in TIFF file handling])
SPANDSP_SUPPORT_TIFF_FX="#define SPANDSP_SUPPORT_TIFF_FX 1"
else
SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX"
fi
AC_CHECK_LIB([tiff], [TIFFCreateCustomDirectory], [
if test "$ac_cv_header_tif_dir_h" = "yes" ; then
AC_DEFINE([SPANDSP_SUPPORT_TIFF_FX], [1], [Support TIFF/FX in TIFF file handling])
SPANDSP_SUPPORT_TIFF_FX="#define SPANDSP_SUPPORT_TIFF_FX 1"
else
SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX"
fi
], [SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX"], -lm)
AC_CHECK_HEADERS([jpeglib.h])
AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"])
AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libjpeg-devel or libjpeg-turbo-devel package?)"))
LIBS="$LIBS $TIFF_LIBS $JPEG_LIBS"

View File

@ -0,0 +1,45 @@
# @synopsis AX_CHECK_ARM_NEON
#
# Does the machine support the ARM NEON instruction set?
# @version 1.0 Dec 31 2012
# @author Steve Underwood
#
# Permission to use, copy, modify, distribute, and sell this file for any
# purpose is hereby granted without fee, provided that the above copyright
# and this permission notice appear in all copies. No representations are
# made about the suitability of this software for any purpose. It is
# provided "as is" without express or implied warranty.
AC_DEFUN([AX_CHECK_ARM_NEON],
[AC_CACHE_CHECK([if $1 supports the ARM NEON instructions set],
ac_cv_symbol_arm_neon,
[# Initialize to unknown
ac_cv_symbol_arm_neon="no"
case "${ax_cv_c_compiler_vendor}" in
gnu)
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -mfpu=neon"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[#include <arm_neon.h>
int32x4_t testfunc(int16_t *a, int16_t *b)
{return vmull_s16(vld1_s16(a), vld1_s16(b));}],
[;]
)],
[AC_MSG_RESULT([yes])
COMP_VENDOR_CFLAGS="-mfpu=neon $COMP_VENDOR_CFLAGS"
COMP_VENDOR_CXXFLAGS="-mfpu=neon $COMP_VENDOR_CXXFLAGS"
ac_cv_symbol_arm_neon="yes"],
[AC_MSG_RESULT([no])]
)
CFLAGS="${save_CFLAGS}"
;;
esac])
AS_IF([test AS_VAR_GET(ac_cv_symbol_arm_neon) = yes], [$2], [$3])[]dnl
]) # AX_CHECK_ARM_NEON

View File

@ -413,6 +413,12 @@ SPAN_DECLARE(int) adsi_rx(adsi_rx_state_t *s, const int16_t amp[], int len)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) adsi_rx_get_logging_state(adsi_rx_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(adsi_rx_state_t *) adsi_rx_init(adsi_rx_state_t *s,
int standard,
put_msg_func_t put_msg,
@ -642,6 +648,12 @@ SPAN_DECLARE(int) adsi_tx_put_message(adsi_tx_state_t *s, const uint8_t *msg, in
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) adsi_tx_get_logging_state(adsi_tx_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(adsi_tx_state_t *) adsi_tx_init(adsi_tx_state_t *s, int standard)
{
if (s == NULL)

View File

@ -898,7 +898,7 @@ static const char *at_cmd_dummy(at_state_t *s, const char *t)
static const char *at_cmd_A(at_state_t *s, const char *t)
{
/* V.250 6.3.5 - Answer (abortable) */
/* V.250 6.3.5 - Answer (abortable) */
t += 1;
if (!answer_call(s))
return NULL;
@ -913,7 +913,7 @@ static const char *at_cmd_D(at_state_t *s, const char *t)
char num[100 + 1];
char ch;
/* V.250 6.3.1 - Dial (abortable) */
/* V.250 6.3.1 - Dial (abortable) */
at_reset_call_info(s);
s->do_hangup = FALSE;
s->silent_dial = FALSE;
@ -1023,7 +1023,7 @@ static const char *at_cmd_E(at_state_t *s, const char *t)
{
int val;
/* V.250 6.2.4 - Command echo */
/* V.250 6.2.4 - Command echo */
t += 1;
if ((val = parse_num(&t, 1)) < 0)
return NULL;
@ -1036,7 +1036,7 @@ static const char *at_cmd_H(at_state_t *s, const char *t)
{
int val;
/* V.250 6.3.6 - Hook control */
/* V.250 6.3.6 - Hook control */
t += 1;
if ((val = parse_num(&t, 1)) < 0)
return NULL;
@ -1068,7 +1068,7 @@ static const char *at_cmd_I(at_state_t *s, const char *t)
{
int val;
/* V.250 6.1.3 - Request identification information */
/* V.250 6.1.3 - Request identification information */
/* N.B. The information supplied in response to an ATIx command is very
variable. It was widely used in different ways before the AT command
set was standardised by the ITU. */
@ -1106,7 +1106,7 @@ static const char *at_cmd_M(at_state_t *s, const char *t)
{
int val;
/* V.250 6.3.14 - Monitor speaker mode */
/* V.250 6.3.14 - Monitor speaker mode */
/* Just absorb this command, as we have no speaker */
t += 1;
if ((val = parse_num(&t, 255)) < 0)
@ -1120,7 +1120,7 @@ static const char *at_cmd_O(at_state_t *s, const char *t)
{
int val;
/* V.250 6.3.7 - Return to online data state */
/* V.250 6.3.7 - Return to online data state */
t += 1;
if ((val = parse_num(&t, 1)) < 0)
return NULL;
@ -1135,7 +1135,7 @@ static const char *at_cmd_O(at_state_t *s, const char *t)
static const char *at_cmd_P(at_state_t *s, const char *t)
{
/* V.250 6.3.3 - Select pulse dialling (command) */
/* V.250 6.3.3 - Select pulse dialling (command) */
t += 1;
s->p.pulse_dial = TRUE;
return t;
@ -1146,7 +1146,7 @@ static const char *at_cmd_Q(at_state_t *s, const char *t)
{
int val;
/* V.250 6.2.5 - Result code suppression */
/* V.250 6.2.5 - Result code suppression */
t += 1;
if ((val = parse_num(&t, 1)) < 0)
return NULL;
@ -1165,7 +1165,7 @@ static const char *at_cmd_Q(at_state_t *s, const char *t)
static const char *at_cmd_S0(at_state_t *s, const char *t)
{
/* V.250 6.3.8 - Automatic answer */
/* V.250 6.3.8 - Automatic answer */
t += 2;
return s_reg_handler(s, t, 0);
}
@ -1173,7 +1173,7 @@ static const char *at_cmd_S0(at_state_t *s, const char *t)
static const char *at_cmd_S10(at_state_t *s, const char *t)
{
/* V.250 6.3.12 - Automatic disconnect delay */
/* V.250 6.3.12 - Automatic disconnect delay */
t += 3;
return s_reg_handler(s, t, 10);
}
@ -1181,7 +1181,7 @@ static const char *at_cmd_S10(at_state_t *s, const char *t)
static const char *at_cmd_S3(at_state_t *s, const char *t)
{
/* V.250 6.2.1 - Command line termination character */
/* V.250 6.2.1 - Command line termination character */
t += 2;
return s_reg_handler(s, t, 3);
}
@ -1189,7 +1189,7 @@ static const char *at_cmd_S3(at_state_t *s, const char *t)
static const char *at_cmd_S4(at_state_t *s, const char *t)
{
/* V.250 6.2.2 - Response formatting character */
/* V.250 6.2.2 - Response formatting character */
t += 2;
return s_reg_handler(s, t, 4);
}
@ -1197,7 +1197,7 @@ static const char *at_cmd_S4(at_state_t *s, const char *t)
static const char *at_cmd_S5(at_state_t *s, const char *t)
{
/* V.250 6.2.3 - Command line editing character */
/* V.250 6.2.3 - Command line editing character */
t += 2;
return s_reg_handler(s, t, 5);
}
@ -1205,7 +1205,7 @@ static const char *at_cmd_S5(at_state_t *s, const char *t)
static const char *at_cmd_S6(at_state_t *s, const char *t)
{
/* V.250 6.3.9 - Pause before blind dialling */
/* V.250 6.3.9 - Pause before blind dialling */
t += 2;
return s_reg_handler(s, t, 6);
}
@ -1213,7 +1213,7 @@ static const char *at_cmd_S6(at_state_t *s, const char *t)
static const char *at_cmd_S7(at_state_t *s, const char *t)
{
/* V.250 6.3.10 - Connection completion timeout */
/* V.250 6.3.10 - Connection completion timeout */
t += 2;
return s_reg_handler(s, t, 7);
}
@ -1221,7 +1221,7 @@ static const char *at_cmd_S7(at_state_t *s, const char *t)
static const char *at_cmd_S8(at_state_t *s, const char *t)
{
/* V.250 6.3.11 - Comma dial modifier time */
/* V.250 6.3.11 - Comma dial modifier time */
t += 2;
return s_reg_handler(s, t, 8);
}
@ -1229,7 +1229,7 @@ static const char *at_cmd_S8(at_state_t *s, const char *t)
static const char *at_cmd_T(at_state_t *s, const char *t)
{
/* V.250 6.3.2 - Select tone dialling (command) */
/* V.250 6.3.2 - Select tone dialling (command) */
t += 1;
s->p.pulse_dial = FALSE;
return t;
@ -1240,7 +1240,7 @@ static const char *at_cmd_V(at_state_t *s, const char *t)
{
int val;
/* V.250 6.2.6 - DCE response format */
/* V.250 6.2.6 - DCE response format */
t += 1;
if ((val = parse_num(&t, 1)) < 0)
return NULL;
@ -1278,7 +1278,7 @@ static const char *at_cmd_Z(at_state_t *s, const char *t)
{
int val;
/* V.250 6.1.1 - Reset to default configuration */
/* V.250 6.1.1 - Reset to default configuration */
t += 1;
if ((val = parse_num(&t, sizeof(profiles)/sizeof(profiles[0]) - 1)) < 0)
return NULL;
@ -1295,7 +1295,7 @@ static const char *at_cmd_amp_C(at_state_t *s, const char *t)
{
int val;
/* V.250 6.2.8 - Circuit 109 (received line signal detector) behaviour */
/* V.250 6.2.8 - Circuit 109 (received line signal detector) behaviour */
/* We have no RLSD pin, so just absorb this. */
t += 2;
if ((val = parse_num(&t, 1)) < 0)
@ -1309,7 +1309,7 @@ static const char *at_cmd_amp_D(at_state_t *s, const char *t)
{
int val;
/* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
/* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
t += 2;
if ((val = parse_num(&t, 2)) < 0)
return NULL;
@ -1324,7 +1324,7 @@ static const char *at_cmd_amp_F(at_state_t *s, const char *t)
{
t += 2;
/* V.250 6.1.2 - Set to factory-defined configuration */
/* V.250 6.1.2 - Set to factory-defined configuration */
/* Just make sure we are on hook */
at_modem_control(s, AT_MODEM_CONTROL_HANGUP, NULL);
at_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND);
@ -1474,7 +1474,7 @@ static const char *at_cmd_plus_A8T(at_state_t *s, const char *t)
static const char *at_cmd_plus_ASTO(at_state_t *s, const char *t)
{
/* V.250 6.3.15 - Store telephone number */
/* V.250 6.3.15 - Store telephone number */
/* TODO: */
t += 5;
if (!parse_out(s, &t, NULL, 1, "+ASTO:", ""))
@ -3250,7 +3250,7 @@ static const char *at_cmd_plus_CXT(at_state_t *s, const char *t)
static const char *at_cmd_plus_DR(at_state_t *s, const char *t)
{
/* V.250 6.6.2 - Data compression reporting */
/* V.250 6.6.2 - Data compression reporting */
/* TODO: */
t += 3;
if (!parse_out(s, &t, NULL, 1, "+DR:", ""))
@ -3261,7 +3261,7 @@ static const char *at_cmd_plus_DR(at_state_t *s, const char *t)
static const char *at_cmd_plus_DS(at_state_t *s, const char *t)
{
/* V.250 6.6.1 - Data compression */
/* V.250 6.6.1 - Data compression */
/* TODO: */
t += 3;
if (!parse_out(s, &t, NULL, 1, "+DS:", ""))
@ -3281,7 +3281,7 @@ static const char *at_cmd_plus_DS44(at_state_t *s, const char *t)
static const char *at_cmd_plus_EB(at_state_t *s, const char *t)
{
/* V.250 6.5.2 - Break handling in error control operation */
/* V.250 6.5.2 - Break handling in error control operation */
/* TODO: */
t += 3;
if (!parse_out(s, &t, NULL, 1, "+EB:", ""))
@ -3292,7 +3292,7 @@ static const char *at_cmd_plus_EB(at_state_t *s, const char *t)
static const char *at_cmd_plus_EFCS(at_state_t *s, const char *t)
{
/* V.250 6.5.4 - 32-bit frame check sequence */
/* V.250 6.5.4 - 32-bit frame check sequence */
/* TODO: */
t += 5;
if (!parse_out(s, &t, NULL, 2, "+EFCS:", "(0-2)"))
@ -3303,7 +3303,7 @@ static const char *at_cmd_plus_EFCS(at_state_t *s, const char *t)
static const char *at_cmd_plus_EFRAM(at_state_t *s, const char *t)
{
/* V.250 6.5.8 - Frame length */
/* V.250 6.5.8 - Frame length */
/* TODO: */
t += 6;
if (!parse_2_out(s, &t, NULL, 65535, NULL, 65535, "+EFRAM:", "(1-65535),(1-65535)"))
@ -3314,7 +3314,7 @@ static const char *at_cmd_plus_EFRAM(at_state_t *s, const char *t)
static const char *at_cmd_plus_ER(at_state_t *s, const char *t)
{
/* V.250 6.5.5 - Error control reporting */
/* V.250 6.5.5 - Error control reporting */
/* 0 Error control reporting disabled (no +ER intermediate result code transmitted)
1 Error control reporting enabled (+ER intermediate result code transmitted) */
/* TODO: */
@ -3333,7 +3333,7 @@ static const char *at_cmd_plus_ES(at_state_t *s, const char *t)
};
int *locations[3];
/* V.250 6.5.1 - Error control selection */
/* V.250 6.5.1 - Error control selection */
/* orig_rqst
0: Direct mode
@ -3403,7 +3403,7 @@ static const char *at_cmd_plus_ESA(at_state_t *s, const char *t)
static const char *at_cmd_plus_ESR(at_state_t *s, const char *t)
{
/* V.250 6.5.3 - Selective repeat */
/* V.250 6.5.3 - Selective repeat */
/* TODO: */
t += 4;
return t;
@ -3412,7 +3412,7 @@ static const char *at_cmd_plus_ESR(at_state_t *s, const char *t)
static const char *at_cmd_plus_ETBM(at_state_t *s, const char *t)
{
/* V.250 6.5.6 - Call termination buffer management */
/* V.250 6.5.6 - Call termination buffer management */
/* TODO: */
t += 5;
if (!parse_2_out(s, &t, NULL, 2, NULL, 2, "+ETBM:", "(0-2),(0-2),(0-30)"))
@ -3423,7 +3423,7 @@ static const char *at_cmd_plus_ETBM(at_state_t *s, const char *t)
static const char *at_cmd_plus_EWIND(at_state_t *s, const char *t)
{
/* V.250 6.5.7 - Window size */
/* V.250 6.5.7 - Window size */
/* TODO: */
t += 6;
if (!parse_2_out(s, &t, &s->rx_window, 127, &s->tx_window, 127, "+EWIND:", "(1-127),(1-127)"))
@ -3473,7 +3473,7 @@ static const char *at_cmd_plus_FAP(at_state_t *s, const char *t)
static const char *at_cmd_plus_FAR(at_state_t *s, const char *t)
{
/* T.31 8.5.1 - Adaptive reception control */
/* T.31 8.5.1 - Adaptive reception control */
t += 4;
if (!parse_out(s, &t, &s->p.adaptive_receive, 1, NULL, "0,1"))
return NULL;
@ -3519,7 +3519,7 @@ static const char *at_cmd_plus_FCC(at_state_t *s, const char *t)
static const char *at_cmd_plus_FCL(at_state_t *s, const char *t)
{
/* T.31 8.5.2 - Carrier loss timeout */
/* T.31 8.5.2 - Carrier loss timeout */
t += 4;
if (!parse_out(s, &t, &s->carrier_loss_timeout, 255, NULL, "(0-255)"))
return NULL;
@ -3529,7 +3529,7 @@ static const char *at_cmd_plus_FCL(at_state_t *s, const char *t)
static const char *at_cmd_plus_FCLASS(at_state_t *s, const char *t)
{
/* T.31 8.2 - Capabilities identification and control */
/* T.31 8.2 - Capabilities identification and control */
t += 7;
/* T.31 says the reply string should be "0,1.0", however making
it "0,1,1.0" makes things compatible with a lot more software
@ -3578,7 +3578,7 @@ static const char *at_cmd_plus_FCT(at_state_t *s, const char *t)
static const char *at_cmd_plus_FDD(at_state_t *s, const char *t)
{
/* T.31 8.5.3 - Double escape character replacement */
/* T.31 8.5.3 - Double escape character replacement */
t += 4;
if (!parse_out(s, &t, &s->p.double_escape, 1, NULL, "(0,1)"))
return NULL;
@ -3668,7 +3668,7 @@ static const char *at_cmd_plus_FIS(at_state_t *s, const char *t)
static const char *at_cmd_plus_FIT(at_state_t *s, const char *t)
{
/* T.31 8.5.4 - DTE inactivity timeout */
/* T.31 8.5.4 - DTE inactivity timeout */
t += 4;
if (!parse_2_out(s, &t, &s->dte_inactivity_timeout, 255, &s->dte_inactivity_action, 1, "+FIT:", "(0-255),(0-1)"))
return NULL;
@ -3696,10 +3696,16 @@ static const char *at_cmd_plus_FLI(at_state_t *s, const char *t)
static const char *at_cmd_plus_FLO(at_state_t *s, const char *t)
{
/* T.31 Annex A */
/* Implement something similar to the V.250 +IFC command */
/* TODO: */
/* T.31 Annex A */
/* Implement something similar to the V.250 +IFC command */
/* 0: None.
1: XON/XOFF.
2: Hardware (default) */
t += 4;
span_log(&s->logging, SPAN_LOG_FLOW, "+FLO received\n");
if (!parse_out(s, &t, &s->dte_dce_flow_control, 2, "+FLO:", "(0-2)"))
return NULL;
s->dce_dte_flow_control = s->dte_dce_flow_control;
return t;
}
/*- End of function --------------------------------------------------------*/
@ -3715,7 +3721,7 @@ static const char *at_cmd_plus_FLP(at_state_t *s, const char *t)
static const char *at_cmd_plus_FMI(at_state_t *s, const char *t)
{
/* T.31 says to duplicate +GMI */
/* T.31 says to duplicate +GMI */
t += 4;
if (t[0] == '?')
{
@ -3728,7 +3734,7 @@ static const char *at_cmd_plus_FMI(at_state_t *s, const char *t)
static const char *at_cmd_plus_FMM(at_state_t *s, const char *t)
{
/* T.31 says to duplicate +GMM */
/* T.31 says to duplicate +GMM */
t += 4;
if (t[0] == '?')
{
@ -3741,7 +3747,7 @@ static const char *at_cmd_plus_FMM(at_state_t *s, const char *t)
static const char *at_cmd_plus_FMR(at_state_t *s, const char *t)
{
/* T.31 says to duplicate +GMR */
/* T.31 says to duplicate +GMR */
t += 4;
if (t[0] == '?')
{
@ -3810,8 +3816,8 @@ static const char *at_cmd_plus_FPP(at_state_t *s, const char *t)
static const char *at_cmd_plus_FPR(at_state_t *s, const char *t)
{
/* T.31 Annex A */
/* Implement something similar to the V.250 +IPR command */
/* T.31 Annex A */
/* Implement something similar to the V.250 +IPR command */
t += 4;
if (!parse_out(s, &t, &s->dte_rate, 115200, NULL, "115200"))
return NULL;
@ -3837,7 +3843,7 @@ static const char *at_cmd_plus_FPW(at_state_t *s, const char *t)
static const char *at_cmd_plus_FRH(at_state_t *s, const char *t)
{
/* T.31 8.3.6 - HDLC receive */
/* T.31 8.3.6 - HDLC receive */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3846,7 +3852,7 @@ static const char *at_cmd_plus_FRH(at_state_t *s, const char *t)
static const char *at_cmd_plus_FRM(at_state_t *s, const char *t)
{
/* T.31 8.3.4 - Facsimile receive */
/* T.31 8.3.4 - Facsimile receive */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3864,7 +3870,7 @@ static const char *at_cmd_plus_FRQ(at_state_t *s, const char *t)
static const char *at_cmd_plus_FRS(at_state_t *s, const char *t)
{
/* T.31 8.3.2 - Receive silence */
/* T.31 8.3.2 - Receive silence */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3900,7 +3906,7 @@ static const char *at_cmd_plus_FSP(at_state_t *s, const char *t)
static const char *at_cmd_plus_FTH(at_state_t *s, const char *t)
{
/* T.31 8.3.5 - HDLC transmit */
/* T.31 8.3.5 - HDLC transmit */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3909,7 +3915,7 @@ static const char *at_cmd_plus_FTH(at_state_t *s, const char *t)
static const char *at_cmd_plus_FTM(at_state_t *s, const char *t)
{
/* T.31 8.3.3 - Facsimile transmit */
/* T.31 8.3.3 - Facsimile transmit */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3918,7 +3924,7 @@ static const char *at_cmd_plus_FTM(at_state_t *s, const char *t)
static const char *at_cmd_plus_FTS(at_state_t *s, const char *t)
{
/* T.31 8.3.1 - Transmit silence */
/* T.31 8.3.1 - Transmit silence */
if (!process_class1_cmd(s, &t))
return NULL;
return t;
@ -3947,7 +3953,7 @@ static const char *at_cmd_plus_GCAP(at_state_t *s, const char *t)
static const char *at_cmd_plus_GCI(at_state_t *s, const char *t)
{
/* V.250 6.1.10 - Country of installation, */
/* V.250 6.1.10 - Country of installation, */
t += 4;
if (!parse_hex_out(s, &t, &s->country_of_installation, 255, "+GCI:", "(00-FF)"))
return NULL;
@ -3957,7 +3963,7 @@ static const char *at_cmd_plus_GCI(at_state_t *s, const char *t)
static const char *at_cmd_plus_GMI(at_state_t *s, const char *t)
{
/* V.250 6.1.4 - Request manufacturer identification */
/* V.250 6.1.4 - Request manufacturer identification */
t += 4;
if (t[0] == '?')
{
@ -3970,7 +3976,7 @@ static const char *at_cmd_plus_GMI(at_state_t *s, const char *t)
static const char *at_cmd_plus_GMM(at_state_t *s, const char *t)
{
/* V.250 6.1.5 - Request model identification */
/* V.250 6.1.5 - Request model identification */
t += 4;
if (t[0] == '?')
{
@ -3983,7 +3989,7 @@ static const char *at_cmd_plus_GMM(at_state_t *s, const char *t)
static const char *at_cmd_plus_GMR(at_state_t *s, const char *t)
{
/* V.250 6.1.6 - Request revision identification */
/* V.250 6.1.6 - Request revision identification */
t += 4;
if (t[0] == '?')
{
@ -3996,7 +4002,7 @@ static const char *at_cmd_plus_GMR(at_state_t *s, const char *t)
static const char *at_cmd_plus_GOI(at_state_t *s, const char *t)
{
/* V.250 6.1.8 - Request global object identification */
/* V.250 6.1.8 - Request global object identification */
/* TODO: */
t += 4;
if (t[0] == '?')
@ -4010,7 +4016,7 @@ static const char *at_cmd_plus_GOI(at_state_t *s, const char *t)
static const char *at_cmd_plus_GSN(at_state_t *s, const char *t)
{
/* V.250 6.1.7 - Request product serial number identification */
/* V.250 6.1.7 - Request product serial number identification */
/* TODO: */
t += 4;
if (t[0] == '?')
@ -4090,7 +4096,7 @@ static const char *at_cmd_plus_IBM(at_state_t *s, const char *t)
static const char *at_cmd_plus_ICF(at_state_t *s, const char *t)
{
/* V.250 6.2.11 - DTE-DCE character framing */
/* V.250 6.2.11 - DTE-DCE character framing */
t += 4;
/* Character format
0: auto detect
@ -4114,7 +4120,7 @@ static const char *at_cmd_plus_ICF(at_state_t *s, const char *t)
static const char *at_cmd_plus_ICLOK(at_state_t *s, const char *t)
{
/* V.250 6.2.14 - Select sync transmit clock source */
/* V.250 6.2.14 - Select sync transmit clock source */
t += 6;
if (!parse_out(s, &t, &s->sync_tx_clock_source, 2, "+ICLOK:", "(0-2)"))
return NULL;
@ -4124,7 +4130,7 @@ static const char *at_cmd_plus_ICLOK(at_state_t *s, const char *t)
static const char *at_cmd_plus_IDSR(at_state_t *s, const char *t)
{
/* V.250 6.2.16 - Select data set ready option */
/* V.250 6.2.16 - Select data set ready option */
t += 5;
if (!parse_out(s, &t, &s->dsr_option, 2, "+IDSR:", "(0-2)"))
return NULL;
@ -4134,16 +4140,21 @@ static const char *at_cmd_plus_IDSR(at_state_t *s, const char *t)
static const char *at_cmd_plus_IFC(at_state_t *s, const char *t)
{
/* V.250 6.2.12 - DTE-DCE local flow control */
/* TODO: */
/* V.250 6.2.12 - DTE-DCE local flow control */
/* 0: None.
1: XON/XOFF.
2: Hardware (default) */
span_log(&s->logging, SPAN_LOG_FLOW, "+IFC received\n");
t += 4;
if (!parse_2_out(s, &t, &s->dte_dce_flow_control, 2, &s->dce_dte_flow_control, 2, "+IFC:", "(0-2),(0-2)"))
return NULL;
return t;
}
/*- End of function --------------------------------------------------------*/
static const char *at_cmd_plus_ILRR(at_state_t *s, const char *t)
{
/* V.250 6.2.13 - DTE-DCE local rate reporting */
/* V.250 6.2.13 - DTE-DCE local rate reporting */
/* TODO: */
t += 5;
return t;
@ -4152,7 +4163,7 @@ static const char *at_cmd_plus_ILRR(at_state_t *s, const char *t)
static const char *at_cmd_plus_ILSD(at_state_t *s, const char *t)
{
/* V.250 6.2.15 - Select long space disconnect option */
/* V.250 6.2.15 - Select long space disconnect option */
t += 5;
if (!parse_out(s, &t, &s->long_space_disconnect_option, 2, "+ILSD:", "(0,1)"))
return NULL;
@ -4162,7 +4173,7 @@ static const char *at_cmd_plus_ILSD(at_state_t *s, const char *t)
static const char *at_cmd_plus_IPR(at_state_t *s, const char *t)
{
/* V.250 6.2.10 - Fixed DTE rate */
/* V.250 6.2.10 - Fixed DTE rate */
/* TODO: */
t += 4;
if (!parse_out(s, &t, &s->dte_rate, 115200, "+IPR:", "(115200),(115200)"))
@ -4173,7 +4184,7 @@ static const char *at_cmd_plus_IPR(at_state_t *s, const char *t)
static const char *at_cmd_plus_IRTS(at_state_t *s, const char *t)
{
/* V.250 6.2.17 - Select synchronous mode RTS option */
/* V.250 6.2.17 - Select synchronous mode RTS option */
t += 5;
if (!parse_out(s, &t, NULL, 1, "+IRTS:", "(0,1)"))
return NULL;
@ -4192,7 +4203,7 @@ static const char *at_cmd_plus_ITF(at_state_t *s, const char *t)
static const char *at_cmd_plus_MA(at_state_t *s, const char *t)
{
/* V.250 6.4.2 - Modulation automode control */
/* V.250 6.4.2 - Modulation automode control */
/* TODO: */
t += 3;
return t;
@ -4201,9 +4212,9 @@ static const char *at_cmd_plus_MA(at_state_t *s, const char *t)
static const char *at_cmd_plus_MR(at_state_t *s, const char *t)
{
/* V.250 6.4.3 - Modulation reporting control */
/* 0 Disables reporting of modulation connection (+MCR: and +MRR: are not transmitted)
1 Enables reporting of modulation connection (+MCR: and +MRR: are transmitted) */
/* V.250 6.4.3 - Modulation reporting control */
/* 0: Disables reporting of modulation connection (+MCR: and +MRR: are not transmitted)
1: Enables reporting of modulation connection (+MCR: and +MRR: are transmitted) */
/* TODO: */
t += 3;
if (!parse_out(s, &t, NULL, 1, "+MR:", "(0,1)"))
@ -4214,7 +4225,7 @@ static const char *at_cmd_plus_MR(at_state_t *s, const char *t)
static const char *at_cmd_plus_MS(at_state_t *s, const char *t)
{
/* V.250 6.4.1 - Modulation selection */
/* V.250 6.4.1 - Modulation selection */
/* TODO: */
t += 3;
return t;
@ -4223,7 +4234,7 @@ static const char *at_cmd_plus_MS(at_state_t *s, const char *t)
static const char *at_cmd_plus_MSC(at_state_t *s, const char *t)
{
/* V.250 6.4.8 - Seamless rate change enable */
/* V.250 6.4.8 - Seamless rate change enable */
/* 0 Disables V.34 seamless rate change
1 Enables V.34 seamless rate change */
/* TODO: */
@ -4236,7 +4247,7 @@ static const char *at_cmd_plus_MSC(at_state_t *s, const char *t)
static const char *at_cmd_plus_MV18AM(at_state_t *s, const char *t)
{
/* V.250 6.4.6 - V.18 answering message editing */
/* V.250 6.4.6 - V.18 answering message editing */
/* TODO: */
t += 7;
return t;
@ -4245,7 +4256,7 @@ static const char *at_cmd_plus_MV18AM(at_state_t *s, const char *t)
static const char *at_cmd_plus_MV18P(at_state_t *s, const char *t)
{
/* V.250 6.4.7 - Order of probes */
/* V.250 6.4.7 - Order of probes */
/* 2 Send probe message in 5-bit (Baudot) mode
3 Send probe message in DTMF mode
4 Send probe message in EDT mode
@ -4262,7 +4273,7 @@ static const char *at_cmd_plus_MV18P(at_state_t *s, const char *t)
static const char *at_cmd_plus_MV18R(at_state_t *s, const char *t)
{
/* V.250 6.4.5 - V.18 reporting control */
/* V.250 6.4.5 - V.18 reporting control */
/* TODO: */
t += 6;
if (!parse_out(s, &t, NULL, 1, "+MV18R:", "(0,1)"))
@ -4273,7 +4284,7 @@ static const char *at_cmd_plus_MV18R(at_state_t *s, const char *t)
static const char *at_cmd_plus_MV18S(at_state_t *s, const char *t)
{
/* V.250 6.4.4 - V.18 selection */
/* V.250 6.4.4 - V.18 selection */
/* mode:
0 Disables V.18 operation
1 V.18 operation, auto detect mode
@ -4536,7 +4547,7 @@ static const char *at_cmd_plus_SVT(at_state_t *s, const char *t)
static const char *at_cmd_plus_TADR(at_state_t *s, const char *t)
{
/* V.250 6.7.2.9 - Local V.54 address */
/* V.250 6.7.2.9 - Local V.54 address */
/* TODO: */
t += 5;
return t;
@ -4545,7 +4556,7 @@ static const char *at_cmd_plus_TADR(at_state_t *s, const char *t)
static const char *at_cmd_plus_TAL(at_state_t *s, const char *t)
{
/* V.250 6.7.2.15 - Local analogue loop */
/* V.250 6.7.2.15 - Local analogue loop */
/* Action
0 Disable analogue loop
1 Enable analogue loop
@ -4562,7 +4573,7 @@ static const char *at_cmd_plus_TAL(at_state_t *s, const char *t)
static const char *at_cmd_plus_TALS(at_state_t *s, const char *t)
{
/* V.250 6.7.2.6 - Analogue loop status */
/* V.250 6.7.2.6 - Analogue loop status */
/* 0 Inactive
1 V.24 circuit 141 invoked
2 Front panel invoked
@ -4577,7 +4588,7 @@ static const char *at_cmd_plus_TALS(at_state_t *s, const char *t)
static const char *at_cmd_plus_TDLS(at_state_t *s, const char *t)
{
/* V.250 6.7.2.7 - Local digital loop status */
/* V.250 6.7.2.7 - Local digital loop status */
/* 0 Disabled
1 Enabled, inactive
2 Front panel invoked
@ -4593,7 +4604,7 @@ static const char *at_cmd_plus_TDLS(at_state_t *s, const char *t)
static const char *at_cmd_plus_TE140(at_state_t *s, const char *t)
{
/* V.250 6.7.2.1 - Enable ckt 140 */
/* V.250 6.7.2.1 - Enable ckt 140 */
/* 0 Disabled
1 Enabled */
/* TODO: */
@ -4606,7 +4617,7 @@ static const char *at_cmd_plus_TE140(at_state_t *s, const char *t)
static const char *at_cmd_plus_TE141(at_state_t *s, const char *t)
{
/* V.250 6.7.2.2 - Enable ckt 141 */
/* V.250 6.7.2.2 - Enable ckt 141 */
/* 0 Response is disabled
1 Response is enabled */
/* TODO: */
@ -4619,7 +4630,7 @@ static const char *at_cmd_plus_TE141(at_state_t *s, const char *t)
static const char *at_cmd_plus_TEPAL(at_state_t *s, const char *t)
{
/* V.250 6.7.2.5 - Enable front panel analogue loop */
/* V.250 6.7.2.5 - Enable front panel analogue loop */
/* 0 Disabled
1 Enabled */
/* TODO: */
@ -4632,7 +4643,7 @@ static const char *at_cmd_plus_TEPAL(at_state_t *s, const char *t)
static const char *at_cmd_plus_TEPDL(at_state_t *s, const char *t)
{
/* V.250 6.7.2.4 - Enable front panel RDL */
/* V.250 6.7.2.4 - Enable front panel RDL */
/* 0 Disabled
1 Enabled */
/* TODO: */
@ -4645,7 +4656,7 @@ static const char *at_cmd_plus_TEPDL(at_state_t *s, const char *t)
static const char *at_cmd_plus_TERDL(at_state_t *s, const char *t)
{
/* V.250 6.7.2.3 - Enable RDL from remote */
/* V.250 6.7.2.3 - Enable RDL from remote */
/* 0 Local DCE will ignore command from remote
1 Local DCE will obey command from remote */
/* TODO: */
@ -4680,7 +4691,7 @@ static const char *at_cmd_plus_TMO(at_state_t *s, const char *t)
static const char *at_cmd_plus_TMODE(at_state_t *s, const char *t)
{
/* V.250 6.7.2.10 - Set V.54 mode */
/* V.250 6.7.2.10 - Set V.54 mode */
/* TODO: */
t += 6;
if (!parse_out(s, &t, NULL, 1, "+TMODE:", "(0,1)"))
@ -4691,7 +4702,7 @@ static const char *at_cmd_plus_TMODE(at_state_t *s, const char *t)
static const char *at_cmd_plus_TNUM(at_state_t *s, const char *t)
{
/* V.250 6.7.2.12 - Errored bit and block counts */
/* V.250 6.7.2.12 - Errored bit and block counts */
/* TODO: */
t += 5;
return t;
@ -4700,7 +4711,7 @@ static const char *at_cmd_plus_TNUM(at_state_t *s, const char *t)
static const char *at_cmd_plus_TRDL(at_state_t *s, const char *t)
{
/* V.250 6.7.2.14 - Request remote digital loop */
/* V.250 6.7.2.14 - Request remote digital loop */
/* 0 Stop RDL
1 Start RDL */
/* TODO: */
@ -4713,7 +4724,7 @@ static const char *at_cmd_plus_TRDL(at_state_t *s, const char *t)
static const char *at_cmd_plus_TRDLS(at_state_t *s, const char *t)
{
/* V.250 6.7.2.8 - Remote digital loop status */
/* V.250 6.7.2.8 - Remote digital loop status */
/* TODO: */
t += 6;
return t;
@ -4722,7 +4733,7 @@ static const char *at_cmd_plus_TRDLS(at_state_t *s, const char *t)
static const char *at_cmd_plus_TRES(at_state_t *s, const char *t)
{
/* V.250 6.7.2.17 - Self test result */
/* V.250 6.7.2.17 - Self test result */
/* 0 No test
1 Pass
2 Fail */
@ -4736,7 +4747,7 @@ static const char *at_cmd_plus_TRES(at_state_t *s, const char *t)
static const char *at_cmd_plus_TSELF(at_state_t *s, const char *t)
{
/* V.250 6.7.2.16 - Self test */
/* V.250 6.7.2.16 - Self test */
/* 0 Intrusive full test
1 Safe partial test */
/* TODO: */
@ -4749,7 +4760,7 @@ static const char *at_cmd_plus_TSELF(at_state_t *s, const char *t)
static const char *at_cmd_plus_TTER(at_state_t *s, const char *t)
{
/* V.250 6.7.2.11 - Test error rate */
/* V.250 6.7.2.11 - Test error rate */
/* TODO: */
t += 5;
if (!parse_2_out(s, &t, NULL, 65535, NULL, 65535, "+TTER:", "(0-65535),(0-65535)"))
@ -5057,7 +5068,7 @@ static const char *at_cmd_plus_VSP(at_state_t *s, const char *t)
static const char *at_cmd_plus_VTA(at_state_t *s, const char *t)
{
/* V.253 10.5.4 - Train acoustic echo-canceller */
/* V.253 10.5.4 - Train acoustic echo-canceller */
/* TODO: */
t += 4;
return t;
@ -5084,7 +5095,7 @@ static const char *at_cmd_plus_VTER(at_state_t *s, const char *t)
static const char *at_cmd_plus_VTH(at_state_t *s, const char *t)
{
/* V.253 10.5.5 - Train line echo-canceller */
/* V.253 10.5.5 - Train line echo-canceller */
/* TODO: */
t += 4;
return t;
@ -5562,6 +5573,12 @@ SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t hand
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
at_tx_handler_t at_tx_handler,
void *at_tx_user_data,
@ -5583,6 +5600,8 @@ SPAN_DECLARE(at_state_t *) at_init(at_state_t *s,
s->call_id = NULL;
s->local_id = NULL;
s->display_call_info = 0;
s->dte_dce_flow_control = 2;
s->dce_dte_flow_control = 2;
at_set_at_rx_mode(s, AT_MODE_ONHOOK_COMMAND);
s->p = profiles[0];
return s;

View File

@ -38,9 +38,9 @@
const char *wordlist[] =
{
" ", /* Dummy to absorb spaces in commands */
"&C", /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
"&D", /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
"&F", /* V.250 6.1.2 - Set to factory-defined configuration */
"&C", /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
"&D", /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
"&F", /* V.250 6.1.2 - Set to factory-defined configuration */
"+A8A", /* V.251 6.3 - V.8 calling tone indication */
"+A8C", /* V.251 6.2 - V.8 answer signal indication */
"+A8E", /* V.251 5.1 - V.8 and V.8bis operation controls */
@ -49,7 +49,7 @@ const char *wordlist[] =
"+A8M", /* V.251 5.2 - Send V.8 menu signals */
"+A8R", /* V.251 6.6 - V.8bis signal and message reporting */
"+A8T", /* V.251 5.3 - Send V.8bis signal and/or message(s) */
"+ASTO", /* V.250 6.3.15 - Store telephone number */
"+ASTO", /* V.250 6.3.15 - Store telephone number */
"+CAAP", /* 3GPP TS 27.007 7.25 - Automatic answer for eMLPP Service */
"+CACM", /* 3GPP TS 27.007 8.25 - Accumulated call meter */
"+CACSP", /* 3GPP TS 27.007 11.1.7 - Voice Group or Voice Broadcast Call State Attribute Presentation */
@ -217,33 +217,33 @@ const char *wordlist[] =
"+CVHU", /* 3GPP TS 27.007 6.20 - Voice Hangup Control */
"+CVIB", /* 3GPP TS 27.007 8.22 - Vibrator mode */
"+CXT", /* IS-99 5.6 - Cellular extension */
"+DR", /* V.250 6.6.2 - Data compression reporting */
"+DS", /* V.250 6.6.1 - Data compression */
"+DR", /* V.250 6.6.2 - Data compression reporting */
"+DS", /* V.250 6.6.1 - Data compression */
"+DS44", /* V.250 6.6.2 - V.44 data compression */
"+EB", /* V.250 6.5.2 - Break handling in error control operation */
"+EFCS", /* V.250 6.5.4 - 32-bit frame check sequence */
"+EFRAM", /* V.250 6.5.8 - Frame length */
"+ER", /* V.250 6.5.5 - Error control reporting */
"+ES", /* V.250 6.5.1 - Error control selection */
"+ESA", /* V.80 8.2 - Synchronous access mode configuration */
"+ESR", /* V.250 6.5.3 - Selective repeat */
"+ETBM", /* V.250 6.5.6 - Call termination buffer management */
"+EWIND", /* V.250 6.5.7 - Window size */
"+EB", /* V.250 6.5.2 - Break handling in error control operation */
"+EFCS", /* V.250 6.5.4 - 32-bit frame check sequence */
"+EFRAM", /* V.250 6.5.8 - Frame length */
"+ER", /* V.250 6.5.5 - Error control reporting */
"+ES", /* V.250 6.5.1 - Error control selection */
"+ESA", /* V.80 8.2 - Synchronous access mode configuration */
"+ESR", /* V.250 6.5.3 - Selective repeat */
"+ETBM", /* V.250 6.5.6 - Call termination buffer management */
"+EWIND", /* V.250 6.5.7 - Window size */
"+F34", /* T.31 B.6.1 - Initial V.34 rate controls for FAX */
"+FAA", /* T.32 8.5.2.5 - Adaptive Answer parameter */
"+FAP", /* T.32 8.5.1.12 - Addressing and polling capabilities parameter */
"+FAR", /* T.31 8.5.1 - Adaptive reception control */
"+FAR", /* T.31 8.5.1 - Adaptive reception control */
"+FBO", /* T.32 8.5.3.4 - Phase C data bit order */
"+FBS", /* T.32 8.5.3.2 - Buffer Size, read only parameter */
"+FBU", /* T.32 8.5.1.10 - HDLC Frame Reporting parameter */
"+FCC", /* T.32 8.5.1.1 - DCE capabilities parameters */
"+FCL", /* T.31 8.5.2 - Carrier loss timeout */
"+FCLASS", /* T.31 8.2 - Capabilities identification and control */
"+FCL", /* T.31 8.5.2 - Carrier loss timeout */
"+FCLASS", /* T.31 8.2 - Capabilities identification and control */
"+FCQ", /* T.32 8.5.2.3 - Copy quality checking parameter */
"+FCR", /* T.32 8.5.1.9 - Capability to receive parameter */
"+FCS", /* T.32 8.5.1.3 - Current Session Results parameters */
"+FCT", /* T.32 8.5.2.6 - DTE phase C timeout parameter */
"+FDD", /* T.31 8.5.3 - Double escape character replacement */
"+FDD", /* T.31 8.5.3 - Double escape character replacement */
"+FDR", /* T.32 8.3.4 - Data reception command */
"+FDT", /* T.32 8.3.3 - Data transmission command */
"+FEA", /* T.32 8.5.3.5 - Phase C received EOL alignment parameter */
@ -253,14 +253,14 @@ const char *wordlist[] =
"+FIE", /* T.32 8.5.2.1 - Procedure interrupt enable parameter */
"+FIP", /* T.32 8.3.6 - Initialize facsimile parameters */
"+FIS", /* T.32 8.5.1.2 - Current session parameters */
"+FIT", /* T.31 8.5.4 - DTE inactivity timeout */
"+FIT", /* T.31 8.5.4 - DTE inactivity timeout */
"+FKS", /* T.32 8.3.5 - Session termination command */
"+FLI", /* T.32 8.5.1.5 - Local ID string parameter, TSI or CSI */
"+FLO", /* T.31 says to implement something similar to +IFC */
"+FLO", /* T.31 says to implement something similar to +IFC */
"+FLP", /* T.32 8.5.1.7 - Indicate document to poll parameter */
"+FMI", /* T.31 says to duplicate +GMI */
"+FMM", /* T.31 says to duplicate +GMM */
"+FMR", /* T.31 says to duplicate +GMR */
"+FMI", /* T.31 says to duplicate +GMI */
"+FMM", /* T.31 says to duplicate +GMM */
"+FMR", /* T.31 says to duplicate +GMR */
"+FMS", /* T.32 8.5.2.9 - Minimum phase C speed parameter */
"+FND", /* T.32 8.5.2.10 - Non-Standard Message Data Indication parameter */
"+FNR", /* T.32 8.5.1.11 - Negotiation message reporting control parameters */
@ -268,44 +268,44 @@ const char *wordlist[] =
"+FPA", /* T.32 8.5.1.13 - Selective polling address parameter */
"+FPI", /* T.32 8.5.1.5 - Local Polling ID String parameter */
"+FPP", /* T.32 8.5.3 - Facsimile packet protocol */
"+FPR", /* T.31 says to implement something similar to +IPR */
"+FPR", /* T.31 says to implement something similar to +IPR */
"+FPS", /* T.32 8.5.2.2 - Page Status parameter */
"+FPW", /* T.32 8.5.1.13 - PassWord parameter (Sending or Polling) */
"+FRH", /* T.31 8.3.6 - HDLC receive */
"+FRM", /* T.31 8.3.4 - Facsimile receive */
"+FRH", /* T.31 8.3.6 - HDLC receive */
"+FRM", /* T.31 8.3.4 - Facsimile receive */
"+FRQ", /* T.32 8.5.2.4 - Receive Quality Thresholds parameters */
"+FRS", /* T.31 8.3.2 - Receive silence */
"+FRS", /* T.31 8.3.2 - Receive silence */
"+FRY", /* T.32 8.5.2.8 - ECM Retry Value parameter */
"+FSA", /* T.32 8.5.1.13 - Subaddress parameter */
"+FSP", /* T.32 8.5.1.8 - Request to poll parameter */
"+FTH", /* T.31 8.3.5 - HDLC transmit */
"+FTM", /* T.31 8.3.3 - Facsimile transmit */
"+FTS", /* T.31 8.3.1 - Transmit silence */
"+GCAP", /* V.250 6.1.9 - Request complete capabilities list */
"+GCI", /* V.250 6.1.10 - Country of installation, */
"+GMI", /* V.250 6.1.4 - Request manufacturer identification */
"+GMM", /* V.250 6.1.5 - Request model identification */
"+GMR", /* V.250 6.1.6 - Request revision identification */
"+GOI", /* V.250 6.1.8 - Request global object identification */
"+GSN", /* V.250 6.1.7 - Request product serial number identification */
"+FTH", /* T.31 8.3.5 - HDLC transmit */
"+FTM", /* T.31 8.3.3 - Facsimile transmit */
"+FTS", /* T.31 8.3.1 - Transmit silence */
"+GCAP", /* V.250 6.1.9 - Request complete capabilities list */
"+GCI", /* V.250 6.1.10 - Country of installation, */
"+GMI", /* V.250 6.1.4 - Request manufacturer identification */
"+GMM", /* V.250 6.1.5 - Request model identification */
"+GMR", /* V.250 6.1.6 - Request revision identification */
"+GOI", /* V.250 6.1.8 - Request global object identification */
"+GSN", /* V.250 6.1.7 - Request product serial number identification */
"+IBC", /* V.80 7.9 - Control of in-band control */
"+IBM", /* V.80 7.10 - In-band MARK idle reporting control */
"+ICF", /* V.250 6.2.11 - DTE-DCE character framing */
"+ICLOK", /* V.250 6.2.14 - Select sync transmit clock source */
"+IDSR", /* V.250 6.2.16 - Select data set ready option */
"+IFC", /* V.250 6.2.12 - DTE-DCE local flow control */
"+ILRR", /* V.250 6.2.13 - DTE-DCE local rate reporting */
"+ILSD", /* V.250 6.2.15 - Select long space disconnect option */
"+IPR", /* V.250 6.2.10 - Fixed DTE rate */
"+IRTS", /* V.250 6.2.17 - Select synchronous mode RTS option */
"+ICF", /* V.250 6.2.11 - DTE-DCE character framing */
"+ICLOK", /* V.250 6.2.14 - Select sync transmit clock source */
"+IDSR", /* V.250 6.2.16 - Select data set ready option */
"+IFC", /* V.250 6.2.12 - DTE-DCE local flow control */
"+ILRR", /* V.250 6.2.13 - DTE-DCE local rate reporting */
"+ILSD", /* V.250 6.2.15 - Select long space disconnect option */
"+IPR", /* V.250 6.2.10 - Fixed DTE rate */
"+IRTS", /* V.250 6.2.17 - Select synchronous mode RTS option */
"+ITF", /* V.80 8.4 - Transmit flow control thresholds */
"+MA", /* V.250 6.4.2 - Modulation automode control */
"+MR", /* V.250 6.4.3 - Modulation reporting control */
"+MS", /* V.250 6.4.1 - Modulation selection */
"+MSC", /* V.250 6.4.8 - Seamless rate change enable */
"+MV18AM", /* V.250 6.4.6 - V.18 answering message editing */
"+MV18P", /* V.250 6.4.7 - Order of probes */
"+MV18R", /* V.250 6.4.5 - V.18 reporting control */
"+MA", /* V.250 6.4.2 - Modulation automode control */
"+MR", /* V.250 6.4.3 - Modulation reporting control */
"+MS", /* V.250 6.4.1 - Modulation selection */
"+MSC", /* V.250 6.4.8 - Seamless rate change enable */
"+MV18AM", /* V.250 6.4.6 - V.18 answering message editing */
"+MV18P", /* V.250 6.4.7 - Order of probes */
"+MV18R", /* V.250 6.4.5 - V.18 reporting control */
"+MV18S", /* V.250 6.4.4 - V.18 selection */
"+PCW", /* V.250 6.8.1 - Call waiting enable (V.92 DCE) */
"+PIG", /* V.250 6.8.5 - PCM upstream ignore */
@ -332,24 +332,24 @@ const char *wordlist[] =
"+SVR", /* V.252 5.5 - Video receive channel indication */
"+SVRR", /* V.252 3.10 - Video indication reporting */
"+SVT", /* V.252 5.6 - Video transmit channel indication */
"+TADR", /* V.250 6.7.2.9 - Local V.54 address */
"+TAL", /* V.250 6.7.2.15 - Local analogue loop */
"+TALS", /* V.250 6.7.2.6 - Analogue loop status */
"+TDLS", /* V.250 6.7.2.7 - Local digital loop status */
"+TE140", /* V.250 6.7.2.1 - Enable ckt 140 */
"+TE141", /* V.250 6.7.2.2 - Enable ckt 141 */
"+TEPAL", /* V.250 6.7.2.5 - Enable front panel analogue loop */
"+TEPDL", /* V.250 6.7.2.4 - Enable front panel RDL */
"+TERDL", /* V.250 6.7.2.3 - Enable RDL from remote */
"+TLDL", /* V.250 6.7.2.13 - Local digital loop */
"+TADR", /* V.250 6.7.2.9 - Local V.54 address */
"+TAL", /* V.250 6.7.2.15 - Local analogue loop */
"+TALS", /* V.250 6.7.2.6 - Analogue loop status */
"+TDLS", /* V.250 6.7.2.7 - Local digital loop status */
"+TE140", /* V.250 6.7.2.1 - Enable ckt 140 */
"+TE141", /* V.250 6.7.2.2 - Enable ckt 141 */
"+TEPAL", /* V.250 6.7.2.5 - Enable front panel analogue loop */
"+TEPDL", /* V.250 6.7.2.4 - Enable front panel RDL */
"+TERDL", /* V.250 6.7.2.3 - Enable RDL from remote */
"+TLDL", /* V.250 6.7.2.13 - Local digital loop */
"+TMO", /* V.250 6.9 - V.59 command */
"+TMODE", /* V.250 6.7.2.10 - Set V.54 mode */
"+TNUM", /* V.250 6.7.2.12 - Errored bit and block counts */
"+TRDL", /* V.250 6.7.2.14 - Request remote digital loop */
"+TRDLS", /* V.250 6.7.2.8 - Remote digital loop status */
"+TRES", /* V.250 6.7.2.17 - Self test result */
"+TSELF", /* V.250 6.7.2.16 - Self test */
"+TTER", /* V.250 6.7.2.11 - Test error rate */
"+TMODE", /* V.250 6.7.2.10 - Set V.54 mode */
"+TNUM", /* V.250 6.7.2.12 - Errored bit and block counts */
"+TRDL", /* V.250 6.7.2.14 - Request remote digital loop */
"+TRDLS", /* V.250 6.7.2.8 - Remote digital loop status */
"+TRES", /* V.250 6.7.2.17 - Self test result */
"+TSELF", /* V.250 6.7.2.16 - Self test */
"+TTER", /* V.250 6.7.2.11 - Test error rate */
"+VAC", /* V.252 4.1 - Set audio code */
"+VACR", /* V.252 6.1 - Audio code report */
"+VBT", /* 3GPP TS 27.007 C.2.2 - Buffer threshold setting */
@ -382,10 +382,10 @@ const char *wordlist[] =
"+VSID", /* Extension - Set the originating number */
"+VSM", /* V.253 10.2.8 - Compression method selection */
"+VSP", /* V.253 10.5.1 - Voice speakerphone state */
"+VTA", /* V.253 10.5.4 - Train acoustic echo-canceller */
"+VTA", /* V.253 10.5.4 - Train acoustic echo-canceller */
"+VTD", /* V.253 10.2.9 - Beep tone duration timer */
"+VTER", /* V.252 6.4 - Simple telephony event report */
"+VTH", /* V.253 10.5.5 - Train line echo-canceller */
"+VTH", /* V.253 10.5.5 - Train line echo-canceller */
"+VTR", /* V.253 10.1.4 - Voice duplex state */
"+VTS", /* V.253 10.1.5 - DTMF and tone generation in voice */
"+VTX", /* V.253 10.1.6 - Transmit data state */
@ -417,27 +417,27 @@ const char *wordlist[] =
"+WS58", /* TIA-678 B.3.1.8 Idle time-out value */
"+WSTL", /* TIA-678 C.5.2 Call session time limit */
";", /* Dummy to absorb semi-colon delimiters in commands */
"A", /* V.250 6.3.5 - Answer */
"D", /* V.250 6.3.1 - Dial */
"E", /* V.250 6.2.4 - Command echo */
"H", /* V.250 6.3.6 - Hook control */
"I", /* V.250 6.1.3 - Request identification information */
"L", /* V.250 6.3.13 - Monitor speaker loudness */
"M", /* V.250 6.3.14 - Monitor speaker mode */
"O", /* V.250 6.3.7 - Return to online data state */
"P", /* V.250 6.3.3 - Select pulse dialling (command) */
"Q", /* V.250 6.2.5 - Result code suppression */
"S0", /* V.250 6.3.8 - Automatic answer */
"S10", /* V.250 6.3.12 - Automatic disconnect delay */
"S3", /* V.250 6.2.1 - Command line termination character */
"S4", /* V.250 6.2.2 - Response formatting character */
"S5", /* V.250 6.2.3 - Command line editing character */
"S6", /* V.250 6.3.9 - Pause before blind dialling */
"S7", /* V.250 6.3.10 - Connection completion timeout */
"S8", /* V.250 6.3.11 - Comma dial modifier time */
"T", /* V.250 6.3.2 - Select tone dialling (command) */
"V", /* V.250 6.2.6 - DCE response format */
"X", /* V.250 6.2.7 - Result code selection and call progress monitoring control */
"A", /* V.250 6.3.5 - Answer */
"D", /* V.250 6.3.1 - Dial */
"E", /* V.250 6.2.4 - Command echo */
"H", /* V.250 6.3.6 - Hook control */
"I", /* V.250 6.1.3 - Request identification information */
"L", /* V.250 6.3.13 - Monitor speaker loudness */
"M", /* V.250 6.3.14 - Monitor speaker mode */
"O", /* V.250 6.3.7 - Return to online data state */
"P", /* V.250 6.3.3 - Select pulse dialling (command) */
"Q", /* V.250 6.2.5 - Result code suppression */
"S0", /* V.250 6.3.8 - Automatic answer */
"S10", /* V.250 6.3.12 - Automatic disconnect delay */
"S3", /* V.250 6.2.1 - Command line termination character */
"S4", /* V.250 6.2.2 - Response formatting character */
"S5", /* V.250 6.2.3 - Command line editing character */
"S6", /* V.250 6.3.9 - Pause before blind dialling */
"S7", /* V.250 6.3.10 - Connection completion timeout */
"S8", /* V.250 6.3.11 - Comma dial modifier time */
"T", /* V.250 6.3.2 - Select tone dialling (command) */
"V", /* V.250 6.2.6 - DCE response format */
"X", /* V.250 6.2.7 - Result code selection and call progress monitoring control */
"Z", /* V.250 6.1.1 - Reset to default configuration */
NULL
};

View File

@ -390,6 +390,12 @@ extern "C"
{
#endif
/*! Get the logging context associated with an ADSI receive context.
\brief Get the logging context associated with an ADSI receive context.
\param s The ADSI receive context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) adsi_rx_get_logging_state(adsi_rx_state_t *s);
/*! \brief Initialise an ADSI receive context.
\param s The ADSI receive context.
\param standard The code for the ADSI standard to be used.
@ -423,6 +429,12 @@ SPAN_DECLARE(int) adsi_rx_free(adsi_rx_state_t *s);
*/
SPAN_DECLARE(int) adsi_rx(adsi_rx_state_t *s, const int16_t amp[], int len);
/*! Get the logging context associated with an ADSI transmit context.
\brief Get the logging context associated with an ADSI transmit context.
\param s The ADSI transmit context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) adsi_tx_get_logging_state(adsi_tx_state_t *s);
/*! \brief Initialise an ADSI transmit context.
\param s The ADSI transmit context.
\param standard The code for the ADSI standard to be used.

View File

@ -167,6 +167,12 @@ SPAN_DECLARE(void) at_interpreter(at_state_t *s, const char *cmd, int len);
SPAN_DECLARE(void) at_set_class1_handler(at_state_t *s, at_class1_handler_t handler, void *user_data);
/*! Get the logging context associated with an AT interpreter context.
\brief Get the logging context associated with an AT interpreter context.
\param s The AT context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) at_get_logging_state(at_state_t *s);
/*! Initialise an AT interpreter context.
\brief Initialise an AT interpreter context.
\param s The AT context.

View File

@ -91,6 +91,8 @@ struct at_state_s
uint8_t rx_data[256];
int rx_data_bytes;
int dte_dce_flow_control;
int dce_dte_flow_control;
int display_call_info;
int call_info_displayed;
at_call_id_t *call_id;

View File

@ -131,8 +131,8 @@ struct fax_modems_state_s
span_tx_handler_t tx_handler;
void *tx_user_data;
/*! The next transmit signal handler, for two stage transmit operations.
E.g. a short silence followed by a modem signal. */
/*! \brief The next transmit signal handler, for two stage transmit operations.
E.g. a short silence followed by a modem signal. */
span_tx_handler_t next_tx_handler;
void *next_tx_user_data;

View File

@ -26,6 +26,40 @@
#if !defined(_SPANDSP_PRIVATE_T31_H_)
#define _SPANDSP_PRIVATE_T31_H_
#define T31_TX_BUF_LEN (4096)
#define T31_TX_BUF_HIGH_TIDE (4096 - 1024)
#define T31_TX_BUF_LOW_TIDE (1024)
#define T31_MAX_HDLC_LEN 284
/*! The maximum length of an HDLC frame buffer. This must be big enough for ECM frames. */
#define T31_T38_MAX_HDLC_LEN 260
/*! The number of HDLC transmit buffers */
#define T31_TX_HDLC_BUFS 256
/*!
T.31 T.38 HDLC buffer.
*/
typedef struct
{
/*! \brief HDLC message buffers. */
uint8_t buf[T31_MAX_HDLC_LEN];
/*! \brief HDLC message lengths. */
int16_t len;
} t31_hdlc_buf_t;
/*!
T.31 T.38 HDLC state.
*/
typedef struct
{
/*! \brief HDLC message buffers. */
t31_hdlc_buf_t buf[T31_TX_HDLC_BUFS];
/*! \brief HDLC buffer number for input. */
int in;
/*! \brief HDLC buffer number for output. */
int out;
} t31_hdlc_state_t;
/*!
Analogue FAX front end channel descriptor. This defines the state of a single working
instance of an analogue line FAX front end.
@ -102,6 +136,8 @@ typedef struct
int extra_bits;
} hdlc_tx;
t31_hdlc_state_t hdlc_from_t31;
/*! \brief TRUE if we are using ECM mode. This is used to select HDLC faking, necessary
with clunky class 1 modems. */
int ecm_mode;
@ -149,6 +185,7 @@ struct t31_state_s
/*! HDLC buffer, for composing an HDLC frame from the computer to the channel. */
struct
{
/*! \brief The HDLC transmit buffer. */
uint8_t buf[T31_MAX_HDLC_LEN];
int len;
int ptr;
@ -158,8 +195,9 @@ struct t31_state_s
/*! Buffer for data from the computer to the channel. */
struct
{
/*! \brief The transmit buffer. */
uint8_t data[T31_TX_BUF_LEN];
/*! \brief The number of bytes stored in transmit buffer. */
/*! \brief The number of bytes stored in the transmit buffer. */
int in_bytes;
/*! \brief The number of bytes sent from the transmit buffer. */
int out_bytes;
@ -169,7 +207,7 @@ struct t31_state_s
int holding;
/*! \brief TRUE when the end of non-ECM data from the computer has been detected. */
int final;
} tx;
} non_ecm_tx;
/*! TRUE if DLE prefix just used */
int dled;

View File

@ -28,6 +28,13 @@
#if !defined(_SPANDSP_PRIVATE_T38_GATEWAY_H_)
#define _SPANDSP_PRIVATE_T38_GATEWAY_H_
/*! The number of HDLC transmit buffers */
#define T38_TX_HDLC_BUFS 256
/*! The maximum length of an HDLC frame buffer. This must be big enough for ECM frames. */
#define T38_MAX_HDLC_LEN 260
/*! The receive buffer length */
#define T38_RX_BUF_LEN 2048
/*!
T.38 gateway T.38 side channel descriptor.
*/
@ -71,9 +78,9 @@ typedef struct
/*! \brief Current pointer into the data buffer. */
int data_ptr;
/*! \brief The current octet being received as non-ECM data. */
unsigned int bit_stream;
uint16_t bit_stream;
/*! \brief The number of bits taken from the modem for the current scan row. This
is used during non-ECM transmission will fill bit removal to see that
is used during non-ECM transmission with fill bit removal to see that
T.38 packet transmissions do not stretch too far apart. */
int bits_absorbed;
/*! \brief The current bit number in the current non-ECM octet. */
@ -86,9 +93,9 @@ typedef struct
the current rate and the current specified packet interval. */
int octets_per_data_packet;
/*! \brief Bits into the non-ECM buffer */
/*! \brief The number of bits into the non-ECM buffer */
int in_bits;
/*! \brief Octets fed out from the non-ECM buffer */
/*! \brief The number of octets fed out from the non-ECM buffer */
int out_octets;
} t38_gateway_to_t38_state_t;
@ -100,11 +107,11 @@ typedef struct
/*! \brief HDLC message buffers. */
uint8_t buf[T38_MAX_HDLC_LEN];
/*! \brief HDLC message lengths. */
int len;
int16_t len;
/*! \brief HDLC message status flags. */
int flags;
uint16_t flags;
/*! \brief HDLC buffer contents. */
int contents;
int16_t contents;
} t38_gateway_hdlc_buf_t;
/*!
@ -114,16 +121,6 @@ typedef struct
{
/*! \brief HDLC message buffers. */
t38_gateway_hdlc_buf_t buf[T38_TX_HDLC_BUFS];
#if 0
/*! \brief HDLC message buffers. */
uint8_t buf[T38_TX_HDLC_BUFS][T38_MAX_HDLC_LEN];
/*! \brief HDLC message lengths. */
int len[T38_TX_HDLC_BUFS];
/*! \brief HDLC message status flags. */
int flags[T38_TX_HDLC_BUFS];
/*! \brief HDLC buffer contents. */
int contents[T38_TX_HDLC_BUFS];
#endif
/*! \brief HDLC buffer number for input. */
int in;
/*! \brief HDLC buffer number for output. */

View File

@ -247,7 +247,7 @@ static __inline__ int16_t saturated_add16(int16_t a, int16_t b)
int16_t z;
__asm__ __volatile__(
" qsub16 %[z],%[a],%[b];\n"
" qadd16 %[z],%[a],%[b];\n"
: [z] "=r" (z)
: [a] "r" (a), [b] "r" (b)
);

View File

@ -44,12 +44,6 @@ typedef struct t31_state_s t31_state_t;
typedef int (*t31_modem_control_handler_t)(t31_state_t *s, void *user_data, int op, const char *num);
#define T31_TX_BUF_LEN (4096)
#define T31_TX_BUF_HIGH_TIDE (4096 - 1024)
#define T31_TX_BUF_LOW_TIDE (1024)
#define T31_MAX_HDLC_LEN 284
#define T31_T38_MAX_HDLC_LEN 260
#if defined(__cplusplus)
extern "C"
{
@ -116,6 +110,11 @@ SPAN_DECLARE(void) t31_set_tep_mode(t31_state_t *s, int use_tep);
*/
SPAN_DECLARE(void) t31_set_t38_config(t31_state_t *s, int without_pacing);
/*! Set audio or T.38 mode.
\brief Set audio or T.38 mode.
\param s The T.31 modem context.
\param t38_mode TRUE for T.38 mode operation. FALSE for audio mode operation.
*/
SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode);
/*! Get a pointer to the logging context associated with a T.31 context.
@ -125,6 +124,18 @@ SPAN_DECLARE(void) t31_set_mode(t31_state_t *s, int t38_mode);
*/
SPAN_DECLARE(logging_state_t *) t31_get_logging_state(t31_state_t *s);
/*! Get a pointer to the AT interpreter context associated with a T.31 context.
\brief Get a pointer to the AT interpreter context associated with a T.31 context.
\param s The T.31 context.
\return A pointer to the AT interpreter context, or NULL.
*/
SPAN_DECLARE(at_state_t *) t31_get_at_state(t31_state_t *s);
/*! Get a pointer to the T.38 core context associated with a T.31 context.
\brief Get a pointer to the T.38 core context associated with a T.31 context.
\param s The T.31 context.
\return A pointer to the T.38 core context, or NULL.
*/
SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s);
/*! Initialise a T.31 context. This must be called before the first

View File

@ -38,13 +38,6 @@ to maximum the tolerance of jitter and packet loss on the IP network.
\section t38_gateway_page_sec_2 How does it work?
*/
/*! The receive buffer length */
#define T38_RX_BUF_LEN 2048
/*! The number of HDLC transmit buffers */
#define T38_TX_HDLC_BUFS 256
/*! The maximum length of an HDLC frame buffer. This must be big enough for ECM frames. */
#define T38_MAX_HDLC_LEN 260
typedef struct t38_gateway_state_s t38_gateway_state_t;
/*!

View File

@ -254,6 +254,12 @@ typedef struct
extern "C" {
#endif
/*! Get the logging context associated with a T.4 receive context.
\brief Get the logging context associated with a T.4 receive context.
\param s The T.4 receive context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t4_rx_get_logging_state(t4_rx_state_t *s);
/*! \brief Prepare for reception of a document.
\param s The T.4 context.
\param file The name of the file to be received.

View File

@ -86,6 +86,12 @@ SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_length(t4_t6_decode_state_t *s);
\return The size of the compressed image, in bits. */
SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s);
/*! Get the logging context associated with a T.4 or T.6 decode context.
\brief Get the logging context associated with a T.4 or T.6 decode context.
\param s The T.4/T.6 context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t4_t6_decode_get_logging_state(t4_t6_decode_state_t *s);
SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width);
/*! \brief Prepare to decode an image in T.4 or T.6 format.

View File

@ -106,6 +106,12 @@ SPAN_DECLARE(void) t4_t6_encode_set_min_bits_per_row(t4_t6_encode_state_t *s, in
greater than the maximum number of 2D rows between each 1D row. */
SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t *s, int max);
/*! Get the logging context associated with a T.4 or T.6 encode context.
\brief Get the logging context associated with a T.4 or T.6 encode context.
\param s The T.4/T.6 context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t4_t6_encode_get_logging_state(t4_t6_encode_state_t *s);
/*! \brief Restart a T.4 or T.6 encode context.
\param s The T.4/T.6 context.
\param image width The image width, in pixels.

View File

@ -217,6 +217,12 @@ extern "C" {
SPAN_DECLARE(void) TIFF_FX_init(void);
#endif
/*! Get the logging context associated with a T.4 transmit context.
\brief Get the logging context associated with a T.4 transmit context.
\param s The T.4 transmit context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t4_tx_get_logging_state(t4_tx_state_t *s);
/*! \brief Prepare for transmission of a document.
\param s The T.4 context.
\param file The name of the file to be sent.

View File

@ -70,6 +70,12 @@ SPAN_DECLARE(int) v42_tx_bit(void *user_data);
SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, modem_status_func_t callback, void *user_data);
/*! Get the logging context associated with a V.42 context.
\brief Get the logging context associated with a V.42 context.
\param s The V.42 context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) v42_get_logging_state(v42_state_t *s);
/*! Initialise a V.42 context.
\param s The V.42 context.
\param calling_party TRUE if caller mode, else answerer mode.

View File

@ -99,6 +99,12 @@ SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *s);
V42BIS_COMPRESSION_MODE_NEVER */
SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode);
/*! Get the logging context associated with a V.42bis context.
\brief Get the logging context associated with a V.42bis context.
\param s The V.42bis context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) v42bis_get_logging_state(v42bis_state_t *s);
/*! Initialise a V.42bis context.
\param s The V.42bis context.
\param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.

View File

@ -173,22 +173,19 @@ enum
T38_TIMED_STEP_HDLC_MODEM_3 = 0x22,
T38_TIMED_STEP_HDLC_MODEM_4 = 0x23,
T38_TIMED_STEP_HDLC_MODEM_5 = 0x24,
T38_TIMED_STEP_FAKE_HDLC_MODEM = 0x30,
T38_TIMED_STEP_FAKE_HDLC_MODEM_2 = 0x31,
T38_TIMED_STEP_FAKE_HDLC_MODEM_3 = 0x32,
T38_TIMED_STEP_FAKE_HDLC_MODEM_4 = 0x33,
T38_TIMED_STEP_FAKE_HDLC_MODEM_5 = 0x34,
T38_TIMED_STEP_CED = 0x40,
T38_TIMED_STEP_CED_2 = 0x41,
T38_TIMED_STEP_CED_3 = 0x42,
T38_TIMED_STEP_CNG = 0x50,
T38_TIMED_STEP_CNG_2 = 0x51,
T38_TIMED_STEP_PAUSE = 0x60,
T38_TIMED_STEP_NO_SIGNAL = 0x70
T38_TIMED_STEP_CED = 0x30,
T38_TIMED_STEP_CED_2 = 0x31,
T38_TIMED_STEP_CED_3 = 0x32,
T38_TIMED_STEP_CNG = 0x40,
T38_TIMED_STEP_CNG_2 = 0x41,
T38_TIMED_STEP_PAUSE = 0x50,
T38_TIMED_STEP_NO_SIGNAL = 0x60
};
static int restart_modem(t31_state_t *s, int new_modem);
static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int ok);
static void hdlc_accept_frame2(void *user_data, const uint8_t *msg, int len, int ok);
static void hdlc_accept_frame3(void *user_data, const uint8_t *msg, int len, int ok);
static int silence_rx(void *user_data, const int16_t amp[], int len);
static int cng_rx(void *user_data, const int16_t amp[], int len);
static void non_ecm_put_bit(void *user_data, int bit);
@ -482,15 +479,31 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC OK (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
if (fe->hdlc_rx.len >= 3 && (fe->hdlc_rx.buf[2] & 0xFE) == T30_DCS)
if (data_type == T38_DATA_V21)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
fe->ecm_mode = (fe->hdlc_rx.len >= 7 && (fe->hdlc_rx.buf[6] & DISBIT3));
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", fe->ecm_mode);
if (fe->hdlc_rx.len >= 3)
{
if ((fe->hdlc_rx.buf[2] & 0xFE) == T30_DCS)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
fe->ecm_mode = (fe->hdlc_rx.len >= 7 && (fe->hdlc_rx.buf[6] & DISBIT3)) ? 1 : 0;
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", fe->ecm_mode);
}
else if (s->t38_fe.ecm_mode == 1 && (fe->hdlc_rx.buf[2] & 0xFE) == T30_CFR)
{
s->t38_fe.ecm_mode = 2;
}
/*endif*/
}
/*endif*/
crc_itu16_append(fe->hdlc_rx.buf, fe->hdlc_rx.len);
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
}
else
{
hdlc_accept_frame2(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
}
/*endif*/
crc_itu16_append(fe->hdlc_rx.buf, fe->hdlc_rx.len);
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
}
/*endif*/
fe->hdlc_rx.len = 0;
@ -511,7 +524,11 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
if (data_type == T38_DATA_V21)
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
else
hdlc_accept_frame2(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
/*endif*/
}
/*endif*/
fe->hdlc_rx.len = 0;
@ -532,16 +549,33 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC OK, sig end (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
if (fe->hdlc_rx.len >= 3 && (fe->hdlc_rx.buf[2] & 0xFE) == T30_DCS)
if (data_type == T38_DATA_V21)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
fe->ecm_mode = (fe->hdlc_rx.len >= 7 && (fe->hdlc_rx.buf[6] & DISBIT3));
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", fe->ecm_mode);
if (fe->hdlc_rx.len >= 3)
{
if ((fe->hdlc_rx.buf[2] & 0xFE) == T30_DCS)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
fe->ecm_mode = (fe->hdlc_rx.len >= 7 && (fe->hdlc_rx.buf[6] & DISBIT3)) ? 1 : 0;
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", fe->ecm_mode);
}
else if (s->t38_fe.ecm_mode == 1 && (fe->hdlc_rx.buf[2] & 0xFE) == T30_CFR)
{
s->t38_fe.ecm_mode = 2;
}
/*endif*/
}
/*endif*/
crc_itu16_append(fe->hdlc_rx.buf, fe->hdlc_rx.len);
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
}
else
{
hdlc_accept_frame2(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
non_ecm_rx_status(s, SIG_STATUS_CARRIER_DOWN);
}
/*endif*/
crc_itu16_append(fe->hdlc_rx.buf, fe->hdlc_rx.len);
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, !fe->rx_data_missing);
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
}
/*endif*/
fe->hdlc_rx.len = 0;
@ -562,8 +596,17 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Type %s - CRC bad, sig end (%s)\n", (fe->hdlc_rx.len >= 3) ? t30_frametype(fe->hdlc_rx.buf[2]) : "???", (fe->rx_data_missing) ? "missing octets" : "clean");
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
if (data_type == T38_DATA_V21)
{
hdlc_accept_frame(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
}
else
{
hdlc_accept_frame2(s, fe->hdlc_rx.buf, fe->hdlc_rx.len, FALSE);
non_ecm_rx_status(s, SIG_STATUS_CARRIER_DOWN);
}
/*endif*/
}
/*endif*/
fe->hdlc_rx.len = 0;
@ -592,19 +635,23 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
fe->hdlc_rx.len = 0;
fe->rx_data_missing = FALSE;
fe->timeout_rx_samples = 0;
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
if (data_type == T38_DATA_V21)
hdlc_rx_status(s, SIG_STATUS_CARRIER_DOWN);
else
non_ecm_rx_status(s, SIG_STATUS_CARRIER_DOWN);
/*endif*/
}
/*endif*/
break;
case T38_FIELD_T4_NON_ECM_DATA:
if (!s->at_state.rx_signal_present)
{
non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED);
s->at_state.rx_signal_present = TRUE;
}
/*endif*/
if (len > 0)
{
if (!s->at_state.rx_signal_present)
{
non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED);
s->at_state.rx_signal_present = TRUE;
}
/*endif*/
bit_reverse(buf2, buf, len);
non_ecm_put(s, buf2, len);
}
@ -691,11 +738,19 @@ static void send_hdlc(void *user_data, const uint8_t *msg, int len)
}
else
{
if (len >= 3 && (s->hdlc_tx.buf[2] & 0xFE) == T30_DCS)
if (len >= 3)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
s->t38_fe.ecm_mode = (len >= 7 && (s->hdlc_tx.buf[6] & DISBIT3));
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", s->t38_fe.ecm_mode);
if ((s->hdlc_tx.buf[2] & 0xFE) == T30_DCS)
{
/* We need to know if ECM is about to be used, so we can fake HDLC stuff. */
s->t38_fe.ecm_mode = (len >= 7 && (s->hdlc_tx.buf[6] & DISBIT3)) ? 1 : 0;
span_log(&s->logging, SPAN_LOG_FLOW, "ECM mode: %d\n", s->t38_fe.ecm_mode);
}
else if (s->t38_fe.ecm_mode == 1 && (s->hdlc_tx.buf[2] & 0xFE) == T30_CFR)
{
s->t38_fe.ecm_mode = 2;
}
/*endif*/
}
/*endif*/
s->t38_fe.hdlc_tx.extra_bits = extra_bits_in_stuffed_frame(msg, len);
@ -973,7 +1028,9 @@ static int stream_hdlc(t31_state_t *s)
return delay;
/*endif*/
delay += t38_core_send_flags_delay(&fe->t38, fe->next_tx_indicator);
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
if (fe->current_tx_data_type == T38_DATA_V21)
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
/*endif*/
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
break;
case T38_TIMED_STEP_HDLC_MODEM_3:
@ -981,8 +1038,26 @@ static int stream_hdlc(t31_state_t *s)
if (s->hdlc_tx.len == 0)
{
/* We don't have a frame ready yet, so wait a little */
delay = US_PER_TX_CHUNK;
break;
if (fe->current_tx_data_type != T38_DATA_V21
&&
s->t38_fe.hdlc_from_t31.in != s->t38_fe.hdlc_from_t31.out)
{
bit_reverse(s->hdlc_tx.buf, s->t38_fe.hdlc_from_t31.buf[s->t38_fe.hdlc_from_t31.out].buf, s->t38_fe.hdlc_from_t31.buf[s->t38_fe.hdlc_from_t31.out].len);
s->hdlc_tx.len = s->t38_fe.hdlc_from_t31.buf[s->t38_fe.hdlc_from_t31.out].len;
s->hdlc_tx.ptr = 0;
if (++s->t38_fe.hdlc_from_t31.out >= T31_TX_HDLC_BUFS)
s->t38_fe.hdlc_from_t31.out = 0;
/*endif*/
if (s->t38_fe.hdlc_from_t31.in == s->t38_fe.hdlc_from_t31.out)
s->hdlc_tx.final = s->non_ecm_tx.final;
/*endif*/
}
else
{
delay = US_PER_TX_CHUNK;
break;
}
/*endif*/
}
/*endif*/
i = s->hdlc_tx.len - s->hdlc_tx.ptr;
@ -1015,7 +1090,9 @@ static int stream_hdlc(t31_state_t *s)
/*endif*/
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
delay = bits_to_us(s, i*8 + fe->hdlc_tx.extra_bits);
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
if (fe->current_tx_data_type == T38_DATA_V21)
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
/*endif*/
}
else
{
@ -1071,7 +1148,9 @@ static int stream_hdlc(t31_state_t *s)
return res;
/*endif*/
fe->timed_step = T38_TIMED_STEP_HDLC_MODEM_3;
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
if (fe->current_tx_data_type == T38_DATA_V21)
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
/*endif*/
/* We should now wait enough time for everything to clear through an analogue modem at the far end. */
delay = bits_to_us(s, fe->hdlc_tx.extra_bits);
}
@ -1112,12 +1191,6 @@ static int stream_hdlc(t31_state_t *s)
}
/*- End of function --------------------------------------------------------*/
static int stream_fake_hdlc(t31_state_t *s)
{
return 0;
}
/*- End of function --------------------------------------------------------*/
static int stream_ced(t31_state_t *s)
{
t31_t38_front_end_state_t *fe;
@ -1237,9 +1310,6 @@ SPAN_DECLARE(int) t31_t38_send_timeout(t31_state_t *s, int samples)
case T38_TIMED_STEP_HDLC_MODEM:
delay = stream_hdlc(s);
break;
case T38_TIMED_STEP_FAKE_HDLC_MODEM:
delay = stream_fake_hdlc(s);
break;
case T38_TIMED_STEP_CED:
delay = stream_ced(s);
break;
@ -1275,9 +1345,9 @@ static int t31_modem_control_handler(at_state_t *s, void *user_data, int op, con
t->call_samples = 0;
break;
case AT_MODEM_CONTROL_ONHOOK:
if (t->tx.holding)
if (t->non_ecm_tx.holding)
{
t->tx.holding = FALSE;
t->non_ecm_tx.holding = FALSE;
/* Tell the application to release further data */
at_modem_control(&t->at_state, AT_MODEM_CONTROL_CTS, (void *) 1);
}
@ -1401,6 +1471,12 @@ static void non_ecm_put(void *user_data, const uint8_t buf[], int len)
int i;
s = (t31_state_t *) user_data;
if (!s->at_state.rx_signal_present)
{
non_ecm_rx_status(s, SIG_STATUS_TRAINING_SUCCEEDED);
s->at_state.rx_signal_present = TRUE;
}
/*endif*/
/* Ignore any fractional bytes which may have accumulated */
for (i = 0; i < len; i++)
{
@ -1432,36 +1508,36 @@ static int non_ecm_get_bit(void *user_data)
s = (t31_state_t *) user_data;
if (s->audio.bit_no <= 0)
{
if (s->tx.out_bytes != s->tx.in_bytes)
if (s->non_ecm_tx.out_bytes != s->non_ecm_tx.in_bytes)
{
/* There is real data available to send */
s->audio.current_byte = s->tx.data[s->tx.out_bytes++];
if (s->tx.out_bytes > T31_TX_BUF_LEN - 1)
s->audio.current_byte = s->non_ecm_tx.data[s->non_ecm_tx.out_bytes++];
if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LEN - 1)
{
s->tx.out_bytes = T31_TX_BUF_LEN - 1;
s->non_ecm_tx.out_bytes = T31_TX_BUF_LEN - 1;
span_log(&s->logging, SPAN_LOG_FLOW, "End of transmit buffer reached!\n");
}
/*endif*/
if (s->tx.holding)
if (s->non_ecm_tx.holding)
{
/* See if the buffer is approaching empty. It might be time to
release flow control. */
if (s->tx.out_bytes > T31_TX_BUF_LOW_TIDE)
if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LOW_TIDE)
{
s->tx.holding = FALSE;
s->non_ecm_tx.holding = FALSE;
/* Tell the application to release further data */
at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1);
}
/*endif*/
}
/*endif*/
s->tx.data_started = TRUE;
s->non_ecm_tx.data_started = TRUE;
}
else
{
if (s->tx.final)
if (s->non_ecm_tx.final)
{
s->tx.final = FALSE;
s->non_ecm_tx.final = FALSE;
/* This will put the modem into its shutdown sequence. When
it has finally shut down, an OK response will be sent. */
return SIG_STATUS_END_OF_DATA;
@ -1469,7 +1545,7 @@ static int non_ecm_get_bit(void *user_data)
/*endif*/
/* Fill with 0xFF bytes at the start of transmission, or 0x00 if we are in
the middle of transmission. This follows T.31 and T.30 practice. */
s->audio.current_byte = (s->tx.data_started) ? 0x00 : 0xFF;
s->audio.current_byte = (s->non_ecm_tx.data_started) ? 0x00 : 0xFF;
}
/*endif*/
s->audio.bit_no = 8;
@ -1490,35 +1566,35 @@ static int non_ecm_get(void *user_data, uint8_t buf[], int len)
s = (t31_state_t *) user_data;
for (i = 0; i < len; i++)
{
if (s->tx.out_bytes != s->tx.in_bytes)
if (s->non_ecm_tx.out_bytes != s->non_ecm_tx.in_bytes)
{
/* There is real data available to send */
buf[i] = s->tx.data[s->tx.out_bytes++];
if (s->tx.out_bytes > T31_TX_BUF_LEN - 1)
buf[i] = s->non_ecm_tx.data[s->non_ecm_tx.out_bytes++];
if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LEN - 1)
{
s->tx.out_bytes = T31_TX_BUF_LEN - 1;
s->non_ecm_tx.out_bytes = T31_TX_BUF_LEN - 1;
span_log(&s->logging, SPAN_LOG_FLOW, "End of transmit buffer reached!\n");
}
/*endif*/
if (s->tx.holding)
if (s->non_ecm_tx.holding)
{
/* See if the buffer is approaching empty. It might be time to release flow control. */
if (s->tx.out_bytes > T31_TX_BUF_LOW_TIDE)
if (s->non_ecm_tx.out_bytes > T31_TX_BUF_LOW_TIDE)
{
s->tx.holding = FALSE;
s->non_ecm_tx.holding = FALSE;
/* Tell the application to release further data */
at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 1);
}
/*endif*/
}
/*endif*/
s->tx.data_started = TRUE;
s->non_ecm_tx.data_started = TRUE;
}
else
{
if (s->tx.final)
if (s->non_ecm_tx.final)
{
s->tx.final = FALSE;
s->non_ecm_tx.final = FALSE;
/* This will put the modem into its shutdown sequence. When
it has finally shut down, an OK response will be sent. */
//return SIG_STATUS_END_OF_DATA;
@ -1527,7 +1603,7 @@ static int non_ecm_get(void *user_data, uint8_t buf[], int len)
/*endif*/
/* Fill with 0xFF bytes at the start of transmission, or 0x00 if we are in
the middle of transmission. This follows T.31 and T.30 practice. */
buf[i] = (s->tx.data_started) ? 0x00 : 0xFF;
buf[i] = (s->non_ecm_tx.data_started) ? 0x00 : 0xFF;
}
/*endif*/
}
@ -1575,6 +1651,11 @@ static void hdlc_tx_underflow(void *user_data)
}
/*- End of function --------------------------------------------------------*/
static void hdlc_tx_underflow2(void *user_data)
{
}
/*- End of function --------------------------------------------------------*/
static void hdlc_rx_status(void *user_data, int status)
{
t31_state_t *s;
@ -1784,6 +1865,131 @@ static void hdlc_accept_frame(void *user_data, const uint8_t *msg, int len, int
}
/*- End of function --------------------------------------------------------*/
static void hdlc_accept_frame2(void *user_data, const uint8_t *msg, int len, int ok)
{
t31_state_t *s;
int i;
int byte_in_progress;
int txbyte;
int pos;
int ptr;
uint16_t crc;
#if defined(_MSC_VER)
uint8_t *buf2 = (uint8_t *) _alloca(2*len + 20);
#else
uint8_t buf2[2*len + 20];
#endif
/* Accept an ECM image mode HDLC frame received as T.38 */
if (len < 0)
return;
/*endif*/
s = (t31_state_t *) user_data;
span_log(&s->logging, SPAN_LOG_FLOW, "Accept2 %d %d\n", len, ok);
crc = crc_itu16_calc(msg, len, 0xFFFF);
/* If the frame is not good, don't flip the CRC to the correct value */
if (ok)
crc ^= 0xFFFF;
/*endif*/
ptr = 0;
buf2[ptr++] = s->t38_fe.hdlc_tx_term.idle_octet;
buf2[ptr++] = s->t38_fe.hdlc_tx_term.idle_octet;
for (pos = 0; pos < len; pos++)
{
byte_in_progress = msg[pos];
i = bottom_bit(byte_in_progress | 0x100);
s->t38_fe.hdlc_tx_term.octets_in_progress <<= i;
byte_in_progress >>= i;
for ( ; i < 8; i++)
{
s->t38_fe.hdlc_tx_term.octets_in_progress = (s->t38_fe.hdlc_tx_term.octets_in_progress << 1) | (byte_in_progress & 0x01);
byte_in_progress >>= 1;
if ((s->t38_fe.hdlc_tx_term.octets_in_progress & 0x1F) == 0x1F)
{
/* There are 5 ones - stuff */
s->t38_fe.hdlc_tx_term.octets_in_progress <<= 1;
s->t38_fe.hdlc_tx_term.num_bits++;
}
/*endif*/
}
/*endfor*/
/* An input byte will generate between 8 and 10 output bits */
buf2[ptr++] = (s->t38_fe.hdlc_tx_term.octets_in_progress >> s->t38_fe.hdlc_tx_term.num_bits) & 0xFF;
if (s->t38_fe.hdlc_tx_term.num_bits >= 8)
{
s->t38_fe.hdlc_tx_term.num_bits -= 8;
buf2[ptr++] = (s->t38_fe.hdlc_tx_term.octets_in_progress >> s->t38_fe.hdlc_tx_term.num_bits) & 0xFF;
}
/*endif*/
}
/*endfor*/
for (pos = 0; pos < 2; pos++)
{
byte_in_progress = crc & 0xFF;
crc >>= 8;
i = bottom_bit(byte_in_progress | 0x100);
s->t38_fe.hdlc_tx_term.octets_in_progress <<= i;
byte_in_progress >>= i;
for ( ; i < 8; i++)
{
s->t38_fe.hdlc_tx_term.octets_in_progress = (s->t38_fe.hdlc_tx_term.octets_in_progress << 1) | (byte_in_progress & 0x01);
byte_in_progress >>= 1;
if ((s->t38_fe.hdlc_tx_term.octets_in_progress & 0x1F) == 0x1F)
{
/* There are 5 ones - stuff */
s->t38_fe.hdlc_tx_term.octets_in_progress <<= 1;
s->t38_fe.hdlc_tx_term.num_bits++;
}
/*endif*/
}
/*endfor*/
/* An input byte will generate between 8 and 10 output bits */
buf2[ptr++] = (s->t38_fe.hdlc_tx_term.octets_in_progress >> s->t38_fe.hdlc_tx_term.num_bits) & 0xFF;
if (s->t38_fe.hdlc_tx_term.num_bits >= 8)
{
s->t38_fe.hdlc_tx_term.num_bits -= 8;
buf2[ptr++] = (s->t38_fe.hdlc_tx_term.octets_in_progress >> s->t38_fe.hdlc_tx_term.num_bits) & 0xFF;
}
/*endif*/
}
/*endif*/
/* Finish off the current byte with some flag bits. If we are at the
start of a byte we need a at least one whole byte of flag to ensure
we cannot end up with back to back frames, and no flag octet at all */
txbyte = (uint8_t) ((s->t38_fe.hdlc_tx_term.octets_in_progress << (8 - s->t38_fe.hdlc_tx_term.num_bits)) | (0x7E >> s->t38_fe.hdlc_tx_term.num_bits));
/* Create a rotated octet of flag for idling... */
s->t38_fe.hdlc_tx_term.idle_octet = (0x7E7E >> s->t38_fe.hdlc_tx_term.num_bits) & 0xFF;
/* ...and the partial flag octet needed to start off the next message. */
s->t38_fe.hdlc_tx_term.octets_in_progress = s->t38_fe.hdlc_tx_term.idle_octet >> (8 - s->t38_fe.hdlc_tx_term.num_bits);
buf2[ptr++] = txbyte;
buf2[ptr++] = s->t38_fe.hdlc_tx_term.idle_octet;
buf2[ptr++] = s->t38_fe.hdlc_tx_term.idle_octet;
bit_reverse(buf2, buf2, ptr);
non_ecm_put(s, buf2, ptr);
}
/*- End of function --------------------------------------------------------*/
static void hdlc_accept_frame3(void *user_data, const uint8_t *msg, int len, int ok)
{
t31_state_t *s;
/* Accept an ECM image mode HDLC frame received as a bit stream from the FAX software,
and to be send as T.38 HDLC data. */
if (len < 0)
return;
/*endif*/
s = (t31_state_t *) user_data;
memcpy(s->t38_fe.hdlc_from_t31.buf[s->t38_fe.hdlc_from_t31.in].buf, msg, len);
s->t38_fe.hdlc_from_t31.buf[s->t38_fe.hdlc_from_t31.in].len = len;
if (++s->t38_fe.hdlc_from_t31.in >= T31_TX_HDLC_BUFS)
s->t38_fe.hdlc_from_t31.in = 0;
/*endif*/
}
/*- End of function --------------------------------------------------------*/
static void t31_v21_rx(t31_state_t *s)
{
s->at_state.ok_is_pending = FALSE;
@ -1809,7 +2015,7 @@ static int restart_modem(t31_state_t *s, int new_modem)
/*endif*/
queue_flush(s->rx_queue);
s->modem = new_modem;
s->tx.final = FALSE;
s->non_ecm_tx.final = FALSE;
s->at_state.rx_signal_present = FALSE;
s->at_state.rx_trained = FALSE;
s->audio.modems.rx_trained = FALSE;
@ -1943,15 +2149,15 @@ static int restart_modem(t31_state_t *s, int new_modem)
}
/*endswitch*/
set_octets_per_data_packet(s, s->bit_rate);
s->t38_fe.timed_step = (s->t38_fe.ecm_mode) ? T38_TIMED_STEP_FAKE_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
s->t38_fe.timed_step = (s->t38_fe.ecm_mode == 2) ? T38_TIMED_STEP_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
}
else
{
fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc);
}
/*endif*/
s->tx.out_bytes = 0;
s->tx.data_started = FALSE;
s->non_ecm_tx.out_bytes = 0;
s->non_ecm_tx.data_started = FALSE;
s->at_state.transmit = TRUE;
break;
case FAX_MODEM_V27TER_TX:
@ -1970,15 +2176,15 @@ static int restart_modem(t31_state_t *s, int new_modem)
}
/*endswitch*/
set_octets_per_data_packet(s, s->bit_rate);
s->t38_fe.timed_step = (s->t38_fe.ecm_mode) ? T38_TIMED_STEP_FAKE_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
s->t38_fe.timed_step = (s->t38_fe.ecm_mode == 2) ? T38_TIMED_STEP_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
}
else
{
fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc);
}
/*endif*/
s->tx.out_bytes = 0;
s->tx.data_started = FALSE;
s->non_ecm_tx.out_bytes = 0;
s->non_ecm_tx.data_started = FALSE;
s->at_state.transmit = TRUE;
break;
case FAX_MODEM_V29_TX:
@ -1997,15 +2203,15 @@ static int restart_modem(t31_state_t *s, int new_modem)
}
/*endswitch*/
set_octets_per_data_packet(s, s->bit_rate);
s->t38_fe.timed_step = (s->t38_fe.ecm_mode) ? T38_TIMED_STEP_FAKE_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
s->t38_fe.timed_step = (s->t38_fe.ecm_mode == 2) ? T38_TIMED_STEP_HDLC_MODEM : T38_TIMED_STEP_NON_ECM_MODEM;
}
else
{
fax_modems_start_fast_modem(t, s->modem, s->bit_rate, s->short_train, use_hdlc);
}
/*endif*/
s->tx.out_bytes = 0;
s->tx.data_started = FALSE;
s->non_ecm_tx.out_bytes = 0;
s->non_ecm_tx.data_started = FALSE;
s->at_state.transmit = TRUE;
break;
case FAX_MODEM_SILENCE_TX:
@ -2060,8 +2266,8 @@ static int restart_modem(t31_state_t *s, int new_modem)
/*endswitch*/
s->audio.bit_no = 0;
s->audio.current_byte = 0xFF;
s->tx.in_bytes = 0;
s->tx.out_bytes = 0;
s->non_ecm_tx.in_bytes = 0;
s->non_ecm_tx.out_bytes = 0;
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -2089,7 +2295,7 @@ static __inline__ void dle_unstuff_hdlc(t31_state_t *s, const char *stuffed, int
}
/*endif*/
}
else if (stuffed[i] == SUB)
else if (s->at_state.p.double_escape && stuffed[i] == SUB)
{
s->hdlc_tx.buf[s->hdlc_tx.len++] = DLE;
s->hdlc_tx.buf[s->hdlc_tx.len++] = DLE;
@ -2114,10 +2320,10 @@ static __inline__ void dle_unstuff_hdlc(t31_state_t *s, const char *stuffed, int
}
/*- End of function --------------------------------------------------------*/
static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len)
static __inline__ void dle_unstuff_fake_hdlc(t31_state_t *s, const char *stuffed, int len)
{
int i;
for (i = 0; i < len; i++)
{
if (s->dled)
@ -2125,20 +2331,72 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len)
s->dled = FALSE;
if (stuffed[i] == ETX)
{
s->tx.final = TRUE;
s->non_ecm_tx.final = TRUE;
t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND);
return;
}
else if (s->at_state.p.double_escape && stuffed[i] == SUB)
{
hdlc_rx_put_byte(&s->t38_fe.hdlc_rx_term, bit_reverse8(DLE));
hdlc_rx_put_byte(&s->t38_fe.hdlc_rx_term, bit_reverse8(DLE));
}
else
{
hdlc_rx_put_byte(&s->t38_fe.hdlc_rx_term, bit_reverse8(stuffed[i]));
}
/*endif*/
}
else
{
if (stuffed[i] == DLE)
s->dled = TRUE;
else
hdlc_rx_put_byte(&s->t38_fe.hdlc_rx_term, bit_reverse8(stuffed[i]));
/*endif*/
}
/*endif*/
}
/*endfor*/
}
/*- End of function --------------------------------------------------------*/
static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len)
{
int i;
for (i = 0; i < len; i++)
{
if (s->dled)
{
s->dled = FALSE;
if (stuffed[i] == ETX)
{
s->non_ecm_tx.final = TRUE;
t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND);
return;
}
/*endif*/
if (s->at_state.p.double_escape && stuffed[i] == SUB)
{
s->non_ecm_tx.data[s->non_ecm_tx.in_bytes++] = DLE;
s->non_ecm_tx.data[s->non_ecm_tx.in_bytes++] = DLE;
}
else
{
s->non_ecm_tx.data[s->non_ecm_tx.in_bytes++] = stuffed[i];
}
/*endif*/
}
else if (stuffed[i] == DLE)
else
{
s->dled = TRUE;
continue;
if (stuffed[i] == DLE)
s->dled = TRUE;
else
s->non_ecm_tx.data[s->non_ecm_tx.in_bytes++] = stuffed[i];
/*endif*/
}
/*endif*/
s->tx.data[s->tx.in_bytes++] = stuffed[i];
if (s->tx.in_bytes > T31_TX_BUF_LEN - 1)
if (s->non_ecm_tx.in_bytes > T31_TX_BUF_LEN - 2)
{
/* Oops. We hit the end of the buffer. Give up. Loose stuff. :-( */
span_log(&s->logging, SPAN_LOG_FLOW, "No room in buffer for new data!\n");
@ -2147,12 +2405,12 @@ static __inline__ void dle_unstuff(t31_state_t *s, const char *stuffed, int len)
/*endif*/
}
/*endfor*/
if (!s->tx.holding)
if (!s->non_ecm_tx.holding)
{
/* See if the buffer is approaching full. We might need to apply flow control. */
if (s->tx.in_bytes > T31_TX_BUF_HIGH_TIDE)
if (s->non_ecm_tx.in_bytes > T31_TX_BUF_HIGH_TIDE)
{
s->tx.holding = TRUE;
s->non_ecm_tx.holding = TRUE;
/* Tell the application to hold further data */
at_modem_control(&s->at_state, AT_MODEM_CONTROL_CTS, (void *) 0);
}
@ -2402,7 +2660,7 @@ SPAN_DECLARE(void) t31_call_event(t31_state_t *s, int event)
SPAN_DECLARE(int) t31_at_rx_free_space(t31_state_t *s)
{
return T31_TX_BUF_LEN - (s->tx.in_bytes - s->tx.out_bytes) - 1;
return T31_TX_BUF_LEN - (s->non_ecm_tx.in_bytes - s->non_ecm_tx.out_bytes) - 1;
}
/*- End of function --------------------------------------------------------*/
@ -2441,15 +2699,19 @@ SPAN_DECLARE(int) t31_at_rx(t31_state_t *s, const char *t, int len)
dle_unstuff_hdlc(s, t, len);
break;
case AT_MODE_STUFFED:
if (s->tx.out_bytes)
if (s->non_ecm_tx.out_bytes)
{
/* Make room for new data in existing data buffer. */
s->tx.in_bytes -= s->tx.out_bytes;
memmove(&s->tx.data[0], &s->tx.data[s->tx.out_bytes], s->tx.in_bytes);
s->tx.out_bytes = 0;
s->non_ecm_tx.in_bytes -= s->non_ecm_tx.out_bytes;
memmove(&s->non_ecm_tx.data[0], &s->non_ecm_tx.data[s->non_ecm_tx.out_bytes], s->non_ecm_tx.in_bytes);
s->non_ecm_tx.out_bytes = 0;
}
/*endif*/
dle_unstuff(s, t, len);
if (s->t38_fe.ecm_mode == 2)
dle_unstuff_fake_hdlc(s, t, len);
else
dle_unstuff(s, t, len);
/*endif*/
break;
case AT_MODE_CONNECTED:
/* TODO: Implement for data modem operation */
@ -2674,6 +2936,12 @@ SPAN_DECLARE(logging_state_t *) t31_get_logging_state(t31_state_t *s)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(at_state_t *) t31_get_at_state(t31_state_t *s)
{
return &s->at_state;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(t38_core_state_t *) t31_get_t38_core_state(t31_state_t *s)
{
return &s->t38_fe.t38;
@ -2707,8 +2975,8 @@ static int t31_t38_fe_init(t31_state_t *t,
t->hdlc_tx.ptr = 0;
hdlc_tx_init(&s->hdlc_tx_term, FALSE, 1, FALSE, NULL, NULL);
hdlc_rx_init(&s->hdlc_rx_term, FALSE, TRUE, 2, NULL, NULL);
hdlc_tx_init(&s->hdlc_tx_term, FALSE, 1, FALSE, hdlc_tx_underflow2, s);
hdlc_rx_init(&s->hdlc_rx_term, FALSE, TRUE, 2, hdlc_accept_frame3, t);
return 0;
}
/*- End of function --------------------------------------------------------*/

View File

@ -1075,7 +1075,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
of the incrementing sequence numbers. We need to filter them here in a context sensitive manner. */
if (t->current_rx_data_type != data_type || t->current_rx_field_type != field_type)
{
span_log(&s->logging, SPAN_LOG_FLOW, "HDLC frame type %s - CRC good\n", t30_frametype(hdlc_buf->buf[2]));
span_log(&s->logging, SPAN_LOG_FLOW, "HDLC frame type %s - CRC OK\n", t30_frametype(hdlc_buf->buf[2]));
if (hdlc_buf->contents != (data_type | FLAG_DATA))
{
queue_missing_indicator(s, data_type);
@ -1593,7 +1593,7 @@ static void non_ecm_put_bit(void *user_data, int bit)
{
t38_gateway_state_t *t;
t38_gateway_to_t38_state_t *s;
if (bit < 0)
{
non_ecm_rx_status(user_data, bit);
@ -1622,7 +1622,7 @@ static void non_ecm_remove_fill_and_put_bit(void *user_data, int bit)
{
t38_gateway_state_t *t;
t38_gateway_to_t38_state_t *s;
if (bit < 0)
{
non_ecm_rx_status(user_data, bit);

View File

@ -711,6 +711,12 @@ SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) t4_rx_get_logging_state(t4_rx_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int output_encoding)
{
int allocated;

View File

@ -806,6 +806,12 @@ SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) t4_t6_decode_get_logging_state(t4_t6_decode_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width)
{
int bytes_per_row;

View File

@ -1088,6 +1088,12 @@ SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) t4_t6_encode_get_logging_state(t4_t6_encode_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) t4_t6_encode_restart(t4_t6_encode_state_t *s, int image_width)
{
/* Allow for pages being of different width. */

View File

@ -1136,6 +1136,12 @@ SPAN_DECLARE(int) t4_tx_end_page(t4_tx_state_t *s)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) t4_tx_get_logging_state(t4_tx_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int start_page, int stop_page)
{
int allocated;

View File

@ -62,7 +62,7 @@ static __inline__ int flag_is_changeable_p(uint32_t flag)
uint32_t f1;
uint32_t f2;
__asm__ __volatile__ (
__asm__ __volatile__(
" pushfl\n"
" pushfl\n"
" popl %0\n"
@ -94,7 +94,7 @@ int has_MMX(void)
if (!have_cpuid_p())
return 0;
/*endif*/
__asm__ __volatile__ (
__asm__ __volatile__(
" push %%ebx;\n"
" mov $1,%%eax;\n"
" cpuid;\n"
@ -118,7 +118,7 @@ int has_SIMD(void)
if (!have_cpuid_p())
return 0;
/*endif*/
__asm__ __volatile__ (
__asm__ __volatile__(
" push %%ebx;\n"
" mov $1,%%eax;\n"
" cpuid;\n"
@ -142,7 +142,7 @@ int has_SIMD2(void)
if (!have_cpuid_p())
return 0;
/*endif*/
__asm__ __volatile__ (
__asm__ __volatile__(
" push %%ebx;\n"
" mov $1,%%eax;\n"
" cpuid;\n"
@ -166,7 +166,7 @@ int has_3DNow(void)
if (!have_cpuid_p())
return 0;
/*endif*/
__asm__ __volatile__ (
__asm__ __volatile__(
" push %%ebx;\n"
" mov $0x80000000,%%eax;\n"
" cpuid;\n"

View File

@ -1456,6 +1456,12 @@ SPAN_DECLARE(int) v42_get_far_busy_status(v42_state_t *s)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) v42_get_logging_state(v42_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) v42_set_status_callback(v42_state_t *s, modem_status_func_t status_handler, void *user_data)
{
s->lapm.status_handler = status_handler;

View File

@ -708,6 +708,12 @@ SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(logging_state_t *) v42bis_get_logging_state(v42bis_state_t *s)
{
return &s->logging;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(v42bis_state_t *) v42bis_init(v42bis_state_t *s,
int negotiated_p0,
int negotiated_p1,

View File

@ -103,6 +103,7 @@ noinst_PROGRAMS = ademco_contactid_tests \
super_tone_rx_tests \
super_tone_tx_tests \
swept_tone_tests \
t31_pseudo_terminal_tests \
t31_tests \
t35_tests \
t38_core_tests \
@ -297,6 +298,9 @@ super_tone_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR
swept_tone_tests_SOURCES = swept_tone_tests.c
swept_tone_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
t31_pseudo_terminal_tests_SOURCES = t31_pseudo_terminal_tests.c fax_utils.c pseudo_terminals.c
t31_pseudo_terminal_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim -lspandsp -lutil
t31_tests_SOURCES = t31_tests.c fax_utils.c media_monitor.cpp
t31_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp

View File

@ -29,9 +29,6 @@
\section ademco_contactid_tests_page_sec_2 How does it work?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -43,10 +40,6 @@
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
//#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -34,9 +34,6 @@ tests, these tests do not include line modelling.
\section adsi_tests_page_sec_2 How does it work?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -48,16 +45,12 @@ tests, these tests do not include line modelling.
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
#define OUTPUT_FILE_NAME "adsi.wav"
#define OUTPUT_FILE_NAME "adsi.wav"
#define BLOCK_LEN 160
#define BLOCK_LEN 160
#define MITEL_DIR "../test-data/mitel/"
#define BELLCORE_DIR "../test-data/bellcore/"
@ -808,10 +801,10 @@ int main(int argc, char *argv[])
current_standard = test_standard;
rx_adsi = adsi_rx_init(NULL, current_standard, put_adsi_msg, NULL);
#if 0
span_log_set_level(rx_adsi.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(rx_adsi.logging, "ADSI");
#endif
span_log_set_level(adsi_rx_get_logging_state(rx_adsi), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(adsi_rx_get_logging_state(rx_adsi), "ADSI");
for (;;)
{
len = sf_readf_short(inhandle, amp, BLOCK_LEN);

View File

@ -38,9 +38,7 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -42,7 +42,6 @@ These tests exercise all the commands which should be understood by the AT inter
#include <assert.h>
#include <sndfile.h>
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include "spandsp.h"
#define DLE 0x10
@ -78,14 +77,14 @@ static const struct command_response_s general_test_seq[] =
{"AT+FCLASS=?\r", "\r\n0,1,1.0\r\n\r\nOK\r\n"},
/* Try all the commands */
{"AT&C\r", "\r\nOK\r\n"}, /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
{"AT&D\r", "\r\nOK\r\n"}, /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
{"AT&F\r", "\r\nOK\r\n"}, /* V.250 6.1.2 - Set to factory-defined configuration */
{"AT&C\r", "\r\nOK\r\n"}, /* V.250 6.2.8 - Circuit 109 (received line signal detector), behaviour */
{"AT&D\r", "\r\nOK\r\n"}, /* V.250 6.2.9 - Circuit 108 (data terminal ready) behaviour */
{"AT&F\r", "\r\nOK\r\n"}, /* V.250 6.1.2 - Set to factory-defined configuration */
{"ATE0\r", "ATE0\r\r\nOK\r\n"}, /* Counteract the effects of the above */
{"AT+A8E=?\r", "\r\n+A8E:(0-6),(0-5),(00-FF)\r\n\r\nOK\r\n"}, /* V.251 5.1 - V.8 and V.8bis operation controls */
{"AT+A8M\r", "\r\nOK\r\n"}, /* V.251 5.2 - Send V.8 menu signals */
{"AT+A8T=?\r", "\r\n+A8T:(0-10)\r\n\r\nOK\r\n"}, /* V.251 5.3 - Send V.8bis signal and/or message(s) */
{"AT+ASTO=?\r", "\r\n+ASTO:\r\n\r\nOK\r\n"}, /* V.250 6.3.15 - Store telephone number */
{"AT+ASTO=?\r", "\r\n+ASTO:\r\n\r\nOK\r\n"}, /* V.250 6.3.15 - Store telephone number */
{"AT+CAAP=?\r", "\r\n+CAAP:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 7.25 - Automatic answer for eMLPP Service */
{"AT+CACM=?\r", "\r\n+CACM:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 8.25 - Accumulated call meter */
{"AT+CACSP=?\r", "\r\n+CACSP:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 11.1.7 - Voice Group or Voice Broadcast Call State Attribute Presentation */
@ -214,120 +213,122 @@ static const struct command_response_s general_test_seq[] =
{"AT+CV120=?\r", "\r\n+CV120:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 6.21 - V.120 rate adaption protocol */
{"AT+CVHU=?\r", "\r\n+CVHU:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 6.20 - Voice Hangup Control */
{"AT+CVIB=?\r", "\r\n+CVIB:\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 8.22 - Vibrator mode */
{"AT+DR=?\r", "\r\n+DR:\r\n\r\nOK\r\n"}, /* V.250 6.6.2 - Data compression reporting */
{"AT+DS=?\r", "\r\n+DS:\r\n\r\nOK\r\n"}, /* V.250 6.6.1 - Data compression */
{"AT+EB=?\r", "\r\n+EB:\r\n\r\nOK\r\n"}, /* V.250 6.5.2 - Break handling in error control operation */
{"AT+EFCS=?\r", "\r\n+EFCS:(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.5.4 - 32-bit frame check sequence */
{"AT+DR=?\r", "\r\n+DR:\r\n\r\nOK\r\n"}, /* V.250 6.6.2 - Data compression reporting */
{"AT+DS=?\r", "\r\n+DS:\r\n\r\nOK\r\n"}, /* V.250 6.6.1 - Data compression */
{"AT+EB=?\r", "\r\n+EB:\r\n\r\nOK\r\n"}, /* V.250 6.5.2 - Break handling in error control operation */
{"AT+EFCS=?\r", "\r\n+EFCS:(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.5.4 - 32-bit frame check sequence */
{"AT+EFCS?\r", "\r\n+EFCS:0\r\n\r\nOK\r\n"},
{"AT+EFRAM=?\r", "\r\n+EFRAM:(1-65535),(1-65535)\r\n\r\nOK\r\n"},
/* V.250 6.5.8 - Frame length */
{"AT+ER=?\r", "\r\n+ER:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.5.5 - Error control reporting */
{"AT+ES=?\r", "\r\n+ES:(0-7),(0-4),(0-9)\r\n\r\nOK\r\n"}, /* V.250 6.5.1 - Error control selection */
/* V.250 6.5.8 - Frame length */
{"AT+ER=?\r", "\r\n+ER:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.5.5 - Error control reporting */
{"AT+ES=?\r", "\r\n+ES:(0-7),(0-4),(0-9)\r\n\r\nOK\r\n"}, /* V.250 6.5.1 - Error control selection */
{"AT+ES?\r", "\r\n+ES:0,0,0\r\n\r\nOK\r\n"},
{"AT+ESA=?\r", "\r\n+ESA:(0-2),(0-1),(0-1),(0-1),(0-2),(0-1),(0-255),(0-255)\r\n\r\nOK\r\n"},
/* V.80 8.2 - Synchronous access mode configuration */
{"AT+ESA?\r", "\r\n+ESA:0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"},
{"AT+ESR\r", "\r\nOK\r\n"}, /* V.250 6.5.3 - Selective repeat */
{"AT+ETBM=?\r", "\r\n+ETBM:(0-2),(0-2),(0-30)\r\n\r\nOK\r\n"}, /* T.31 8.5.1 - Adaptive reception control */
{"AT+ESR\r", "\r\nOK\r\n"}, /* V.250 6.5.3 - Selective repeat */
{"AT+ETBM=?\r", "\r\n+ETBM:(0-2),(0-2),(0-30)\r\n\r\nOK\r\n"}, /* T.31 8.5.1 - Adaptive reception control */
{"AT+ETBM?\r", "\r\n+ETBM:0,0\r\n\r\nOK\r\n"},
{"AT+EWIND=?\r", "\r\n+EWIND:(1-127),(1-127)\r\n\r\nOK\r\n"}, /* V.250 6.5.7 - Window size */
{"AT+EWIND=?\r", "\r\n+EWIND:(1-127),(1-127)\r\n\r\nOK\r\n"}, /* V.250 6.5.7 - Window size */
{"AT+EWIND?\r", "\r\n+EWIND:0,0\r\n\r\nOK\r\n"},
{"AT+F34=?\r", "\r\n+F34:(0-14),(0-14),(0-2),(0-14),(0-14)\r\n\r\nOK\r\n"},
/* T.31 B.6.1 - Initial V.34 rate controls for FAX */
{"AT+F34?\r", "\r\n+F34:0,0,0,0,0\r\n\r\nOK\r\n"},
{"AT+FAR=?\r", "\r\n0,1\r\n\r\nOK\r\n"}, /* T.31 8.5.1 - Adaptive reception control */
{"AT+FAR=?\r", "\r\n0,1\r\n\r\nOK\r\n"}, /* T.31 8.5.1 - Adaptive reception control */
{"AT+FAR?\r", "\r\n0\r\n\r\nOK\r\n"},
{"AT+FCL=?\r", "\r\n(0-255)\r\n\r\nOK\r\n"}, /* T.31 8.5.2 - Carrier loss timeout */
{"AT+FCLASS=?\r", "\r\n0,1,1.0\r\n\r\nOK\r\n"}, /* T.31 8.2 - Capabilities identification and control */
{"AT+FCL=?\r", "\r\n(0-255)\r\n\r\nOK\r\n"}, /* T.31 8.5.2 - Carrier loss timeout */
{"AT+FCLASS=?\r", "\r\n0,1,1.0\r\n\r\nOK\r\n"}, /* T.31 8.2 - Capabilities identification and control */
{"AT+FCLASS?\r", "\r\n1\r\n\r\nOK\r\n"},
{"AT+FDD=?\r", "\r\n(0,1)\r\n\r\nOK\r\n"}, /* T.31 8.5.3 - Double escape character replacement */
{"AT+FDD=?\r", "\r\n(0,1)\r\n\r\nOK\r\n"}, /* T.31 8.5.3 - Double escape character replacement */
{"AT+FDD?\r", "\r\n0\r\n\r\nOK\r\n"},
{"AT+FIT=?\r", "\r\n+FIT:(0-255),(0-1)\r\n\r\nOK\r\n"}, /* T.31 8.5.4 - DTE inactivity timeout */
{"AT+FIT=?\r", "\r\n+FIT:(0-255),(0-1)\r\n\r\nOK\r\n"}, /* T.31 8.5.4 - DTE inactivity timeout */
{"AT+FIT?\r", "\r\n+FIT:0,0\r\n\r\nOK\r\n"},
{"AT+FLO\r", "\r\nOK\r\n"}, /* T.31 says to implement something similar to +IFC */
{"AT+FMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMI */
{"AT+FMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMM */
{"AT+FMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMR */
{"AT+FPR=?\r", "\r\n115200\r\n\r\nOK\r\n"}, /* T.31 says to implement something similar to +IPR */
{"AT+FLO=?\r", "\r\n+FLO:(0-2)\r\n\r\nOK\r\n"}, /* T.31 says to implement something similar to +IFC */
{"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"},
{"AT+FMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMI */
{"AT+FMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMM */
{"AT+FMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMR */
{"AT+FPR=?\r", "\r\n115200\r\n\r\nOK\r\n"}, /* T.31 says to implement something similar to +IPR */
{"AT+FPR?\r", "\r\n0\r\n\r\nOK\r\n"},
{"AT+FRH=?\r", "\r\n3\r\n\r\nOK\r\n"}, /* T.31 8.3.6 - HDLC receive */
{"AT+FRH=?\r", "\r\n3\r\n\r\nOK\r\n"}, /* T.31 8.3.6 - HDLC receive */
{"AT+FRH?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+FRM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.4 - Facsimile receive */
{"AT+FRM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.4 - Facsimile receive */
{"AT+FRM?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+FRS=?\r", "\r\n0-255\r\n\r\nOK\r\n"}, /* T.31 8.3.2 - Receive silence */
{"AT+FRS=?\r", "\r\n0-255\r\n\r\nOK\r\n"}, /* T.31 8.3.2 - Receive silence */
{"AT+FRS?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+FTH=?\r", "\r\n3\r\n\r\nOK\r\n"}, /* T.31 8.3.5 - HDLC transmit */
{"AT+FTH=?\r", "\r\n3\r\n\r\nOK\r\n"}, /* T.31 8.3.5 - HDLC transmit */
{"AT+FTH?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+FTM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.3 - Facsimile transmit */
{"AT+FTM=?\r", "\r\n24,48,72,73,74,96,97,98,121,122,145,146\r\n\r\nOK\r\n"}, /* T.31 8.3.3 - Facsimile transmit */
{"AT+FTM?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+FTS=?\r", "\r\n0-255\r\n\r\nOK\r\n"}, /* T.31 8.3.1 - Transmit silence */
{"AT+FTS=?\r", "\r\n0-255\r\n\r\nOK\r\n"}, /* T.31 8.3.1 - Transmit silence */
{"AT+FTS?\r", "\r\n-1\r\n\r\nOK\r\n"},
{"AT+GCAP\r", "\r\nOK\r\n"}, /* V.250 6.1.9 - Request complete capabilities list */
{"AT+GCI=?\r", "\r\n+GCI:(00-FF)\r\n\r\nOK\r\n"}, /* V.250 6.1.10 - Country of installation, */
{"AT+GCAP\r", "\r\nOK\r\n"}, /* V.250 6.1.9 - Request complete capabilities list */
{"AT+GCI=?\r", "\r\n+GCI:(00-FF)\r\n\r\nOK\r\n"}, /* V.250 6.1.10 - Country of installation, */
{"AT+GCI?\r", "\r\n+GCI:00\r\n\r\nOK\r\n"},
{"AT+GMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"}, /* V.250 6.1.4 - Request manufacturer identification */
{"AT+GMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* V.250 6.1.5 - Request model identification */
{"AT+GMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* V.250 6.1.6 - Request revision identification */
{"AT+GOI\r", "\r\nOK\r\n"}, /* V.250 6.1.8 - Request global object identification */
{"AT+GSN?\r", "\r\n42\r\n\r\nOK\r\n"}, /* V.250 6.1.7 - Request product serial number identification */
{"AT+GMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"}, /* V.250 6.1.4 - Request manufacturer identification */
{"AT+GMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* V.250 6.1.5 - Request model identification */
{"AT+GMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* V.250 6.1.6 - Request revision identification */
{"AT+GOI\r", "\r\nOK\r\n"}, /* V.250 6.1.8 - Request global object identification */
{"AT+GSN?\r", "\r\n42\r\n\r\nOK\r\n"}, /* V.250 6.1.7 - Request product serial number identification */
{"AT+IBC=?\r", "\r\n+IBC:(0-2),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0.1),(0,1)\r\n\r\nOK\r\n"},
/* V.80 7.9 - Control of in-band control */
{"AT+IBC?\r", "\r\n+IBC:0,0,0,0,0,0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"},
{"AT+IBM=?\r", "\r\n+IBM:(0-7),(0-255),(0-255)\r\n\r\nOK\r\n"}, /* V.80 7.10 - In-band MARK idle reporting control */
{"AT+IBM?\r", "\r\n+IBM:0,0,0\r\n\r\nOK\r\n"},
{"AT+ICF?\r", "\r\n+ICF:0,0\r\n\r\nOK\r\n"}, /* V.250 6.2.11 - DTE-DCE character framing */
{"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"}, /* V.250 6.2.14 - Select sync transmit clock source */
{"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"}, /* V.250 6.2.16 - Select data set ready option */
{"AT+IFC\r", "\r\nOK\r\n"}, /* V.250 6.2.12 - DTE-DCE local flow control */
{"AT+ILRR\r", "\r\nOK\r\n"}, /* V.250 6.2.13 - DTE-DCE local rate reporting */
{"AT+ILSD=?\r", "\r\n+ILSD:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.2.15 - Select long space disconnect option */
{"AT+ICF?\r", "\r\n+ICF:0,0\r\n\r\nOK\r\n"}, /* V.250 6.2.11 - DTE-DCE character framing */
{"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"}, /* V.250 6.2.14 - Select sync transmit clock source */
{"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"}, /* V.250 6.2.16 - Select data set ready option */
{"AT+IFC=?\r", "\r\n+IFC:(0-2),(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.2.12 - DTE-DCE local flow control */
{"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"},
{"AT+ILRR\r", "\r\nOK\r\n"}, /* V.250 6.2.13 - DTE-DCE local rate reporting */
{"AT+ILSD=?\r", "\r\n+ILSD:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.2.15 - Select long space disconnect option */
{"AT+ILSD?\r", "\r\n+ILSD:0\r\n\r\nOK\r\n"},
{"AT+IPR=?\r", "\r\n+IPR:(115200),(115200)\r\n\r\nOK\r\n"}, /* V.250 6.2.10 - Fixed DTE rate */
{"AT+IPR=?\r", "\r\n+IPR:(115200),(115200)\r\n\r\nOK\r\n"}, /* V.250 6.2.10 - Fixed DTE rate */
{"AT+IPR?\r", "\r\n+IPR:0\r\n\r\nOK\r\n"},
{"AT+IRTS=?\r", "\r\n+IRTS:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.2.17 - Select synchronous mode RTS option */
{"AT+IRTS=?\r", "\r\n+IRTS:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.2.17 - Select synchronous mode RTS option */
{"AT+IRTS?\r", "\r\n+IRTS:0\r\n\r\nOK\r\n"},
{"AT+MA\r", "\r\nOK\r\n"}, /* V.250 6.4.2 - Modulation automode control */
{"AT+MR=?\r", "\r\n+MR:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.3 - Modulation reporting control */
{"AT+MA\r", "\r\nOK\r\n"}, /* V.250 6.4.2 - Modulation automode control */
{"AT+MR=?\r", "\r\n+MR:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.3 - Modulation reporting control */
{"AT+MR?\r", "\r\n+MR:0\r\n\r\nOK\r\n"},
{"AT+MS\r", "\r\nOK\r\n"}, /* V.250 6.4.1 - Modulation selection */
{"AT+MSC=?\r", "\r\n+MSC:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.8 - Seamless rate change enable */
{"AT+MS\r", "\r\nOK\r\n"}, /* V.250 6.4.1 - Modulation selection */
{"AT+MSC=?\r", "\r\n+MSC:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.8 - Seamless rate change enable */
{"AT+MSC?\r", "\r\n+MSC:0\r\n\r\nOK\r\n"},
{"AT+MV18AM\r", "\r\nOK\r\n"}, /* V.250 6.4.6 - V.18 answering message editing */
{"AT+MV18P=?\r", "\r\n+MV18P:(2-7)\r\n\r\nOK\r\n"}, /* V.250 6.4.7 - Order of probes */
{"AT+MV18AM\r", "\r\nOK\r\n"}, /* V.250 6.4.6 - V.18 answering message editing */
{"AT+MV18P=?\r", "\r\n+MV18P:(2-7)\r\n\r\nOK\r\n"}, /* V.250 6.4.7 - Order of probes */
{"AT+MV18P?\r", "\r\n+MV18P:0\r\n\r\nOK\r\n"},
{"AT+MV18R=?\r", "\r\n+MV18R:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.5 - V.18 reporting control */
{"AT+MV18R=?\r", "\r\n+MV18R:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.4.5 - V.18 reporting control */
{"AT+MV18R?\r", "\r\n+MV18R:0\r\n\r\nOK\r\n"},
{"AT+MV18S\r", "\r\nOK\r\n"}, /* V.250 6.4.4 - V.18 selection */
{"AT+TADR\r", "\r\nOK\r\n"}, /* V.250 6.7.2.9 - Local V.54 address */
{"AT+TAL=?\r", "\r\n+TAL:(0,1),(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.15 - Local analogue loop */
{"AT+MV18S\r", "\r\nOK\r\n"}, /* V.250 6.4.4 - V.18 selection */
{"AT+TADR\r", "\r\nOK\r\n"}, /* V.250 6.7.2.9 - Local V.54 address */
{"AT+TAL=?\r", "\r\n+TAL:(0,1),(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.15 - Local analogue loop */
{"AT+TAL?\r", "\r\n+TAL:0,0\r\n\r\nOK\r\n"},
{"AT+TALS=?\r", "\r\n+TALS:(0-3)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.6 - Analogue loop status */
{"AT+TALS=?\r", "\r\n+TALS:(0-3)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.6 - Analogue loop status */
{"AT+TALS?\r", "\r\n+TALS:0\r\n\r\nOK\r\n"},
{"AT+TDLS=?\r", "\r\n+TDLS:(0-4)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.7 - Local digital loop status */
{"AT+TDLS=?\r", "\r\n+TDLS:(0-4)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.7 - Local digital loop status */
{"AT+TDLS?\r", "\r\n+TDLS:0\r\n\r\nOK\r\n"},
{"AT+TE140=?\r", "\r\n+TE140:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.1 - Enable ckt 140 */
{"AT+TE140=?\r", "\r\n+TE140:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.1 - Enable ckt 140 */
{"AT+TE140?\r", "\r\n+TE140:0\r\n\r\nOK\r\n"},
{"AT+TE141=?\r", "\r\n+TE141:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.2 - Enable ckt 141 */
{"AT+TE141=?\r", "\r\n+TE141:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.2 - Enable ckt 141 */
{"AT+TE141?\r", "\r\n+TE141:0\r\n\r\nOK\r\n"},
{"AT+TEPAL=?\r", "\r\n+TEPAL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.5 - Enable front panel analogue loop */
{"AT+TEPAL=?\r", "\r\n+TEPAL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.5 - Enable front panel analogue loop */
{"AT+TEPAL?\r", "\r\n+TEPAL:0\r\n\r\nOK\r\n"},
{"AT+TEPDL=?\r", "\r\n+TEPDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.4 - Enable front panel RDL */
{"AT+TEPDL=?\r", "\r\n+TEPDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.4 - Enable front panel RDL */
{"AT+TEPDL?\r", "\r\n+TEPDL:0\r\n\r\nOK\r\n"},
{"AT+TERDL=?\r", "\r\n+TERDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.3 - Enable RDL from remote */
{"AT+TERDL=?\r", "\r\n+TERDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.3 - Enable RDL from remote */
{"AT+TERDL?\r", "\r\n+TERDL:0\r\n\r\nOK\r\n"},
{"AT+TLDL=?\r", "\r\n+TLDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.13 - Local digital loop */
{"AT+TLDL=?\r", "\r\n+TLDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.13 - Local digital loop */
{"AT+TLDL?\r", "\r\n+TLDL:0\r\n\r\nOK\r\n"},
{"AT+TMODE=?\r", "\r\n+TMODE:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.10 - Set V.54 mode */
{"AT+TMODE=?\r", "\r\n+TMODE:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.10 - Set V.54 mode */
{"AT+TMODE?\r", "\r\n+TMODE:0\r\n\r\nOK\r\n"},
{"AT+TNUM\r", "\r\nOK\r\n"}, /* V.250 6.7.2.12 - Errored bit and block counts */
{"AT+TRDL=?\r", "\r\n+TRDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.14 - Request remote digital loop */
{"AT+TNUM\r", "\r\nOK\r\n"}, /* V.250 6.7.2.12 - Errored bit and block counts */
{"AT+TRDL=?\r", "\r\n+TRDL:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.14 - Request remote digital loop */
{"AT+TRDL?\r", "\r\n+TRDL:0\r\n\r\nOK\r\n"},
{"AT+TRDLS\r", "\r\nOK\r\n"}, /* V.250 6.7.2.8 - Remote digital loop status */
{"AT+TRES=?\r", "\r\n+TRES:(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.17 - Self test result */
{"AT+TRDLS\r", "\r\nOK\r\n"}, /* V.250 6.7.2.8 - Remote digital loop status */
{"AT+TRES=?\r", "\r\n+TRES:(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.17 - Self test result */
{"AT+TRES?\r", "\r\n+TRES:0\r\n\r\nOK\r\n"},
{"AT+TSELF=?\r", "\r\n+TSELF:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.16 - Self test */
{"AT+TSELF=?\r", "\r\n+TSELF:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.16 - Self test */
{"AT+TSELF?\r", "\r\n+TSELF:0\r\n\r\nOK\r\n"},
{"AT+TTER=?\r", "\r\n+TTER:(0-65535),(0-65535)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.11 - Test error rate */
{"AT+TTER=?\r", "\r\n+TTER:(0-65535),(0-65535)\r\n\r\nOK\r\n"}, /* V.250 6.7.2.11 - Test error rate */
{"AT+TTER?\r", "\r\n+TTER:0,0\r\n\r\nOK\r\n"},
{"AT+VBT\r", "\r\nOK\r\n"}, /* 3GPP TS 27.007 C.2.2 - Buffer threshold setting */
{"AT+VCID=?\r", "\r\n0,1\r\n\r\nOK\r\n"}, /* 3GPP TS 27.007 C.2.3 - Calling number ID presentation */
@ -354,44 +355,44 @@ static const struct command_response_s general_test_seq[] =
{"AT+VSID?\r", "\r\n12345\r\n\r\nOK\r\n"},
{"AT+VSM\r", "\r\nOK\r\n"}, /* V.253 10.2.8 - Compression method selection */
{"AT+VSP\r", "\r\nOK\r\n"}, /* V.253 10.5.1 - Voice speakerphone state */
{"AT+VTA\r", "\r\nOK\r\n"}, /* V.253 10.5.4 - Train acoustic echo-canceller */
{"AT+VTA\r", "\r\nOK\r\n"}, /* V.253 10.5.4 - Train acoustic echo-canceller */
{"AT+VTD\r", "\r\nOK\r\n"}, /* V.253 10.2.9 - Beep tone duration timer */
{"AT+VTH\r", "\r\nOK\r\n"}, /* V.253 10.5.5 - Train line echo-canceller */
{"AT+VTH\r", "\r\nOK\r\n"}, /* V.253 10.5.5 - Train line echo-canceller */
{"AT+VTR\r", "\r\nOK\r\n"}, /* V.253 10.1.4 - Voice duplex state */
{"AT+VTS\r", "\r\nOK\r\n"}, /* V.253 10.1.5 - DTMF and tone generation in voice */
{"AT+VTX\r", "\r\nOK\r\n"}, /* V.253 10.1.6 - Transmit data state */
{"AT+WS46\r", "\r\nOK\r\n"}, /* 3GPP TS 27.007 5.9 - PCCA STD-101 [17] select wireless network */
{"ATA\r", "\r\nERROR\r\n"}, /* V.250 6.3.5 - Answer */
{"ATDT -1234567890ABCDPSTW*#+,!@\r;", ""}, /* V.250 6.3.1 - Dial */
{"ATE1\r", "\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATE0\r", "ATE0\r\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATH\r", "\r\nOK\r\n"}, /* V.250 6.3.6 - Hook control */
{"ATI\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* V.250 6.1.3 - Request identification information */
{"ATL\r", "\r\nOK\r\n"}, /* V.250 6.3.13 - Monitor speaker loudness */
{"ATM\r", "\r\nOK\r\n"}, /* V.250 6.3.14 - Monitor speaker mode */
{"ATO\r", "\r\nCONNECT\r\n\r\nOK\r\n"}, /* V.250 6.3.7 - Return to online data state */
{"ATP\r", "\r\nOK\r\n"}, /* V.250 6.3.3 - Select pulse dialling (command) */
{"ATQ\r", "\r\nOK\r\n"}, /* V.250 6.2.5 - Result code suppression */
{"ATS0=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.8 - Automatic answer */
{"ATA\r", "\r\nERROR\r\n"}, /* V.250 6.3.5 - Answer */
{"ATDT -1234567890ABCDPSTW*#+,!@\r;", ""}, /* V.250 6.3.1 - Dial */
{"ATE1\r", "\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATE0\r", "ATE0\r\r\nOK\r\n"}, /* V.250 6.2.4 - Command echo */
{"ATH\r", "\r\nOK\r\n"}, /* V.250 6.3.6 - Hook control */
{"ATI\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* V.250 6.1.3 - Request identification information */
{"ATL\r", "\r\nOK\r\n"}, /* V.250 6.3.13 - Monitor speaker loudness */
{"ATM\r", "\r\nOK\r\n"}, /* V.250 6.3.14 - Monitor speaker mode */
{"ATO\r", "\r\nCONNECT\r\n\r\nOK\r\n"}, /* V.250 6.3.7 - Return to online data state */
{"ATP\r", "\r\nOK\r\n"}, /* V.250 6.3.3 - Select pulse dialling (command) */
{"ATQ\r", "\r\nOK\r\n"}, /* V.250 6.2.5 - Result code suppression */
{"ATS0=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.8 - Automatic answer */
{"ATS0?\r", "\r\n000\r\n\r\nOK\r\n"},
{"ATS10=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.12 - Automatic disconnect delay */
{"ATS10=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.12 - Automatic disconnect delay */
{"ATS10?\r", "\r\n000\r\n\r\nOK\r\n"},
{"ATS3=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.1 - Command line termination character */
{"ATS3=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.1 - Command line termination character */
{"ATS3?\r", "\r\n013\r\n\r\nOK\r\n"},
{"ATS4=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.2 - Response formatting character */
{"ATS4=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.2 - Response formatting character */
{"ATS4?\r", "\r\n010\r\n\r\nOK\r\n"},
{"ATS5=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.3 - Command line editing character */
{"ATS5=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.2.3 - Command line editing character */
{"ATS5?\r", "\r\n008\r\n\r\nOK\r\n"},
{"ATS6=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.9 - Pause before blind dialling */
{"ATS6=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.9 - Pause before blind dialling */
{"ATS6?\r", "\r\n001\r\n\r\nOK\r\n"},
{"ATS7=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.10 - Connection completion timeout */
{"ATS7=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.10 - Connection completion timeout */
{"ATS7?\r", "\r\n060\r\n\r\nOK\r\n"},
{"ATS8=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.11 - Comma dial modifier time */
{"ATS8=?\r", "\r\n000\r\n\r\nOK\r\n"}, /* V.250 6.3.11 - Comma dial modifier time */
{"ATS8?\r", "\r\n005\r\n\r\nOK\r\n"},
{"ATT\r", "\r\nOK\r\n"}, /* V.250 6.3.2 - Select tone dialling (command) */
{"ATV0\r", "0\r"}, /* V.250 6.2.6 - DCE response format */
{"ATT\r", "\r\nOK\r\n"}, /* V.250 6.3.2 - Select tone dialling (command) */
{"ATV0\r", "0\r"}, /* V.250 6.2.6 - DCE response format */
{"ATV1\r", "\r\nOK\r\n"},
{"ATX4\r", "\r\nOK\r\n"}, /* V.250 6.2.7 - Result code selection and call progress monitoring control */
{"ATX4\r", "\r\nOK\r\n"}, /* V.250 6.2.7 - Result code selection and call progress monitoring control */
{"ATZ\r", "\r\nOK\r\n"}, /* V.250 6.1.1 - Reset to default configuration */
{"", ""}
};
@ -550,14 +551,14 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz
int main(int argc, char *argv[])
{
at_state_t at_state;
at_state_t *at_state;
if (at_init(&at_state, at_tx_handler, NULL, modem_call_control, NULL) == NULL)
if ((at_state = at_init(NULL, at_tx_handler, NULL, modem_call_control, NULL)) == NULL)
{
fprintf(stderr, "Cannot start the AT interpreter\n");
exit(2);
}
if (general_test(&at_state))
if (general_test(at_state))
{
printf("Tests failed.\n");
exit(2);

View File

@ -35,9 +35,7 @@
#include <stdio.h>
#include <string.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -64,7 +62,7 @@ int main(int argc, char *argv[])
double o;
double error;
int bins[65536];
awgn_state_t noise_source;
awgn_state_t *noise_source;
/* Generate noise at several RMS levels between -50dBm and 0dBm. Noise is
generated for a large number of samples (1,000,000), and the RMS value
@ -77,18 +75,18 @@ int main(int argc, char *argv[])
clip_high = 0;
clip_low = 0;
total = 0.0;
awgn_init_dbm0(&noise_source, idum, (float) j);
noise_source = awgn_init_dbm0(NULL, idum, (float) j);
total_samples = 1000000;
for (i = 0; i < total_samples; i++)
{
value = awgn(&noise_source);
value = awgn(noise_source);
if (value == 32767)
clip_high++;
else if (value == -32768)
clip_low++;
total += ((double) value)*((double) value);
}
error = 100.0*(1.0 - sqrt(total/total_samples)/noise_source.rms);
error = 100.0*(1.0 - sqrt(total/total_samples)/noise_source->rms);
printf("RMS = %.3f (expected %d) %.2f%% error [clipped samples %d+%d]\n",
10.0*log10((total/total_samples)/(32768.0*32768.0) + 1.0e-10) + DBM0_MAX_POWER,
j,
@ -109,18 +107,18 @@ int main(int argc, char *argv[])
memset(bins, 0, sizeof(bins));
clip_high = 0;
clip_low = 0;
awgn_init_dbm0(&noise_source, idum, -15);
awgn_init_dbm0(noise_source, idum, -15);
total_samples = 10000000;
for (i = 0; i < total_samples; i++)
{
value = awgn(&noise_source);
value = awgn(noise_source);
if (value == 32767)
clip_high++;
else if (value == -32768)
clip_low++;
bins[value + 32768]++;
}
o = noise_source.rms;
o = noise_source->rms;
for (i = 0; i < 65536 - 10; i++)
{
x = i - 32768;

View File

@ -48,9 +48,7 @@ a fair test of performance in a real PSTN channel.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -44,10 +44,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -40,9 +40,7 @@ These tests exercise each of the BERT standards supported by the BERT module.
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -75,9 +73,9 @@ int8_t test[0x800000];
int main(int argc, char *argv[])
{
bert_state_t tx_bert;
bert_state_t rx_bert;
bert_state_t bert;
bert_state_t *tx_bert;
bert_state_t *rx_bert;
bert_state_t *bert;
bert_results_t bert_results;
int i;
int bit;
@ -85,14 +83,14 @@ int main(int argc, char *argv[])
int max_zeros;
int failed;
bert_init(&tx_bert, 0, BERT_PATTERN_ZEROS, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ZEROS, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ZEROS, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ZEROS, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("Zeros: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -100,14 +98,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ONES, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ONES, 300, 20);
bert_init(tx_bert, 0, BERT_PATTERN_ONES, 300, 20);
bert_init(rx_bert, 0, BERT_PATTERN_ONES, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("Ones: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -115,14 +113,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_1_TO_7, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_1_TO_7, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_7, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_7, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("1 to 7: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -130,14 +128,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_1_TO_3, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_1_TO_3, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_3, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_3, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("1 to 3: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -145,14 +143,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_1_TO_1, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_1_TO_1, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_1, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_1_TO_1, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("1 to 1: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -160,14 +158,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_3_TO_1, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_3_TO_1, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_3_TO_1, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_3_TO_1, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("3 to 1: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -175,14 +173,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_7_TO_1, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_7_TO_1, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_7_TO_1, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_7_TO_1, 300, 20);
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("7 to 1: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 950)
{
@ -190,15 +188,15 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ITU_O153_9, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ITU_O153_9, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O153_9, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O153_9, 300, 20);
for (i = 0; i < 0x200; i++)
test[i] = 0;
max_zeros = 0;
zeros = 0;
for (i = 0; i < 511*2; i++)
{
bit = bert_get_bit(&tx_bert);
bit = bert_get_bit(tx_bert);
if (bit)
{
if (zeros > max_zeros)
@ -209,8 +207,8 @@ int main(int argc, char *argv[])
{
zeros++;
}
bert_put_bit(&rx_bert, bit);
test[tx_bert.tx.reg]++;
bert_put_bit(rx_bert, bit);
test[tx_bert->tx.reg]++;
}
failed = FALSE;
if (test[0] != 0)
@ -226,7 +224,7 @@ int main(int argc, char *argv[])
failed = TRUE;
}
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("O.153(9): Bad bits %d/%d, max zeros %d\n", bert_results.bad_bits, bert_results.total_bits, max_zeros);
if (bert_results.bad_bits || bert_results.total_bits != 986 || failed)
{
@ -234,15 +232,15 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ITU_O152_11, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ITU_O152_11, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O152_11, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O152_11, 300, 20);
for (i = 0; i < 0x800; i++)
test[i] = 0;
max_zeros = 0;
zeros = 0;
for (i = 0; i < 2047*2; i++)
{
bit = bert_get_bit(&tx_bert);
bit = bert_get_bit(tx_bert);
if (bit)
{
if (zeros > max_zeros)
@ -253,8 +251,8 @@ int main(int argc, char *argv[])
{
zeros++;
}
bert_put_bit(&rx_bert, bit);
test[tx_bert.tx.reg]++;
bert_put_bit(rx_bert, bit);
test[tx_bert->tx.reg]++;
}
failed = FALSE;
if (test[0] != 0)
@ -270,7 +268,7 @@ int main(int argc, char *argv[])
failed = TRUE;
}
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("O.152(11): Bad bits %d/%d, max zeros %d\n", bert_results.bad_bits, bert_results.total_bits, max_zeros);
if (bert_results.bad_bits || bert_results.total_bits != 4052 || failed)
{
@ -278,15 +276,15 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ITU_O151_15, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ITU_O151_15, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_15, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_15, 300, 20);
for (i = 0; i < 0x8000; i++)
test[i] = 0;
max_zeros = 0;
zeros = 0;
for (i = 0; i < 32767*2; i++)
{
bit = bert_get_bit(&tx_bert);
bit = bert_get_bit(tx_bert);
if (bit)
{
if (zeros > max_zeros)
@ -297,8 +295,8 @@ int main(int argc, char *argv[])
{
zeros++;
}
bert_put_bit(&rx_bert, bit);
test[tx_bert.tx.reg]++;
bert_put_bit(rx_bert, bit);
test[tx_bert->tx.reg]++;
}
failed = FALSE;
if (test[0] != 0)
@ -314,7 +312,7 @@ int main(int argc, char *argv[])
failed = TRUE;
}
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("O.151(15): Bad bits %d/%d, max zeros %d\n", bert_results.bad_bits, bert_results.total_bits, max_zeros);
if (bert_results.bad_bits || bert_results.total_bits != 65480 || failed)
{
@ -322,15 +320,15 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ITU_O151_20, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ITU_O151_20, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_20, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_20, 300, 20);
for (i = 0; i < 0x100000; i++)
test[i] = 0;
test[i] = 0;
max_zeros = 0;
zeros = 0;
for (i = 0; i < 1048575*2; i++)
{
bit = bert_get_bit(&tx_bert);
bit = bert_get_bit(tx_bert);
if (bit)
{
if (zeros > max_zeros)
@ -341,8 +339,8 @@ int main(int argc, char *argv[])
{
zeros++;
}
bert_put_bit(&rx_bert, bit);
test[tx_bert.tx.reg]++;
bert_put_bit(rx_bert, bit);
test[tx_bert->tx.reg]++;
}
failed = FALSE;
if (test[0] != 0)
@ -355,7 +353,7 @@ int main(int argc, char *argv[])
if (test[i] != 2)
printf("XXX %d %d\n", i, test[i]);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("O.151(20): Bad bits %d/%d, max zeros %d\n", bert_results.bad_bits, bert_results.total_bits, max_zeros);
if (bert_results.bad_bits || bert_results.total_bits != 2097066 || failed)
{
@ -363,15 +361,15 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_ITU_O151_23, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_ITU_O151_23, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_23, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_ITU_O151_23, 300, 20);
for (i = 0; i < 0x800000; i++)
test[i] = 0;
test[i] = 0;
max_zeros = 0;
zeros = 0;
for (i = 0; i < 8388607*2; i++)
{
bit = bert_get_bit(&tx_bert);
bit = bert_get_bit(tx_bert);
if (bit)
{
if (zeros > max_zeros)
@ -382,8 +380,8 @@ int main(int argc, char *argv[])
{
zeros++;
}
bert_put_bit(&rx_bert, bit);
test[tx_bert.tx.reg]++;
bert_put_bit(rx_bert, bit);
test[tx_bert->tx.reg]++;
}
failed = FALSE;
if (test[0] != 0)
@ -396,7 +394,7 @@ int main(int argc, char *argv[])
if (test[i] != 2)
printf("XXX %d %d\n", i, test[i]);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("O.151(23): Bad bits %d/%d, max zeros %d\n", bert_results.bad_bits, bert_results.total_bits, max_zeros);
if (bert_results.bad_bits || bert_results.total_bits != 16777136 || failed)
{
@ -404,14 +402,14 @@ int main(int argc, char *argv[])
exit(2);
}
bert_init(&tx_bert, 0, BERT_PATTERN_QBF, 300, 20);
bert_init(&rx_bert, 0, BERT_PATTERN_QBF, 300, 20);
tx_bert = bert_init(NULL, 0, BERT_PATTERN_QBF, 300, 20);
rx_bert = bert_init(NULL, 0, BERT_PATTERN_QBF, 300, 20);
for (i = 0; i < 100000; i++)
{
bit = bert_get_bit(&tx_bert);
bert_put_bit(&rx_bert, bit);
bit = bert_get_bit(tx_bert);
bert_put_bit(rx_bert, bit);
}
bert_result(&rx_bert, &bert_results);
bert_result(rx_bert, &bert_results);
printf("QBF: Bad bits %d/%d\n", bert_results.bad_bits, bert_results.total_bits);
if (bert_results.bad_bits || bert_results.total_bits != 100000)
{
@ -421,13 +419,13 @@ int main(int argc, char *argv[])
/* Test the mechanism for categorising the error rate into <10^x bands */
/* TODO: The result of this test is not checked automatically */
bert_init(&bert, 15000000, BERT_PATTERN_ITU_O152_11, 300, 20);
bert_set_report(&bert, 100000, reporter, (intptr_t) 0);
bert = bert_init(NULL, 15000000, BERT_PATTERN_ITU_O152_11, 300, 20);
bert_set_report(bert, 100000, reporter, (intptr_t) 0);
for (;;)
{
if ((bit = bert_get_bit(&bert)) == SIG_STATUS_END_OF_DATA)
if ((bit = bert_get_bit(bert)) == SIG_STATUS_END_OF_DATA)
{
bert_result(&bert, &bert_results);
bert_result(bert, &bert_results);
printf("Rate test: %d bits, %d bad bits, %d resyncs\n", bert_results.total_bits, bert_results.bad_bits, bert_results.resyncs);
if (bert_results.total_bits != 15000000 - 42
||
@ -439,15 +437,15 @@ int main(int argc, char *argv[])
exit(2);
}
break;
//bert_init(&bert, 15000000, BERT_PATTERN_ITU_O152_11, 300, 20);
//bert_set_report(&bert, 100000, reporter, (intptr_t) 0);
//bert = bert_init(NULL, 15000000, BERT_PATTERN_ITU_O152_11, 300, 20);
//bert_set_report(bert, 100000, reporter, (intptr_t) 0);
//continue;
}
if ((my_rand() & 0x3FFFF) == 0)
bit ^= 1;
//if ((my_rand() & 0xFFF) == 0)
// bert_put_bit(&bert, bit);
bert_put_bit(&bert, bit);
// bert_put_bit(bert, bit);
bert_put_bit(bert, bit);
}
printf("Tests passed.\n");

View File

@ -39,9 +39,7 @@
#include <string.h>
#include <assert.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -36,15 +36,11 @@
#include <memory.h>
#include <time.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
int main (int argc, char *argv[])
{
awgn_state_t noise_source;
awgn_state_t *noise_source;
dc_restore_state_t dc_state;
int i;
int idum = 1234567;
@ -55,11 +51,11 @@ int main (int argc, char *argv[])
int dc_offset;
dc_offset = 5000;
awgn_init_dbm0(&noise_source, idum, -10.0);
noise_source = awgn_init_dbm0(NULL, idum, -10.0);
dc_restore_init(&dc_state);
for (i = 0; i < 100000; i++)
{
dirty = awgn(&noise_source) + dc_offset;
dirty = awgn(noise_source) + dc_offset;
dc_restore(&dc_state, dirty);
if ((i % 1000) == 0)
{
@ -74,7 +70,7 @@ int main (int argc, char *argv[])
max = -99999;
for (i = 0; i < 100000; i++)
{
dirty = awgn(&noise_source) + dc_offset;
dirty = awgn(noise_source) + dc_offset;
dc_restore(&dc_state, dirty);
estimate = dc_restore_estimate(&dc_state);
if (estimate < min)

View File

@ -94,10 +94,6 @@ they wish to give it away for free.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -44,10 +44,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -57,10 +57,6 @@ all the tests in G.168 are fully implemented at this time.
#define GEN_CONST
#include <math.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp/g168models.h"
#include "spandsp-sim.h"

View File

@ -41,9 +41,7 @@
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -55,9 +55,7 @@
#include <libxml/xinclude.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -47,9 +47,6 @@ T.30<->T.38<--------------------------UDPTL/RTP-------------------------->T.38<-
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -80,10 +77,6 @@ T.30<->T.38<--------------------------UDPTL/RTP-------------------------->T.38<-
#include <libxml/xinclude.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "udptl.h"
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -32,9 +32,7 @@
#include <string.h>
#include <assert.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
@ -109,8 +107,8 @@ void fax_log_page_transfer_statistics(t30_state_t *s, const char *tag)
printf("%s: Compressed image size %d bytes\n", tag, t.image_size);
printf("%s: Image size %d pels x %d pels\n", tag, t.width, t.length);
printf("%s: Image resolution %d pels/m x %d pels/m\n", tag, t.x_resolution, t.y_resolution);
#if defined(WITH_SPANDSP_INTERNALS)
printf("%s: Bits per row - min %d, max %d\n", tag, s->t4.min_row_bits, s->t4.max_row_bits);
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
printf("%s: Bits per row - min %d, max %d\n", tag, s->t4.tx.encoder.t4_t6.min_row_bits, s->t4.tx.encoder.t4_t6.max_row_bits);
#endif
fax_log_final_transfer_statistics(s, tag);

View File

@ -51,10 +51,6 @@ These tests allow either:
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -42,10 +42,6 @@
#define GEN_CONST
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -34,10 +34,6 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp/g168models.h"
#include "spandsp-sim.h"

View File

@ -40,10 +40,6 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -54,9 +54,6 @@ The file ../test-data/local/short_wb_voice.wav will be compressed to the specifi
and the resulting audio stored in post_g722.wav.
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -71,9 +68,7 @@ and the resulting audio stored in post_g722.wav.
#include "spandsp.h"
#if 1 //defined(WITH_SPANDSP_INTERNALS)
#include "spandsp/private/g722.h"
#endif
#define G722_SAMPLE_RATE 16000
@ -218,8 +213,8 @@ static int get_test_vector(const char *file, uint16_t buf[], int max_len)
static void itu_compliance_tests(void)
{
g722_encode_state_t enc_state;
g722_decode_state_t dec_state;
g722_encode_state_t *enc_state;
g722_decode_state_t *dec_state;
int i;
int j;
int k;
@ -262,9 +257,9 @@ static void itu_compliance_tests(void)
break;
}
len = j - i;
g722_encode_init(&enc_state, 64000, 0);
enc_state.itu_test_mode = TRUE;
len2 = g722_encode(&enc_state, compressed, itu_data + i, len);
enc_state = g722_encode_init(NULL, 64000, 0);
enc_state->itu_test_mode = TRUE;
len2 = g722_encode(enc_state, compressed, itu_data + i, len);
/* Check the result against the ITU's reference output data */
j = 0;
@ -328,9 +323,9 @@ static void itu_compliance_tests(void)
for (k = 0; k < len; k++)
compressed[k] = itu_data[k + i] >> ((mode == 3) ? 10 : (mode == 2) ? 9 : 8);
g722_decode_init(&dec_state, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0);
dec_state.itu_test_mode = TRUE;
len2 = g722_decode(&dec_state, decompressed, compressed, len);
dec_state = g722_decode_init(NULL, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0);
dec_state->itu_test_mode = TRUE;
len2 = g722_decode(dec_state, decompressed, compressed, len);
/* Check the result against the ITU's reference output data */
j = 0;
@ -360,8 +355,8 @@ static void itu_compliance_tests(void)
static void signal_to_distortion_tests(void)
{
g722_encode_state_t enc_state;
g722_decode_state_t dec_state;
g722_encode_state_t *enc_state;
g722_decode_state_t *dec_state;
swept_tone_state_t *swept;
power_meter_t in_meter;
power_meter_t out_meter;
@ -377,8 +372,8 @@ static void signal_to_distortion_tests(void)
/* Test a back to back encoder/decoder pair to ensure we comply with Figure 11/G.722 to
Figure 16/G.722, Figure A.1/G.722, and Figure A.2/G.722 */
g722_encode_init(&enc_state, 64000, 0);
g722_decode_init(&dec_state, 64000, 0);
enc_state = g722_encode_init(NULL, 64000, 0);
dec_state = g722_decode_init(NULL, 64000, 0);
power_meter_init(&in_meter, 7);
power_meter_init(&out_meter, 7);
@ -387,8 +382,8 @@ static void signal_to_distortion_tests(void)
memset(original, 0, len*sizeof(original[0]));
for (i = 0; i < len; i++)
in_level = power_meter_update(&in_meter, original[i]);
len2 = g722_encode(&enc_state, compressed, original, len);
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
len2 = g722_encode(enc_state, compressed, original, len);
len3 = g722_decode(dec_state, decompressed, compressed, len2);
out_level = 0;
for (i = 0; i < len3; i++)
out_level = power_meter_update(&out_meter, decompressed[i]);
@ -401,8 +396,8 @@ static void signal_to_distortion_tests(void)
len = swept_tone(swept, original, 1024);
for (i = 0; i < len; i++)
in_level = power_meter_update(&in_meter, original[i]);
len2 = g722_encode(&enc_state, compressed, original, len);
len3 = g722_decode(&dec_state, decompressed, compressed, len2);
len2 = g722_encode(enc_state, compressed, original, len);
len3 = g722_decode(dec_state, decompressed, compressed, len2);
for (i = 0; i < len3; i++)
out_level = power_meter_update(&out_meter, decompressed[i]);
printf("%10d, %10d, %f\n", in_level, out_level, (float) out_level/in_level);
@ -413,8 +408,8 @@ static void signal_to_distortion_tests(void)
int main(int argc, char *argv[])
{
g722_encode_state_t enc_state;
g722_decode_state_t dec_state;
g722_encode_state_t *enc_state;
g722_decode_state_t *dec_state;
int len2;
int len3;
int i;
@ -581,9 +576,9 @@ int main(int argc, char *argv[])
}
}
if (eight_k_in)
g722_encode_init(&enc_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000);
enc_state = g722_encode_init(NULL, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000);
else
g722_encode_init(&enc_state, bit_rate, G722_PACKED);
enc_state = g722_encode_init(NULL, bit_rate, G722_PACKED);
}
else
{
@ -608,9 +603,9 @@ int main(int argc, char *argv[])
exit(2);
}
if (eight_k_out)
g722_decode_init(&dec_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000);
dec_state = g722_decode_init(NULL, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000);
else
g722_decode_init(&dec_state, bit_rate, G722_PACKED);
dec_state = g722_decode_init(NULL, bit_rate, G722_PACKED);
}
else
{
@ -632,7 +627,7 @@ int main(int argc, char *argv[])
for (i = 0; i < samples; i++)
indata[i] = dds_modf(&tone_phase, tone_phase_rate, tone_level, 0);
}
len2 = g722_encode(&enc_state, adpcmdata, indata, samples);
len2 = g722_encode(enc_state, adpcmdata, indata, samples);
}
else
{
@ -642,7 +637,7 @@ int main(int argc, char *argv[])
}
if (decode)
{
len3 = g722_decode(&dec_state, outdata, adpcmdata, len2);
len3 = g722_decode(dec_state, outdata, adpcmdata, len2);
outframes = sf_writef_short(outhandle, outdata, len3);
if (outframes != len3)
{

View File

@ -58,9 +58,6 @@ The test file ../test-data/local/short_nb_voice.wav will be compressed to the sp
decompressed, and the resulting audio stored in post_g726.wav.
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -73,20 +70,16 @@ decompressed, and the resulting audio stored in post_g726.wav.
#include <ctype.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
#define BLOCK_LEN 320
#define MAX_TEST_VECTOR_LEN 40000
#define TESTDATA_DIR "../test-data/itu/g726/"
#define TESTDATA_DIR "../test-data/itu/g726/"
#define IN_FILE_NAME "../test-data/local/short_nb_voice.wav"
#define OUT_FILE_NAME "post_g726.wav"
#define IN_FILE_NAME "../test-data/local/short_nb_voice.wav"
#define OUT_FILE_NAME "post_g726.wav"
int16_t outdata[MAX_TEST_VECTOR_LEN];
uint8_t adpcmdata[MAX_TEST_VECTOR_LEN];
@ -131,7 +124,7 @@ Algorithm Input Intermediate Output Input Output Input
40F NRM.A RN40FA.I RN40FA.O I40 RI40FA.O OVR.A RV40FA.I RV40FA.O
HN40FA.I HN40FA.O HI40FA.O HV40FA.I HV40FA.O
Table 6 ¡V Reset and homing cross sequences for u-law -> A-law
Table 6 - Reset and homing cross sequences for u-law -> A-law
Normal Overload
Algorithm Input Intermediate Output Input Intermediate Output
(PCM) (ADPCM) (PCM) (PCM) (ADPCM) (PCM)
@ -147,7 +140,7 @@ Algorithm Input Intermediate Output Input Intermediate Output
40F NRM.M RN40FM.I RN40FC.O OVR.M RV40FM.I RV40FC.O
HN40FM.I HN40FC.O HV40FM.I HV40FC.O
Table 7 ¡V Reset and homing cross sequences for A-law -> u-law
Table 7 - Reset and homing cross sequences for A-law -> u-law
Normal Overload
Algorithm Input Intermediate Output Input Intermediate Output
(PCM) (ADPCM) (PCM) (PCM) (ADPCM) (PCM)

View File

@ -123,10 +123,6 @@ will be compressed to GSM 06.10 data, decompressed, and the resulting audio stor
#include <ctype.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -49,10 +49,6 @@ of the degradation in quality caused by the compression.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -42,9 +42,7 @@
#include <math.h>
#include <errno.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -667,6 +665,7 @@ static void lenna_tests(int output_width, int output_length_scaling, const char
im.current_row = 0;
im.bytes_per_pixel = samples_per_pixel;
s2 = NULL;
switch (output_length_scaling)
{
case -2:

View File

@ -43,9 +43,7 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -40,10 +40,6 @@
#include <memory.h>
#include <time.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
static int tests_failed = FALSE;
@ -106,54 +102,54 @@ static void message_handler2(void *user_data, int level, const char *text)
int main(int argc, char *argv[])
{
logging_state_t log;
logging_state_t *log;
int i;
uint8_t buf[1000];
struct timespec delay;
/* Set up a logger */
if (span_log_init(&log, 123, "TAG") == NULL)
if ((log = span_log_init(NULL, 123, "TAG")) == NULL)
{
fprintf(stderr, "Failed to initialise log.\n");
exit(2);
}
/* Try it */
span_log_set_level(&log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
if (span_log(&log, SPAN_LOG_FLOW, "Logging to fprintf, as simple as %d %d %d\n", 1, 2, 3))
span_log_set_level(log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
if (span_log(log, SPAN_LOG_FLOW, "Logging to fprintf, as simple as %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
/* Now set a custom log handler */
span_log_set_message_handler(&log, &message_handler, NULL);
span_log_set_sample_rate(&log, 44100);
span_log_set_message_handler(log, &message_handler, NULL);
span_log_set_sample_rate(log, 44100);
/* Try the different logging elements */
span_log_set_level(&log, SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
if (span_log(&log, SPAN_LOG_FLOW, "Log with tag %d %d %d\n", 1, 2, 3))
span_log_set_level(log, SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
if (span_log(log, SPAN_LOG_FLOW, "Log with tag %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
span_log_set_level(&log, SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
if (span_log(&log, SPAN_LOG_FLOW, "Log with protocol %d %d %d\n", 1, 2, 3))
span_log_set_level(log, SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
if (span_log(log, SPAN_LOG_FLOW, "Log with protocol %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
span_log_set_level(&log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_FLOW);
if (span_log(&log, SPAN_LOG_ERROR, "Log with severity log %d %d %d\n", 1, 2, 3))
span_log_set_level(log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_FLOW);
if (span_log(log, SPAN_LOG_ERROR, "Log with severity log %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
span_log_set_level(&log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
span_log_set_tag(&log, "NewTag");
if (span_log(&log, SPAN_LOG_FLOW, "Log with new tag %d %d %d\n", 1, 2, 3))
span_log_set_level(log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
span_log_set_tag(log, "NewTag");
if (span_log(log, SPAN_LOG_FLOW, "Log with new tag %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
span_log_set_protocol(&log, "Protocol");
if (span_log(&log, SPAN_LOG_FLOW, "Log with protocol %d %d %d\n", 1, 2, 3))
span_log_set_protocol(log, "Protocol");
if (span_log(log, SPAN_LOG_FLOW, "Log with protocol %d %d %d\n", 1, 2, 3))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
@ -161,11 +157,11 @@ int main(int argc, char *argv[])
/* Test logging of buffer contents */
for (i = 0; i < 1000; i++)
buf[i] = i;
if (span_log_buf(&log, SPAN_LOG_FLOW, "Buf", buf, 10))
if (span_log_buf(log, SPAN_LOG_FLOW, "Buf", buf, 10))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
if (span_log_buf(&log, SPAN_LOG_FLOW, "Buf", buf, 1000))
if (span_log_buf(log, SPAN_LOG_FLOW, "Buf", buf, 1000))
fprintf(stderr, "Logged.\n");
else
fprintf(stderr, "Not logged.\n");
@ -173,7 +169,7 @@ int main(int argc, char *argv[])
/* Test the correct severities will be logged */
for (i = 0; i < 10; i++)
{
if (!span_log_test(&log, i))
if (!span_log_test(log, i))
{
if (i != 6)
tests_failed = TRUE;
@ -182,19 +178,19 @@ int main(int argc, char *argv[])
}
/* Check timestamping by samples */
span_log_set_level(&log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_level(log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW | SPAN_LOG_SHOW_SAMPLE_TIME);
for (i = 0; i < 10; i++)
{
span_log(&log, SPAN_LOG_FLOW, "Time tagged log %d %d %d\n", 1, 2, 3);
span_log_bump_samples(&log, 441*2);
span_log(log, SPAN_LOG_FLOW, "Time tagged log %d %d %d\n", 1, 2, 3);
span_log_bump_samples(log, 441*2);
}
/* Check timestamping by current date and time */
span_log_set_message_handler(&log, &message_handler2, NULL);
span_log_set_level(&log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW | SPAN_LOG_SHOW_DATE);
span_log_set_message_handler(log, &message_handler2, NULL);
span_log_set_level(log, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW | SPAN_LOG_SHOW_DATE);
for (i = 0; i < 10; i++)
{
span_log(&log, SPAN_LOG_FLOW, "Date/time tagged log %d %d %d\n", 1, 2, 3);
span_log(log, SPAN_LOG_FLOW, "Date/time tagged log %d %d %d\n", 1, 2, 3);
delay.tv_sec = 0;
delay.tv_nsec = 20000000;
nanosleep(&delay, NULL);
@ -205,7 +201,7 @@ int main(int argc, char *argv[])
return 2;
}
span_log_set_message_handler(&log, &message_handler, NULL);
span_log_set_message_handler(log, &message_handler, NULL);
printf("Tests passed.\n");
return 0;

View File

@ -46,10 +46,6 @@ will be compressed to LPC10 data, decompressed, and the resulting audio stored i
#include <ctype.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -48,10 +48,6 @@
#include <fftw.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp/g168models.h"
@ -139,7 +135,7 @@ int main(int argc, char *argv[])
double scale;
SNDFILE *filehandle;
SF_INFO info;
awgn_state_t noise_source;
awgn_state_t *noise_source;
memset(&info, 0, sizeof(info));
info.frames = 0;
@ -317,9 +313,9 @@ int main(int argc, char *argv[])
ms = rms(voiced_sound, voiced_length);
printf("Voiced level = %.2fdB, crest factor = %.2fdB\n", rms_to_dbm0(ms), rms_to_db(pk/ms));
awgn_init_dbm0(&noise_source, 7162534, rms_to_dbm0(ms));
noise_source = awgn_init_dbm0(NULL, 7162534, rms_to_dbm0(ms));
for (i = 0; i < 8192; i++)
noise_sound[i] = awgn(&noise_source);
noise_sound[i] = awgn(noise_source);
pk = peak(noise_sound, 8192);
ms = rms(noise_sound, 8192);
printf("Unfiltered noise level = %.2fdB, crest factor = %.2fdB\n", rms_to_dbm0(ms), rms_to_db(pk/ms));

View File

@ -40,10 +40,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
static void fixed_reciprocal16_tests(void)

View File

@ -28,9 +28,6 @@
These tests...
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -42,10 +39,6 @@ These tests...
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -90,10 +90,6 @@ cancellor.
#define GEN_CONST
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp/g168models.h"
#include "spandsp-sim.h"

View File

@ -36,10 +36,6 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -50,10 +50,6 @@ compression may be tested.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -44,10 +44,6 @@ Both tones and noise are used to check the meter's behaviour.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -0,0 +1,200 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* pseudo_terminals.c - pseudo terminal handling.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2012 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <inttypes.h>
#include <stdlib.h>
#if defined(WIN32)
#include <windows.h>
#else
#if defined(__APPLE__)
#include <util.h>
#include <sys/ioctl.h>
#elif defined(__FreeBSD__)
#include <libutil.h>
#include <termios.h>
#else
#include <pty.h>
#endif
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#endif
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include "spandsp.h"
#include "pseudo_terminals.h"
int next_id = 0;
int psuedo_terminal_close(modem_t *modem)
{
#if defined(WIN32)
if (modem->master)
{
CloseHandle(modem->master);
modem->master = 0;
}
#else
if (modem->master > -1)
{
shutdown(modem->master, 2);
close(modem->master);
modem->master = -1;
}
#endif
if (modem->slave > -1)
{
shutdown(modem->slave, 2);
close(modem->slave);
modem->slave = -1;
}
if (unlink(modem->devlink))
return -1;
return 0;
}
/*- End of function --------------------------------------------------------*/
int psuedo_terminal_create(modem_t *modem)
{
#if defined(WIN32)
COMMTIMEOUTS timeouts = {0};
#endif
memset(modem, 0, sizeof(*modem));
span_log_init(&modem->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&modem->logging, "PTY");
span_log_set_level(&modem->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(&modem->logging, "PTY");
modem->master = -1;
modem->slave = -1;
#if USE_OPENPTY
if (openpty(&modem->master, &modem->slave, NULL, NULL, NULL))
{
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to initialize pty\n");
return -1;
}
modem->stty = ttyname(modem->slave);
#else
#if defined(WIN32)
modem->slot = 4 + next_id++; /* need work here we start at COM4 for now*/
snprintf(modem->devlink, sizeof(modem->devlink), "COM%d", modem->slot);
modem->master = CreateFile(modem->devlink,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0);
if (modem->master == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: Serial port does not exist\n");
else
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: Serial port open error\n");
return -1;
}
#elif !defined(HAVE_POSIX_OPENPT)
modem->master = open("/dev/ptmx", O_RDWR);
#else
modem->master = posix_openpt(O_RDWR | O_NOCTTY);
#endif
#if !defined(WIN32)
if (modem->master < 0)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to initialize UNIX98 master pty\n");
if (grantpt(modem->master) < 0)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to grant access to slave pty\n");
if (unlockpt(modem->master) < 0)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to unlock slave pty\n");
if ((modem->stty = ptsname(modem->master)) == NULL)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to obtain slave pty filename\n");
if ((modem->slave = open(modem->stty, O_RDWR)) < 0)
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to open slave pty %s\n", modem->stty);
#endif
#if defined(SOLARIS)
ioctl(modem->slave, I_PUSH, "ptem");
ioctl(modem->slave, I_PUSH, "ldterm");
#endif
#endif
#if defined(WIN32)
timeouts.ReadIntervalTimeout = 50;
timeouts.ReadTotalTimeoutConstant = 50;
timeouts.ReadTotalTimeoutMultiplier = 10;
timeouts.WriteTotalTimeoutConstant = 50;
timeouts.WriteTotalTimeoutMultiplier = 10;
SetCommMask(modem->master, EV_RXCHAR);
if (!SetCommTimeouts(modem->master, &timeouts))
{
span_log(&modem->logging, SPAN_LOG_ERROR, "Cannot set up non-blocking read on %s\n", modem->devlink);
psuedo_terminal_close(modem);
return -1;
}
modem->threadAbort = CreateEvent(NULL, TRUE, FALSE, NULL);
#else
modem->slot = next_id++;
snprintf(modem->devlink, sizeof(modem->devlink), "/dev/spandsp/%d", modem->slot);
/* Remove any stale link which might be present */
unlink(modem->devlink);
if (symlink(modem->stty, modem->devlink))
{
span_log(&modem->logging, SPAN_LOG_ERROR, "Fatal error: failed to create %s symbolic link\n", modem->devlink);
psuedo_terminal_close(modem);
return -1;
}
if (fcntl(modem->master, F_SETFL, fcntl(modem->master, F_GETFL, 0) | O_NONBLOCK))
{
span_log(&modem->logging, SPAN_LOG_ERROR, "Cannot set up non-blocking read on %s\n", ttyname(modem->master));
psuedo_terminal_close(modem);
return -1;
}
#endif
return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/

View File

@ -0,0 +1,46 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* pseudo_terminals.h - pseudo terminal handling.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2012 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(HAVE_POSIX_OPENPT) && !defined(HAVE_DEV_PTMX) && !defined(WIN32)
#define USE_OPENPTY 1
#endif
struct modem_s
{
int slot;
int master;
int slave;
const char *stty;
char devlink[128];
int block_read;
int block_write;
logging_state_t logging;
};
typedef struct modem_s modem_t;
int psuedo_terminal_close(modem_t *modem);
int psuedo_terminal_create(modem_t *modem);

View File

@ -0,0 +1,71 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* pseudo_terminals_tests.c - pseudo terminal handling tests.
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2012 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <inttypes.h>
#include <stdlib.h>
#if defined(WIN32)
#include <windows.h>
#else
#if defined(__APPLE__)
#include <util.h>
#include <sys/ioctl.h>
#elif defined(__FreeBSD__)
#include <libutil.h>
#include <termios.h>
#include <sys/socket.h>
#else
#include <pty.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#endif
#include "spandsp.h"
#include "pseudo_terminals.h"
int main(int argc, char *argv[])
{
modem_t modem[10];
int i;
for (i = 0; i < 10; i++)
{
if (psuedo_terminal_create(&modem[i]))
printf("Failure\n");
printf("%s %s\n", modem[i].devlink, modem[i].stty);
}
getchar();
for (i = 0; i < 10; i++)
{
if (psuedo_terminal_close(&modem[i]))
printf("Failure\n");
}
return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/

View File

@ -23,8 +23,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
/*! \page queue_tests_page Queue tests
\section queue_tests_page_sec_1 What does it do?
*/
@ -41,9 +39,7 @@
#include <pthread.h>
#include <sched.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -37,9 +37,6 @@ distortion this produces is comparable to u-law, so it should be
a fair test of performance in a real PSTN channel.
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -51,9 +48,7 @@ a fair test of performance in a real PSTN channel.
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -179,13 +174,13 @@ static int my_mf_generate(int16_t amp[], char digit)
{
int len;
char *cp;
tone_gen_state_t tone;
tone_gen_state_t *tone;
len = 0;
if ((cp = strchr(r2_mf_tone_codes, digit)))
{
tone_gen_init(&tone, &my_mf_digit_tones[cp - r2_mf_tone_codes]);
len += tone_gen(&tone, amp + len, 9999);
tone = tone_gen_init(NULL, &my_mf_digit_tones[cp - r2_mf_tone_codes]);
len += tone_gen(tone, amp + len, 9999);
}
return len;
}
@ -242,10 +237,10 @@ static int test_a_tone_set(int fwd)
float rrb;
float rcfo;
int16_t amp[100000];
r2_mf_rx_state_t mf_state;
awgn_state_t noise_source;
r2_mf_rx_state_t *mf_state;
awgn_state_t *noise_source;
r2_mf_rx_init(&mf_state, fwd, NULL, NULL);
mf_state = r2_mf_rx_init(NULL, fwd, NULL, NULL);
/* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
which has no meaning here. */
@ -268,8 +263,8 @@ static int test_a_tone_set(int fwd)
{
len = my_mf_generate(amp, digit);
codec_munge (amp, len);
r2_mf_rx(&mf_state, amp, len);
actual = r2_mf_rx_get(&mf_state);
r2_mf_rx(mf_state, amp, len);
actual = r2_mf_rx_get(mf_state);
if (actual != digit)
{
printf (" Sent '%c'\n", digit);
@ -320,8 +315,8 @@ static int test_a_tone_set(int fwd)
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, fwd);
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nplus++;
}
for (nminus = 0, i = -1; i >= -60; i--)
@ -329,8 +324,8 @@ static int test_a_tone_set(int fwd)
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, fwd);
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nminus++;
}
rrb = (float) (nplus + nminus)/10.0;
@ -353,8 +348,8 @@ static int test_a_tone_set(int fwd)
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, fwd);
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nplus++;
}
for (nminus = 0, i = -1; i >= -60; i--)
@ -362,8 +357,8 @@ static int test_a_tone_set(int fwd)
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, fwd);
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nminus++;
}
rrb = (float) (nplus + nminus)/10.0;
@ -399,8 +394,8 @@ static int test_a_tone_set(int fwd)
len = my_mf_generate(amp, digit);
codec_munge (amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nplus++;
}
printf (" %c normal twist = %.2fdB\n", digit, (float) nplus/10.0);
@ -415,8 +410,8 @@ static int test_a_tone_set(int fwd)
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) == digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) == digit)
nminus++;
}
printf (" %c reverse twist = %.2fdB\n", digit, (float) nminus/10.0);
@ -445,8 +440,8 @@ static int test_a_tone_set(int fwd)
{
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) != digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) != digit)
break;
}
if (j < 100)
@ -488,8 +483,8 @@ static int test_a_tone_set(int fwd)
{
len = my_mf_generate(amp, digit);
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) != digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) != digit)
break;
}
if (j < 500)
@ -518,15 +513,15 @@ static int test_a_tone_set(int fwd)
while (*s)
{
digit = *s++;
awgn_init_dbm0(&noise_source, 1234567, (float) i);
noise_source = awgn_init_dbm0(NULL, 1234567, (float) i);
for (j = 0; j < 500; j++)
{
len = my_mf_generate(amp, digit);
for (sample = 0; sample < len; sample++)
amp[sample] = saturate(amp[sample] + awgn(&noise_source));
amp[sample] = saturate(amp[sample] + awgn(noise_source));
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
if (r2_mf_rx_get(&mf_state) != digit)
r2_mf_rx(mf_state, amp, len);
if (r2_mf_rx_get(mf_state) != digit)
break;
}
if (j < 500)
@ -546,24 +541,24 @@ static int test_a_tone_set(int fwd)
printf("Test 8: Callback digit delivery mode.\n");
callback_ok = FALSE;
callback_roll = 0;
r2_mf_rx_init(&mf_state, fwd, digit_delivery, (void *) 0x12345678);
mf_state = r2_mf_rx_init(NULL, fwd, digit_delivery, (void *) 0x12345678);
my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd);
s = r2_mf_tone_codes;
awgn_init_dbm0(&noise_source, 1234567, -40.0f);
noise_source = awgn_init_dbm0(NULL, 1234567, -40.0f);
while (*s)
{
digit = *s++;
len = my_mf_generate(amp, digit);
for (sample = 0; sample < len; sample++)
amp[sample] = saturate(amp[sample] + awgn(&noise_source));
amp[sample] = saturate(amp[sample] + awgn(noise_source));
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
r2_mf_rx(mf_state, amp, len);
len = 160;
memset(amp, '\0', len*sizeof(int16_t));
for (sample = 0; sample < len; sample++)
amp[sample] = saturate(amp[sample] + awgn(&noise_source));
amp[sample] = saturate(amp[sample] + awgn(noise_source));
codec_munge(amp, len);
r2_mf_rx(&mf_state, amp, len);
r2_mf_rx(mf_state, amp, len);
}
if (!callback_ok)
{

View File

@ -33,9 +33,6 @@
???.
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -47,10 +44,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -44,10 +44,6 @@
#define GEN_CONST
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -43,10 +43,6 @@
#include <memory.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -52,10 +52,6 @@
#include <libxml/xinclude.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -54,10 +54,6 @@
#include <libxml/xinclude.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -0,0 +1,836 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* t31_pseudo_terminal_tests.c -
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2012 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <inttypes.h>
#include <stdlib.h>
#if defined(WIN32)
#include <windows.h>
#else
#if defined(__APPLE__)
#include <util.h>
#include <sys/ioctl.h>
#elif defined(__FreeBSD__)
#include <libutil.h>
#include <termios.h>
#include <sys/socket.h>
#else
#include <pty.h>
#endif
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#endif
#include "spandsp.h"
#include "spandsp/t30_fcf.h"
#include "spandsp-sim.h"
#undef SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include "pseudo_terminals.h"
#if defined(ENABLE_GUI)
#include "media_monitor.h"
#endif
#include "fax_utils.h"
#define INPUT_FILE_NAME "../test-data/itu/fax/itutests.tif"
#define OUTPUT_FILE_NAME "t31_pseudo_terminal.tif"
#define OUTPUT_WAVE_FILE_NAME "t31_tests.wav"
#define MANUFACTURER "www.soft-switch.org"
#define SAMPLES_PER_CHUNK 160
typedef enum
{
MODEM_POLL_READ = (1 << 0),
MODEM_POLL_WRITE = (1 << 1),
MODEM_POLL_ERROR = (1 << 2)
} modem_poll_t;
g1050_state_t *path_a_to_b;
g1050_state_t *path_b_to_a;
double when = 0.0;
int t38_mode = FALSE;
struct modem_s modem[10];
char *decode_test_file = NULL;
int countdown = 0;
int answered = 0;
int done = FALSE;
int test_seq_ptr = 0;
t31_state_t *t31_state;
static int phase_b_handler(t30_state_t *s, void *user_data, int result)
{
int i;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase B", i);
printf("%c: Phase B handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
static int phase_d_handler(t30_state_t *s, void *user_data, int result)
{
int i;
char tag[20];
i = (int) (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase D", i);
printf("%c: Phase D handler on channel %c - (0x%X) %s\n", i, i, result, t30_frametype(result));
fax_log_page_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
return T30_ERR_OK;
}
/*- End of function --------------------------------------------------------*/
static void phase_e_handler(t30_state_t *s, void *user_data, int result)
{
int i;
char tag[20];
i = (intptr_t) user_data;
snprintf(tag, sizeof(tag), "%c: Phase E", i);
printf("Phase E handler on channel %c\n", i);
fax_log_final_transfer_statistics(s, tag);
fax_log_tx_parameters(s, tag);
fax_log_rx_parameters(s, tag);
//exit(0);
}
/*- End of function --------------------------------------------------------*/
static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len)
{
#if defined(WIN32)
DWORD res;
OVERLAPPED o;
#else
int res;
#endif
modem_t *modem;
int i;
printf("YYZ %d - ", (int) len);
for (i = 0; i < len; i++)
printf(" 0x%02x", buf[i]);
printf("\n");
modem = (modem_t *) user_data;
#if defined(WIN32)
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
/* Initialize the rest of the OVERLAPPED structure to zero. */
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;
assert(o.hEvent);
if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
GetOverlappedResult(modem->master, &o, &res, TRUE);
CloseHandle(o.hEvent);
#else
res = write(modem->master, buf, len);
#endif
if (res != len)
{
printf("Failed to write the whole buffer to the device. %d bytes of %d written: %s\n", res, (int) len, strerror(errno));
if (res == -1)
res = 0;
#if !defined(WIN32)
if (tcflush(modem->master, TCOFLUSH))
printf("Unable to flush pty master buffer: %s\n", strerror(errno));
else if (tcflush(modem->slave, TCOFLUSH))
printf("Unable to flush pty slave buffer: %s\n", strerror(errno));
else
printf("Successfully flushed pty buffer\n");
#endif
}
return 0;
}
/*- End of function --------------------------------------------------------*/
static int t31_call_control(t31_state_t *s, void *user_data, int op, const char *num)
{
uint8_t x[2];
modem_t *modem;
printf("Modem control - %s", at_modem_control_to_str(op));
modem = (modem_t *) user_data;
switch (op)
{
case AT_MODEM_CONTROL_CALL:
printf(" %s", num);
t31_call_event(t31_state, AT_CALL_EVENT_CONNECTED);
answered = 2;
break;
case AT_MODEM_CONTROL_ANSWER:
answered = 1;
break;
case AT_MODEM_CONTROL_HANGUP:
//done = TRUE;
break;
case AT_MODEM_CONTROL_OFFHOOK:
break;
case AT_MODEM_CONTROL_DTR:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RTS:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_CTS:
printf(" %d", (int) (intptr_t) num);
/* Use XON/XOFF characters for flow control */
switch (t31_state->at_state.dte_dce_flow_control)
{
case 1:
x[0] = (num) ? 0x11 : 0x13;
at_tx_handler(&t31_state->at_state, user_data, x, 1);
break;
case 2:
break;
}
/*endswitch*/
modem->block_read = (num == NULL);
break;
case AT_MODEM_CONTROL_CAR:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RNG:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_DSR:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_SETID:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RESTART:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_DTE_TIMEOUT:
printf(" %d", (int) (intptr_t) num);
break;
}
/*endswitch*/
printf("\n");
return 0;
}
/*- End of function --------------------------------------------------------*/
static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
{
int i;
/* This routine queues messages between two instances of T.38 processing, from the T.38 terminal side. */
span_log(t38_core_get_logging_state(s), SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
for (i = 0; i < count; i++)
{
if (g1050_put(path_a_to_b, buf, len, s->tx_seq_no, when) < 0)
printf("Lost packet %d\n", s->tx_seq_no);
}
return 0;
}
/*- End of function --------------------------------------------------------*/
static int t31_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
{
int i;
/* This routine queues messages between two instances of T.38 processing, from the T.31 modem side. */
span_log(t38_core_get_logging_state(s), SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
for (i = 0; i < count; i++)
{
if (g1050_put(path_b_to_a, buf, len, s->tx_seq_no, when) < 0)
printf("Lost packet %d\n", s->tx_seq_no);
}
return 0;
}
/*- End of function --------------------------------------------------------*/
#if defined(WIN32)
static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
{
/* This method ignores ms and waits infinitely */
DWORD dwEvtMask;
DWORD dwWait;
DWORD comerrors;
OVERLAPPED o;
BOOL result;
int ret;
HANDLE arHandles[2];
ret = MODEM_POLL_ERROR;
arHandles[0] = modem->threadAbort;
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
arHandles[1] = o.hEvent;
/* Initialize the rest of the OVERLAPPED structure to zero. */
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;
assert(o.hEvent);
if ((result = WaitCommEvent(modem->master, &dwEvtMask, &o)) == 0)
{
if (GetLastError() != ERROR_IO_PENDING)
{
/* Something went horribly wrong with WaitCommEvent(), so
clear all errors and try again */
ClearCommError(modem->master, &comerrors, 0);
}
else
{
/* IO is pending, wait for it to finish */
dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE);
if (dwWait == WAIT_OBJECT_0 + 1 && !modem->block_read)
ret = MODEM_POLL_READ;
}
}
else
{
if (!modem->block_read)
ret = MODEM_POLL_READ;
}
CloseHandle (o.hEvent);
return ret;
}
/*- End of function --------------------------------------------------------*/
#else
static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
{
struct pollfd pfds[2] = {{0}};
int s;
int ret;
pfds[0].fd = sock;
if ((flags & MODEM_POLL_READ))
pfds[0].events |= POLLIN;
if ((flags & MODEM_POLL_WRITE))
pfds[0].events |= POLLOUT;
if ((flags & MODEM_POLL_ERROR))
pfds[0].events |= POLLERR;
s = poll(pfds, (modem->block_read) ? 0 : 1, ms);
ret = 0;
if (s < 0)
{
ret = s;
}
else if (s > 0)
{
if ((pfds[0].revents & POLLIN))
ret |= MODEM_POLL_READ;
if ((pfds[0].revents & POLLOUT))
ret |= MODEM_POLL_WRITE;
if ((pfds[0].revents & POLLERR))
ret |= MODEM_POLL_ERROR;
}
return ret;
}
/*- End of function --------------------------------------------------------*/
#endif
static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int test_sending, int g1050_model_no, int g1050_speed_pattern_no)
{
t38_terminal_state_t *t38_state;
fax_state_t *fax_state;
uint8_t msg[1024];
char buf[1024];
int len;
int msg_len;
int t30_len;
int t31_len;
int t38_version;
int without_pacing;
int use_tep;
int seq_no;
double tx_when;
double rx_when;
t30_state_t *t30;
t38_core_state_t *t38_core;
logging_state_t *logging;
int k;
int outframes;
int ret;
int16_t t30_amp[SAMPLES_PER_CHUNK];
int16_t t31_amp[SAMPLES_PER_CHUNK];
int16_t silence[SAMPLES_PER_CHUNK];
int16_t out_amp[2*SAMPLES_PER_CHUNK];
SNDFILE *wave_handle;
SNDFILE *in_handle;
at_state_t *at_state;
#if defined(WIN32)
DWORD read_bytes;
OVERLAPPED o;
#endif
/* Test the T.31 modem against the full FAX machine in spandsp */
/* Set up the test environment */
t38_version = 1;
without_pacing = FALSE;
use_tep = FALSE;
wave_handle = NULL;
if (log_audio)
{
if ((wave_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
{
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
exit(2);
}
}
in_handle = NULL;
if (decode_test_file)
{
if ((in_handle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
{
fprintf(stderr, " Cannot create audio file '%s'\n", decode_test_file);
exit(2);
}
}
srand48(0x1234567);
if ((path_a_to_b = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
if ((path_b_to_a = g1050_init(g1050_model_no, g1050_speed_pattern_no, 100, 33)) == NULL)
{
fprintf(stderr, "Failed to start IP network path model\n");
exit(2);
}
t38_state = NULL;
fax_state = NULL;
if (test_sending)
{
if (t38_mode)
{
if ((t38_state = t38_terminal_init(NULL, FALSE, t38_tx_packet_handler, t31_state)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 channel\n");
exit(2);
}
t30 = t38_terminal_get_t30_state(t38_state);
}
else
{
fax_state = fax_init(NULL, FALSE);
t30 = fax_get_t30_state(fax_state);
}
t30_set_rx_file(t30, OUTPUT_FILE_NAME, -1);
countdown = 0;
}
else
{
if (t38_mode)
{
if ((t38_state = t38_terminal_init(NULL, TRUE, t38_tx_packet_handler, t31_state)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 channel\n");
exit(2);
}
t30 = t38_terminal_get_t30_state(t38_state);
}
else
{
fax_state = fax_init(NULL, TRUE);
t30 = fax_get_t30_state(fax_state);
}
t30_set_tx_file(t30, INPUT_FILE_NAME, -1, -1);
countdown = 250;
}
t30_set_ecm_capability(t30, use_ecm);
if (t38_mode)
{
t38_core = t38_terminal_get_t38_core_state(t38_state);
t38_set_t38_version(t38_core, t38_version);
t38_terminal_set_config(t38_state, without_pacing);
t38_terminal_set_tep_mode(t38_state, use_tep);
}
t30_set_tx_ident(t30, "11111111");
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
//t30_set_tx_nsf(t30, (const uint8_t *) "\x50\x00\x00\x00Spandsp\x00", 12);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) 'A');
if (t38_mode)
logging = t38_terminal_get_logging_state(t38_state);
else
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, (t38_mode) ? "T.38" : "FAX");
if (t38_mode)
{
t38_core = t38_terminal_get_t38_core_state(t38_state);
logging = t38_core_get_logging_state(t38_core);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
logging = t30_get_logging_state(t30);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.38");
}
else
{
logging = fax_get_logging_state(fax_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "FAX");
}
memset(silence, 0, sizeof(silence));
memset(t30_amp, 0, sizeof(t30_amp));
/* Now set up and run the T.31 modem */
if ((t31_state = t31_init(NULL, at_tx_handler, &modem[0], t31_call_control, &modem[0], t31_tx_packet_handler, NULL)) == NULL)
{
fprintf(stderr, " Cannot start the T.31 modem\n");
exit(2);
}
at_state = t31_get_at_state(t31_state);
logging = t31_get_logging_state(t31_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
logging = at_get_logging_state(at_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
if (t38_mode)
{
t38_core = t31_get_t38_core_state(t31_state);
logging = t38_core_get_logging_state(t38_core);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
t31_set_mode(t31_state, TRUE);
t38_set_t38_version(t38_core, t38_version);
}
at_reset_call_info(at_state);
at_set_call_info(at_state, "DATE", "1231");
at_set_call_info(at_state, "TIME", "1200");
at_set_call_info(at_state, "NAME", "Name");
at_set_call_info(at_state, "NMBR", "123456789");
at_set_call_info(at_state, "ANID", "987654321");
at_set_call_info(at_state, "USER", "User");
at_set_call_info(at_state, "CDID", "234567890");
at_set_call_info(at_state, "NDID", "345678901");
#if defined(ENABLE_GUI)
if (use_gui)
start_media_monitor();
#endif
while (!done)
{
/* Deal with call setup, through the AT interface. */
if (test_sending)
{
}
else
{
if (answered == 0)
{
if (--countdown == 0)
{
t31_call_event(t31_state, AT_CALL_EVENT_ALERTING);
countdown = 250;
}
}
else if (answered == 1)
{
printf("ZZZ\n");
answered = 2;
t31_call_event(t31_state, AT_CALL_EVENT_ANSWERED);
}
}
ret = modem_wait_sock(modem[0].master, 20, MODEM_POLL_READ);
if ((ret & MODEM_POLL_READ))
{
#if defined(WIN32)
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
/* Initialize the rest of the OVERLAPPED structure to zero. */
o.Internal = 0;
o.InternalHigh = 0;
o.Offset = 0;
o.OffsetHigh = 0;
assert(o.hEvent);
if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
CloseHandle (o.hEvent);
if ((len = read_bytes))
#else
if ((len = read(modem[0].master, buf, 1024)))
#endif
{
int i;
printf("YYY %d - ", len);
for (i = 0; i < len; i++)
printf(" 0x%02x", buf[i] & 0xFF);
printf("\n");
t31_at_rx(t31_state, buf, len);
}
}
if (answered == 2)
{
if (t38_mode)
{
while ((msg_len = g1050_get(path_a_to_b, msg, 1024, when, &seq_no, &tx_when, &rx_when)) >= 0)
{
#if defined(ENABLE_GUI)
if (use_gui)
media_monitor_rx(seq_no, tx_when, rx_when);
#endif
t38_core = t31_get_t38_core_state(t31_state);
t38_core_rx_ifp_packet(t38_core, msg, msg_len, seq_no);
}
while ((msg_len = g1050_get(path_b_to_a, msg, 1024, when, &seq_no, &tx_when, &rx_when)) >= 0)
{
#if defined(ENABLE_GUI)
if (use_gui)
media_monitor_rx(seq_no, tx_when, rx_when);
#endif
t38_core = t38_terminal_get_t38_core_state(t38_state);
t38_core_rx_ifp_packet(t38_core, msg, msg_len, seq_no);
}
#if defined(ENABLE_GUI)
if (use_gui)
media_monitor_update_display();
#endif
/* Bump the G.1050 models along */
when += (float) SAMPLES_PER_CHUNK/(float) SAMPLE_RATE;
/* Bump things along on the t38_terminal side */
span_log_bump_samples(t38_terminal_get_logging_state(t38_state), SAMPLES_PER_CHUNK);
t38_core = t38_terminal_get_t38_core_state(t38_state);
span_log_bump_samples(t38_core_get_logging_state(t38_core), SAMPLES_PER_CHUNK);
t38_terminal_send_timeout(t38_state, SAMPLES_PER_CHUNK);
t31_t38_send_timeout(t31_state, SAMPLES_PER_CHUNK);
}
else
{
t30_len = fax_tx(fax_state, t30_amp, SAMPLES_PER_CHUNK);
/* The receive side always expects a full block of samples, but the
transmit side may not be sending any when it doesn't need to. We
may need to pad with some silence. */
if (t30_len < SAMPLES_PER_CHUNK)
{
memset(t30_amp + t30_len, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - t30_len));
t30_len = SAMPLES_PER_CHUNK;
}
if (log_audio)
{
for (k = 0; k < t30_len; k++)
out_amp[2*k] = t30_amp[k];
}
if (t31_rx(t31_state, t30_amp, t30_len))
break;
t31_len = t31_tx(t31_state, t31_amp, SAMPLES_PER_CHUNK);
if (t31_len < SAMPLES_PER_CHUNK)
{
memset(t31_amp + t31_len, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - t31_len));
t31_len = SAMPLES_PER_CHUNK;
}
if (log_audio)
{
for (k = 0; k < t31_len; k++)
out_amp[2*k + 1] = t31_amp[k];
}
if (fax_rx(fax_state, t31_amp, SAMPLES_PER_CHUNK))
break;
if (log_audio)
{
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
if (outframes != SAMPLES_PER_CHUNK)
break;
}
/* Bump things along on the FAX machine side */
span_log_bump_samples(fax_get_logging_state(fax_state), SAMPLES_PER_CHUNK);
}
/* Bump things along on the FAX machine side */
span_log_bump_samples(t30_get_logging_state(t30), SAMPLES_PER_CHUNK);
/* Bump things along on the T.31 modem side */
t38_core = t31_get_t38_core_state(t31_state);
span_log_bump_samples(t38_core_get_logging_state(t38_core), SAMPLES_PER_CHUNK);
span_log_bump_samples(t31_get_logging_state(t31_state), SAMPLES_PER_CHUNK);
span_log_bump_samples(at_get_logging_state(t31_get_at_state(t31_state)), SAMPLES_PER_CHUNK);
}
}
if (t38_mode)
t38_terminal_release(t38_state);
if (decode_test_file)
{
if (sf_close_telephony(in_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
exit(2);
}
}
if (log_audio)
{
if (sf_close_telephony(wave_handle))
{
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
exit(2);
}
}
if (!done)
{
printf("Tests failed\n");
return 2;
}
return 0;
}
/*- End of function --------------------------------------------------------*/
int main(int argc, char *argv[])
{
int log_audio;
int t38_mode;
int test_sending;
int use_ecm;
int use_gui;
int g1050_model_no;
int g1050_speed_pattern_no;
int opt;
#if !defined(WIN32)
int tioflags;
#endif
decode_test_file = NULL;
log_audio = FALSE;
test_sending = FALSE;
t38_mode = FALSE;
use_ecm = FALSE;
use_gui = FALSE;
g1050_model_no = 0;
g1050_speed_pattern_no = 1;
while ((opt = getopt(argc, argv, "d:eglM:rS:st")) != -1)
{
switch (opt)
{
case 'd':
decode_test_file = optarg;
break;
case 'e':
use_ecm = TRUE;
break;
case 'g':
#if defined(ENABLE_GUI)
use_gui = TRUE;
#else
fprintf(stderr, "Graphical monitoring not available\n");
exit(2);
#endif
break;
case 'l':
log_audio = TRUE;
break;
case 'M':
g1050_model_no = optarg[0] - 'A' + 1;
break;
case 'r':
test_sending = FALSE;
break;
case 'S':
g1050_speed_pattern_no = atoi(optarg);
break;
case 's':
test_sending = TRUE;
break;
case 't':
t38_mode = TRUE;
break;
default:
//usage();
exit(2);
break;
}
}
if (psuedo_terminal_create(&modem[0]))
printf("Failure\n");
#if !defined(WIN32)
ioctl(modem[0].slave, TIOCMGET, &tioflags);
tioflags |= TIOCM_RI;
ioctl(modem[0].slave, TIOCMSET, &tioflags);
#endif
t30_tests(t38_mode, use_ecm, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no);
if (psuedo_terminal_close(&modem[0]))
printf("Failure\n");
printf("Tests passed\n");
return 0;
}
/*- End of function --------------------------------------------------------*/
/*- End of file ------------------------------------------------------------*/

View File

@ -29,9 +29,6 @@
\section t31_tests_page_sec_1 What does it do?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -48,10 +45,6 @@
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp/t30_fcf.h"
#include "spandsp-sim.h"
@ -112,8 +105,11 @@ static const struct command_response_s fax_send_test_seq[] =
RESPONSE("\r\nOK\r\n"),
EXCHANGE("AT+FRH=3\r", "\r\nCONNECT\r\n"),
//<DIS frame data>
RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\x78\x57\x10\x03"), // For audio FAXing
//RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\xE4\xE7\x10\x03"), // For T.38 FAXing
#if 0
RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\x78\x57\x10\x03"), // For audio FAXing
#else
RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\xE4\xE7\x10\x03"), // For T.38 FAXing
#endif
RESPONSE("\r\nOK\r\n"),
//EXCHANGE("AT+FRH=3\r", "\r\nNO CARRIER\r\n"),
EXCHANGE("AT+FTH=3\r", "\r\nCONNECT\r\n"),
@ -329,46 +325,51 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
static int modem_call_control(t31_state_t *s, void *user_data, int op, const char *num)
{
printf("\nModem control - %s", at_modem_control_to_str(op));
switch (op)
{
case AT_MODEM_CONTROL_ANSWER:
printf("\nModem control - Answering\n");
answered = TRUE;
break;
case AT_MODEM_CONTROL_CALL:
printf("\nModem control - Dialing '%s'\n", num);
printf(" %s", num);
t31_call_event(t31_state, AT_CALL_EVENT_CONNECTED);
break;
case AT_MODEM_CONTROL_ANSWER:
answered = TRUE;
break;
case AT_MODEM_CONTROL_HANGUP:
printf("\nModem control - Hanging up\n");
done = TRUE;
break;
case AT_MODEM_CONTROL_OFFHOOK:
printf("\nModem control - Going off hook\n");
break;
case AT_MODEM_CONTROL_DTR:
printf("\nModem control - DTR %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RTS:
printf("\nModem control - RTS %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_CTS:
printf("\nModem control - CTS %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_CAR:
printf("\nModem control - CAR %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RNG:
printf("\nModem control - RNG %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_DSR:
printf("\nModem control - DSR %d\n", (int) (intptr_t) num);
printf(" %d", (int) (intptr_t) num);
break;
default:
printf("\nModem control - operation %d\n", op);
case AT_MODEM_CONTROL_SETID:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_RESTART:
printf(" %d", (int) (intptr_t) num);
break;
case AT_MODEM_CONTROL_DTE_TIMEOUT:
printf(" %d", (int) (intptr_t) num);
break;
}
/*endswitch*/
printf("\n");
return 0;
}
/*- End of function --------------------------------------------------------*/
@ -482,8 +483,6 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
int fast_send;
int fast_send_tcf;
int fast_blocks;
uint8_t fast_buf[1000];
uint8_t msg[1024];
int msg_len;
int t30_len;
int t31_len;
@ -491,14 +490,16 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
int without_pacing;
int use_tep;
int seq_no;
int i;
int k;
int outframes;
uint8_t fast_buf[1000];
uint8_t msg[1024];
double tx_when;
double rx_when;
t30_state_t *t30;
t38_core_state_t *t38_core;
logging_state_t *logging;
int i;
int k;
int outframes;
int16_t t30_amp[SAMPLES_PER_CHUNK];
int16_t t31_amp[SAMPLES_PER_CHUNK];
int16_t silence[SAMPLES_PER_CHUNK];
@ -640,6 +641,10 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
logging = at_get_logging_state(t31_get_at_state(t31_state));
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
if (t38_mode)
{
t38_core = t31_get_t38_core_state(t31_state);
@ -647,9 +652,6 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(logging, "T.31");
span_log_set_level(&t31_state->at_state.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
span_log_set_tag(&t31_state->at_state.logging, "T.31");
t31_set_mode(t31_state, TRUE);
t38_set_t38_version(t38_core, t38_version);
}
@ -842,7 +844,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
t38_core = t31_get_t38_core_state(t31_state);
span_log_bump_samples(t38_core_get_logging_state(t38_core), SAMPLES_PER_CHUNK);
span_log_bump_samples(t31_get_logging_state(t31_state), SAMPLES_PER_CHUNK);
span_log_bump_samples(&t31_state->at_state.logging, SAMPLES_PER_CHUNK);
span_log_bump_samples(at_get_logging_state(t31_get_at_state(t31_state)), SAMPLES_PER_CHUNK);
}
if (t38_mode)

View File

@ -29,9 +29,6 @@
\section t35_tests_page_sec_1 What does it do?
*/
/* Enable the following definition to enable direct probing into the structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -44,10 +41,6 @@
#include <assert.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
int main(int argc, char *argv[])

View File

@ -40,13 +40,11 @@ These tests exercise the T.38 core ASN.1 processing code.
#include <string.h>
#include <assert.h>
#include <errno.h>
#if !defined(_WIN32)
#if !defined(WIN32)
#include <unistd.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -130,7 +128,7 @@ static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t
t38_core_state_t *t;
t = (t38_core_state_t *) user_data;
span_log(&s->logging, SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
span_log(t38_core_get_logging_state(s), SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
if (t38_core_rx_ifp_packet(t, buf, len, seq_no) < 0)
succeeded = FALSE;
seq_no++;
@ -140,7 +138,7 @@ static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t
static int tx_concat_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
span_log(t38_core_get_logging_state(s), SPAN_LOG_FLOW, "Send seq %d, len %d, count %d\n", s->tx_seq_no, len, count);
memcpy(&concat[concat_len], buf, len);
concat_len += len;
seq_no++;
@ -474,8 +472,10 @@ static int attack_tests(t38_core_state_t *s, int packets)
int main(int argc, char *argv[])
{
t38_core_state_t t38_core_a;
t38_core_state_t t38_core_b;
t38_core_state_t t38_core_ax;
t38_core_state_t t38_core_bx;
t38_core_state_t *t38_core_a;
t38_core_state_t *t38_core_b;
int attack_packets;
int opt;
@ -501,62 +501,62 @@ int main(int argc, char *argv[])
printf("Using T.38 version %d\n", t38_version);
if (t38_core_init(&t38_core_a,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_b,
tx_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_bx,
tx_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
if (t38_core_init(&t38_core_b,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_a,
tx_packet_handler,
&t38_core_a) == NULL)
if ((t38_core_b = t38_core_init(&t38_core_bx,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_ax,
tx_packet_handler,
&t38_core_ax)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(&t38_core_b, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
t38_set_t38_version(t38_core_b, t38_version);
span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_a.logging, "T.38-A");
span_log_set_level(&t38_core_b.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_b.logging, "T.38-B");
span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
span_log_set_level(t38_core_get_logging_state(t38_core_b), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_b), "T.38-B");
/* Encode and decode all possible frame types, one by one */
if (encode_decode_tests(&t38_core_a, &t38_core_b))
if (encode_decode_tests(t38_core_a, t38_core_b))
{
printf("Encode/decode tests failed\n");
exit(2);
}
if (t38_core_init(&t38_core_a,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_b,
tx_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_bx,
tx_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
//span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(&t38_core_a.logging, "T.38-A");
//span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
if (attack_tests(&t38_core_a, attack_packets))
if (attack_tests(t38_core_a, attack_packets))
{
printf("Attack tests failed\n");
exit(2);
@ -571,72 +571,72 @@ int main(int argc, char *argv[])
printf("Using T.38 version %d\n", t38_version);
if (t38_core_init(&t38_core_a,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_b,
tx_concat_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_bx,
tx_concat_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
if (t38_core_init(&t38_core_b,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_a,
tx_concat_packet_handler,
&t38_core_a) == NULL)
if ((t38_core_b = t38_core_init(&t38_core_bx,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_ax,
tx_concat_packet_handler,
&t38_core_ax)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(&t38_core_b, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
t38_set_t38_version(t38_core_b, t38_version);
t38_set_pace_transmission(&t38_core_a, FALSE);
t38_set_pace_transmission(&t38_core_b, FALSE);
t38_set_pace_transmission(t38_core_a, FALSE);
t38_set_pace_transmission(t38_core_b, FALSE);
t38_set_data_transport_protocol(&t38_core_a, T38_TRANSPORT_TCP);
t38_set_data_transport_protocol(&t38_core_b, T38_TRANSPORT_TCP);
t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP);
t38_set_data_transport_protocol(t38_core_b, T38_TRANSPORT_TCP);
span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_a.logging, "T.38-A");
span_log_set_level(&t38_core_b.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_b.logging, "T.38-B");
span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
span_log_set_level(t38_core_get_logging_state(t38_core_b), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_b), "T.38-B");
/* Encode all possible frames types into a large block, and then decode them */
if (encode_then_decode_tests(&t38_core_a, &t38_core_b))
if (encode_then_decode_tests(t38_core_a, t38_core_b))
{
printf("Encode then decode tests failed\n");
exit(2);
}
if (t38_core_init(&t38_core_a,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_b,
tx_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_bx,
tx_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
t38_set_pace_transmission(&t38_core_a, FALSE);
t38_set_pace_transmission(t38_core_a, FALSE);
t38_set_data_transport_protocol(&t38_core_a, T38_TRANSPORT_TCP);
t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP);
//span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(&t38_core_a.logging, "T.38-A");
//span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
if (attack_tests(&t38_core_a, attack_packets))
if (attack_tests(t38_core_a, attack_packets))
{
printf("Attack tests failed\n");
exit(2);
@ -651,71 +651,71 @@ int main(int argc, char *argv[])
printf("Using T.38 version %d\n", t38_version);
if (t38_core_init(&t38_core_a,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_b,
tx_concat_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_bx,
tx_concat_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
if (t38_core_init(&t38_core_b,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_a,
tx_concat_packet_handler,
&t38_core_a) == NULL)
if ((t38_core_b = t38_core_init(&t38_core_bx,
rx_indicator_handler,
rx_data_handler,
rx_missing_handler,
&t38_core_ax,
tx_concat_packet_handler,
&t38_core_ax)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(&t38_core_b, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
t38_set_t38_version(t38_core_b, t38_version);
t38_set_pace_transmission(&t38_core_a, FALSE);
t38_set_pace_transmission(&t38_core_b, FALSE);
t38_set_pace_transmission(t38_core_a, FALSE);
t38_set_pace_transmission(t38_core_b, FALSE);
t38_set_data_transport_protocol(&t38_core_a, T38_TRANSPORT_TCP_TPKT);
t38_set_data_transport_protocol(&t38_core_b, T38_TRANSPORT_TCP_TPKT);
t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP_TPKT);
t38_set_data_transport_protocol(t38_core_b, T38_TRANSPORT_TCP_TPKT);
span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_a.logging, "T.38-A");
span_log_set_level(&t38_core_b.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(&t38_core_b.logging, "T.38-B");
span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
span_log_set_level(t38_core_get_logging_state(t38_core_b), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
span_log_set_tag(t38_core_get_logging_state(t38_core_b), "T.38-B");
/* Encode all possible frames types into a large block, and then decode them */
if (encode_then_decode_tests(&t38_core_a, &t38_core_b))
if (encode_then_decode_tests(t38_core_a, t38_core_b))
{
printf("Encode then decode tests failed\n");
exit(2);
}
if (t38_core_init(&t38_core_a,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_b,
tx_packet_handler,
&t38_core_b) == NULL)
if ((t38_core_a = t38_core_init(&t38_core_ax,
rx_indicator_attack_handler,
rx_data_attack_handler,
rx_missing_attack_handler,
&t38_core_bx,
tx_packet_handler,
&t38_core_bx)) == NULL)
{
fprintf(stderr, "Cannot start the T.38 core\n");
exit(2);
}
t38_set_t38_version(&t38_core_a, t38_version);
t38_set_t38_version(t38_core_a, t38_version);
t38_set_pace_transmission(&t38_core_a, FALSE);
t38_set_pace_transmission(t38_core_a, FALSE);
t38_set_data_transport_protocol(&t38_core_a, T38_TRANSPORT_TCP_TPKT);
t38_set_data_transport_protocol(t38_core_a, T38_TRANSPORT_TCP_TPKT);
//span_log_set_level(&t38_core_a.logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(&t38_core_a.logging, "T.38-A");
//span_log_set_level(t38_core_get_logging_state(t38_core_a), SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG);
//span_log_set_tag(t38_core_get_logging_state(t38_core_a), "T.38-A");
if (attack_tests(&t38_core_a, attack_packets))
if (attack_tests(t38_core_a, attack_packets))
{
printf("Attack tests failed\n");
exit(2);

View File

@ -25,9 +25,6 @@
/*! \file */
/* Enable the following definition to enable direct probing into the FAX structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -44,10 +41,6 @@
#include <unistd.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "udptl.h"
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -42,9 +42,7 @@ module, used for T.38 gateways.
#include <assert.h>
#include <errno.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -39,9 +39,7 @@
#include <unistd.h>
#include <memory.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -41,16 +41,14 @@ in ITU specifications T.4 and T.6.
#include <unistd.h>
#include <memory.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
//#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
#include "spandsp.h"
#define XSIZE 1728
t4_t6_encode_state_t send_state;
t4_t6_decode_state_t receive_state;
t4_t6_encode_state_t *send_state;
t4_t6_decode_state_t *receive_state;
/* The following are some test cases from T.4 */
#define FILL_70 " "
@ -328,30 +326,27 @@ int main(int argc, char *argv[])
break;
}
}
/* Create a send and a receive end */
memset(&send_state, 0, sizeof(send_state));
memset(&receive_state, 0, sizeof(receive_state));
end_of_page = FALSE;
#if 1
printf("Testing image_function->compress->decompress->image_function\n");
/* Send end gets image from a function */
if (t4_t6_encode_init(&send_state, compression, 1728, row_read_handler, NULL) == NULL)
if ((send_state = t4_t6_encode_init(NULL, compression, 1728, row_read_handler, NULL)) == NULL)
{
printf("Failed to init T.4/T.6 encoder\n");
exit(2);
}
span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
t4_t6_encode_set_min_bits_per_row(&send_state, min_row_bits);
t4_t6_encode_set_max_2d_rows_per_1d_row(&send_state, 2);
span_log_set_level(t4_t6_encode_get_logging_state(send_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
t4_t6_encode_set_min_bits_per_row(send_state, min_row_bits);
t4_t6_encode_set_max_2d_rows_per_1d_row(send_state, 2);
/* Receive end puts TIFF to a function. */
if (t4_t6_decode_init(&receive_state, compression, 1728, row_write_handler, NULL) == NULL)
if ((receive_state = t4_t6_decode_init(NULL, compression, 1728, row_write_handler, NULL)) == NULL)
{
printf("Failed to init T.4/T.6 decoder\n");
exit(2);
}
span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
span_log_set_level(t4_t6_decode_get_logging_state(receive_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
/* Now send and receive the test data with all compression modes. */
/* If we are stepping around the compression schemes, reset to the start of the sequence. */
@ -366,12 +361,12 @@ int main(int argc, char *argv[])
if (compression < 0)
break;
}
t4_t6_encode_set_encoding(&send_state, compression);
t4_t6_decode_set_encoding(&receive_state, compression);
t4_t6_encode_set_encoding(send_state, compression);
t4_t6_decode_set_encoding(receive_state, compression);
if (t4_t6_encode_restart(&send_state, 1728))
if (t4_t6_encode_restart(send_state, 1728))
break;
if (t4_t6_decode_restart(&receive_state, 1728))
if (t4_t6_decode_restart(receive_state, 1728))
break;
detect_page_end(-1000000, compression);
switch (block_size)
@ -380,7 +375,7 @@ int main(int argc, char *argv[])
end_of_page = FALSE;
for (;;)
{
bit = t4_t6_encode_get_bit(&send_state);
bit = t4_t6_encode_get_bit(send_state);
if ((res = detect_page_end(bit, end_of_page)))
{
if (res != 1)
@ -391,13 +386,13 @@ int main(int argc, char *argv[])
break;
}
if (!end_of_page)
end_of_page = t4_t6_decode_put_bit(&receive_state, bit & 1);
end_of_page = t4_t6_decode_put_bit(receive_state, bit & 1);
}
break;
default:
do
{
len = t4_t6_encode_get(&send_state, chunk_buf, block_size);
len = t4_t6_encode_get(send_state, chunk_buf, block_size);
if (len == 0)
{
if (++end_marks > 50)
@ -409,7 +404,7 @@ int main(int argc, char *argv[])
chunk_buf[0] = 0xFF;
len = 1;
}
end_of_page = t4_t6_decode_put(&receive_state, chunk_buf, len);
end_of_page = t4_t6_decode_put(receive_state, chunk_buf, len);
}
while (!end_of_page);
break;
@ -417,8 +412,8 @@ int main(int argc, char *argv[])
if (compression_step < 0)
break;
}
t4_t6_encode_release(&send_state);
t4_t6_decode_release(&receive_state);
t4_t6_encode_release(send_state);
t4_t6_decode_release(receive_state);
#endif
printf("Tests passed\n");
return 0;

View File

@ -41,9 +41,7 @@ in ITU specifications T.4 and T.6.
#include <unistd.h>
#include <memory.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -52,8 +50,8 @@ in ITU specifications T.4 and T.6.
#define XSIZE 1728
t4_tx_state_t send_state;
t4_rx_state_t receive_state;
t4_tx_state_t *send_state;
t4_rx_state_t *receive_state;
/* The following are some test cases from T.4 */
#define FILL_70 " "
@ -421,9 +419,6 @@ int main(int argc, char *argv[])
break;
}
}
/* Create a send and a receive end */
memset(&send_state, 0, sizeof(send_state));
memset(&receive_state, 0, sizeof(receive_state));
end_of_page = T4_DECODE_MORE_DATA;
if (decode_file_name)
@ -431,19 +426,19 @@ int main(int argc, char *argv[])
if (compression < 0)
compression = T4_COMPRESSION_ITU_T4_1D;
/* Receive end puts TIFF to a new file. We assume the receive width here. */
if (t4_rx_init(&receive_state, OUT_FILE_NAME, T4_COMPRESSION_ITU_T4_2D) == NULL)
if ((receive_state = t4_rx_init(NULL, OUT_FILE_NAME, T4_COMPRESSION_ITU_T4_2D)) == NULL)
{
printf("Failed to init T.4 rx\n");
exit(2);
}
span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_rx_encoding(&receive_state, compression);
t4_rx_set_x_resolution(&receive_state, T4_X_RESOLUTION_R8);
//t4_rx_set_y_resolution(&receive_state, T4_Y_RESOLUTION_FINE);
t4_rx_set_y_resolution(&receive_state, T4_Y_RESOLUTION_STANDARD);
t4_rx_set_image_width(&receive_state, XSIZE);
span_log_set_level(t4_rx_get_logging_state(receive_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_rx_encoding(receive_state, compression);
t4_rx_set_x_resolution(receive_state, T4_X_RESOLUTION_R8);
//t4_rx_set_y_resolution(receive_state, T4_Y_RESOLUTION_FINE);
t4_rx_set_y_resolution(receive_state, T4_Y_RESOLUTION_STANDARD);
t4_rx_set_image_width(receive_state, XSIZE);
t4_rx_start_page(&receive_state);
t4_rx_start_page(receive_state);
last_pkt_no = 0;
file = fopen(decode_file_name, "r");
while (fgets(buf, 1024, file))
@ -457,7 +452,7 @@ int main(int argc, char *argv[])
break;
block[i] = bit;
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (sscanf(buf, "HDLC: %x", &pkt_no) == 1)
{
@ -468,7 +463,7 @@ int main(int argc, char *argv[])
break;
block[i] = bit;
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (sscanf(buf, "%*d:%*d:%*d.%*d T.38 Rx %d: IFP %x %x", &pkt_no, (unsigned int *) &bit, (unsigned int *) &bit) == 3)
{
@ -482,7 +477,7 @@ int main(int argc, char *argv[])
break;
block[i] = bit_reverse8(bit);
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (strlen(buf) > 2 && sscanf(buf, "T.30 Rx: %x %x %x %x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &pkt_no) == 4)
{
@ -496,7 +491,7 @@ int main(int argc, char *argv[])
break;
block[i] = bit_reverse8(bit);
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (sscanf(buf, "%04x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
{
@ -506,7 +501,7 @@ int main(int argc, char *argv[])
break;
block[i] = bit_reverse8(bit);
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (sscanf(buf, "%08x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
{
@ -516,11 +511,11 @@ int main(int argc, char *argv[])
break;
block[i] = bit_reverse8(bit);
}
end_of_page = t4_rx_put(&receive_state, block, i);
end_of_page = t4_rx_put(receive_state, block, i);
}
else if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1)
{
if ((end_of_page = t4_rx_put_bit(&receive_state, bit)))
if ((end_of_page = t4_rx_put_bit(receive_state, bit)))
{
printf("End of page detected\n");
break;
@ -529,38 +524,38 @@ int main(int argc, char *argv[])
}
fclose(file);
if (dump_as_xxx)
dump_image_as_xxx(&receive_state);
t4_rx_end_page(&receive_state);
display_page_stats(&receive_state);
t4_rx_release(&receive_state);
dump_image_as_xxx(receive_state);
t4_rx_end_page(receive_state);
display_page_stats(receive_state);
t4_rx_release(receive_state);
}
else
{
#if 1
printf("Testing image_function->compress->decompress->image_function\n");
/* Send end gets image from a function */
if (t4_tx_init(&send_state, NULL, -1, -1) == NULL)
if ((send_state = t4_tx_init(NULL, NULL, -1, -1)) == NULL)
{
printf("Failed to init T.4 tx\n");
exit(2);
}
span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_tx_set_row_read_handler(&send_state, row_read_handler, NULL);
t4_tx_set_image_width(&send_state, 1728);
t4_tx_set_min_bits_per_row(&send_state, min_row_bits);
t4_tx_set_max_2d_rows_per_1d_row(&send_state, 2);
span_log_set_level(t4_tx_get_logging_state(send_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_tx_set_row_read_handler(send_state, row_read_handler, NULL);
t4_tx_set_image_width(send_state, 1728);
t4_tx_set_min_bits_per_row(send_state, min_row_bits);
t4_tx_set_max_2d_rows_per_1d_row(send_state, 2);
/* Receive end puts TIFF to a function. */
if (t4_rx_init(&receive_state, NULL, T4_COMPRESSION_ITU_T4_2D) == NULL)
if ((receive_state = t4_rx_init(NULL, NULL, T4_COMPRESSION_ITU_T4_2D)) == NULL)
{
printf("Failed to init T.4 rx\n");
exit(2);
}
span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_row_write_handler(&receive_state, row_write_handler, NULL);
t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state));
t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state));
t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state));
span_log_set_level(t4_rx_get_logging_state(receive_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_rx_set_row_write_handler(receive_state, row_write_handler, NULL);
t4_rx_set_image_width(receive_state, t4_tx_get_image_width(send_state));
t4_rx_set_x_resolution(receive_state, t4_tx_get_x_resolution(send_state));
t4_rx_set_y_resolution(receive_state, t4_tx_get_y_resolution(send_state));
/* Now send and receive the test data with all compression modes. */
/* If we are stepping around the compression schemes, reset to the start of the sequence. */
@ -575,21 +570,21 @@ int main(int argc, char *argv[])
if (compression < 0 || (block_size == 0 && compression_step >= 3))
break;
}
t4_tx_set_tx_encoding(&send_state, compression);
t4_rx_set_rx_encoding(&receive_state, compression);
t4_tx_set_tx_encoding(send_state, compression);
t4_rx_set_rx_encoding(receive_state, compression);
rows_read = 0;
rows_written = 0;
if (t4_tx_start_page(&send_state))
if (t4_tx_start_page(send_state))
break;
if (t4_rx_start_page(&receive_state))
if (t4_rx_start_page(receive_state))
break;
detect_page_end(-1000000, compression);
page_ended = FALSE;
switch (block_size)
{
case 0:
while ((bit = t4_tx_get_bit(&send_state)) >= 0)
while ((bit = t4_tx_get_bit(send_state)) >= 0)
{
/* Monitor whether the EOLs are there in the correct amount */
if ((res = detect_page_end(bit, page_ended)))
@ -605,12 +600,12 @@ int main(int argc, char *argv[])
if ((rand() % bit_error_rate) == 0)
bit ^= 1;
}
end_of_page = t4_rx_put_bit(&receive_state, bit);
end_of_page = t4_rx_put_bit(receive_state, bit);
}
}
while (end_of_page != T4_DECODE_OK)
{
end_of_page = t4_rx_put_bit(&receive_state, 0);
end_of_page = t4_rx_put_bit(receive_state, 0);
if (++end_marks > 50)
{
printf("Receiver missed the end of page mark\n");
@ -621,22 +616,22 @@ int main(int argc, char *argv[])
/* Now throw junk at the receive context, to ensure stuff occuring
after the end of page condition has no bad effect. */
for (i = 0; i < 1000; i++)
t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
t4_rx_put_bit(receive_state, (rand() >> 10) & 1);
break;
default:
/* Some decoders require a few extra bits before the recognise the end
of an image, so be prepared to offer it a few. */
do
{
len = t4_tx_get(&send_state, block, block_size);
len = t4_tx_get(send_state, block, block_size);
if (len > 0)
end_of_page = t4_rx_put(&receive_state, block, len);
end_of_page = t4_rx_put(receive_state, block, len);
}
while (len > 0);
while (end_of_page != T4_DECODE_OK)
{
block[0] = 0;
end_of_page = t4_rx_put(&receive_state, block, 1);
end_of_page = t4_rx_put(receive_state, block, 1);
if (++end_marks > 5)
{
printf("Receiver missed the end of page mark\n");
@ -646,9 +641,9 @@ int main(int argc, char *argv[])
}
break;
}
display_page_stats(&receive_state);
t4_tx_end_page(&send_state);
t4_rx_end_page(&receive_state);
display_page_stats(receive_state);
t4_tx_end_page(send_state);
t4_rx_end_page(receive_state);
if (rows_read != (15 + 1) || rows_written != (15 + 1))
{
printf("Test failed: %d rows read, %d rows written\n", rows_read, rows_written);
@ -657,28 +652,28 @@ int main(int argc, char *argv[])
if (compression_step < 0)
break;
}
t4_tx_release(&send_state);
t4_rx_release(&receive_state);
t4_tx_release(send_state);
t4_rx_release(receive_state);
#endif
#if 1
printf("Testing TIFF->compress->decompress->TIFF cycle\n");
/* Send end gets TIFF from a file */
if (t4_tx_init(&send_state, in_file_name, -1, -1) == NULL)
if ((send_state = t4_tx_init(NULL, in_file_name, -1, -1)) == NULL)
{
printf("Failed to init T.4 send\n");
exit(2);
}
span_log_set_level(&send_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_tx_set_min_bits_per_row(&send_state, min_row_bits);
t4_tx_set_local_ident(&send_state, "111 2222 3333");
span_log_set_level(t4_tx_get_logging_state(send_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
t4_tx_set_min_bits_per_row(send_state, min_row_bits);
t4_tx_set_local_ident(send_state, "111 2222 3333");
/* Receive end puts TIFF to a new file. */
if (t4_rx_init(&receive_state, OUT_FILE_NAME, T4_COMPRESSION_ITU_T4_2D) == NULL)
if ((receive_state = t4_rx_init(NULL, OUT_FILE_NAME, T4_COMPRESSION_ITU_T4_2D)) == NULL)
{
printf("Failed to init T.4 rx for '%s'\n", OUT_FILE_NAME);
exit(2);
}
span_log_set_level(&receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
span_log_set_level(t4_rx_get_logging_state(receive_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
/* Now send and receive all the pages in the source TIFF file */
sends = 0;
@ -690,19 +685,19 @@ int main(int argc, char *argv[])
end_marks = 0;
/* Add a header line to alternate pages, if required */
if (add_page_headers && (sends & 2))
t4_tx_set_header_info(&send_state, "Header");
t4_tx_set_header_info(send_state, "Header");
else
t4_tx_set_header_info(&send_state, NULL);
t4_tx_set_header_info(send_state, NULL);
if (page_header_tz && page_header_tz[0])
{
if (tz_init(&tz, page_header_tz))
t4_tx_set_header_tz(&send_state, &tz);
t4_tx_set_header_tz(send_state, &tz);
}
t4_tx_set_header_overlays_image(&send_state, overlay_page_headers);
t4_tx_set_header_overlays_image(send_state, overlay_page_headers);
if (restart_pages && (sends & 1))
{
/* Use restart, to send the page a second time */
if (t4_tx_restart_page(&send_state))
if (t4_tx_restart_page(send_state))
break;
}
else
@ -716,22 +711,22 @@ int main(int argc, char *argv[])
compression = compression_sequence[compression_step++];
}
}
t4_tx_set_tx_encoding(&send_state, compression);
t4_rx_set_rx_encoding(&receive_state, compression);
t4_tx_set_tx_encoding(send_state, compression);
t4_rx_set_rx_encoding(receive_state, compression);
if (t4_tx_start_page(&send_state))
if (t4_tx_start_page(send_state))
break;
t4_rx_set_x_resolution(&receive_state, t4_tx_get_x_resolution(&send_state));
t4_rx_set_y_resolution(&receive_state, t4_tx_get_y_resolution(&send_state));
t4_rx_set_image_width(&receive_state, t4_tx_get_image_width(&send_state));
t4_rx_set_x_resolution(receive_state, t4_tx_get_x_resolution(send_state));
t4_rx_set_y_resolution(receive_state, t4_tx_get_y_resolution(send_state));
t4_rx_set_image_width(receive_state, t4_tx_get_image_width(send_state));
}
t4_rx_start_page(&receive_state);
t4_rx_start_page(receive_state);
detect_page_end(-1000000, compression);
page_ended = FALSE;
switch (block_size)
{
case 0:
while ((bit = t4_tx_get_bit(&send_state)) >= 0)
while ((bit = t4_tx_get_bit(send_state)) >= 0)
{
/* Monitor whether the EOLs are there in the correct amount */
if ((res = detect_page_end(bit, page_ended)))
@ -745,11 +740,11 @@ int main(int argc, char *argv[])
if ((rand() % bit_error_rate) == 0)
bit ^= 1;
}
end_of_page = t4_rx_put_bit(&receive_state, bit);
end_of_page = t4_rx_put_bit(receive_state, bit);
}
while (end_of_page != T4_DECODE_OK)
{
end_of_page = t4_rx_put_bit(&receive_state, 0);
end_of_page = t4_rx_put_bit(receive_state, 0);
if (++end_marks > 50)
{
printf("Receiver missed the end of page mark\n");
@ -760,14 +755,14 @@ int main(int argc, char *argv[])
/* Now throw junk at the receive context, to ensure stuff occuring
after the end of page condition has no bad effect. */
for (i = 0; i < 1000; i++)
t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
t4_rx_put_bit(receive_state, (rand() >> 10) & 1);
break;
default:
do
{
len = t4_tx_get(&send_state, block, block_size);
len = t4_tx_get(send_state, block, block_size);
if (len > 0)
end_of_page = t4_rx_put(&receive_state, block, len);
end_of_page = t4_rx_put(receive_state, block, len);
}
while (len > 0);
/* Some decoders require a few extra bits before the recognise the end
@ -775,7 +770,7 @@ int main(int argc, char *argv[])
while (end_of_page != T4_DECODE_OK)
{
block[0] = 0;
end_of_page = t4_rx_put(&receive_state, block, 1);
end_of_page = t4_rx_put(receive_state, block, 1);
if (++end_marks > 5)
{
printf("Receiver missed the end of page mark\n");
@ -786,15 +781,15 @@ int main(int argc, char *argv[])
break;
}
if (dump_as_xxx)
dump_image_as_xxx(&receive_state);
display_page_stats(&receive_state);
dump_image_as_xxx(receive_state);
display_page_stats(receive_state);
if (!restart_pages || (sends & 1))
t4_tx_end_page(&send_state);
t4_rx_end_page(&receive_state);
t4_tx_end_page(send_state);
t4_rx_end_page(receive_state);
sends++;
}
t4_tx_release(&send_state);
t4_rx_release(&receive_state);
t4_tx_release(send_state);
t4_rx_release(receive_state);
/* And we should now have a matching received TIFF file. Note this will only match
at the image level. TIFF files allow a lot of ways to express the same thing,
so bit matching of the files is not the normal case. */

View File

@ -46,9 +46,7 @@ the present time.
#include <stddef.h>
#include <string.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"

View File

@ -50,9 +50,7 @@ in ITU specifications T.85.
#include <stddef.h>
#include <string.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
@ -74,12 +72,7 @@ int clip_to_row = 0;
static int row_read_handler(void *user_data, uint8_t buf[], size_t len)
{
//t85_encode_state_t *s;
//s = (t85_encode_state_t *) user_data;
memcpy(buf, &test_image[len*read_row], len);
//printf("Read row %d\n", read_row);
if (clip_to_row && read_row == clip_to_row)
{
clip_to_row = 0;
@ -187,8 +180,8 @@ static int test_cycle(const char *test_id,
const uint8_t *comment,
size_t correct_length)
{
t85_encode_state_t t85_enc;
t85_decode_state_t t85_dec;
t85_encode_state_t *t85_enc;
t85_decode_state_t *t85_dec;
long int l;
size_t image_size;
int result;
@ -212,33 +205,33 @@ static int test_cycle(const char *test_id,
if ((optionsx & T85_VLENGTH))
{
t85_encode_init(&t85_enc, width, height + 10, row_read_handler, &t85_enc);
t85_enc = t85_encode_init(NULL, width, height + 10, row_read_handler, NULL);
clip_to_row = height;
}
else
{
t85_encode_init(&t85_enc, width, height, row_read_handler, &t85_enc);
t85_enc = t85_encode_init(NULL, width, height, row_read_handler, NULL);
clip_to_row = 0;
}
read_row = 0;
t85_encode_set_options(&t85_enc, l0, mx, options);
t85_encode_set_options(t85_enc, l0, mx, options);
/* A comment inserted here should always succeed. The later one, inserted some way
down the image, will only succeed if a new chunk is started afterwards. */
if (comment)
t85_encode_comment(&t85_enc, comment, strlen((const char *) comment) + 1);
t85_encode_comment(t85_enc, comment, strlen((const char *) comment) + 1);
testbuf_len = 0;
max_len = 100;
while ((len = t85_encode_get(&t85_enc, &testbuf[testbuf_len], max_len)) > 0)
while ((len = t85_encode_get(t85_enc, &testbuf[testbuf_len], max_len)) > 0)
{
testbuf_len += len;
max_len = 100;
if (testbuf_len + 100 > TESTBUF_SIZE)
max_len = TESTBUF_SIZE - testbuf_len;
if (comment && testbuf_len == 1000)
t85_encode_comment(&t85_enc, comment, strlen((const char *) comment) + 1);
t85_encode_comment(t85_enc, comment, strlen((const char *) comment) + 1);
}
t85_encode_release(&t85_enc);
t85_encode_release(t85_enc);
printf("Encoded BIE has %lu bytes\n", (unsigned long int) testbuf_len);
if (correct_length > 0)
{
@ -257,15 +250,15 @@ static int test_cycle(const char *test_id,
fprintf(stderr, "Out of memory!\n");
exit(2);
}
t85_decode_init(&t85_dec, row_write_handler, decoded_image);
t85_dec = t85_decode_init(NULL, row_write_handler, decoded_image);
if (comment && comment[0] != 'X')
t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL);
t85_decode_set_comment_handler(t85_dec, 1000, comment_handler, NULL);
write_row = 0;
result = t85_decode_put(&t85_dec, testbuf, testbuf_len);
result = t85_decode_put(t85_dec, testbuf, testbuf_len);
if (result == T4_DECODE_MORE_DATA)
result = t85_decode_put(&t85_dec, NULL, 0);
cnt_a = t85_encode_get_compressed_image_size(&t85_enc);
cnt_b = t85_decode_get_compressed_image_size(&t85_dec);
result = t85_decode_put(t85_dec, NULL, 0);
cnt_a = t85_encode_get_compressed_image_size(t85_enc);
cnt_b = t85_decode_get_compressed_image_size(t85_dec);
if (cnt_a != cnt_b || cnt_a != testbuf_len*8 || result != T4_DECODE_OK)
{
printf("Decode result %d\n", result);
@ -273,7 +266,7 @@ static int test_cycle(const char *test_id,
(long int) cnt_a,
(long int) cnt_b,
(unsigned long int) testbuf_len*8,
(unsigned long int) t85_dec.y);
(unsigned long int) t85_dec->y);
printf("Test failed\n");
exit(2);
}
@ -284,7 +277,7 @@ static int test_cycle(const char *test_id,
exit(2);
}
free(decoded_image);
t85_decode_release(&t85_dec);
t85_decode_release(t85_dec);
printf("Test passed\n");
printf("%s.3: Decode byte by byte\n", test_id);
@ -293,14 +286,14 @@ static int test_cycle(const char *test_id,
fprintf(stderr, "Out of memory!\n");
exit(2);
}
t85_decode_init(&t85_dec, row_write_handler, decoded_image);
t85_dec = t85_decode_init(NULL, row_write_handler, decoded_image);
if (comment && comment[0] != 'X')
t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL);
t85_decode_set_comment_handler(t85_dec, 1000, comment_handler, NULL);
write_row = 0;
result = T4_DECODE_MORE_DATA;
for (l = 0; l < testbuf_len; l++)
{
result = t85_decode_put(&t85_dec, &testbuf[l], 1);
result = t85_decode_put(t85_dec, &testbuf[l], 1);
if (result != T4_DECODE_MORE_DATA)
{
l++;
@ -308,14 +301,14 @@ static int test_cycle(const char *test_id,
}
}
if (result == T4_DECODE_MORE_DATA)
result = t85_decode_put(&t85_dec, NULL, 0);
result = t85_decode_put(t85_dec, NULL, 0);
if (l != testbuf_len || result != T4_DECODE_OK)
{
printf("Decode result %d\n", result);
printf("%ld bytes of %ld bytes of BIE read. %lu lines decoded.\n",
(long int) l,
(unsigned long int) testbuf_len,
(unsigned long int) t85_dec.y);
(unsigned long int) t85_dec->y);
printf("Test failed\n");
exit(2);
}
@ -326,7 +319,7 @@ static int test_cycle(const char *test_id,
exit(2);
}
free(decoded_image);
t85_decode_release(&t85_dec);
t85_decode_release(t85_dec);
printf("Test passed\n");
return 0;

View File

@ -37,10 +37,6 @@
#include <string.h>
#include <time.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#ifndef FALSE

View File

@ -38,10 +38,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#define DEC_SAMPLE_RATE 800
@ -71,8 +67,8 @@ static int periodogram_tests(void)
int32_t phase_rate2;
uint32_t phase_acc1;
uint32_t phase_acc2;
awgn_state_t noise_source_re;
awgn_state_t noise_source_im;
awgn_state_t *noise_source_re;
awgn_state_t *noise_source_im;
phase_rate1 = DEC_RATIO*dds_phase_ratef(FREQ1 - 5.0f);
phase_rate2 = DEC_RATIO*dds_phase_ratef(FREQ2);
@ -91,8 +87,8 @@ static int periodogram_tests(void)
for (k = -50; k < 0; k++)
{
printf("Setting noise to %ddBm0\n", k);
awgn_init_dbm0(&noise_source_re, 1234567, (float) k);
awgn_init_dbm0(&noise_source_im, 7654321, (float) k);
noise_source_re = awgn_init_dbm0(NULL, 1234567, (float) k);
noise_source_im = awgn_init_dbm0(NULL, 7654321, (float) k);
last_result = complex_setf(0.0f, 0.0f);
for (i = 0; i < 100; i++)
{
@ -104,8 +100,8 @@ static int periodogram_tests(void)
result = dds_complexf(&phase_acc2, phase_rate2);
camp[j].re += result.re*scale2;
camp[j].im += result.im*scale2;
camp[j].re += awgn(&noise_source_re);
camp[j].im += awgn(&noise_source_im);
camp[j].re += awgn(noise_source_re);
camp[j].im += awgn(noise_source_im);
}
result = periodogram(coeffs, camp, PG_WINDOW);
level = sqrtf(result.re*result.re + result.im*result.im);

View File

@ -38,10 +38,6 @@
#include <time.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -57,10 +57,6 @@
#include <libxml/xinclude.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -44,9 +44,6 @@ display of modem status is maintained.
\section v17_tests_page_sec_2 How is it used?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -67,9 +64,7 @@ display of modem status is maintained.
#include <fenv.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
@ -444,7 +439,7 @@ int main(int argc, char *argv[])
span_log_set_tag(logging, "V.17-tx");
v17_tx_power(tx, signal_level);
v17_tx_set_modem_status_handler(tx, v17_tx_status, (void *) tx);
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
/* Move the carrier off a bit */
tx->carrier_phase_rate = dds_phase_ratef(1792.0f);
tx->carrier_phase = 0x40000000;
@ -529,7 +524,7 @@ int main(int argc, char *argv[])
break;
}
memset(&latest_results, 0, sizeof(latest_results));
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
signal_level--;
/* Bump the receiver AGC gain by 1dB, to compensate for the above */
rx->agc_scaling_save *= 1.122f;

View File

@ -27,9 +27,6 @@
\section v18_tests_page_sec_1 What does it do?
*/
/* Enable the following definition to enable direct probing into the spandsp structures */
//#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -41,10 +38,6 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"

View File

@ -43,9 +43,6 @@ display of modem status is maintained.
\section v27ter_tests_page_sec_2 How is it used?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -66,9 +63,7 @@ display of modem status is maintained.
#include <fenv.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
@ -459,7 +454,7 @@ int main(int argc, char *argv[])
v27ter_tx_power(tx, signal_level);
v27ter_tx_set_modem_status_handler(tx, v27ter_tx_status, (void *) tx);
/* Move the carrier off a bit */
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
tx->carrier_phase_rate = dds_phase_ratef(1810.0f);
#endif
bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20);

View File

@ -43,9 +43,6 @@ display of modem status is maintained.
\section v29_tests_page_sec_2 How is it used?
*/
/* Enable the following definition to enable direct probing into the FAX structures */
#define WITH_SPANDSP_INTERNALS
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif
@ -66,9 +63,7 @@ display of modem status is maintained.
#include <fenv.h>
#endif
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"
@ -432,7 +427,7 @@ int main(int argc, char *argv[])
span_log_set_tag(logging, "V.29-tx");
v29_tx_power(tx, signal_level);
v29_tx_set_modem_status_handler(tx, v29_tx_status, (void *) tx);
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
/* Move the carrier off a bit */
tx->carrier_phase_rate = dds_phase_ratef(1710.0f);
tx->carrier_phase = 0;
@ -455,7 +450,7 @@ int main(int argc, char *argv[])
v29_rx_signal_cutoff(rx, -45.5f);
v29_rx_set_modem_status_handler(rx, v29_rx_status, (void *) rx);
v29_rx_set_qam_report_handler(rx, qam_report, (void *) rx);
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
/* Rotate the starting phase */
rx->carrier_phase = 0x80000000;
#endif
@ -520,7 +515,7 @@ int main(int argc, char *argv[])
v29_tx_restart(tx, test_bps, tep);
v29_tx_power(tx, signal_level);
v29_rx_restart(rx, test_bps, FALSE);
#if defined(WITH_SPANDSP_INTERNALS)
#if defined(SPANDSP_EXPOSE_INTERNAL_STRUCTURES)
rx->eq_put_step = rand()%(48*10/3);
#endif
bert_init(&bert, bits_per_test, BERT_PATTERN_ITU_O152_11, test_bps, 20);

View File

@ -41,14 +41,14 @@ then exchanged between them.
#include <string.h>
#include <assert.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
v42_state_t caller;
v42_state_t answerer;
v42_state_t callerx;
v42_state_t answererx;
v42_state_t *caller;
v42_state_t *answerer;
int variable_length;
int rx_next[3] = {0};
@ -80,7 +80,7 @@ static int v42_get_frames(void *user_data, uint8_t msg[], int len)
return 0;
}
s = (v42_state_t *) user_data;
x = (s == &caller) ? 1 : 2;
x = (s == caller) ? 1 : 2;
if (variable_length)
{
j = make_mask32(len);
@ -112,7 +112,7 @@ static void v42_put_frames(void *user_data, const uint8_t msg[], int len)
return;
}
s = (v42_state_t *) user_data;
x = (s == &caller) ? 1 : 2;
x = (s == caller) ? 1 : 2;
for (i = 0; i < len; i++)
{
if (msg[i] != (rx_next[x] & 0xFF))
@ -124,7 +124,7 @@ static void v42_put_frames(void *user_data, const uint8_t msg[], int len)
}
printf("%p: Got frame len %d\n", user_data, len);
printf("%p: %d Far end busy status %d\n", user_data, count, v42_get_far_busy_status(s));
if (s == &caller)
if (s == caller)
{
if (++count == 5)
{
@ -135,7 +135,7 @@ static void v42_put_frames(void *user_data, const uint8_t msg[], int len)
else
{
if (xxx && ++count == 45)
v42_set_local_busy_status(&caller, FALSE);
v42_set_local_busy_status(caller, FALSE);
}
}
/*- End of function --------------------------------------------------------*/
@ -169,28 +169,28 @@ int main(int argc, char *argv[])
}
}
v42_init(&caller, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) &caller);
v42_init(&answerer, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) &answerer);
v42_set_status_callback(&caller, v42_status, (void *) &caller);
v42_set_status_callback(&answerer, v42_status, (void *) &answerer);
v42_restart(&caller);
v42_restart(&answerer);
caller = v42_init(&callerx, TRUE, TRUE, v42_get_frames, v42_put_frames, (void *) &callerx);
answerer = v42_init(&answererx, FALSE, TRUE, v42_get_frames, v42_put_frames, (void *) &answererx);
v42_set_status_callback(caller, v42_status, (void *) caller);
v42_set_status_callback(answerer, v42_status, (void *) answerer);
v42_restart(caller);
v42_restart(answerer);
span_log_set_level(&caller.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
span_log_set_tag(&caller.logging, "caller");
span_log_set_level(&answerer.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
span_log_set_tag(&answerer.logging, "answerer");
span_log_set_level(v42_get_logging_state(caller), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
span_log_set_tag(v42_get_logging_state(caller), "caller");
span_log_set_level(v42_get_logging_state(answerer), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_DEBUG);
span_log_set_tag(v42_get_logging_state(answerer), "answerer");
for (i = 0; i < 1000000; i++)
{
bit = v42_tx_bit(&caller);
bit = v42_tx_bit(caller);
if (insert_caller_bit_errors && i%insert_caller_bit_errors == 0)
bit ^= 1;
v42_rx_bit(&answerer, bit);
bit = v42_tx_bit(&answerer);
v42_rx_bit(answerer, bit);
bit = v42_tx_bit(answerer);
if (insert_answerer_bit_errors && i%insert_answerer_bit_errors == 0)
bit ^= 1;
v42_rx_bit(&caller, bit);
v42_rx_bit(caller, bit);
}
return 0;
}

View File

@ -46,10 +46,6 @@ of this file should exactly match the original file.
#include <ctype.h>
#include <assert.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#define COMPRESSED_FILE_NAME "v42bis_tests.v42bis"
@ -79,8 +75,8 @@ static void data_handler(void *user_data, const uint8_t *buf, int len)
int main(int argc, char *argv[])
{
int len;
v42bis_state_t state_a;
v42bis_state_t state_b;
v42bis_state_t *state_a;
v42bis_state_t *state_b;
uint8_t buf[1024];
int in_fd;
int v42bis_fd;
@ -153,10 +149,10 @@ int main(int argc, char *argv[])
}
time(&now);
v42bis_init(&state_a, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, NULL, 512);
span_log_set_level(&state_a.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(&state_a.logging, "V.42bis");
//v42bis_compression_control(&state_a, V42BIS_COMPRESSION_MODE_ALWAYS);
state_a = v42bis_init(NULL, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, NULL, 512);
span_log_set_level(v42bis_get_logging_state(state_a), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(v42bis_get_logging_state(state_a), "V.42bis");
//v42bis_compression_control(state_a, V42BIS_COMPRESSION_MODE_ALWAYS);
in_octets_to_date = 0;
out_octets_to_date = 0;
while ((len = read(in_fd, buf, 1024)) > 0)
@ -166,24 +162,24 @@ int main(int argc, char *argv[])
{
while ((len - seg) >= stutter_time)
{
if (v42bis_compress(&state_a, buf + seg, stutter_time))
if (v42bis_compress(state_a, buf + seg, stutter_time))
{
fprintf(stderr, "Bad return code from compression\n");
exit(2);
}
v42bis_compress_flush(&state_a);
v42bis_compress_flush(state_a);
seg += stutter_time;
stutter_time = rand() & 0x3FF;
}
}
if (v42bis_compress(&state_a, buf + seg, len - seg))
if (v42bis_compress(state_a, buf + seg, len - seg))
{
fprintf(stderr, "Bad return code from compression\n");
exit(2);
}
in_octets_to_date += len;
}
v42bis_compress_flush(&state_a);
v42bis_compress_flush(state_a);
printf("%d bytes compressed to %d bytes in %lds\n", in_octets_to_date, out_octets_to_date, time(NULL) - now);
close(in_fd);
close(v42bis_fd);
@ -204,21 +200,21 @@ int main(int argc, char *argv[])
}
time(&now);
v42bis_init(&state_b, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, (void *) (intptr_t) out_fd, 512);
span_log_set_level(&state_b.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(&state_b.logging, "V.42bis");
state_b = v42bis_init(NULL, 3, 512, 6, frame_handler, (void *) (intptr_t) v42bis_fd, 512, data_handler, (void *) (intptr_t) out_fd, 512);
span_log_set_level(v42bis_get_logging_state(state_b), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
span_log_set_tag(v42bis_get_logging_state(state_b), "V.42bis");
in_octets_to_date = 0;
out_octets_to_date = 0;
while ((len = read(v42bis_fd, buf, 1024)) > 0)
{
if (v42bis_decompress(&state_b, buf, len))
if (v42bis_decompress(state_b, buf, len))
{
fprintf(stderr, "Bad return code from decompression\n");
exit(2);
}
in_octets_to_date += len;
}
v42bis_decompress_flush(&state_b);
v42bis_decompress_flush(state_b);
printf("%d bytes decompressed to %d bytes in %lds\n", in_octets_to_date, out_octets_to_date, time(NULL) - now);
close(v42bis_fd);
close(out_fd);

View File

@ -38,10 +38,6 @@
#include <string.h>
#include <sndfile.h>
//#if defined(WITH_SPANDSP_INTERNALS)
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
//#endif
#include "spandsp.h"
#include "spandsp-sim.h"