Browse Source

Add support for ALARM STATUS command

Georgi Chorbadzhiyski 5 months ago
parent
commit
f40b692f00
16 changed files with 4698 additions and 19 deletions
  1. 2
    1
      README
  2. 18
    0
      cmd.c
  3. 2
    1
      cmd.h
  4. 14
    1
      data.h
  5. 18
    0
      display.c
  6. 1
    0
      display.h
  7. 2
    0
      test/input-17.txt
  8. 51
    0
      test/input-288-alarms.txt
  9. 3226
    0
      test/input-288.txt
  10. 6
    0
      test/run
  11. 8
    14
      test/test-17.ok
  12. 44
    0
      test/test-288-alarms.ok
  13. 1294
    0
      test/test-288.ok
  14. 1
    1
      test/test-r2.ok
  15. 5
    1
      videohubctrl.1
  16. 6
    0
      videohubctrl.c

+ 2
- 1
README View File

@@ -15,6 +15,7 @@ videohubctrl currently displays and can configure:
15 15
   - Serial ports names, routing, locking and directions
16 16
   - Processing units
17 17
   - Frames
18
+  - Alarms status
18 19
 
19 20
 Configuration of Videohub's network settings can be made using
20 21
 Blackmagic's Windows program when the device is connected via USB.
@@ -59,6 +60,7 @@ Commands:
59 60
  --list-serial              | List device serial ports.
60 61
  --list-proc-units          | List device processing units.
61 62
  --list-frames              | List device frame buffers.
63
+ --list-alarms              | List device alarms.
62 64
 
63 65
  --set-name <name>          | Set the device "friendly name".
64 66
 
@@ -412,7 +414,6 @@ TODO list
412 414
 Help is very much welcome for these tasks:
413 415
 
414 416
  - Find out what these undocumented commands do:
415
-    ALARM STATUS:
416 417
     END PRELUDE:
417 418
     ENGINEERING:
418 419
 

+ 18
- 0
cmd.c View File

