Browse Source

Add support for setting device friendly name using --set-name

My Videohub Micro doesn't support this extra but I suppose the
bigger models do (at least the official software v6 reads this
value and shows it instead of the device model).
Georgi Chorbadzhiyski 9 years ago
parent
commit
dd92e76c94
15 changed files with 52 additions and 1 deletions
  1. 1
    0
      ChangeLog
  2. 2
    0
      README
  3. 16
    0
      cmd.c
  4. 3
    0
      display.c
  5. 1
    0
      test/input-00.txt
  6. 3
    1
      test/run
  7. 1
    0
      test/test-01.ok
  8. 1
    0
      test/test-02.ok
  9. 2
    0
      test/test-03.ok
  10. 2
    0
      test/test-04.ok
  11. 1
    0
      test/test-05.ok
  12. 1
    0
      test/test-06.ok
  13. 1
    0
      test/test-07.ok
  14. 4
    0
      videohubctrl.1
  15. 13
    0
      videohubctrl.c

+ 1
- 0
ChangeLog View File

@@ -1,6 +1,7 @@
1 1
 |-----------------------------------------------------------------------|
2 2
 xxxx-xx-xx : Version -next
3 3
  * Add support for --list-proc-units and --list-frames.
4
+ * Add support for setting device friendly name using --set-name option.
4 5
 
5 6
 2014-12-03 : Version 1.0
6 7
  * Add missing documentation for --list-moutputs parameter.

+ 2
- 0
README View File

@@ -59,6 +59,8 @@ Commands:
59 59
  --list-proc-units          | List device processing units.
60 60
  --list-frames              | List device frame buffers.
61 61
 
62
+ --set-name <name>          | Set the device "friendly name".
63
+
62 64
 Video inputs configuration:
63 65
  --vi-name <in_X> <name>    | Set video input port X name.
64 66
 

+ 16
- 0
cmd.c View File

