Browse Source

Report invalid port statuses.

Georgi Chorbadzhiyski 9 years ago
parent
commit
c4d62cb179
3 changed files with 87 additions and 10 deletions
  1. 21
    5
      cmd.c
  2. 31
    1
      test/input-14.txt
  3. 35
    4
      test/test-14.ok

+ 21
- 5
cmd.c View File

@@ -198,16 +198,32 @@ bool parse_command(struct videohub_data *d, char *cmd) {
198 198
 			break;
199 199
 		case PARSE_STATUS:
200 200
 			s_port->port[port_num].status = S_UNKNOWN;
201
-			if (streq("BNC", port_data))          s_port->port[port_num].status = S_BNC;
202
-			else if (streq("Optical", port_data)) s_port->port[port_num].status = S_OPTICAL;
203
-			else if (streq("RS422", port_data))   s_port->port[port_num].status = S_RS422;
204
-			else if (streq("None", port_data))    s_port->port[port_num].status = S_NONE;
205
-			else if (streq("Thunderbolt", port_data)) s_port->port[port_num].status = S_THUNDERBOLT;
201
+			bool invalid_status = false;
202
+			if (v->cmd == CMD_SERIAL_PORT_STATUS) {
203
+				if (streq("RS422", port_data))        s_port->port[port_num].status = S_RS422;
204
+				else if (streq("None", port_data))    s_port->port[port_num].status = S_NONE;
205
+				else invalid_status = true;
206
+			} else {
207
+				if (streq("BNC", port_data))          s_port->port[port_num].status = S_BNC;
208
+				else if (streq("Optical", port_data)) s_port->port[port_num].status = S_OPTICAL;
209
+				else if (streq("None", port_data))    s_port->port[port_num].status = S_NONE;
210
+				else if (streq("Thunderbolt", port_data)) s_port->port[port_num].status = S_THUNDERBOLT;
211
+				else invalid_status = true;
212
+			}
213
+			if (invalid_status) {
214
+				q("WARNING: %s command returned unknown status: '%s'\n", cmd_txt, port_data);
215
+				q("Please report this line to author's email: georgi@unixsol.org\n");
216
+			}
206 217
 			break;
207 218
 		case PARSE_DIR:
208 219
 			s_port->port[port_num].direction = DIR_AUTO;
209 220
 			if (streq("control", port_data))      s_port->port[port_num].direction = DIR_CONTROL;
210 221
 			else if (streq("slave", port_data))   s_port->port[port_num].direction = DIR_SLAVE;
222
+			else if (streq("auto", port_data))    s_port->port[port_num].direction = DIR_AUTO;
223
+			else {
224
+				q("WARNING: %s command returned unknown direction: '%s'\n", cmd_txt, port_data);
225
+				q("Please report this line to author's email: georgi@unixsol.org\n");
226
+			}
211 227
 			break;
212 228
 		case PARSE_ROUTE:
213 229
 			dest_port_num = strtoul(port_data, NULL, 10);

+ 31
- 1
test/input-14.txt View File

@@ -9,7 +9,7 @@ Video inputs: 16
9 9
 Video processing units: 0
10 10
 Video outputs: 16
11 11
 Video monitoring outputs: 0
12
-Serial ports: 0
12
+Serial ports: 4
13 13
 
14 14
 INPUT LABELS:
15 15
 0 Windows 1
@@ -83,3 +83,33 @@ VIDEO OUTPUT ROUTING:
83 83
 14 -1
84 84
 15 15
85 85
 
86
+VIDEO OUTPUT STATUS:
87
+0 BNC
88
+1 None
89
+2 Optical
90
+3 Thunderbolt
91
+4 Something unknown
92
+5 RS422
93
+
94
+SERIAL PORT LABELS:
95
+0 Remote 1
96
+1 Remote 2
97
+2 Remote 3
98
+3 Remote 4
99
+
100
+SERIAL PORT DIRECTIONS:
101
+0 auto
102
+1 control
103
+2 slave
104
+3 Wrong direction
105
+
106
+UNKNOWN COMMAND:
107
+0 Something
108
+1 Something Else
109
+
110
+SERIAL PORT STATUS:
111
+0 BNC
112
+1 Optical
113
+2 Thunderbolt
114
+3 RS422
115
+

+ 35
- 4
test/test-14.ok View File

@@ -3,6 +3,26 @@ WARNING: OUTPUT LABELS: invalid video output port 17 (valid 0..15)
3 3
 WARNING: VIDEO OUTPUT LOCKS: invalid video output port 19 (valid 0..15)
4 4
 WARNING: VIDEO OUTPUT ROUTING: invalid video output port 66 (valid 0..15)
5 5
 WARNING: VIDEO OUTPUT ROUTING: invalid video input port 99 (valid 0..15)
6
+WARNING: VIDEO OUTPUT STATUS command returned unknown status: 'Something unknown'
7
+Please report this line to author's email: georgi@unixsol.org
8
+WARNING: VIDEO OUTPUT STATUS command returned unknown status: 'RS422'
9
+Please report this line to author's email: georgi@unixsol.org
10
+WARNING: SERIAL PORT DIRECTIONS command returned unknown direction: 'Wrong direction'
11
+Please report this line to author's email: georgi@unixsol.org
12
+WARNING: Videohub sent unknown command!
13
+         Please report this command to author's email: georgi@unixsol.org
14
+         You may use -q or --quiet to suppress the message.
15
+---------8<-----------8<----------- cut here ---------8<------------8<---------
16
+UNKNOWN COMMAND:
17
+0 Something
18
+1 Something Else
19
+---------8<-----------8<----------- cut here ---------8<------------8<---------
20
+WARNING: SERIAL PORT STATUS command returned unknown status: 'BNC'
21
+Please report this line to author's email: georgi@unixsol.org
22
+WARNING: SERIAL PORT STATUS command returned unknown status: 'Optical'
23
+Please report this line to author's email: georgi@unixsol.org
24
+WARNING: SERIAL PORT STATUS command returned unknown status: 'Thunderbolt'
25
+Please report this line to author's email: georgi@unixsol.org
6 26
 Device info
7 27
   -----------------------------------------------------------
8 28
   | Device address             | sdi-matrix                 |
@@ -12,6 +32,7 @@ Device info
12 32
   | Protocol                   | 2.4                        |
13 33
   | Video inputs               | 16                         |
14 34
   | Video outputs              | 16                         |
35
+  | Serial ports               | 4                          |
15 36
   -----------------------------------------------------------
16 37
 
17 38
 Video inputs
@@ -44,10 +65,10 @@ Video outputs
44 65
   --------------------------------------------------------------------
45 66
   | ## | x | Video output name        | Connected video input    | s |
46 67
   --------------------------------------------------------------------
47
-  |  1 | L | Enc1 1                   | Windows 3                |   |
48
-  |  2 | L | Enc1 2                   | Windows 2                |   |
49
-  |  3 | L | Enc1 3                   | Windows 1                |   |
50
-  |  4 | L | Enc1 4                   | Windows 1                |   |
68
+  |  1 | L | Enc1 1                   | Windows 3                | B |
69
+  |  2 | L | Enc1 2                   | Windows 2                | x |
70
+  |  3 | L | Enc1 3                   | Windows 1                | o |
71
+  |  4 | L | Enc1 4                   | Windows 1                | T |
51 72
   |  5 |   | Output 5                 | Input 5                  |   |
52 73
   |  6 |   | Output 6                 | Input 6                  |   |
53 74
   |  7 |   | Output 7                 | Windows 1                |   |
@@ -62,3 +83,13 @@ Video outputs
62 83
   | 16 |   | Loopback                 | Loopback                 |   |
63 84
   --------------------------------------------------------------------
64 85
 
86
+Serial ports
87
+  ---------------------------------------------------------------
88
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
89
+  ---------------------------------------------------------------
90
+  |  1 |   | auto | Remote 1           |                    |   |
91
+  |  2 |   |   in | Remote 2           |                    |   |
92
+  |  3 |   |  out | Remote 3           |                    |   |
93
+  |  4 |   | auto | Remote 4           |                    | 4 |
94
+  ---------------------------------------------------------------
95
+

Loading…
Cancel
Save