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
 
287
 
288
 	/* Check if everything is within limits */
288
 	/* Check if everything is within limits */
289
 	switch (v->cmd) {
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
 	case CMD_VIDEOHUB_DEVICE:
290
 	case CMD_VIDEOHUB_DEVICE:
301
 		if (!data->device.dev_present) {
291
 		if (!data->device.dev_present) {
302
 			die("Device reports that it's not present.");
292
 			die("Device reports that it's not present.");

+ 8
- 2
videohubctrl.c View File

114
 }
114
 }
115
 
115
 
116
 static void print_device_desc(struct device_desc *d) {
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
 	printf("\n");
117
 	printf("\n");
120
 	printf("Protocol version: %s\n", d->protocol_ver);
118
 	printf("Protocol version: %s\n", d->protocol_ver);
121
 	printf("Model name: %s\n", d->model_name);
119
 	printf("Model name: %s\n", d->model_name);
175
 		exit(EXIT_FAILURE);
173
 		exit(EXIT_FAILURE);
176
 
174
 
177
 	read_device_command_stream(data);
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
 	if (show_monitor) {
184
 	if (show_monitor) {
179
 		while (1) {
185
 		while (1) {
180
 			printf("\e[2J\e[H"); // Clear screen
186
 			printf("\e[2J\e[H"); // Clear screen

Loading…
Cancel
Save