Browse Source

Add support for serial ports (names, routing, locks and directions).

Georgi Chorbadzhiyski 9 years ago
parent
commit
30a6246f79
20 changed files with 462 additions and 8 deletions
  1. 2
    0
      ChangeLog
  2. 43
    0
      README
  3. 68
    0
      cmd.c
  4. 8
    1
      cmd.h
  5. 15
    1
      data.h
  6. 47
    0
      display.c
  7. 1
    0
      display.h
  8. 39
    1
      test/input-00.txt
  9. 9
    1
      test/input-03.txt
  10. 19
    0
      test/run
  11. 15
    0
      test/test-01.ok
  12. 26
    0
      test/test-02.ok
  13. 43
    0
      test/test-03.ok
  14. 24
    0
      test/test-04.ok
  15. 15
    0
      test/test-05.ok
  16. 8
    0
      test/test-06.ok
  17. 1
    0
      test/test-07.ok
  18. 14
    0
      test/test-16.ok
  19. 27
    0
      videohubctrl.1
  20. 38
    4
      videohubctrl.c

+ 2
- 0
ChangeLog View File

1
 |-----------------------------------------------------------------------|
1
 |-----------------------------------------------------------------------|
2
 xxxx-xx-xx : Version 0.5-dev
2
 xxxx-xx-xx : Version 0.5-dev
3
  * Add missing documentation for --list-moutputs parameter.
3
  * Add missing documentation for --list-moutputs parameter.
4
+ * Add support for serial ports (names, routing, locks and directions),
5
+    --se-name, --se-input, --se-lock, --se-unlock and --se-dir.
4
 
6
 
5
 2014-11-30 : Version 0.4
7
 2014-11-30 : Version 0.4
6
  * Add videohubctrl(1) man page.
8
  * Add videohubctrl(1) man page.

+ 43
- 0
README View File

52
  --list-vinputs             | List device video inputs.
52
  --list-vinputs             | List device video inputs.
53
  --list-voutputs            | List device video outputs.
53
  --list-voutputs            | List device video outputs.
54
  --list-moutputs            | List device monitoring outputs.
54
  --list-moutputs            | List device monitoring outputs.
55
+ --list-serial              | List device serial ports.
55
 
56
 
56
 Video inputs configuration:
57
 Video inputs configuration:
57
  --vi-name <in_X> <name>    | Set video input port X name.
58
  --vi-name <in_X> <name>    | Set video input port X name.
68
  --mo-lock <mout_X>         | Lock monitoring port X.
69
  --mo-lock <mout_X>         | Lock monitoring port X.
69
  --mo-unlock <mout_X>       | Unlock monitoring port X.
70
  --mo-unlock <mout_X>       | Unlock monitoring port X.
70
 
71
 
72
+Serial ports configuration:
73
+ --se-name <ser_X> <name>   | Set serial port X name.
74
+ --se-route <ser_X> <ser_Y> | Connect serial X to serial Y
75
+ --se-lock <ser_X>          | Lock serial port X.
76
+ --se-unlock <ser_X>        | Unlock serial port X.
77
+ --se-dir <ser_X> <dir>     | Set serial port X direction.
78
+                            . <dir> can be 'auto', 'in' or 'out'.
79
+
71
 Misc options:
80
 Misc options:
72
  -T --test-input <file>     | Read commands from <file>.
81
  -T --test-input <file>     | Read commands from <file>.
73
  -d --debug                 | Increase logging verbosity.
82
  -d --debug                 | Increase logging verbosity.
156
   | Protocol                   | 2.4                        |
165
   | Protocol                   | 2.4                        |
157
   | Video inputs               | 16                         |
166
   | Video inputs               | 16                         |
158
   | Video outputs              | 16                         |
167
   | Video outputs              | 16                         |
168
+  | Serial ports               | 8                          |
159
   | Video monitoring outputs   | 4                          |
169
   | Video monitoring outputs   | 4                          |
160
   -----------------------------------------------------------
170
   -----------------------------------------------------------
161
 
171
 
215
   |  4 |   | Monitor 4                | Windows 4 HD             |
225
   |  4 |   | Monitor 4                | Windows 4 HD             |
216
   ----------------------------------------------------------------
226
   ----------------------------------------------------------------
217
 
227
 
228
+Serial ports
229
+  ---------------------------------------------------------------
230
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
231
+  ---------------------------------------------------------------
232
+  |  1 | O |   in | Serial Ctrl 1      | Deck 3             | 4 |
233
+  |  2 |   | auto | Serial Ctrl 2      | Deck 4             | 4 |
234
+  |  3 | L |  out | Deck 3             |                    | 4 |
235
+  |  4 |   | auto | Deck 4             |                    | 4 |
236
+  |  5 |   | auto | Serial 5           |                    |   |
237
+  |  6 |   | auto | Serial 6           |                    |   |
238
+  |  7 |   |   in | Serial 7           |                    | x |
239
+  |  8 |   |  out | Serial 8           |                    | x |
240
+  ---------------------------------------------------------------
241
+
218
 |----------------------------------------------------------------------|
242
 |----------------------------------------------------------------------|
219
 
243
 
220
 
244
 
247
  Column 5 (s)  - Port status /type/. Same format as in input ports.
271
  Column 5 (s)  - Port status /type/. Same format as in input ports.
248
 
272
 
249
 
273
 
274
+Serial ports Legend
275
+===================
276
+
277
+ Column 1 (##)  - Serial port number
278
+ Column 2 (x)   - Serial port lock status
279
+ Column 3 (Dir) - Serial port direction.
280
+                   in   - Input/Control (Workstation) port
281
+                   out  - Output/Slave (Deck) port
282
+                   auto - Automatic in/out
283
+ Column 4       - Serial port name
284
+ Column 5       - Which serial port is connected here.
285
+ Column 5 (s)   - Port status /type/. Same format as in input ports.
286
+                     - Empty means that the device do not support port
287
+                       status.
288
+                   x - The port type is "None". This means that the
289
+                       port is not installed.
290
+                   4 - The port type is "RS422".
291
+
292
+
250
 Development
293
 Development
251
 ===========
294
 ===========
252
 
295
 

+ 68
- 0
cmd.c View File

31
 	[CMD_MONITORING_OUTPUT_LABELS]  = "MONITORING OUTPUT LABELS",
31
 	[CMD_MONITORING_OUTPUT_LABELS]  = "MONITORING OUTPUT LABELS",
32
 	[CMD_MONITORING_OUTPUT_LOCKS]   = "MONITORING OUTPUT LOCKS",
32
 	[CMD_MONITORING_OUTPUT_LOCKS]   = "MONITORING OUTPUT LOCKS",
33
 	[CMD_MONITORING_OUTPUT_ROUTING] = "VIDEO MONITORING OUTPUT ROUTING",
33
 	[CMD_MONITORING_OUTPUT_ROUTING] = "VIDEO MONITORING OUTPUT ROUTING",
34
+	[CMD_SERIAL_PORT_LABELS]     = "SERIAL PORT LABELS",
35
+	[CMD_SERIAL_PORT_ROUTING]    = "SERIAL PORT ROUTING",
36
+	[CMD_SERIAL_PORT_LOCKS]      = "SERIAL PORT LOCKS",
37
+	[CMD_SERIAL_PORT_STATUS]     = "SERIAL PORT STATUS",
38
+	[CMD_SERIAL_PORT_DIRECTIONS] = "SERIAL PORT DIRECTIONS",
34
 	[CMD_PING]                 = "PING",
39
 	[CMD_PING]                 = "PING",
35
 	[CMD_ACK]                  = "ACK",
40
 	[CMD_ACK]                  = "ACK",
36
 	[CMD_NAK]                  = "NAK",
41
 	[CMD_NAK]                  = "NAK",
90
 		.port_id2 = "video input",
95
 		.port_id2 = "video input",
91
 		.opt_prefix = "mo",
96
 		.opt_prefix = "mo",
92
 	},
