Browse Source

Add proper protocol version checks.

Georgi Chorbadzhiyski 9 years ago
parent
commit
37992c486a
2 changed files with 8 additions and 12 deletions
  1. 0
    10
      cmd.c
  2. 8
    2
      videohubctrl.c

+ 0
- 10
cmd.c View File

@@ -287,16 +287,6 @@ bool parse_command(struct videohub_data *data, char *cmd) {
287 287
 
288 288
 	/* Check if everything is within limits */
289 289
 	switch (v->cmd) {
290
-	case CMD_PROTOCOL_PREAMBLE:
291
-		if (!streq(data->device.protocol_ver, "2.4")) {
292
-			if (!quiet) {
293
-				fprintf(stderr, "WARNING: Device protocol is %s but this program is tested with 2.4 only.\n",
294
-					data->device.protocol_ver);
295
-				fprintf(stderr, "         Please report successes/failures to author's email: georgi@unixsol.org\n");
296
-				fprintf(stderr, "         You may use -q or --quiet to suppress the message.\n");
297
-			}
298
-		}
299
-		break;
300 290
 	case CMD_VIDEOHUB_DEVICE:
301 291
 		if (!data->device.dev_present) {
302 292
 			die("Device reports that it's not present.");

+ 8
- 2
videohubctrl.c View File

@@ -114,8 +114,6 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
114 114
 }
115 115
 
116 116
 static void print_device_desc(struct device_desc *d) {
117
-	if (!strlen(d->protocol_ver) || !strlen(d->model_name))
118
-		die("The device does not return protocol version and model name!");
119 117
 	printf("\n");
120 118
 	printf("Protocol version: %s\n", d->protocol_ver);
121 119
 	printf("Model name: %s\n", d->model_name);
@@ -175,6 +173,14 @@ int main(int argc, char **argv) {
175 173
 		exit(EXIT_FAILURE);
176 174
 
177 175
 	read_device_command_stream(data);
176
+
177
+	if (!strlen(data->device.protocol_ver) || !strlen(data->device.model_name))
178
+		die("The device does not respond correctly. Is it Videohub?");
179
+
180
+	if (strstr(data->device.protocol_ver, "2.") != data->device.protocol_ver)
181
+		die("Device protocol is %s but this program supports 2.x only.\n",
182
+			data->device.protocol_ver);
183
+
178 184
 	if (show_monitor) {
179 185
 		while (1) {
180 186
 			printf("\e[2J\e[H"); // Clear screen

Loading…
Cancel
Save