mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-12 04:27:06 +00:00
update spandsp to use newest snapshot http://www.soft-switch.org/downloads/snapshots/spandsp/spandsp-20080910.tar.gz
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9493 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
bc5cf34915
commit
ea964d8fe6
79 files changed
+2804
-1642
No files matched your search
@@ -22,7 +22,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: hdlc_tests.c,v 1.43 2008/05/13 13:17:25 steveu Exp $
|
||||
* $Id: hdlc_tests.c,v 1.46 2008/09/07 12:55:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -39,6 +39,7 @@ using both 16 and 32 bit CRCs.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
@@ -92,43 +93,15 @@ static void frame_handler(void *user_data, const uint8_t *pkt, int len, int ok)
|
||||
if (len < 0)
|
||||
{
|
||||
/* Special conditions */
|
||||
printf("HDLC rx status is %s (%d)\n", signal_status_to_str(len), len);
|
||||
switch (len)
|
||||
{
|
||||
case PUTBIT_TRAINING_IN_PROGRESS:
|
||||
printf("Training in progress\n");
|
||||
break;
|
||||
case PUTBIT_TRAINING_FAILED:
|
||||
printf("Training failed\n");
|
||||
break;
|
||||
case PUTBIT_TRAINING_SUCCEEDED:
|
||||
printf("Training succeeded\n");
|
||||
break;
|
||||
case PUTBIT_CARRIER_UP:
|
||||
printf("Carrier up\n");
|
||||
break;
|
||||
case PUTBIT_CARRIER_DOWN:
|
||||
printf("Carrier down\n");
|
||||
break;
|
||||
case PUTBIT_FRAMING_OK:
|
||||
case SIG_STATUS_FRAMING_OK:
|
||||
framing_ok_reported = TRUE;
|
||||
framing_ok_reports++;
|
||||
//printf("Framing OK\n");
|
||||
break;
|
||||
case PUTBIT_END_OF_DATA:
|
||||
printf("End of data\n");
|
||||
break;
|
||||
case PUTBIT_ABORT:
|
||||
case SIG_STATUS_ABORT:
|
||||
abort_reported = TRUE;
|
||||
//printf("Abort\n");
|
||||
break;
|
||||
case PUTBIT_BREAK:
|
||||
printf("Break\n");
|
||||
break;
|
||||
case PUTBIT_OCTET_REPORT:
|
||||
printf("Octet report\n");
|
||||
break;
|
||||
default:
|
||||
printf("Eh!\n");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
@@ -779,7 +752,7 @@ static int test_hdlc_octet_count_handling(void)
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void hdlc_tests(void)
|
||||
{
|
||||
printf("HDLC module tests\n");
|
||||
|
||||
@@ -811,6 +784,76 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
printf("Tests passed.\n");
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void decode_handler(void *user_data, const uint8_t *pkt, int len, int ok)
|
||||
{
|
||||
if (len < 0)
|
||||
{
|
||||
/* Special conditions */
|
||||
printf("HDLC rx status is %s (%d)\n", signal_status_to_str(len), len);
|
||||
return;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
printf("Good frame, len = %d\n", len);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Bad frame, len = %d\n", len);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void decode_bitstream(const char *in_file_name)
|
||||
{
|
||||
char buf[1024];
|
||||
int bit;
|
||||
hdlc_rx_state_t rx;
|
||||
FILE *in;
|
||||
|
||||
if ((in = fopen(in_file_name, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
hdlc_rx_init(&rx, TRUE, TRUE, 2, decode_handler, NULL);
|
||||
while (fgets(buf, 1024, in))
|
||||
{
|
||||
if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1)
|
||||
{
|
||||
hdlc_rx_put_bit(&rx, bit);
|
||||
}
|
||||
}
|
||||
fclose(in);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
const char *in_file_name;
|
||||
|
||||
in_file_name = NULL;
|
||||
while ((opt = getopt(argc, argv, "d:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
in_file_name = optarg;
|
||||
break;
|
||||
default:
|
||||
//usage();
|
||||
exit(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_file_name)
|
||||
decode_bitstream(in_file_name);
|
||||
else
|
||||
hdlc_tests();
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
Reference in new issue
Block a user