97
 	},
98
+	[CMD_SERIAL_PORT_LABELS]  = { .cmd = CMD_SERIAL_PORT_LABELS, .type = PARSE_LABEL,
99
+		.ports1 = OFS(serial),
100
+		.port_id1 = "serial",
101
+		.opt_prefix = "se",
102
+	},
103
+	[CMD_SERIAL_PORT_LOCKS]   = { .cmd = CMD_SERIAL_PORT_LOCKS  , .type = PARSE_LOCK,
104
+		.ports1 = OFS(serial),
105
+		.port_id1 = "serial",
106
+		.opt_prefix = "se",
107
+	},
108
+	[CMD_SERIAL_PORT_ROUTING] = { .cmd = CMD_SERIAL_PORT_ROUTING, .type = PARSE_ROUTE,
109
+		.ports1 = OFS(serial),
110
+		.ports2 = OFS(serial),
111
+		.port_id1 = "serial",
112
+		.port_id2 = "serial",
113
+		.opt_prefix = "se",
114
+	},
115
+	[CMD_SERIAL_PORT_STATUS]  = { .cmd = CMD_SERIAL_PORT_STATUS , .type = PARSE_STATUS,
116
+		.ports1 = OFS(serial),
117
+		.port_id1 = "serial",
118
+		.opt_prefix = "se",
119
+	},
120
+	[CMD_SERIAL_PORT_DIRECTIONS] = { .cmd = CMD_SERIAL_PORT_DIRECTIONS, .type = PARSE_DIR,
121
+		.ports1 = OFS(serial),
122
+		.port_id1 = "serial",
123
+		.opt_prefix = "se",
124
+	},
93
 	[CMD_PING]                 = { .cmd = CMD_PING                , .type = PARSE_NONE },
125
 	[CMD_PING]                 = { .cmd = CMD_PING                , .type = PARSE_NONE },
94
 	[CMD_ACK]                  = { .cmd = CMD_ACK                 , .type = PARSE_NONE },
126
 	[CMD_ACK]                  = { .cmd = CMD_ACK                 , .type = PARSE_NONE },
95
 	[CMD_NAK]                  = { .cmd = CMD_NAK                 , .type = PARSE_NONE },
127
 	[CMD_NAK]                  = { .cmd = CMD_NAK                 , .type = PARSE_NONE },
167
 		case PARSE_STATUS:
199
 		case PARSE_STATUS:
168
 			snprintf(s_port->port[port_num].status, sizeof(s_port->port[port_num].status), "%s", port_data);
200
 			snprintf(s_port->port[port_num].status, sizeof(s_port->port[port_num].status), "%s", port_data);
169
 			break;
201
 			break;
202
+		case PARSE_DIR:
203
+			s_port->port[port_num].direction = DIR_AUTO;
204
+			if (streq("control", port_data)) s_port->port[port_num].direction = DIR_CONTROL;
205
+			if (streq("slave", port_data))   s_port->port[port_num].direction = DIR_SLAVE;
206
+			break;
170
 		case PARSE_ROUTE:
207
 		case PARSE_ROUTE:
171
 			dest_port_num = strtoul(port_data, NULL, 10);
208
 			dest_port_num = strtoul(port_data, NULL, 10);
172
 			if (dest_port_num + 1 > d_port->num) {
209
 			if (dest_port_num + 1 > d_port->num) {
175
 				continue;
212
 				continue;
176
 			}
213
 			}
177
 			s_port->port[port_num].routed_to = dest_port_num;
214
 			s_port->port[port_num].routed_to = dest_port_num;
215
+			s_port->port[port_num].routed_to_set = true;
178
 			break;
216
 			break;
179
 		case PARSE_LOCK:
217
 		case PARSE_LOCK:
180
 			switch (port_data[0]) {
218
 			switch (port_data[0]) {
295
 	}
333
 	}
296
 }
334
 }
297
 
335
 
336
+static char *dir2cmd(enum serial_dir dir) {
337
+	switch (dir) {
338
+	case DIR_CONTROL: return "control";
339
+	case DIR_SLAVE  : return "slave";
340
+	case DIR_AUTO   : return "auto";
341
+	}
342
+	return "auto";
343
+}
344
+
345
+static char *dir2txt(enum serial_dir dir) {
346
+	switch (dir) {
347
+	case DIR_CONTROL: return "IN (Workstation)";
348
+	case DIR_SLAVE  : return "OUT (Deck)";
349
+	case DIR_AUTO   : return "AUTO";
350
+	}
351
+	return "AUTO";
352
+}
353
+
298
 void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
354
 void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
299
 	switch (e->cmd->type) {
355
 	switch (e->cmd->type) {
300
 	case PARSE_LABEL:
356
 	case PARSE_LABEL:
309
 		snprintf(buf, bufsz, "%s:\n%u %u\n\n", videohub_commands_text[e->cmd->cmd],
365
 		snprintf(buf, bufsz, "%s:\n%u %u\n\n", videohub_commands_text[e->cmd->cmd],
310
 			e->port_no1 - 1, e->port_no2 - 1);
366
 			e->port_no1 - 1, e->port_no2 - 1);
311
 		break;
367
 		break;
368
+	case PARSE_DIR:
369
+		snprintf(buf, bufsz, "%s:\n%u %s\n\n", videohub_commands_text[e->cmd->cmd],
370
+			e->port_no1 - 1, dir2cmd(e->direction));
371
+		break;
312
 	default: break;
372
 	default: break;
313
 	}
373
 	}
314
 }
374
 }
343
 			e->port_no2, d_port->port [e->port_no2 - 1].name
403
 			e->port_no2, d_port->port [e->port_no2 - 1].name
344
 		);
404
 		);
345
 		break;
405
 		break;
406
+	case PARSE_DIR:
407
+		printf("%sset %s %d \"%s\" direction to %s\n",
408
+			prefix,
409
+			e->cmd->port_id1,
410
+			e->port_no1, s_port->port[e->port_no1 - 1].name,
411
+			dir2txt(e->direction)
412
+		);
413
+		break;
346
 	default: break;
414
 	default: break;
347
 	}
415
 	}
348
 }
416
 }

+ 8
- 1
cmd.h View File

15
 
15
 
16
 #include <stdbool.h>
16
 #include <stdbool.h>
17
 
17
 
18
-#define NUM_COMMANDS 14
18
+#define NUM_COMMANDS 19
19
 
19
 