@@ -43,6 +43,7 @@ const char *videohub_commands_text[NUM_COMMANDS] = {
43 43
 	[CMD_FRAME_LABELS]           = "FRAME LABELS",
44 44
 	[CMD_FRAME_BUFFER_ROUTING]   = "FRAME BUFFER ROUTING",
45 45
 	[CMD_FRAME_BUFFER_LOCKS]     = "FRAME BUFFER LOCKS",
46
+	[CMD_ALARM_STATUS]         = "ALARM STATUS",
46 47
 	[CMD_PING]                 = "PING",
47 48
 	[CMD_ACK]                  = "ACK",
48 49
 	[CMD_NAK]                  = "NAK",
@@ -162,6 +163,7 @@ struct videohub_commands videohub_commands[NUM_COMMANDS] = {
162 163
 		.port_id1 = "frame",
163 164
 		.opt_prefix = "fr",
164 165
 	},
166
+	[CMD_ALARM_STATUS]         = { .cmd = CMD_ALARM_STATUS        , .type = PARSE_CUSTOM },
165 167
 	[CMD_END_PRELUDE]          = { .cmd = CMD_END_PRELUDE         , .type = PARSE_NONE },
166 168
 	[CMD_PING]                 = { .cmd = CMD_PING                , .type = PARSE_NONE },
167 169
 	[CMD_ACK]                  = { .cmd = CMD_ACK                 , .type = PARSE_NONE },
@@ -332,6 +334,22 @@ bool parse_command(struct videohub_data *d, char *cmd) {
332 334
 			if ((p = parse_text(line, "Take Mode: "))) {
333 335
 				d->device.conf_take_mode = streq(p, "true");
334 336
 			}
337
+			break;
338
+		case CMD_ALARM_STATUS:
339
+			p = strchr(line, ':');
340
+			if (p) {
341
+				char *alarm_name = line; // Use start of the line
342
+				*p = '\0'; // Terminate the alarm name at :
343
+				char *alarm_status = p + 2; // Set alarm value to point after ': '
344
+				if (d->alarms.num + 1 < MAX_ALARMS) {
345
+					snprintf(d->alarms.alarm[ d->alarms.num ].name  , MAX_NAME_LEN, "%s", alarm_name);
346
+					snprintf(d->alarms.alarm[ d->alarms.num ].status, MAX_ALARM_STATUS_LEN, "%s", alarm_status);
347
+					d->alarms.num++;
348
+				} else {
349
+					q("WARNING: Too many alarms (> %d) increase MAX_ALARMS and recompile. Alarm '%s' value '%s' ignorred\n", d->alarms.num + 1, alarm_name, alarm_status);
350
+				}
351
+		}
352
+			break;
335 353
 		case CMD_NAK:
336 354
 			ret = false;
337 355
 			break;

+ 2
- 1
cmd.h View File

@@ -15,7 +15,7 @@
15 15
 
16 16
 #include <stdbool.h>
17 17
 
18
-#define NUM_COMMANDS 26
18
+#define NUM_COMMANDS 27
19 19
 
20 20
 enum vcmd {
21 21
 	CMD_PROTOCOL_PREAMBLE,
@@ -41,6 +41,7 @@ enum vcmd {
41 41
 	CMD_FRAME_LABELS,
42 42
 	CMD_FRAME_BUFFER_ROUTING,
43 43
 	CMD_FRAME_BUFFER_LOCKS,
44
+	CMD_ALARM_STATUS,
44 45
 	CMD_PING,
45 46
 	CMD_ACK,
46 47
 	CMD_NAK = (NUM_COMMANDS - 1),

+ 14
- 1
data.h View File

@@ -16,9 +16,11 @@
16 16
 #include <stdbool.h>
17 17
 
18 18
 #define MAX_PORTS 288
19
-#define MAX_NAME_LEN 32
19
+#define MAX_NAME_LEN 48
20 20
 #define MAX_RUN_CMDS (288 * 5)
21 21
 #define NO_PORT ((unsigned int) -1)
22
+#define MAX_ALARMS 32
23
+#define MAX_ALARM_STATUS_LEN 256
22 24
 
23 25
 struct device_desc {
24 26
 	bool			dev_present;
@@ -73,6 +75,16 @@ struct port_set {
73 75
 	struct port		port[MAX_PORTS];
74 76
 };
75 77
 
78
+struct alarm {
79
+	char			name[MAX_NAME_LEN];
80
+	char			status[MAX_ALARM_STATUS_LEN];
81
+};
82
+
83
+struct alarm_status {
84
+	unsigned int	num;
85
+	struct alarm	alarm[MAX_ALARMS];
86
+};
87
+
76 88
 struct videohub_data {
77 89
 	char					*dev_host;
78 90
 	char					*dev_port;
@@ -84,6 +96,7 @@ struct videohub_data {
84 96
 	struct port_set			serial;
85 97
 	struct port_set			proc_units;
86 98
 	struct port_set			frames;
99
+	struct alarm_status		alarms;
87 100
 };
88 101
 
89 102
 extern int debug;

+ 18
- 0
display.c View File

@@ -224,6 +224,24 @@ void print_device_frame_buffers(struct videohub_data *d) {
224 224
 	printf("\n");
225 225
 }
226 226
 
227
+void print_device_alarm_status(struct videohub_data *d) {
228
+	unsigned int i, len = 70;
229
+	if (!d->alarms.num)
230
+		return;
231
+	printf("Alarm status\n");
232
+	printf_line(len);
233
+	printf("  | %-32s | %-31s |\n", "Alarm name", "Status");
234
+	printf_line(len);
235
+	for(i = 0; i < d->alarms.num; i++) {
236
+		printf("  | %-32s | %-31s |\n",
237
+			d->alarms.alarm[i].name,
238
+			d->alarms.alarm[i].status
239
+		);
240
+	}
241
+	printf_line(len);
242
+	printf("\n");
243
+}
244
+
227 245
 
228 246
 static void __print_opt(struct videohub_data *d, enum vcmd vcmd) {
229 247
 	unsigned int i, last = 0;

+ 1
- 0
display.h View File

@@ -20,6 +20,7 @@ void print_device_monitoring_outputs(struct videohub_data *d);
20 20
 void print_device_serial_ports(struct videohub_data *d);
21 21
 void print_device_processing_units(struct videohub_data *d);
22 22
 void print_device_frame_buffers(struct videohub_data *d);
23
+void print_device_alarm_status(struct videohub_data *d);
23 24
 
24 25
 void print_device_backup(struct videohub_data *d);
25 26
 

+ 2
- 0
test/input-17.txt View File

@@ -37,7 +37,9 @@ INPUT LABELS:
37 37
 15 Loopback
38 38
 
39 39
 ALARM STATUS:
40
+Fan 1: ok
40 41
 0 Error
42
+Fan 2: Something very bad is happening
41 43
 
42 44
 END PRELUDE:
43 45
 

+ 51
- 0
test/input-288-alarms.txt View File

@@ -0,0 +1,51 @@
1
+PROTOCOL PREAMBLE:
2
+Version: 2.3
3
+
4
+VIDEOHUB DEVICE:
5
+Device present: true
6
+Model name: Blackmagic Universal Videohub
7
+Video inputs: 288
8
+Video processing units: 0
9
+Video outputs: 288
10
+Video monitoring outputs: 0
11
+Serial ports: 288
12
+
13
+ALARM STATUS:
14
+Fan 0: ok
15
+Fan 1: zok
16
+Fan 2: ok
17
+Power Supply Slot 0: ok
18
+Power Supply Slot 1: ok
19
+Power Sufficient for Load: ok
20
+Network Slot 0: ok
21
+Network Slot 1: ok
22
+Card Bus: ok
23
+Card Firmware Version: ok
24
+Logic Slot 0: ok
25
+Logic Slot 1: ok
26
+Logic Firmware Version Slot 0: ok
27
+Logic Firmware Version Slot 1: ok
28
+ProcessorLink: ok
29
+Processor Firmware Version: ok
30
+Crosspoint Slot 0: ok
31
+Crosspoint Slot 1: ok
32
+Bus Host Slot 0: ok
33
+Bus Host Slot 1: ok
34
+Bus Host Firmware Version Slot 0: ok
35
+Bus Host Firmware Version Slot 1: ok
36
+test 01: ok
37
+test 02: ok
38
+test 03: ok
39
+test 04: ok
40
+test 05: ok
41
+test 06: ok
42
+test 07: ok
43
+test 08: ok
44
+test 09: ok
45
+test 10: ok
46
+test 11: ok
47
+test 12: ok
48
+test 13: ok
49
+test 14: ok
50
+test 15: ok
51
+test 16: ok

+ 3226
- 0
test/input-288.txt
File diff suppressed because it is too large
View File


+ 6
- 0
test/run View File

@@ -163,3 +163,9 @@ check test/test-r "Test input with windows line endings"
163 163
 
164 164
 videohubctrl --test-input test/input-r2.txt $@ &> test/test-r2.out
165 165
 check test/test-r2 "Test input with leading whitespace and windows line endings"
166
+
167
+videohubctrl --test-input test/input-288.txt $@ &> test/test-288.out
168
+check test/test-288 "Test videohub 288 config parsing"
169
+
170
+videohubctrl --list-alarms --test-input test/input-288-alarms.txt $@ &> test/test-288-alarms.out
171
+check test/test-288-alarms "Test alarm overflow"

+ 8
- 14
test/test-17.ok View File

@@ -8,13 +8,6 @@ WARNING: Videohub sent unknown command!
8 8
          Please report this command to author's email: georgi@unixsol.org
9 9
          You may use -q or --quiet to suppress the message.
10 10
 ---------8<-----------8<----------- cut here ---------8<------------8<---------
11
-ALARM STATUS:
12
-0 Error
13
----------8<-----------8<----------- cut here ---------8<------------8<---------
14
-WARNING: Videohub sent unknown command!
15
-         Please report this command to author's email: georgi@unixsol.org
16
-         You may use -q or --quiet to suppress the message.
17
----------8<-----------8<----------- cut here ---------8<------------8<---------
18 11
 ENGINEERING:
19 12
 0 Hack
20 13
 1 Hack
@@ -23,13 +16,6 @@ WARNING: Videohub sent unknown command!
23 16
          Please report this command to author's email: georgi@unixsol.org
24 17
          You may use -q or --quiet to suppress the message.
25 18
 ---------8<-----------8<----------- cut here ---------8<------------8<---------
26
-ALARM STATUS:
27
-0 Error
28
----------8<-----------8<----------- cut here ---------8<------------8<---------
29
-WARNING: Videohub sent unknown command!
30
-         Please report this command to author's email: georgi@unixsol.org
31
-         You may use -q or --quiet to suppress the message.
32
----------8<-----------8<----------- cut here ---------8<------------8<---------
33 19
 ENGINEERING:
34 20
 0 Debug
35 21
 ---------8<-----------8<----------- cut here ---------8<------------8<---------
@@ -47,6 +33,14 @@ Device info
47 33
   | Video monitoring outputs   | 8                                  |
48 34
   -------------------------------------------------------------------
49 35
 
36
+Alarm status
37
+  ----------------------------------------------------------------------
38
+  | Alarm name                       | Status                          |
39
+  ----------------------------------------------------------------------
40
+  | Fan 1                            | ok                              |
41
+  | Fan 2                            | Something very bad is happening |
42
+  ----------------------------------------------------------------------
43
+
50 44
 Video inputs
51 45
   ----------------------------------------------------------------------
52 46
   | ### | Video input name         | nn | Routed to output         | s |

+ 44
- 0
test/test-288-alarms.ok View File

@@ -0,0 +1,44 @@
1
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 10' value 'ok' ignorred
2
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 11' value 'ok' ignorred
3
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 12' value 'ok' ignorred
4
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 13' value 'ok' ignorred
5
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 14' value 'ok' ignorred
6
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 15' value 'ok' ignorred
7
+WARNING: Too many alarms (> 32) increase MAX_ALARMS and recompile. Alarm 'test 16' value 'ok' ignorred
8
+Alarm status
9
+  ----------------------------------------------------------------------
10
+  | Alarm name                       | Status                          |
11
+  ----------------------------------------------------------------------
12
+  | Fan 0                            | ok                              |
13
+  | Fan 1                            | zok                             |
14
+  | Fan 2                            | ok                              |
15
+  | Power Supply Slot 0              | ok                              |
16
+  | Power Supply Slot 1              | ok                              |
17
+  | Power Sufficient for Load        | ok                              |
18
+  | Network Slot 0                   | ok                              |
19
+  | Network Slot 1                   | ok                              |
20
+  | Card Bus                         | ok                              |
21
+  | Card Firmware Version            | ok                              |
22
+  | Logic Slot 0                     | ok                              |
23
+  | Logic Slot 1                     | ok                              |
24
+  | Logic Firmware Version Slot 0    | ok                              |
25
+  | Logic Firmware Version Slot 1    | ok                              |
26
+  | ProcessorLink                    | ok                              |
27
+  | Processor Firmware Version       | ok                              |
28
+  | Crosspoint Slot 0                | ok                              |
29
+  | Crosspoint Slot 1                | ok                              |
30
+  | Bus Host Slot 0                  | ok                              |
31
+  | Bus Host Slot 1                  | ok                              |
32
+  | Bus Host Firmware Version Slot 0 | ok                              |
33
+  | Bus Host Firmware Version Slot 1 | ok                              |
34
+  | test 01                          | ok                              |
35
+  | test 02                          | ok                              |
36
+  | test 03                          | ok                              |
37
+  | test 04                          | ok                              |
38
+  | test 05                          | ok                              |
39
+  | test 06                          | ok                              |
40
+  | test 07                          | ok                              |
41
+  | test 08                          | ok                              |
42
+  | test 09                          | ok                              |
43
+  ----------------------------------------------------------------------
44
+

+ 1294
- 0
test/test-288.ok
File diff suppressed because it is too large
View File


+ 1
- 1
test/test-r2.ok View File

@@ -2,7 +2,7 @@ Device info
2 2
   -------------------------------------------------------------------
3 3
   | Device address             | sdi-matrix                         |
4 4
   | Device port                | 9990                               |
5
-  | Model name                 | Blackmagic Smart Videohub 20 x     |
5
+  | Model name                 | Blackmagic Smart Videohub 20 x 20  |
6 6
   | Friendly name              |      (2)            @              |
7 7
   | Unique ID                  | XXXXXXXXXXXX                       |
8 8
   | Protocol                   | 2.7                                |

+ 5
- 1
videohubctrl.1 View File

@@ -1,4 +1,4 @@
1
-.TH VIDEOHUBCTRL "1" "December 2014" "videohubctrl 3.0" "User Commands"
1
+.TH VIDEOHUBCTRL "1" "October 2020" "videohubctrl 3.1" "User Commands"
2 2
 .SH NAME
3 3
 videohubctrl - Blackmagic Design Videohub SDI router control
4 4
 .SH SYNOPSIS
@@ -17,6 +17,7 @@ videohubctrl currently displays and can configure:
17 17
   - Serial ports names, routing, locking and directions
18 18
   - Processing units
19 19
   - Frames
20
+  - Alarms status
20 21
 .SH MAIN OPTIONS
21 22
 .PP
22 23
 .TP
@@ -97,6 +98,9 @@ video inputs.
97 98
 \fB\-\-list\-frames\fR
98 99
 Display stored frame buffers.
99 100
 .TP
101
+\fB\-\-list\-alarms\fR
102
+Display current alarms status.
103
+.TP
100 104
 \fB\-\-set\-name\fR <name>
101 105
 Set the device "friendly name". This name can be used as a device identifier.
102 106
 Only some Videohub models support this functionality.

+ 6
- 0
videohubctrl.c View File

@@ -46,6 +46,7 @@ enum list_actions {
46 46
 	action_list_serial		= (1 << 4),
47 47
 	action_list_proc_units	= (1 << 5),
48 48
 	action_list_frames		= (1 << 6),
49
+	action_list_alarms		= (1 << 7),
49 50
 };
50 51
 
51 52
 static const char *program_id = PROGRAM_NAME " Version: " VERSION " Git: " GIT_VER;
@@ -75,6 +76,7 @@ static const struct option long_options[] = {
75 76
 	{ "list-serial",		no_argument,       NULL, 905 },
76 77
 	{ "list-proc-units",	no_argument,       NULL, 906 },
77 78
 	{ "list-frames",		no_argument,       NULL, 907 },
79
+	{ "list-alarms",		no_argument,       NULL, 908 },
78 80
 
79 81
 	{ "set-name",			required_argument, NULL, 950 },
80 82
 
@@ -167,6 +169,7 @@ static void show_help(struct videohub_data *data) {
167 169
 	printf(" --list-serial              | List device serial ports.\n");
168 170
 	printf(" --list-proc-units          | List device processing units.\n");
169 171
 	printf(" --list-frames              | List device frame buffers.\n");
172
+	printf(" --list-alarms              | List device alarms.\n");
170 173
 	printf("\n");
171 174
 	printf(" --set-name <name>          | Set the device \"friendly name\".\n");
172 175
 	printf("\n");
@@ -344,6 +347,7 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
344 347
 			case 905: show_list |= action_list_serial; break; // --list-serial
345 348
 			case 906: show_list |= action_list_proc_units; break; // --list-proc-units
346 349
 			case 907: show_list |= action_list_frames; break; // --list-frames
350
+			case 908: show_list |= action_list_alarms; break; // --list-alarms
347 351
 			case 950: set_device_option("Friendly name", optarg); break; // --set-name
348 352
 			case 1001: parse_cmd2(argc, argv, CMD_INPUT_LABELS); break; // --in-name
349 353
 			case 1002: parse_cmd2(argc, argv, CMD_VIDEO_OUTPUT_ROUTING); switch_cmd_args(); break; // --in-output
@@ -409,6 +413,7 @@ static void reset_routed_to(struct port_set *p) {
409 413
 
410 414
 static void print_device_full(struct videohub_data *d) {
411 415
 	print_device_info(d);
416
+	print_device_alarm_status(d);
412 417
 	print_device_video_inputs(d);
413 418
 	print_device_video_outputs(d);
414 419
 	print_device_monitoring_outputs(d);
@@ -528,6 +533,7 @@ int main(int argc, char **argv) {
528 533
 		}
529 534
 	} else if (show_list) {
530 535
 		if (show_list & action_list_device)		print_device_info(data);
536
+		if (show_list & action_list_alarms)		print_device_alarm_status(data);
531 537
 		if (show_list & action_list_vinputs)	print_device_video_inputs(data);
532 538
 		if (show_list & action_list_voutputs)	print_device_video_outputs(data);
533 539
 		if (show_list & action_list_moutputs)	print_device_monitoring_outputs(data);

Loading…
Cancel
Save