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
 |-----------------------------------------------------------------------|
1
 |-----------------------------------------------------------------------|
2
 xxxx-xx-xx : Version -next
2
 xxxx-xx-xx : Version -next
3
  * Add support for --list-proc-units and --list-frames.
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
 2014-12-03 : Version 1.0
6
 2014-12-03 : Version 1.0
6
  * Add missing documentation for --list-moutputs parameter.
7
  * Add missing documentation for --list-moutputs parameter.

+ 2
- 0
README View File

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

+ 16
- 0
cmd.c View File

382
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
382
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
383
 	struct port_set *d_port = !e->cmd->ports2 ? NULL : (void *)d + e->cmd->ports2;
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
 	// All command types needs parsing of the "source port"
388
 	// All command types needs parsing of the "source port"
386
 	e->port_no1 = my_atoi(e->param1);
389
 	e->port_no1 = my_atoi(e->param1);
387
 	if (e->port_no1 == 0 || e->port_no1 > s_port->num) {
390
 	if (e->port_no1 == 0 || e->port_no1 > s_port->num) {
430
 }
433
 }
431
 
434
 
432
 void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
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
 	switch (e->cmd->type) {
441
 	switch (e->cmd->type) {
434
 	case PARSE_LABEL:
442
 	case PARSE_LABEL:
435
 		snprintf(buf, bufsz, "%s:\n%u %s\n\n", videohub_commands_text[e->cmd->cmd],
443
 		snprintf(buf, bufsz, "%s:\n%u %s\n\n", videohub_commands_text[e->cmd->cmd],
455
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
463
 	struct port_set *s_port = !e->cmd->ports1 ? NULL : (void *)d + e->cmd->ports1;
456
 	struct port_set *d_port = !e->cmd->ports2 ? NULL : (void *)d + e->cmd->ports2;
464
 	struct port_set *d_port = !e->cmd->ports2 ? NULL : (void *)d + e->cmd->ports2;
457
 	const char *prefix = "videohub: ";
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
 	switch (e->cmd->type) {
474
 	switch (e->cmd->type) {
459
 	case PARSE_LABEL:
475
 	case PARSE_LABEL:
460
 		printf("%srename %s %d \"%s\" to \"%s\"\n",
476
 		printf("%srename %s %d \"%s\" to \"%s\"\n",

+ 3
- 0
display.c View File

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

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

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

+ 3
- 1
test/run View File

32
 check test/test-03 "Test --backup restore"
32
 check test/test-03 "Test --backup restore"
33
 
33
 
34
 videohubctrl --test-input test/input-00.txt \
34
 videohubctrl --test-input test/input-00.txt \
35
+	--set-name "Test name" \
35
 	--vi-name "Windows 4 HD" "Windows 4 HighDef" \
36
 	--vi-name "Windows 4 HD" "Windows 4 HighDef" \
36
 	--vi-name 5 "In 5" \
37
 	--vi-name 5 "In 5" \
37
 	--vi-name "Input 6" "Camera 6" \
38
 	--vi-name "Input 6" "Camera 6" \
111
 ./videohubctrl --test-input test/input-00.txt --se-unlock "Serial 18"                $@ >> test/test-06.out 2>&1
112
 ./videohubctrl --test-input test/input-00.txt --se-unlock "Serial 18"                $@ >> test/test-06.out 2>&1
112
 ./videohubctrl --test-input test/input-00.txt --se-dir 1 err-dir                     $@ >> test/test-06.out 2>&1
113
 ./videohubctrl --test-input test/input-00.txt --se-dir 1 err-dir                     $@ >> test/test-06.out 2>&1
113
 ./videohubctrl --test-input test/input-00.txt --se-dir "Serial 5" err-dir            $@ >> test/test-06.out 2>&1
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
 videohubctrl --test-input test/input-00.txt --list-device $@ &> test/test-07.out
118
 videohubctrl --test-input test/input-00.txt --list-device $@ &> test/test-07.out
117
 check test/test-07 "Test --list-device option output"
119
 check test/test-07 "Test --list-device option output"

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

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

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

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

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

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

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

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

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

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

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

33
 ERROR: Unknown serial port number/name: Serial 18
33
 ERROR: Unknown serial port number/name: Serial 18
34
 ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
34
 ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
35
 ERROR: Invalid serial port direction 'err-dir'. Allowed are: in, out, auto.
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
   | Device address             | sdi-matrix                         |
3
   | Device address             | sdi-matrix                         |
4
   | Device port                | 9990                               |
4
   | Device port                | 9990                               |
5
   | Model name                 | Blackmagic Micro Videohub          |
5
   | Model name                 | Blackmagic Micro Videohub          |
6
+  | Friendly name              | My Videohub                        |
6
   | Unique ID                  | 7c2e0d021714                       |
7
   | Unique ID                  | 7c2e0d021714                       |
7
   | Protocol                   | 2.4                                |
8
   | Protocol                   | 2.4                                |
8
   | Video inputs               | 16                                 |
9
   | Video inputs               | 16                                 |

+ 4
- 0
videohubctrl.1 View File

92
 .TP
92
 .TP
93
 \fB\-\-list\-frames\fR
93
 \fB\-\-list\-frames\fR
94
 Display stored frame buffers.
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
 .SH CONFIGURATION COMMANDS
99
 .SH CONFIGURATION COMMANDS
96
 .PP
100
 .PP
97
 Everywhere where port needs to be set, you can use the port number or the
101
 Everywhere where port needs to be set, you can use the port number or the

+ 13
- 0
videohubctrl.c View File

69
 	{ "list-serial",		no_argument,       NULL, 905 },
69
 	{ "list-serial",		no_argument,       NULL, 905 },
70
 	{ "list-proc-units",	no_argument,       NULL, 906 },
70
 	{ "list-proc-units",	no_argument,       NULL, 906 },
71
 	{ "list-frames",		no_argument,       NULL, 907 },
71
 	{ "list-frames",		no_argument,       NULL, 907 },
72
+	{ "set-name",			required_argument, NULL, 950 },
72
 	{ "vi-name",			required_argument, NULL, 1001 },
73
 	{ "vi-name",			required_argument, NULL, 1001 },
73
 	{ "vo-name",			required_argument, NULL, 2001 },
74
 	{ "vo-name",			required_argument, NULL, 2001 },
74
 	{ "vo-input",			required_argument, NULL, 2002 },
75
 	{ "vo-input",			required_argument, NULL, 2002 },
130
 	printf(" --list-proc-units          | List device processing units.\n");
131
 	printf(" --list-proc-units          | List device processing units.\n");
131
 	printf(" --list-frames              | List device frame buffers.\n");
132
 	printf(" --list-frames              | List device frame buffers.\n");
132
 	printf("\n");
133
 	printf("\n");
134
+	printf(" --set-name <name>          | Set the device \"friendly name\".\n");
135
+	printf("\n");
133
 	printf("Video inputs configuration:\n");
136
 	printf("Video inputs configuration:\n");
134
 	printf(" --vi-name <in_X> <name>    | Set video input port X name.\n");
137
 	printf(" --vi-name <in_X> <name>    | Set video input port X name.\n");
135
 	printf("\n");
138
 	printf("\n");
224
 	num_parsed_cmds++;
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
 static void parse_options(struct videohub_data *data, int argc, char **argv) {
239
 static void parse_options(struct videohub_data *data, int argc, char **argv) {
228
 	int j, err = 0;
240
 	int j, err = 0;
229
 	// Check environment
241
 	// Check environment
281
 			case 905: show_list |= action_list_serial; break; // --list-serial
293
 			case 905: show_list |= action_list_serial; break; // --list-serial
282
 			case 906: show_list |= action_list_proc_units; break; // --list-proc-units
294
 			case 906: show_list |= action_list_proc_units; break; // --list-proc-units
283
 			case 907: show_list |= action_list_frames; break; // --list-frames
295
 			case 907: show_list |= action_list_frames; break; // --list-frames
296
+			case 950: set_device_option("Friendly name", optarg); break; // --set-name
284
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --vi-name
297
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --vi-name
285
 			case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --vo-name
298
 			case 2001: parse_cmd2(argc, argv, CMD_OUTPUT_LABELS); break; // --vo-name
286
 			case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --vo-input
299
 			case 2002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); break; // --vo-input

Loading…
Cancel
Save