20
 enum vcmd {
20
 enum vcmd {
21
 	CMD_PROTOCOL_PREAMBLE,
21
 	CMD_PROTOCOL_PREAMBLE,
29
 	CMD_MONITORING_OUTPUT_LABELS,
29
 	CMD_MONITORING_OUTPUT_LABELS,
30
 	CMD_MONITORING_OUTPUT_LOCKS,
30
 	CMD_MONITORING_OUTPUT_LOCKS,
31
 	CMD_MONITORING_OUTPUT_ROUTING,
31
 	CMD_MONITORING_OUTPUT_ROUTING,
32
+	CMD_SERIAL_PORT_LABELS,
33
+	CMD_SERIAL_PORT_LOCKS,
34
+	CMD_SERIAL_PORT_ROUTING,
35
+	CMD_SERIAL_PORT_STATUS,
36
+	CMD_SERIAL_PORT_DIRECTIONS,
32
 	CMD_PING,
37
 	CMD_PING,
33
 	CMD_ACK,
38
 	CMD_ACK,
34
 	CMD_NAK = (NUM_COMMANDS - 1),
39
 	CMD_NAK = (NUM_COMMANDS - 1),
41
 	PARSE_STATUS, /* Parse [port_num] [port_status] */
46
 	PARSE_STATUS, /* Parse [port_num] [port_status] */
42
 	PARSE_ROUTE,  /* Parse [port_num] [dest_port] */
47
 	PARSE_ROUTE,  /* Parse [port_num] [dest_port] */
43
 	PARSE_LOCK,   /* Parse [port_num] [dest_slot] */
48
 	PARSE_LOCK,   /* Parse [port_num] [dest_slot] */
49
+	PARSE_DIR,    /* Parse [port_num] [port_direction]  - for serial ports */
44
 };
50
 };
45
 
51
 
46
 struct videohub_commands {
52
 struct videohub_commands {
66
 	unsigned int	port_no2;
72
 	unsigned int	port_no2;
67
 	bool			do_lock;
73
 	bool			do_lock;
68
 	enum port_lock	lock;
74
 	enum port_lock	lock;
75
+	enum serial_dir	direction;
69
 };
76
 };
70
 
77
 
71
 void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e);
78
 void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e);

+ 15
- 1
data.h View File

34
 	PORT_LOCKED_OTHER,
34
 	PORT_LOCKED_OTHER,
35
 };
35
 };
36
 
36
 
37
+enum serial_dir {
38
+	DIR_CONTROL,
39
+	DIR_SLAVE,
40
+	DIR_AUTO,
41
+};
42
+
37
 struct port {
43
 struct port {
38
 	char			name[MAX_NAME_LEN];
44
 	char			name[MAX_NAME_LEN];
39
 	// Port statuses are supported only by Universal Videohub
45
 	// Port statuses are supported only by Universal Videohub
40
 	// The statuses (actually they are connection types) are:
46
 	// The statuses (actually they are connection types) are:
41
-	//    BNC, Optical or None /missing port/
47
+	//  BNC, Optical or None /missing port/ - for input/output
48
+	//  RS422, None                         - for serial ports
42
 	char			status[8];
49
 	char			status[8];
50
+	// For serial ports.
51
+	// The values are:
52
+	//    control - In (Workstation)
53
+	//      slave - Out (Deck)
54
+	//       auto - Automatic
55
+	enum serial_dir	direction;
43
 	unsigned int	routed_to;
56
 	unsigned int	routed_to;
57
+	bool			routed_to_set; // For serial ports
44
 	enum port_lock	lock;
58
 	enum port_lock	lock;
45
 };
59
 };
46
 
60
 

+ 47
- 0
display.c View File

31
 	if (streq(status, "BNC"))     return 'B';
31
 	if (streq(status, "BNC"))     return 'B';
32
 	if (streq(status, "Optical")) return 'o';
32
 	if (streq(status, "Optical")) return 'o';
33
 	if (streq(status, "None"))    return 'x';
33
 	if (streq(status, "None"))    return 'x';
34
+	if (streq(status, "RS422"))   return '4'; // For serial ports
34
 	return '?';
35
 	return '?';
35
 }
36
 }
36
 
37
 
145
 	printf("\n");
146
 	printf("\n");
146
 }
147
 }
147
 
148
 
149
+static char *dir2opt(enum serial_dir dir) {
150
+	switch (dir) {
151
+	case DIR_CONTROL: return "in";
152
+	case DIR_SLAVE  : return "out";
153
+	case DIR_AUTO   : return "auto";
154
+	}
155
+	return "auto";
156
+}
157
+
158
+void print_device_serial_ports(struct videohub_data *d) {
159
+	unsigned char port_seen[MAX_PORTS];
160
+	unsigned int i, len = 63;
161
+	if (!d->serial.num)
162
+		return;
163
+	memset(port_seen, 0, sizeof(port_seen));
164
+	printf("Serial ports\n");
165
+	printf_line(len);
166
+	printf("  | ## | x | Dir  | %-18s | %-18s | s |\n", "Serial port", "Connected serial");
167
+	printf_line(len);
168
+	for(i = 0; i < d->serial.num; i++) {
169
+		printf("  | %2d | %c | %4s | %-18s | %-18s | %c |\n",
170
+			i + 1,
171
+			port_lock_symbol(d->serial.port[i].lock),
172
+			dir2opt(d->serial.port[i].direction),
173
+			d->serial.port[i].name,
174
+			(d->serial.port[i].routed_to_set && !port_seen[d->serial.port[i].routed_to]
175
+				? d->serial.port[d->serial.port[i].routed_to].name
176
+				: ""),
177
+			format_status(d->serial.port[i].status)
178
+		);
179
+		port_seen[d->serial.port[i].routed_to]++;
180
+	}
181
+	printf_line(len);
182
+	printf("\n");
183
+}
184
+
148
 static void __print_opt(struct videohub_data *d, enum vcmd vcmd) {
185
 static void __print_opt(struct videohub_data *d, enum vcmd vcmd) {
149
 	unsigned int i, last = 0;
186
 	unsigned int i, last = 0;
150
 	struct videohub_commands *v = &videohub_commands[vcmd];
187
 	struct videohub_commands *v = &videohub_commands[vcmd];
156
 			printf("  --%s-name %2d \"%s\" \\\n", p, i + 1, s_port->port[i].name);
193
 			printf("  --%s-name %2d \"%s\" \\\n", p, i + 1, s_port->port[i].name);
157
 			break;
194
 			break;
158
 		case PARSE_ROUTE:
195
 		case PARSE_ROUTE:
196
+			if (v->cmd == CMD_SERIAL_PORT_ROUTING && !s_port->port[i].routed_to_set)
197
+				continue;
159
 			printf("  --%s-input %2d %2d \\\n", p, i + 1, s_port->port[i].routed_to + 1);
198
 			printf("  --%s-input %2d %2d \\\n", p, i + 1, s_port->port[i].routed_to + 1);
160
 			break;
199
 			break;
161
 		case PARSE_LOCK:
200
 		case PARSE_LOCK:
166
 			} else {
205
 			} else {
167
 				printf("  --%s-unlock %2d%s\n", p, i + 1, last ? " \\" : "");
206
 				printf("  --%s-unlock %2d%s\n", p, i + 1, last ? " \\" : "");
168
 			}
207
 			}
208
+			break;
209
+		case PARSE_DIR:
210
+			printf("  --%s-dir %2d %s \\\n", p, i + 1, dir2opt(s_port->port[i].direction));
211
+			break;
169
 		default: break;
212
 		default: break;
170
 		}
213
 		}
171
 	}
214
 	}
182
 		if (videohub_commands[i].type == PARSE_ROUTE)
225
 		if (videohub_commands[i].type == PARSE_ROUTE)
183
 			__print_opt(d, videohub_commands[i].cmd);
226
 			__print_opt(d, videohub_commands[i].cmd);
184
 	}
227
 	}