@@ -382,6 +382,9 @@ void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e) {
382 382
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
383 383
 	struct port_set *d_port = !e->cmd->ports2 ? NULL : (void *)d + e->cmd->ports2;
384 384
 
385
+	if (e->cmd->type == PARSE_CUSTOM)
386
+		return;
387
+
385 388
 	// All command types needs parsing of the "source port"
386 389
 	e->port_no1 = my_atoi(e->param1);
387 390
 	if (e->port_no1 == 0 || e->port_no1 > s_port->num) {
@@ -430,6 +433,11 @@ static char *dir2txt(enum serial_dir dir) {
430 433
 }
431 434
 
432 435
 void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
436
+	if (e->cmd->cmd == CMD_VIDEOHUB_DEVICE) {
437
+		snprintf(buf, bufsz, "%s:\n%s: %s\n\n", videohub_commands_text[e->cmd->cmd],
438
+			e->param1, e->param2);
439
+		return;
440
+	}
433 441
 	switch (e->cmd->type) {
434 442
 	case PARSE_LABEL:
435 443
 		snprintf(buf, bufsz, "%s:\n%u %s\n\n", videohub_commands_text[e->cmd->cmd],
@@ -455,6 +463,14 @@ void show_cmd(struct videohub_data *d, struct vcmd_entry *e) {
455 463
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
456 464
 	struct port_set *d_port = !e->cmd->ports2 ? NULL : (void *)d + e->cmd->ports2;
457 465
 	const char *prefix = "videohub: ";
466
+	if (e->cmd->cmd == CMD_VIDEOHUB_DEVICE) {
467
+		printf("%sset device \"%s\" to \"%s\"\n",
468
+			prefix,
469
+			e->param1,
470
+			e->param2
471
+		);
472
+		return;
473
+	}
458 474
 	switch (e->cmd->type) {
459 475
 	case PARSE_LABEL:
460 476
 		printf("%srename %s %d \"%s\" to \"%s\"\n",

+ 3
- 0
display.c View File

@@ -260,6 +260,9 @@ static void __print_opt(struct videohub_data *d, enum vcmd vcmd) {
260 260
 void print_device_backup(struct videohub_data *d) {
261 261
 	unsigned int i;
262 262
 	printf("videohubctrl \\\n");
263
+	if (d->device.friendly_name[0]) {
264
+		printf("  --set-name \"%s\" \\\n", d->device.friendly_name);
265
+	}
263 266
 	for (i = 0; i < NUM_COMMANDS; i++) {
264 267
 		if (videohub_commands[i].type == PARSE_LABEL)
265 268
 			__print_opt(d, videohub_commands[i].cmd);

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

@@ -4,6 +4,7 @@ Version: 2.4
4 4
 VIDEOHUB DEVICE:
5 5
 Device present: true
6 6
 Model name: Blackmagic Micro Videohub
7
+Friendly name: My Videohub
7 8
 Unique ID: 7c2e0d021714
8 9
 Video inputs: 16
9 10
 Video processing units: 4

+ 3
- 1
test/run View File

@@ -32,6 +32,7 @@ check test/test-02 "Test --backup option output"
32 32
 check test/test-03 "Test --backup restore"
33 33
 
34 34
 videohubctrl --test-input test/input-00.txt \
35
+	--set-name "Test name" \
35 36
 	--vi-name "Windows 4 HD" "Windows 4 HighDef" \
36 37
 	--vi-name 5 "In 5" \
37 38
 	--vi-name "Input 6" "Camera 6" \
@@ -111,7 +112,8 @@ check test/test-05 "Test if --backup restored correct config."
111 112
 ./videohubctrl --test-input test/input-00.txt --se-unlock "Serial 18"                $@ >> test/test-06.out 2>&1
112 113
 ./videohubctrl --test-input test/input-00.txt --se-dir 1 err-dir                     $@ >> test/test-06.out 2>&1
113 114
 ./videohubctrl --test-input test/input-00.txt --se-dir "Serial 5" err-dir            $@ >> test/test-06.out 2>&1
114
-check test/test-06 "Test errors on commands with invalid ports."
115
+./videohubctrl --test-input test/input-00.txt --set-name                             $@ >> test/test-06.out 2>&1
116
+check test/test-06 "Test errors on commands with invalid parameters."
115 117
 
116 118
 videohubctrl --test-input test/input-00.txt --list-device $@ &> test/test-07.out
117 119
 check test/test-07 "Test --list-device option output"

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

@@ -3,6 +3,7 @@ Device info
3 3
   | Device address             | sdi-matrix                         |
4 4
   | Device port                | 9990                               |
5 5
   | Model name                 | Blackmagic Micro Videohub          |
6
+  | Friendly name              | My Videohub                        |
6 7
   | Unique ID                  | 7c2e0d021714                       |
7 8
   | Protocol                   | 2.4                                |
8 9
   | Video inputs               | 16                                 |

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

@@ -1,4 +1,5 @@
1 1
 videohubctrl \
2
+  --set-name "My Videohub" \
2 3
   --vi-name   1 "Windows 1" \
3 4
   --vi-name   2 "Windows 2" \
4 5
   --vi-name   3 "Windows 3" \

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

@@ -1,3 +1,4 @@
1
+videohub: set device "Friendly name" to "My Videohub"
1 2
 videohub: rename video input 1 "" to "Windows 1"
2 3
 videohub: rename video input 2 "" to "Windows 2"
3 4
 videohub: rename video input 3 "" to "Windows 3"
@@ -147,6 +148,7 @@ Device info
147 148
   | Device address             | sdi-matrix                         |
148 149
   | Device port                | 9990                               |
149 150
   | Model name                 | Blackmagic Micro Videohub          |
151
+  | Friendly name              | My Videohub                        |
150 152
   | Unique ID                  | 7c2e0d021714                       |
151 153
   | Protocol                   | 2.4                                |
152 154
   | Video inputs               | 16                                 |

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

@@ -1,3 +1,4 @@
1
+videohub: set device "Friendly name" to "Test name"
1 2
 videohub: rename video input 4 "Windows 4 HD" to "Windows 4 HighDef"
2 3
 videohub: rename video input 5 "Input 5" to "In 5"
3 4
 videohub: rename video input 6 "Input 6" to "Camera 6"
@@ -51,6 +52,7 @@ Device info
51 52
   | Device address             | sdi-matrix                         |
52 53
   | Device port                | 9990                               |
53 54
   | Model name                 | Blackmagic Micro Videohub          |
55
+  | Friendly name              | Test name                          |
54 56
   | Unique ID                  | 7c2e0d021714                       |
55 57
   | Protocol                   | 2.4                                |
56 58
   | Video inputs               | 16                                 |

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

@@ -3,6 +3,7 @@ Device info
3 3
   | Device address             | sdi-matrix                         |
4 4
   | Device port                | 9990                               |
5 5
   | Model name                 | Blackmagic Micro Videohub          |
6
+  | Friendly name              | My Videohub                        |
6 7
   | Unique ID                  | 7c2e0d021714                       |
7 8
   | Protocol                   | 2.4                                |
8 9
   | Video inputs               | 16                                 |

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

@@ -33,3 +33,4 @@ ERROR: Unknown serial port number/name: 18
33 33
 ERROR: Unknown serial port number/name: Serial 18
34 34
 ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
35 35
 ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
36
+./videohubctrl: option '--set-name' requires an argument

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

@@ -3,6 +3,7 @@ Device info
3 3
   | Device address             | sdi-matrix                         |
4 4
   | Device port                | 9990                               |
5 5
   | Model name                 | Blackmagic Micro Videohub          |
6
+  | Friendly name              | My Videohub                        |
6 7
   | Unique ID                  | 7c2e0d021714                       |
7 8
   | Protocol                   | 2.4                                |
8 9
   | Video inputs               | 16                                 |

+ 4
- 0
videohubctrl.1 View File

@@ -92,6 +92,10 @@ video inputs.
92 92
 .TP
93 93
 \fB\-\-list\-frames\fR
94 94
 Display stored frame buffers.
95
+.TP
96
+\fB\-\-set\-name\fR <name>
97
+Set the device "friendly name". This name can be used as a device identifier.
98
+Only some Videohub models support this functionality.
95 99
 .SH CONFIGURATION COMMANDS
96 100
 .PP
97 101
 Everywhere where port needs to be set, you can use the port number or the

+ 13
- 0
videohubctrl.c View File

@@ -69,6 +69,7 @@ static const struct option long_options[] = {
69 69
 	{ "list-serial",		no_argument,       NULL, 905 },
70 70
 	{ "list-proc-units",	no_argument,       NULL, 906 },
71 71
 	{ "list-frames",		no_argument,       NULL, 907 },
72
+	{ "set-name",			required_argument, NULL, 950 },
72 73
 	{ "vi-name",			required_argument, NULL, 1001 },
73 74
 	{ "vo-name",			required_argument, NULL, 2001 },
74 75
 	{ "vo-input",			required_argument, NULL, 2002 },
@@ -130,6 +131,8 @@ static void show_help(struct videohub_data *data) {
130 131
 	printf(" --list-proc-units          | List device processing units.\n");
131 132
 	printf(" --list-frames              | List device frame buffers.\n");
132 133
 	printf("\n");
134
+	printf(" --set-name <name>          | Set the device \"friendly name\".\n");
135
+	printf("\n");
133 136
 	printf("Video inputs configuration:\n");
134 137
 	printf(" --vi-name <in_X> <name>    | Set video input port X name.\n");
135 138
 	printf("\n");
@@ -224,6 +227,15 @@ static void parse_cmd1(int argc, char **argv, enum vcmd vcmd, bool do_lock) {
224 227
 	num_parsed_cmds++;
225 228
 }
226 229
 
230
+static void set_device_option(char *setting, char *value) {
231
+	check_num_parsed_cmds();
232
+	struct vcmd_entry *c = &parsed_cmds.entry[num_parsed_cmds];
233
+	c->cmd = &videohub_commands[CMD_VIDEOHUB_DEVICE];
234
+	c->param1 = setting;
235
+	c->param2 = value;
236
+	num_parsed_cmds++;
237
+}
238
+
227 239
 static void parse_options(struct videohub_data *data, int argc, char **argv) {
228 240
 	int j, err = 0;
229 241
 	// Check environment
@@ -281,6 +293,7 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
281 293
 			case 905: show_list |= action_list_serial; break; // --list-serial
282 294
 			case 906: show_list |= action_list_proc_units; break; // --list-proc-units
283 295
 			case 907: show_list |= action_list_frames; break; // --list-frames
296
+			case 950: set_device_option("Friendly name", optarg); break; // --set-name
284 297
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --vi-name
285 298
 			case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --vo-name
286 299
 			case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --vo-input

Loading…
Cancel
Save