view cmu200/main.c @ 58:46c72323182a

autocal/rxband.c: do_gmagic() factored out of main()
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 23:17:14 +0000
parents 498b90f6e224
children 3ec82dc1dbda
line wrap: on
line source

/*
 * This module contains the main() function for fc-cmu200d.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int target_fd;

char *bind_socket_pathname = "/tmp/fc_rftest_socket";
char *cmu200_tx_name = "TX";
int cmu200_rf_port = 2;

main(argc, argv)
	char **argv;
{
	extern char *optarg;
	extern int optind;
	int c;

	while ((c = getopt(argc, argv, "1at:")) != EOF)
		switch (c) {
		case '1':
			cmu200_rf_port = 1;
			continue;
		case 'a':
			cmu200_tx_name = "AUXT";
			continue;
		case 't':
			bind_socket_pathname = optarg;
			continue;
		default:
usage:			fprintf(stderr,
				"usage: %s [options] serial-port baud\n",
				argv[0]);
			exit(1);
		}
	if (argc - optind != 2)
		goto usage;

	open_target_serial(argv[optind], argv[optind+1]);
	set_serial_nonblock(0);
	setlinebuf(stdout);	/* to allow logging with tee */
	init_cmu200();
	create_listener_socket();
	for (;;) {
		get_socket_connection();
		handle_session();
	}
}