228
+	for (i = 0; i < NUM_COMMANDS; i++) {
229
+		if (videohub_commands[i].type == PARSE_DIR)
230
+			__print_opt(d, videohub_commands[i].cmd);
231
+	}
185
 	for (i = 0; i < NUM_COMMANDS; i++) {
232
 	for (i = 0; i < NUM_COMMANDS; i++) {
186
 		if (videohub_commands[i].type == PARSE_LOCK)
233
 		if (videohub_commands[i].type == PARSE_LOCK)
187
 			__print_opt(d, videohub_commands[i].cmd);
234
 			__print_opt(d, videohub_commands[i].cmd);

+ 1
- 0
display.h View File

17
 void print_device_video_inputs(struct videohub_data *d);
17
 void print_device_video_inputs(struct videohub_data *d);
18
 void print_device_video_outputs(struct videohub_data *d);
18
 void print_device_video_outputs(struct videohub_data *d);
19
 void print_device_monitoring_outputs(struct videohub_data *d);
19
 void print_device_monitoring_outputs(struct videohub_data *d);
20
+void print_device_serial_ports(struct videohub_data *d);
20
 
21
 
21
 void print_device_backup(struct videohub_data *d);
22
 void print_device_backup(struct videohub_data *d);
22
 
23
 

+ 39
- 1
test/input-00.txt View File

9
 Video processing units: 0
9
 Video processing units: 0
10
 Video outputs: 16
10
 Video outputs: 16
11
 Video monitoring outputs: 4
11
 Video monitoring outputs: 4
12
-Serial ports: 0
12
+Serial ports: 8
13
 
13
 
14
 INPUT LABELS:
14
 INPUT LABELS:
15
 0 Windows 1
15
 0 Windows 1
125
 1 O
125
 1 O
126
 2 L
126
 2 L
127
 3 U
127
 3 U
128
+
129
+SERIAL PORT LABELS:
130
+0 Serial Ctrl 1
131
+1 Serial Ctrl 2
132
+2 Deck 3
133
+3 Deck 4
134
+4 Serial 5
135
+5 Serial 6
136
+6 Serial 7
137
+7 Serial 8
138
+
139
+SERIAL PORT ROUTING:
140
+0 2
141
+1 3
142
+
143
+SERIAL PORT LOCKS:
144
+0 O
145
+1 U
146
+2 L
147
+3 U
148
+
149
+SERIAL PORT STATUS:
150
+0 RS422
151
+1 RS422
152
+2 RS422
153
+3 RS422
154
+6 None
155
+7 None
156
+
157
+SERIAL PORT DIRECTIONS:
158
+0 control
159
+1 auto
160
+2 slave
161
+3 auto
162
+4 auto
163
+5 auto
164
+6 control
165
+7 slave

+ 9
- 1
test/input-03.txt View File

9
 Video processing units: 0
9
 Video processing units: 0
10
 Video outputs: 16
10
 Video outputs: 16
11
 Video monitoring outputs: 4
11
 Video monitoring outputs: 4
12
-Serial ports: 0
12
+Serial ports: 8
13
 
13
 
14
 VIDEO INPUT STATUS:
14
 VIDEO INPUT STATUS:
15
 0 BNC
15
 0 BNC
35
 13 Optical
35
 13 Optical
36
 14 Optical
36
 14 Optical
37
 15 Optical
37
 15 Optical
38
+
39
+SERIAL PORT STATUS:
40
+0 RS422
41
+1 RS422
42
+2 RS422
43
+3 RS422
44
+6 None
45
+7 None

+ 19
- 0
test/run View File

50
 	--mo-lock 4 \
50
 	--mo-lock 4 \
51
 	--mo-name 3 "Loopback" \
51
 	--mo-name 3 "Loopback" \
52
 	--mo-input 3 16 \
52
 	--mo-input 3 16 \
53
+	--se-name 1 "Ren Ctrl 1" \
54
+	--se-name "Deck 3" "Ren Deck 3" \
55
+	--se-unlock 1 \
56
+	--se-lock 2 \
57
+	--se-input 2 1 \
58
+	--se-dir 6 in \
59
+	--se-dir 7 out \
60
+	--se-dir 8 out --se-dir 8 auto \
53
 $@ &> test/test-04.out
61
 $@ &> test/test-04.out
54
 check test/test-04 "Test multiple configuration commands"
62
 check test/test-04 "Test multiple configuration commands"
55
 
63
 
81
 ./videohubctrl --test-input test/input-00.txt --mo-lock "Output 18"                  $@ &>> test/test-06.out
89
 ./videohubctrl --test-input test/input-00.txt --mo-lock "Output 18"                  $@ &>> test/test-06.out
82
 ./videohubctrl --test-input test/input-00.txt --mo-unlock 18                         $@ &>> test/test-06.out
90
 ./videohubctrl --test-input test/input-00.txt --mo-unlock 18                         $@ &>> test/test-06.out
83
 ./videohubctrl --test-input test/input-00.txt --mo-unlock "Output 18"                $@ &>> test/test-06.out
91
 ./videohubctrl --test-input test/input-00.txt --mo-unlock "Output 18"                $@ &>> test/test-06.out
92
+./videohubctrl --test-input test/input-00.txt --se-name 18          "Test Serial 18" $@ &>> test/test-06.out
93
+./videohubctrl --test-input test/input-00.txt --se-name "Serial 18" "Test Serial 18" $@ &>> test/test-06.out
94
+./videohubctrl --test-input test/input-00.txt --se-lock 18                           $@ &>> test/test-06.out
95
+./videohubctrl --test-input test/input-00.txt --se-lock "Serial 18"                  $@ &>> test/test-06.out
96
+./videohubctrl --test-input test/input-00.txt --se-unlock 18                         $@ &>> test/test-06.out
97
+./videohubctrl --test-input test/input-00.txt --se-unlock "Serial 18"                $@ &>> test/test-06.out
98
+./videohubctrl --test-input test/input-00.txt --se-dir 1 err-dir                     $@ &>> test/test-06.out
99
+./videohubctrl --test-input test/input-00.txt --se-dir "Serial 5" err-dir            $@ &>> test/test-06.out
84
 check test/test-06 "Test errors on commands with invalid ports."
100
 check test/test-06 "Test errors on commands with invalid ports."
85
 
101
 
86
 videohubctrl --test-input test/input-00.txt --list-device $@ &> test/test-07.out
102
 videohubctrl --test-input test/input-00.txt --list-device $@ &> test/test-07.out
106
 
122
 
107
 videohubctrl --test-input test/input-00.txt --list-moutputs $@ &> test/test-15.out
123
 videohubctrl --test-input test/input-00.txt --list-moutputs $@ &> test/test-15.out
108
 check test/test-15 "Test --list-moutputs option output"
124
 check test/test-15 "Test --list-moutputs option output"
125
+
126
+videohubctrl --test-input test/input-00.txt --list-serial $@ &> test/test-16.out
127
+check test/test-16 "Test --list-serial option output"

+ 15
- 0
test/test-01.ok View File

7
   | Protocol                   | 2.4                        |
7
   | Protocol                   | 2.4                        |
8
   | Video inputs               | 16                         |
8
   | Video inputs               | 16                         |
9
   | Video outputs              | 16                         |
9
   | Video outputs              | 16                         |
10
+  | Serial ports               | 8                          |
10
   | Video monitoring outputs   | 4                          |
11
   | Video monitoring outputs   | 4                          |
11
   -----------------------------------------------------------
12
   -----------------------------------------------------------
12
 
13
 
66
   |  4 |   | Monitor 4                | Windows 4 HD             |
67
   |  4 |   | Monitor 4                | Windows 4 HD             |
67
   ----------------------------------------------------------------
68
   ----------------------------------------------------------------
68
 
69
 
70
+Serial ports
71
+  ---------------------------------------------------------------
72
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
73
+  ---------------------------------------------------------------
74
+  |  1 | O |   in | Serial Ctrl 1      | Deck 3             | 4 |
75
+  |  2 |   | auto | Serial Ctrl 2      | Deck 4             | 4 |
76
+  |  3 | L |  out | Deck 3             |                    | 4 |
77
+  |  4 |   | auto | Deck 4             |                    | 4 |
78
+  |  5 |   | auto | Serial 5           |                    |   |
79
+  |  6 |   | auto | Serial 6           |                    |   |
80
+  |  7 |   |   in | Serial 7           |                    | x |
81
+  |  8 |   |  out | Serial 8           |                    | x |
82
+  ---------------------------------------------------------------
83
+

+ 26
- 0
test/test-02.ok View File

35
   --mo-name  2 "Monitor 2" \
35
   --mo-name  2 "Monitor 2" \
36
   --mo-name  3 "Monitor 3" \
36
   --mo-name  3 "Monitor 3" \
37
   --mo-name  4 "Monitor 4" \
37
   --mo-name  4 "Monitor 4" \
38
+  --se-name  1 "Serial Ctrl 1" \
39
+  --se-name  2 "Serial Ctrl 2" \
40
+  --se-name  3 "Deck 3" \
41
+  --se-name  4 "Deck 4" \
42
+  --se-name  5 "Serial 5" \
43
+  --se-name  6 "Serial 6" \
44
+  --se-name  7 "Serial 7" \
45
+  --se-name  8 "Serial 8" \
38
   --vo-input  1  3 \
46
   --vo-input  1  3 \
39
   --vo-input  2  2 \
47
   --vo-input  2  2 \
40
   --vo-input  3  1 \
48
   --vo-input  3  1 \
55
   --mo-input  2  2 \
63
   --mo-input  2  2 \
56
   --mo-input  3  3 \
64
   --mo-input  3  3 \
57
   --mo-input  4  4 \
65
   --mo-input  4  4 \
66
+  --se-input  1  3 \
67
+  --se-input  2  4 \
68
+  --se-dir  1 in \
69
+  --se-dir  2 auto \
70
+  --se-dir  3 out \
71
+  --se-dir  4 auto \
72
+  --se-dir  5 auto \
73
+  --se-dir  6 auto \
74
+  --se-dir  7 in \
75
+  --se-dir  8 out \
58
   --vo-unlock  1 --vo-lock  1 \
76
   --vo-unlock  1 --vo-lock  1 \
59
   --vo-unlock  2 --vo-lock  2 \
77
   --vo-unlock  2 --vo-lock  2 \
60
   --vo-unlock  3 --vo-lock  3 \
78
   --vo-unlock  3 --vo-lock  3 \
75
   --mo-unlock  2 --mo-lock  2 \
93
   --mo-unlock  2 --mo-lock  2 \
76
   --mo-unlock  3 --mo-lock  3 \
94
   --mo-unlock  3 --mo-lock  3 \
77
   --mo-unlock  4
95
   --mo-unlock  4
96
+  --se-unlock  1 --se-lock  1 \
97
+  --se-unlock  2 \
98
+  --se-unlock  3 --se-lock  3 \
99
+  --se-unlock  4 \
100
+  --se-unlock  5 \
101
+  --se-unlock  6 \
102
+  --se-unlock  7 \
103
+  --se-unlock  8
78
 
104
 

+ 43
- 0
test/test-03.ok View File

34
 videohub: rename monitoring output 2 "" to "Monitor 2"
34
 videohub: rename monitoring output 2 "" to "Monitor 2"
35
 videohub: rename monitoring output 3 "" to "Monitor 3"
35
 videohub: rename monitoring output 3 "" to "Monitor 3"
36
 videohub: rename monitoring output 4 "" to "Monitor 4"
36
 videohub: rename monitoring output 4 "" to "Monitor 4"
37
+videohub: rename serial 1 "" to "Serial Ctrl 1"
38
+videohub: rename serial 2 "" to "Serial Ctrl 2"
39
+videohub: rename serial 3 "" to "Deck 3"
40
+videohub: rename serial 4 "" to "Deck 4"
41
+videohub: rename serial 5 "" to "Serial 5"
42
+videohub: rename serial 6 "" to "Serial 6"
43
+videohub: rename serial 7 "" to "Serial 7"
44
+videohub: rename serial 8 "" to "Serial 8"
37
 videohub: set video output 1 "Enc1 1" to read from video input 3 "Windows 3"
45
 videohub: set video output 1 "Enc1 1" to read from video input 3 "Windows 3"
38
 videohub: set video output 2 "Enc1 2" to read from video input 2 "Windows 2"
46
 videohub: set video output 2 "Enc1 2" to read from video input 2 "Windows 2"
39
 videohub: set video output 3 "Enc1 3" to read from video input 1 "Windows 1"
47
 videohub: set video output 3 "Enc1 3" to read from video input 1 "Windows 1"
54
 videohub: set monitoring output 2 "Monitor 2" to read from video input 2 "Windows 2"
62
 videohub: set monitoring output 2 "Monitor 2" to read from video input 2 "Windows 2"
55
 videohub: set monitoring output 3 "Monitor 3" to read from video input 3 "Windows 3"
63
 videohub: set monitoring output 3 "Monitor 3" to read from video input 3 "Windows 3"
56
 videohub: set monitoring output 4 "Monitor 4" to read from video input 4 "Windows 4 HD"
64
 videohub: set monitoring output 4 "Monitor 4" to read from video input 4 "Windows 4 HD"
65
+videohub: set serial 1 "Serial Ctrl 1" to read from serial 3 "Deck 3"
66
+videohub: set serial 2 "Serial Ctrl 2" to read from serial 4 "Deck 4"
67
+videohub: set serial 1 "Serial Ctrl 1" direction to IN (Workstation)
68
+videohub: set serial 2 "Serial Ctrl 2" direction to AUTO
69
+videohub: set serial 3 "Deck 3" direction to OUT (Deck)
70
+videohub: set serial 4 "Deck 4" direction to AUTO
71
+videohub: set serial 5 "Serial 5" direction to AUTO
72
+videohub: set serial 6 "Serial 6" direction to AUTO
73
+videohub: set serial 7 "Serial 7" direction to IN (Workstation)
74
+videohub: set serial 8 "Serial 8" direction to OUT (Deck)
57
 videohub: unlock video output 1 "Enc1 1"
75
 videohub: unlock video output 1 "Enc1 1"
58
 videohub: lock video output 1 "Enc1 1"
76
 videohub: lock video output 1 "Enc1 1"
59
 videohub: unlock video output 2 "Enc1 2"
77
 videohub: unlock video output 2 "Enc1 2"
84
 videohub: unlock monitoring output 3 "Monitor 3"
102
 videohub: unlock monitoring output 3 "Monitor 3"
85
 videohub: lock monitoring output 3 "Monitor 3"
103
 videohub: lock monitoring output 3 "Monitor 3"
86
 videohub: unlock monitoring output 4 "Monitor 4"
104
 videohub: unlock monitoring output 4 "Monitor 4"
105
+videohub: unlock serial 1 "Serial Ctrl 1"
106
+videohub: lock serial 1 "Serial Ctrl 1"
107
+videohub: unlock serial 2 "Serial Ctrl 2"
108
+videohub: unlock serial 3 "Deck 3"
109
+videohub: lock serial 3 "Deck 3"
110
+videohub: unlock serial 4 "Deck 4"
111
+videohub: unlock serial 5 "Serial 5"
112
+videohub: unlock serial 6 "Serial 6"
113
+videohub: unlock serial 7 "Serial 7"
114
+videohub: unlock serial 8 "Serial 8"
87
 Device info
115
 Device info
88
   -----------------------------------------------------------
116
   -----------------------------------------------------------
89
   | Device address             | sdi-matrix                 |
117
   | Device address             | sdi-matrix                 |
93
   | Protocol                   | 2.4                        |
121
   | Protocol                   | 2.4                        |
94
   | Video inputs               | 16                         |
122
   | Video inputs               | 16                         |
95
   | Video outputs              | 16                         |
123
   | Video outputs              | 16                         |
124
+  | Serial ports               | 8                          |
96
   | Video monitoring outputs   | 4                          |
125
   | Video monitoring outputs   | 4                          |
97
   -----------------------------------------------------------
126
   -----------------------------------------------------------
98
 
127
 
152
   |  4 |   | Monitor 4                | Windows 4 HD             |
181
   |  4 |   | Monitor 4                | Windows 4 HD             |
153
   ----------------------------------------------------------------
182
   ----------------------------------------------------------------
154
 
183
 
184
+Serial ports
185
+  ---------------------------------------------------------------
186
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
187
+  ---------------------------------------------------------------
188
+  |  1 | O |   in | Serial Ctrl 1      | Deck 3             | 4 |
189
+  |  2 |   | auto | Serial Ctrl 2      | Deck 4             | 4 |
190
+  |  3 | O |  out | Deck 3             |                    | 4 |
191
+  |  4 |   | auto | Deck 4             |                    | 4 |
192
+  |  5 |   | auto | Serial 5           |                    |   |
193
+  |  6 |   | auto | Serial 6           |                    |   |
194
+  |  7 |   |   in | Serial 7           |                    | x |
195
+  |  8 |   |  out | Serial 8           |                    | x |
196
+  ---------------------------------------------------------------
197
+

+ 24
- 0
test/test-04.ok View File

16
 videohub: lock monitoring output 4 "Decklink"
16
 videohub: lock monitoring output 4 "Decklink"
17
 videohub: rename monitoring output 3 "Monitor 3" to "Loopback"
17
 videohub: rename monitoring output 3 "Monitor 3" to "Loopback"
18
 videohub: set monitoring output 3 "Loopback" to read from video input 16 "Loopback"
18
 videohub: set monitoring output 3 "Loopback" to read from video input 16 "Loopback"
19
+videohub: rename serial 1 "Serial Ctrl 1" to "Ren Ctrl 1"
20
+videohub: rename serial 3 "Deck 3" to "Ren Deck 3"
21
+videohub: unlock serial 1 "Ren Ctrl 1"
22
+videohub: lock serial 2 "Serial Ctrl 2"
23
+videohub: set serial 2 "Serial Ctrl 2" to read from serial 1 "Ren Ctrl 1"
24
+videohub: set serial 6 "Serial 6" direction to IN (Workstation)
25
+videohub: set serial 7 "Serial 7" direction to OUT (Deck)
26
+videohub: set serial 8 "Serial 8" direction to OUT (Deck)
27
+videohub: set serial 8 "Serial 8" direction to AUTO
19
 Device info
28
 Device info
20
   -----------------------------------------------------------
29
   -----------------------------------------------------------
21
   | Device address             | sdi-matrix                 |
30
   | Device address             | sdi-matrix                 |
25
   | Protocol                   | 2.4                        |
34
   | Protocol                   | 2.4                        |
26
   | Video inputs               | 16                         |
35
   | Video inputs               | 16                         |
27
   | Video outputs              | 16                         |
36
   | Video outputs              | 16                         |
37
+  | Serial ports               | 8                          |
28
   | Video monitoring outputs   | 4                          |
38
   | Video monitoring outputs   | 4                          |
29
   -----------------------------------------------------------
39
   -----------------------------------------------------------
30
 
40
 
85
   |  4 | O | Decklink                 | Windows 4 HighDef        |
95
   |  4 | O | Decklink                 | Windows 4 HighDef        |
86
   ----------------------------------------------------------------
96
   ----------------------------------------------------------------
87
 
97
 
98
+Serial ports
99
+  ---------------------------------------------------------------
100
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
101
+  ---------------------------------------------------------------
102
+  |  1 |   |   in | Ren Ctrl 1         | Ren Deck 3         | 4 |
103
+  |  2 | O | auto | Serial Ctrl 2      | Ren Ctrl 1         | 4 |
104
+  |  3 | L |  out | Ren Deck 3         |                    | 4 |
105
+  |  4 |   | auto | Deck 4             |                    | 4 |
106
+  |  5 |   | auto | Serial 5           |                    |   |
107
+  |  6 |   |   in | Serial 6           |                    |   |
108
+  |  7 |   |  out | Serial 7           |                    | x |
109
+  |  8 |   | auto | Serial 8           |                    | x |
110
+  ---------------------------------------------------------------
111
+

+ 15
- 0
test/test-05.ok View File

7
   | Protocol                   | 2.4                        |
7
   | Protocol                   | 2.4                        |
8
   | Video inputs               | 16                         |
8
   | Video inputs               | 16                         |
9
   | Video outputs              | 16                         |
9
   | Video outputs              | 16                         |
10
+  | Serial ports               | 8                          |
10
   | Video monitoring outputs   | 4                          |
11
   | Video monitoring outputs   | 4                          |
11
   -----------------------------------------------------------
12
   -----------------------------------------------------------
12
 
13
 
66
   |  4 |   | Monitor 4                | Windows 4 HD             |
67
   |  4 |   | Monitor 4                | Windows 4 HD             |
67
   ----------------------------------------------------------------
68
   ----------------------------------------------------------------
68
 
69
 
70
+Serial ports
71
+  ---------------------------------------------------------------
72
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
73
+  ---------------------------------------------------------------
74
+  |  1 | O |   in | Serial Ctrl 1      | Deck 3             | 4 |
75
+  |  2 |   | auto | Serial Ctrl 2      | Deck 4             | 4 |
76
+  |  3 | O |  out | Deck 3             |                    | 4 |
77
+  |  4 |   | auto | Deck 4             |                    | 4 |
78
+  |  5 |   | auto | Serial 5           |                    |   |
79
+  |  6 |   | auto | Serial 6           |                    |   |
80
+  |  7 |   |   in | Serial 7           |                    | x |
81
+  |  8 |   |  out | Serial 8           |                    | x |
82
+  ---------------------------------------------------------------
83
+

+ 8
- 0
test/test-06.ok View File

22
 ERROR: Unknown monitoring output port number/name: Output 18
22
 ERROR: Unknown monitoring output port number/name: Output 18
23
 ERROR: Unknown monitoring output port number/name: 18
23
 ERROR: Unknown monitoring output port number/name: 18
24
 ERROR: Unknown monitoring output port number/name: Output 18
24
 ERROR: Unknown monitoring output port number/name: Output 18
25
+ERROR: Unknown serial port number/name: 18
26
+ERROR: Unknown serial port number/name: Serial 18
27
+ERROR: Unknown serial port number/name: 18
28
+ERROR: Unknown serial port number/name: Serial 18
29
+ERROR: Unknown serial port number/name: 18
30
+ERROR: Unknown serial port number/name: Serial 18
31
+ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
32
+ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.

+ 1
- 0
test/test-07.ok View File

7
   | Protocol                   | 2.4                        |
7
   | Protocol                   | 2.4                        |
8
   | Video inputs               | 16                         |
8
   | Video inputs               | 16                         |
9
   | Video outputs              | 16                         |
9
   | Video outputs              | 16                         |
10
+  | Serial ports               | 8                          |
10
   | Video monitoring outputs   | 4                          |
11
   | Video monitoring outputs   | 4                          |
11
   -----------------------------------------------------------
12
   -----------------------------------------------------------
12
 
13
 

+ 14
- 0
test/test-16.ok View File

1
+Serial ports
2
+  ---------------------------------------------------------------
3
+  | ## | x | Dir  | Serial port        | Connected serial   | s |
4
+  ---------------------------------------------------------------
5
+  |  1 | O |   in | Serial Ctrl 1      | Deck 3             | 4 |
6
+  |  2 |   | auto | Serial Ctrl 2      | Deck 4             | 4 |
7
+  |  3 | L |  out | Deck 3             |                    | 4 |
8
+  |  4 |   | auto | Deck 4             |                    | 4 |
9
+  |  5 |   | auto | Serial 5           |                    |   |
10
+  |  6 |   | auto | Serial 6           |                    |   |
11
+  |  7 |   |   in | Serial 7           |                    | x |
12
+  |  8 |   |  out | Serial 8           |                    | x |
13
+  ---------------------------------------------------------------
14
+

+ 27
- 0
videohubctrl.1 View File

76
 Display device monitoring outputs. Port numbers, names, locking status and
76
 Display device monitoring outputs. Port numbers, names, locking status and
77
 which input is routed to a given output. The locking statuses are the
77
 which input is routed to a given output. The locking statuses are the
78
 same as video input and output ports.
78
 same as video input and output ports.
79
+.TP
80
+\fB\-\-list\-serial\fR
81
+Display device serial ports. Port numbers, names, locking status, directions
82
+and how serial ports are routed. The locking statuses are the same as video
83
+input, output ports and monitoring ports.
79
 .SH CONFIGURATION COMMANDS
84
 .SH CONFIGURATION COMMANDS
80
 .PP
85
 .PP
81
 Everywhere where port needs to be set, you can use the port number or the
86
 Everywhere where port needs to be set, you can use the port number or the
117
 \fB\-\-mo\-unlock\fR <mout_X>
122
 \fB\-\-mo\-unlock\fR <mout_X>
118
 Unlock monitoring output port X. If the port is locked by somebody
123
 Unlock monitoring output port X. If the port is locked by somebody
119
 else the port would be forcefully unlocked.
124
 else the port would be forcefully unlocked.
125
+.SH SERIAL PORTS CONFIGURATION
126
+.PP
127
+.TP
128
+\fB\-\-se\-name\fR <ser_X> <name>
129
+Set serial port X name.
130
+.TP
131
+\fB\-\-se\-input\fR <ser_X> <ser_Y>
132
+Connect serial port X to serial port Y.
133
+.TP
134
+\fB\-\-se\-lock\fR <ser_X>
135
+Lock serial port X.
136
+.TP
137
+\fB\-\-se\-unlock\fR <ser_X>
138
+Unlock serial port X. If the port is locked by somebody else the
139
+port would be forcefully unlocked.
140
+.TP
141
+\fB\-\-se\-dir\fR <set_X> <in|out|auto>
142
+Set serial port X direction. There are three possible settings for
143
+each port:
144
+ \fBin\fR   - input/control/Workstation
145
+ \fBout\fR  - output/slave/Deck
146
+ \fBauto\fR - Automatic in/out
120
 .SH MISC OPTIONS
147
 .SH MISC OPTIONS
121
 .PP
148
 .PP
122
 .TP
149
 .TP

+ 38
- 4
videohubctrl.c View File

42
 	action_list_vinputs		= (1 << 1),
42
 	action_list_vinputs		= (1 << 1),
43
 	action_list_voutputs	= (1 << 2),
43
 	action_list_voutputs	= (1 << 2),
44
 	action_list_moutputs	= (1 << 3),
44
 	action_list_moutputs	= (1 << 3),
45
+	action_list_serial		= (1 << 4),
45
 };
46
 };
