int main(int argc, char **argv) {
    CameraList	*list;
    Camera		**cams;
    int		ret, i, count;
    const char	*name, *value;
    GPContext	*context;

    context = sample_create_context (); /* see context.c */

    /* Detect all the cameras that can be autodetected... */
    ret = gp_list_new (&list);
    if (ret < GP_OK) return 1;
    count = sample_autodetect (list, context);

    /* Now open all cameras we autodected for usage */
    printf("Number of cameras: %d\n", count);
    cams = calloc (sizeof (Camera*),count);
    for (i = 0; i < count; i++) {
        gp_list_get_name  (list, i, &name);
        gp_list_get_value (list, i, &value);
        ret = sample_open_camera (&cams[i], name, value, context);
        if (ret < GP_OK) fprintf(stderr,"Camera %s on port %s failed to open\n", name, value);
    }
    /* Now call a simple function in each of those cameras. */
    for (i = 0; i < count; i++) {
        CameraText	text;
        char 		*owner;
        ret = gp_camera_get_summary (cams[i], &text, context);
        if (ret < GP_OK) {
            fprintf (stderr, "Failed to get summary.\n");
            continue;
        }

        gp_list_get_name  (list, i, &name);
        gp_list_get_value (list, i, &value);
        printf("%-30s %-16s\n", name, value);
        printf("Summary:\n%s\n", text.text);

        /* Query a simple string configuration variable. */
        ret = get_config_value_string (cams[i], "owner", &owner, context);
        if (ret >= GP_OK) {
            printf("Owner: %s\n", owner);
            free (owner);
        } else {
            printf("Owner: No owner found.\n");
        }

    }
    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char **argv) {
	Camera		*camera;
	int		ret;
	char		*owner;
	GPContext	*context;

	context = sample_create_context (); /* see context.c */

	gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);

	gp_camera_new (&camera);

	/* This call will autodetect cameras, take the
	 * first one from the list and use it. It will ignore
	 * any others... See the *multi* examples on how to
	 * detect and use more than the first one.
	 */
	ret = gp_camera_init (camera, context);
	if (ret < GP_OK) {
		printf("No camera auto detected.\n");
		gp_camera_free (camera);
		return 0;
	}

	ret = get_config_value_string (camera, "ownername", &owner, context);
	if (ret < GP_OK) {
		printf ("Could not query owner.\n");
		goto out;
	}
	printf("Current owner: %s\n", owner);
	if (argc > 1) {
		ret = set_config_value_string (camera, "ownername", argv[1], context);
		if (ret < GP_OK) {
			fprintf (stderr, "Failed to set camera owner to %s; %d\n", argv[1], ret);
		} else 
			printf("New owner: %s\n", argv[1]);
	}
out:
	gp_camera_exit (camera, context);
	gp_camera_free (camera);
	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {
	Camera		*camera;
	int		ret;
	char		*owner;
	GPContext	*context;
	CameraText	text;

	context = sample_create_context (); /* see context.c */
	gp_camera_new (&camera);

	/* This call will autodetect cameras, take the
	 * first one from the list and use it. It will ignore
	 * any others... See the *multi* examples on how to
	 * detect and use more than the first one.
	 */
	ret = gp_camera_init (camera, context);
	if (ret < GP_OK) {
		printf("No camera auto detected.\n");
		gp_camera_free (camera);
		return 0;
	}

	/* Simple query the camera summary text */
	ret = gp_camera_get_summary (camera, &text, context);
	if (ret < GP_OK) {
		printf("Camera failed retrieving summary.\n");
		gp_camera_free (camera);
		return 0;
	}
	printf("Summary:\n%s\n", text.text);

	/* Simple query of a string configuration variable. */
	ret = get_config_value_string (camera, "owner", &owner, context);
	if (ret >= GP_OK) {
		printf("Owner: %s\n", owner);
		free (owner);
	}
	gp_camera_exit (camera, context);
	gp_camera_free (camera);
	gp_context_unref (context);
	return 0;
}