FreeCalypso > hg > freecalypso-sw
changeset 908:ed5dcc53e0b3
rvinterf: hook for fc-lcdemu implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 07 Sep 2015 10:55:01 +0000 |
parents | 7a189b7bbd67 |
children | 16ed75e266f2 |
files | rvinterf/lowlevel/Makefile rvinterf/lowlevel/rviflcd.c rvinterf/lowlevel/rvifmain.c |
diffstat | 3 files changed, 49 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/lowlevel/Makefile Mon Sep 07 10:35:20 2015 +0000 +++ b/rvinterf/lowlevel/Makefile Mon Sep 07 10:55:01 2015 +0000 @@ -7,7 +7,7 @@ RVTDUMP_OBJS= format.o openport.o output.o packetrx.o rvtdump.o RVINTERF_OBJS= clientcmd.o format.o localsock.o logsent.o openport.o output.o \ - packetrx.o packettx.o pktfwd.o rvifmain.o + packetrx.o packettx.o pktfwd.o rviflcd.o rvifmain.o TFC139_OBJS= format.o openport.o output.o packetrx.o packettx.o tfc139.o
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/lowlevel/rviflcd.c Mon Sep 07 10:55:01 2015 +0000 @@ -0,0 +1,38 @@ +/* + * This rvinterf module implements the piping of LCD output to fc-lcdemu + */ + +#include <sys/types.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include <unistd.h> + +extern u_char rxpkt[]; +extern size_t rxpkt_len; + +char *extlcd_program; +FILE *extlcd_pout; + +void +open_extlcd_pipe() +{ + extlcd_pout = popen(extlcd_program, "w"); + if (!extlcd_pout) { + perror(extlcd_program); + exit(1); + } +} + +void +output_to_extlcd() +{ + int i; + + fprintf(extlcd_pout, "%u %u ", rxpkt[1], rxpkt[2]); + for (i = 3; i < rxpkt_len; i += 2) + fprintf(extlcd_pout, "%02X%02X", rxpkt[i+1], rxpkt[i]); + fputc('\n', extlcd_pout); + fflush(extlcd_pout); +}
--- a/rvinterf/lowlevel/rvifmain.c Mon Sep 07 10:35:20 2015 +0000 +++ b/rvinterf/lowlevel/rvifmain.c Mon Sep 07 10:55:01 2015 +0000 @@ -17,6 +17,7 @@ extern int target_fd, listener; extern char *baudrate_name; +extern char *extlcd_program; extern u_char rxpkt[]; extern size_t rxpkt_len; @@ -43,7 +44,7 @@ fd_set fds; struct client *cli, **clip; - while ((c = getopt(argc, argv, "bB:d:l:ns:S:w:")) != EOF) + while ((c = getopt(argc, argv, "bB:d:l:ns:S:w:X:")) != EOF) switch (c) { case 'b': background++; @@ -69,6 +70,9 @@ case 'w': wakeup_after_sec = strtoul(optarg, 0, 0); continue; + case 'X': + extlcd_program = optarg; + continue; case '?': default: usage: fprintf(stderr, @@ -81,6 +85,8 @@ open_target_serial(argv[optind]); } max_fd = target_fd; + if (extlcd_program) + open_extlcd_pipe(); set_serial_nonblock(0); setlinebuf(stdout); @@ -182,10 +188,10 @@ case RVT_EXTUI_HEADER: if (rxpkt_len < 5 || !(rxpkt_len & 1)) goto unknown; - if (!no_output || logF) + if (extlcd_program) + output_to_extlcd(); + else report_extui_packet(); - if (client_head) - forward_nonrvt_pkt(); return; case '*': print_fc_lld_msg();