Browse Source

Make handling of port disconnection generic.

Georgi Chorbadzhiyski 9 years ago
parent
commit
afdb845e60
2 changed files with 4 additions and 3 deletions
  1. 3
    3
      cmd.c
  2. 1
    0
      cmd.h

+ 3
- 3
cmd.c View File

@@ -111,6 +111,7 @@ struct videohub_commands videohub_commands[NUM_COMMANDS] = {
111 111
 		.port_id1 = "serial",
112 112
 		.port_id2 = "serial",
113 113
 		.opt_prefix = "se",
114
+		.allow_disconnect = true,
114 115
 	},
115 116
 	[CMD_SERIAL_PORT_STATUS]  = { .cmd = CMD_SERIAL_PORT_STATUS , .type = PARSE_STATUS,
116 117
 		.ports1 = OFS(serial),
@@ -228,8 +229,7 @@ bool parse_command(struct videohub_data *d, char *cmd) {
228 229
 		case PARSE_ROUTE:
229 230
 			dest_port_num = strtoul(port_data, NULL, 10);
230 231
 			if (dest_port_num == NO_PORT) {
231
-				// Only serial port routing can be disabled with -1
232
-				if (v->cmd == CMD_SERIAL_PORT_ROUTING) {
232
+				if (v->allow_disconnect) {
233 233
 					s_port->port[port_num].routed_to = dest_port_num;
234 234
 					continue;
235 235
 				} else {
@@ -444,7 +444,7 @@ void show_cmd(struct videohub_data *d, struct vcmd_entry *e) {
444 444
 			);
445 445
 			break;
446 446
 		}
447
-		if (e->cmd->cmd == CMD_SERIAL_PORT_ROUTING) {
447
+		if (e->cmd->allow_disconnect) {
448 448
 			printf("%sconnect %s %d \"%s\" to %s %d \"%s\"\n",
449 449
 				prefix,
450 450
 				e->cmd->port_id1,

+ 1
- 0
cmd.h View File

@@ -57,6 +57,7 @@ struct videohub_commands {
57 57
 	const char		*port_id1;
58 58
 	const char		*port_id2;
59 59
 	const char		*opt_prefix;
60
+	bool			allow_disconnect;
60 61
 };
61 62
 
62 63
 extern struct videohub_commands videohub_commands[NUM_COMMANDS];

Loading…
Cancel
Save