46
 
47
 
47
 static const char *program_id = PROGRAM_NAME " Version: " VERSION " Git: " GIT_VER;
48
 static const char *program_id = PROGRAM_NAME " Version: " VERSION " Git: " GIT_VER;
63
 	{ "list-vinputs",		no_argument,       NULL, 902 },
64
 	{ "list-vinputs",		no_argument,       NULL, 902 },
64
 	{ "list-voutputs",		no_argument,       NULL, 903 },
65
 	{ "list-voutputs",		no_argument,       NULL, 903 },
65
 	{ "list-moutputs",		no_argument,       NULL, 904 },
66
 	{ "list-moutputs",		no_argument,       NULL, 904 },
67
+	{ "list-serial",		no_argument,       NULL, 905 },
66
 	{ "vi-name",			required_argument, NULL, 1001 },
68
 	{ "vi-name",			required_argument, NULL, 1001 },
67
 	{ "vo-name",			required_argument, NULL, 2001 },
69
 	{ "vo-name",			required_argument, NULL, 2001 },
68
 	{ "vo-input",			required_argument, NULL, 2002 },
70
 	{ "vo-input",			required_argument, NULL, 2002 },
74
 	{ "mo-route",			required_argument, NULL, 3002 }, // Alias of --mo-input
76
 	{ "mo-route",			required_argument, NULL, 3002 }, // Alias of --mo-input
