view hrutil/dec-parse.c @ 567:2fcb6b27ee9b

hrutil: new program gsmhr-rpf2hex
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Feb 2025 02:32:21 +0000
parents 30c57cf6e87d
children
line wrap: on
line source

/*
 * This program reads an HRv1 *.dec file in ETSI test sequence format
 * (decoder input format) and displays its content in human-readable form.
 */

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "../libgsmhr1/tw_gsmhr.h"
#include "../libtest/local_endian.h"

main(argc, argv)
	char **argv;
{
	char *infname;
	FILE *inf;
	int big_endian;
	unsigned frame_no;
	int16_t params[GSMHR_NUM_PARAMS_DEC];
	int opt, rc;
	extern int optind;

	big_endian = is_native_big_endian();
	while ((opt = getopt(argc, argv, "bl")) != EOF) {
		switch (opt) {
		case 'b':
			big_endian = 1;
			continue;
		case 'l':
			big_endian = 0;
			continue;
		default:
		usage:
			fprintf(stderr, "usage: %s [-b|-l] file.dec\n",
				argv[0]);
			exit(1);
		}
	}
	if (argc != optind + 1)
		goto usage;
	infname = argv[optind];
	inf = fopen(infname, "r");
	if (!inf) {
		perror(infname);
		exit(1);
	}
	for (frame_no = 0; ; frame_no++) {
		rc = read_dec_frame(inf, big_endian, params, infname, frame_no);
		if (!rc)
			break;
		printf("#%u: BFI=%d UFI=%d SID=%d TAF=%d\n", frame_no,
			params[18], params[19], params[20], params[21]);
		print_frame_params(params);
	}
	exit(0);
}