annotate rvinterf/lowlevel/rvifmain.c @ 857:2768b4339275

a flash chip init/reset function added to Application_Initialize(), see the comments in gsm-fw/bsp/flashchipinit.S
author Space Falcon <falcon@ivan.Harhan.ORG>
date Fri, 01 May 2015 16:27:59 +0000
parents d527ac304ad5
children 2682003dcba7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
176
7f727aaf5cd4 rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 174
diff changeset
2 * This module contains the main() function for rvinterf
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/errno.h>
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
191
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
8 #include <string.h>
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
9 #include <strings.h>
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <unistd.h>
179
ebfa9657d03d rvinterf: ignore SIGPIPE
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
12 #include <signal.h>
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
13 #include <time.h>
256
2f285f20d617 rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 195
diff changeset
14 #include "../include/pktmux.h"
2f285f20d617 rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 195
diff changeset
15 #include "../include/localsock.h"
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
16 #include "client.h"
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
18 extern int target_fd, listener;
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern char *baudrate_name;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
21 extern u_char rxpkt[];
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
22 extern size_t rxpkt_len;
133
56b53c289785 rvtdump: some restructuring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 127
diff changeset
23
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
24 struct client *client_head;
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
25 int socketpair_fd;
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
26
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
27 char *logfname;
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
28 FILE *logF;
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
29 time_t logtime;
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
30 int background, no_output;
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
31 int max_fd;
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
32
187
f5f8776f7c66 rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 179
diff changeset
33 char *socket_pathname = "/tmp/rvinterf_socket";
f5f8776f7c66 rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 179
diff changeset
34
265
4c416868524a rvinterf: set -w default to 7, can be disabled with -w0
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
35 int wakeup_after_sec = 7;
191
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
36
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 main(argc, argv)
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 char **argv;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 {
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 extern char *optarg;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 extern int optind;
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
42 int c;
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 fd_set fds;
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
44 struct client *cli, **clip;
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
46 while ((c = getopt(argc, argv, "bB:d:l:ns:S:w:")) != EOF)
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 switch (c) {
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 case 'b':
169
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
49 background++;
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
50 /* FALL THRU */
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
51 case 'n':
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
52 no_output++;
169
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
53 continue;
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
54 case 'B':
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 baudrate_name = optarg;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 continue;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 case 'd':
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 target_fd = atoi(optarg);
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 continue;
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
60 case 'l':
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
61 logfname = optarg;
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
62 continue;
187
f5f8776f7c66 rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 179
diff changeset
63 case 's':
f5f8776f7c66 rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 179
diff changeset
64 socket_pathname = optarg;
f5f8776f7c66 rvinterf: added -s option for changing the local socket pathname
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 179
diff changeset
65 continue;
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
66 case 'S':
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
67 socketpair_fd = atoi(optarg);
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
68 continue;
191
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
69 case 'w':
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
70 wakeup_after_sec = strtoul(optarg, 0, 0);
cf8583923dc4 rvinterf: workaround for sleeping targets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 187
diff changeset
71 continue;
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 case '?':
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 default:
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 usage: fprintf(stderr,
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
75 "usage: %s [options] ttyport\n", argv[0]);
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 exit(1);
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 }
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 if (target_fd <= 0) {
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 if (argc - optind != 1)
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 goto usage;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 open_target_serial(argv[optind]);
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 }
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
83 max_fd = target_fd;
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 set_serial_nonblock(0);
127
f4f0c8738dcb rvtdump: satisfactory handling of output from Pirelli's fw
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 126
diff changeset
86 setlinebuf(stdout);
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
87 if (logfname) {
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
88 logF = fopen(logfname, "w");
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
89 if (!logF) {
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
90 perror(logfname);
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
91 exit(1);
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
92 }
330
1171c32a637b rvinterf & rvtdump: do setlinebuf() on the log file before emitting
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 265
diff changeset
93 setlinebuf(logF);
176
7f727aaf5cd4 rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 174
diff changeset
94 fprintf(logF, "*** Log of rvinterf session ***\n");
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
95 }
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
96 if (socketpair_fd)
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
97 create_socketpair_client();
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
98 else
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
99 create_listener_socket();
169
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
100 if (background) {
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
101 c = fork();
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
102 if (c < 0) {
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
103 perror("fork");
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
104 exit(1);
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
105 }
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
106 if (c) {
176
7f727aaf5cd4 rvinterf: beginning of server implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 174
diff changeset
107 printf("rvinterf forked into background (pid %d)\n", c);
169
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
108 exit(0);
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
109 }
e01e3a60c858 rvinterf: background mode implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
110 }
179
ebfa9657d03d rvinterf: ignore SIGPIPE
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 178
diff changeset
111 signal(SIGPIPE, SIG_IGN);
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 for (;;) {
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 FD_ZERO(&fds);
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 FD_SET(target_fd, &fds);
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
115 if (listener)
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
116 FD_SET(listener, &fds);
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
117 for (clip = &client_head; cli = *clip; ) {
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
118 if (cli->rx_state == 2) {
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
119 close(cli->fd);
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
120 *clip = cli->next;
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
121 free(cli);
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
122 continue;
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
123 }
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
124 FD_SET(cli->fd, &fds);
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
125 clip = &cli->next;
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
126 }
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
127 if (socketpair_fd && !client_head)
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
128 exit(0);
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
129 c = select(max_fd+1, &fds, 0, 0, 0);
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 133
diff changeset
130 time(&logtime);
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 if (c < 0) {
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 if (errno == EINTR)
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 continue;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 perror("select");
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 exit(1);
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 }
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 if (FD_ISSET(target_fd, &fds))
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 process_serial_rx();
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
139 if (listener && FD_ISSET(listener, &fds))
177
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
140 handle_listener_select();
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
141 for (cli = client_head; cli; cli = cli->next)
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
142 if (FD_ISSET(cli->fd, &fds))
fef035264dd4 rvinterf: beginning of local socket handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 176
diff changeset
143 handle_client_select(cli);
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 }
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 }
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 handle_rx_packet()
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 {
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
149 switch (rxpkt[0]) {
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
150 case RVT_RV_HEADER:
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
151 if (rxpkt_len < 6)
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
152 goto unknown;
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
153 if (!no_output || logF)
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
154 print_rv_trace();
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
155 if (client_head)
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
156 forward_rv_trace();
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
157 return;
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
158 case RVT_L1_HEADER:
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
159 if (!no_output || logF)
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
160 print_l1_trace();
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
161 if (client_head)
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
162 forward_nonrvt_pkt();
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
163 return;
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
164 case RVT_L23_HEADER:
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
165 if (!no_output || logF)
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
166 print_g23_trace();
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
167 if (client_head)
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
168 forward_nonrvt_pkt();
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
169 return;
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
170 case RVT_TM_HEADER:
195
549e6cd1e77d rvinterf: support for socketpair invokation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 191
diff changeset
171 if (!no_output || logF)
178
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
172 print_etm_output_raw();
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
173 if (client_head)
7ab6b29e76bb rvinterf: forwarding of Rx packets to clients implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 177
diff changeset
174 forward_nonrvt_pkt();
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
175 return;
856
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 330
diff changeset
176 case '*':
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 330
diff changeset
177 print_fc_lld_msg();
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 330
diff changeset
178 return;
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
179 default:
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
180 unknown:
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
181 print_unknown_packet();
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
182 }
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
183 }