75
 	{ "mo-lock",			required_argument, NULL, 3003 },
77
 	{ "mo-lock",			required_argument, NULL, 3003 },
76
 	{ "mo-unlock",			required_argument, NULL, 3004 },
78
 	{ "mo-unlock",			required_argument, NULL, 3004 },
79
+	{ "se-name",			required_argument, NULL, 4001 },
80
+	{ "se-input",			required_argument, NULL, 4002 },
81
+	{ "se-route",			required_argument, NULL, 4002 }, // Alias of --mo-input
82
+	{ "se-lock",			required_argument, NULL, 4003 },
83
+	{ "se-unlock",			required_argument, NULL, 4004 },
84
+	{ "se-dir",				required_argument, NULL, 4005 },
77
 	{ 0, 0, 0, 0 }
85
 	{ 0, 0, 0, 0 }
78
 };
86
 };
79
 
87
 
98
 	printf(" --list-vinputs             | List device video inputs.\n");
106
 	printf(" --list-vinputs             | List device video inputs.\n");
99
 	printf(" --list-voutputs            | List device video outputs.\n");
107
 	printf(" --list-voutputs            | List device video outputs.\n");
100
 	printf(" --list-moutputs            | List device monitoring outputs.\n");
108
 	printf(" --list-moutputs            | List device monitoring outputs.\n");
