diff rvinterf/rvtdump.c @ 171:4d8e4c58df71

rvtdump: implemented Tx extension hack, compiles
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 20 Nov 2013 05:39:31 +0000
parents e01e3a60c858
children
line wrap: on
line diff
--- a/rvinterf/rvtdump.c	Wed Nov 20 04:05:18 2013 +0000
+++ b/rvinterf/rvtdump.c	Wed Nov 20 05:39:31 2013 +0000
@@ -14,21 +14,22 @@
 extern char *baudrate_name;
 
 extern char pr_item[];
+extern int sendsock_fd;
 
 char *logfname;
 FILE *logF;
 time_t logtime;
-int background;
+int background, sendsock_enable;
 
 main(argc, argv)
 	char **argv;
 {
 	extern char *optarg;
 	extern int optind;
-	int c;
+	int c, maxfd;
 	fd_set fds;
 
-	while ((c = getopt(argc, argv, "bB:d:l:")) != EOF)
+	while ((c = getopt(argc, argv, "bB:d:l:s")) != EOF)
 		switch (c) {
 		case 'b':
 			background++;
@@ -42,6 +43,9 @@
 		case 'l':
 			logfname = optarg;
 			continue;
+		case 's':
+			sendsock_enable++;
+			continue;
 		case '?':
 		default:
 usage:			fprintf(stderr,
@@ -69,6 +73,8 @@
 		fprintf(logF, "*** Log of decoded RVT output ***\n");
 		setlinebuf(logF);
 	}
+	if (sendsock_enable)
+		create_send_socket();
 	if (background) {
 		c = fork();
 		if (c < 0) {
@@ -80,10 +86,15 @@
 			exit(0);
 		}
 	}
+	maxfd = target_fd;
+	if (sendsock_fd > maxfd)
+		maxfd = sendsock_fd;
 	for (;;) {
 		FD_ZERO(&fds);
 		FD_SET(target_fd, &fds);
-		c = select(target_fd+1, &fds, 0, 0, 0);
+		if (sendsock_enable)
+			FD_SET(sendsock_fd, &fds);
+		c = select(maxfd+1, &fds, 0, 0, 0);
 		time(&logtime);
 		if (c < 0) {
 			if (errno == EINTR)
@@ -93,6 +104,8 @@
 		}
 		if (FD_ISSET(target_fd, &fds))
 			process_serial_rx();
+		if (FD_ISSET(sendsock_fd, &fds))
+			handle_sendsock();
 	}
 }