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
 		.port_id1 = "serial",
111
 		.port_id1 = "serial",
112
 		.port_id2 = "serial",
112
 		.port_id2 = "serial",
113
 		.opt_prefix = "se",
113
 		.opt_prefix = "se",
114
+		.allow_disconnect = true,
114
 	},
115
 	},
115
 	[CMD_SERIAL_PORT_STATUS]  = { .cmd = CMD_SERIAL_PORT_STATUS , .type = PARSE_STATUS,
116
 	[CMD_SERIAL_PORT_STATUS]  = { .cmd = CMD_SERIAL_PORT_STATUS , .type = PARSE_STATUS,
116
 		.ports1 = OFS(serial),
117
 		.ports1 = OFS(serial),
228
 		case PARSE_ROUTE:
229
 		case PARSE_ROUTE:
229
 			dest_port_num = strtoul(port_data, NULL, 10);
230
 			dest_port_num = strtoul(port_data, NULL, 10);
230
 			if (dest_port_num == NO_PORT) {
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
 					s_port->port[port_num].routed_to = dest_port_num;
233
 					s_port->port[port_num].routed_to = dest_port_num;
234
 					continue;
234
 					continue;
235
 				} else {
235
 				} else {
444
 			);
444
 			);
445
 			break;
445
 			break;
446
 		}
446
 		}
447
-		if (e->cmd->cmd == CMD_SERIAL_PORT_ROUTING) {
447
+		if (e->cmd->allow_disconnect) {
448
 			printf("%sconnect %s %d \"%s\" to %s %d \"%s\"\n",
448
 			printf("%sconnect %s %d \"%s\" to %s %d \"%s\"\n",
449
 				prefix,
449
 				prefix,
450
 				e->cmd->port_id1,
450
 				e->cmd->port_id1,

+ 1
- 0
cmd.h View File

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

Loading…
Cancel
Save