Browse Source

Show executed commands in human readable commands format.

Georgi Chorbadzhiyski 9 years ago
parent
commit
8e1aefbec6
3 changed files with 43 additions and 5 deletions
  1. 40
    0
      cmd.c
  2. 2
    0
      cmd.h
  3. 1
    5
      videohubctrl.c

+ 40
- 0
cmd.c View File

@@ -404,3 +404,43 @@ void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz) {
404 404
 		break;
405 405
 	}
406 406
 }
407
+
408
+void show_cmd(struct videohub_data *d, struct vcmd_entry *e) {
409
+	const char *prefix = "videohub: ";
410
+	switch (e->cmd) {
411
+	case CMD_INPUT_LABELS:
412
+		printf("%srename video input %d - \"%s\" to \"%s\"\n",
413
+			prefix,
414
+			e->port_no1, d->inputs[e->port_no1 - 1].name,
415
+			e->param2
416
+		);
417
+		break;
418
+	case CMD_OUTPUT_LABELS:
419
+		printf("%srename video output %d - \"%s\" to \"%s\"\n",
420
+			prefix,
421
+			e->port_no1, d->outputs[e->port_no1 - 1].name,
422
+			e->param2
423
+		);
424
+		break;
425
+	case CMD_VIDEO_OUTPUT_LOCKS:
426
+		printf("%s%s video output %d - \"%s\"\n",
427
+			prefix,
428
+			e->do_lock ? "lock" : (e->locked_other ? "force unlock" : "unlock"),
429
+			e->port_no1, d->outputs[e->port_no1 - 1].name
430
+		);
431
+		break;
432
+	case CMD_VIDEO_OUTPUT_ROUTING:
433
+		printf("%sset video output %d \"%s\" to read from input %d \"%s\"\n",
434
+			prefix,
435
+			e->port_no1, d->outputs[e->port_no1 - 1].name,
436
+			e->port_no2, d->inputs [e->port_no2 - 1].name
437
+		);
438
+		break;
439
+	case CMD_PROTOCOL_PREAMBLE:
440
+	case CMD_VIDEOHUB_DEVICE:
441
+	case CMD_PING:
442
+	case CMD_ACK:
443
+	case CMD_NAK:
444
+		break;
445
+	}
446
+}

+ 2
- 0
cmd.h View File

@@ -43,4 +43,6 @@ struct vcmd_entry {
43 43
 void prepare_cmd_entry(struct videohub_data *d, struct vcmd_entry *e);
44 44
 void format_cmd_text(struct vcmd_entry *e, char *buf, unsigned int bufsz);
45 45
 
46
+void show_cmd(struct videohub_data *d, struct vcmd_entry *e);
47
+
46 48
 #endif

+ 1
- 5
videohubctrl.c View File

@@ -253,7 +253,6 @@ int main(int argc, char **argv) {
253 253
 			prepare_cmd_entry(data, &parsed_cmds.entry[i]);
254 254
 		}
255 255
 
256
-		//print_device_settings(data);
257 256
 		for (i = 0; i < ARRAY_SIZE(parsed_cmds.entry); i++) {
258 257
 			char cmd_buffer[1024];
259 258
 			struct vcmd_entry *ve = &parsed_cmds.entry[i];
@@ -261,13 +260,10 @@ int main(int argc, char **argv) {
261 260
 				continue;
262 261
 			format_cmd_text(ve, cmd_buffer, sizeof(cmd_buffer));
263 262
 			if (strlen(cmd_buffer)) {
264
-				printf("%s", cmd_buffer);
263
+				show_cmd(data, ve);
265 264
 				fdwrite(data->dev_fd, cmd_buffer, strlen(cmd_buffer));
266 265
 			}
267 266
 		}
268
-		//usleep(100000);
269
-		//read_device_command_stream(data);
270
-		//print_device_settings(data);
271 267
 	} else if (show_monitor) {
272 268
 		while (1) {
273 269
 			int sleeps = 0;

Loading…
Cancel
Save