109
+	printf(" --list-serial              | List device serial ports.\n");
101
 	printf("\n");
110
 	printf("\n");
102
 	printf("Video inputs configuration:\n");
111
 	printf("Video inputs configuration:\n");
103
 	printf(" --vi-name <in_X> <name>    | Set video input port X name.\n");
112
 	printf(" --vi-name <in_X> <name>    | Set video input port X name.\n");
114
 	printf(" --mo-lock <mout_X>         | Lock monitoring port X.\n");
123
 	printf(" --mo-lock <mout_X>         | Lock monitoring port X.\n");
115
 	printf(" --mo-unlock <mout_X>       | Unlock monitoring port X.\n");
124
 	printf(" --mo-unlock <mout_X>       | Unlock monitoring port X.\n");
116
 	printf("\n");
125
 	printf("\n");
126
+	printf("Serial ports configuration:\n");
127
+	printf(" --se-name <ser_X> <name>   | Set serial port X name.\n");
128
+	printf(" --se-route <ser_X> <ser_Y> | Connect serial X to serial Y\n");
129
+	printf(" --se-lock <ser_X>          | Lock serial port X.\n");
130
+	printf(" --se-unlock <ser_X>        | Unlock serial port X.\n");
131
+	printf(" --se-dir <ser_X> <dir>     | Set serial port X direction.\n");
132
+	printf("                            . <dir> can be 'auto', 'in' or 'out'.\n");
133
+	printf("\n");
117
 	printf("Misc options:\n");
134
 	printf("Misc options:\n");
118
 	printf(" -T --test-input <file>     | Read commands from <file>.\n");
135
 	printf(" -T --test-input <file>     | Read commands from <file>.\n");
119
 	printf(" -d --debug                 | Increase logging verbosity.\n");
136
 	printf(" -d --debug                 | Increase logging verbosity.\n");
128
 	struct vcmd_entry	entry[MAX_RUN_CMDS];
145
 	struct vcmd_entry	entry[MAX_RUN_CMDS];
129
 } parsed_cmds;
146
 } parsed_cmds;
130
 
147
 
148
+static void check_num_parsed_cmds(void) {
149
+	if (num_parsed_cmds == ARRAY_SIZE(parsed_cmds.entry))
150
+		die("No more than %u commands are supported.", num_parsed_cmds);
151
+}
152
+
131
 static void parse_cmd2(int argc, char **argv, enum vcmd vcmd) {
153
 static void parse_cmd2(int argc, char **argv, enum vcmd vcmd) {
154
+	check_num_parsed_cmds();
132
 	struct vcmd_entry *c = &parsed_cmds.entry[num_parsed_cmds];
155
 	struct vcmd_entry *c = &parsed_cmds.entry[num_parsed_cmds];
133
-	if (num_parsed_cmds == ARRAY_SIZE(parsed_cmds.entry))
134
-		die("No more than %u commands are supported.", num_parsed_cmds);
135
 	if (optind == argc || argv[optind - 1][0] == '-' || argv[optind][0] == '-') {
156
 	if (optind == argc || argv[optind - 1][0] == '-' || argv[optind][0] == '-') {
136
 		fprintf(stderr, "%s: option '%s' requires two arguments\n", argv[0], argv[optind - 2]);
157
 		fprintf(stderr, "%s: option '%s' requires two arguments\n", argv[0], argv[optind - 2]);
137
 		exit(EXIT_FAILURE);
158
 		exit(EXIT_FAILURE);
139
 	c->cmd = &videohub_commands[vcmd];
160
 	c->cmd = &videohub_commands[vcmd];
140
 	c->param1 = argv[optind - 1];
161
 	c->param1 = argv[optind - 1];
141
 	c->param2 = argv[optind];
162
 	c->param2 = argv[optind];
163
+	if (vcmd == CMD_SERIAL_PORT_DIRECTIONS) {
164
+		if (strcasecmp("in", c->param2) == 0)        c->direction = DIR_CONTROL;
165
+		else if (strcasecmp("out", c->param2) == 0)  c->direction = DIR_SLAVE;
166
+		else if (strcasecmp("auto", c->param2) == 0) c->direction = DIR_AUTO;
167
+		else die("Invalid serial port direction '%s'. Allowed are: in, out, auto.", c->param2);
168
+	}
142
 	num_parsed_cmds++;
169
 	num_parsed_cmds++;
143
 }
170
 }
144
 
171
 
145
 static void parse_cmd1(int argc, char **argv, enum vcmd vcmd, bool do_lock) {
172
 static void parse_cmd1(int argc, char **argv, enum vcmd vcmd, bool do_lock) {
173
+	check_num_parsed_cmds();
146
 	struct vcmd_entry *c = &parsed_cmds.entry[num_parsed_cmds];
174
 	struct vcmd_entry *c = &parsed_cmds.entry[num_parsed_cmds];
147
-	if (num_parsed_cmds == ARRAY_SIZE(parsed_cmds.entry))
148
-		die("No more than %u commands are supported.", num_parsed_cmds);
149
 	c->cmd = &videohub_commands[vcmd];
175
 	c->cmd = &videohub_commands[vcmd];
150
 	c->param1 = argv[optind - 1];
176
 	c->param1 = argv[optind - 1];
151
 	c->do_lock = do_lock;
177
 	c->do_lock = do_lock;
206
 			case 902: show_list |= action_list_vinputs; break; // --list-vinputs
232
 			case 902: show_list |= action_list_vinputs; break; // --list-vinputs
207
 			case 903: show_list |= action_list_voutputs; break; // --list-voutputs
233
 			case 903: show_list |= action_list_voutputs; break; // --list-voutputs
208
 			case 904: show_list |= action_list_moutputs; break; // --list-moutputs
234
 			case 904: show_list |= action_list_moutputs; break; // --list-moutputs
235
+			case 905: show_list |= action_list_serial; break; // --list-serial
209
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --vi-name
236
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --vi-name
210
 			case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --vo-name
237
 			case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --vo-name
211
 			case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --vo-input
238
 			case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --vo-input
215
 			case 3002: parse_cmd2(argc, argv, CMD_MONITORING_OUTPUT_ROUTING); break; // --mo-route
242
 			case 3002: parse_cmd2(argc, argv, CMD_MONITORING_OUTPUT_ROUTING); break; // --mo-route
216
 			case 3003: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, true); break; // --mo-lock
243
 			case 3003: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, true); break; // --mo-lock
217
 			case 3004: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, false); break; // --mo-unlock
244
 			case 3004: parse_cmd1(argc, argv, CMD_MONITORING_OUTPUT_LOCKS, false); break; // --mo-unlock
245
+			case 4001: parse_cmd2(argc, argv, CMD_SERIAL_PORT_LABELS); break; // --se-name
246
+			case 4002: parse_cmd2(argc, argv, CMD_SERIAL_PORT_ROUTING); break; // --se-route
247
+			case 4003: parse_cmd1(argc, argv, CMD_SERIAL_PORT_LOCKS, true); break; // --se-lock
248
+			case 4004: parse_cmd1(argc, argv, CMD_SERIAL_PORT_LOCKS, false); break; // --se-unlock
249
+			case 4005: parse_cmd2(argc, argv, CMD_SERIAL_PORT_DIRECTIONS); break; // --se-dir
218
 			case 'H': // --help
250
 			case 'H': // --help
219
 				show_help(data);
251
 				show_help(data);
220
 				exit(EXIT_SUCCESS);
252
 				exit(EXIT_SUCCESS);
248
 	print_device_video_inputs(d);
280
 	print_device_video_inputs(d);
249
 	print_device_video_outputs(d);
281
 	print_device_video_outputs(d);
250
 	print_device_monitoring_outputs(d);
282
 	print_device_monitoring_outputs(d);
283
+	print_device_serial_ports(d);
251
 	fflush(stdout);
284
 	fflush(stdout);
252
 }
285
 }
253
 
286
 
353
 		if (show_list & action_list_vinputs)	print_device_video_inputs(data);
386
 		if (show_list & action_list_vinputs)	print_device_video_inputs(data);
354
 		if (show_list & action_list_voutputs)	print_device_video_outputs(data);
387
 		if (show_list & action_list_voutputs)	print_device_video_outputs(data);
355
 		if (show_list & action_list_moutputs)	print_device_monitoring_outputs(data);
388
 		if (show_list & action_list_moutputs)	print_device_monitoring_outputs(data);
389
+		if (show_list & action_list_serial)		print_device_serial_ports(data);
356
 		fflush(stdout);
390
 		fflush(stdout);
357
 	} else if (show_backup) {
391
 	} else if (show_backup) {
358
 		print_device_backup(data);
392
 		print_device_backup(data);

Loading…
Cancel
Save