Exemplo n.º 1
0
static GNOME_C_IDList *
impl_get_files (PortableServer_Servant servant, CORBA_Environment *ev)
{
	KncCDir *d = KNC_C_DIR (bonobo_object (servant));
	KncStatus s;
	KncCamRes cam_res;
	KncCntrlRes cntrl_res;
	unsigned int i;
	KncImageInfo info;
	GNOME_C_IDList *l;

	cntrl_res = knc_get_status (d->priv->c, &cam_res, &s);
	CNIL (cntrl_res, cam_res, ev);
	l = GNOME_C_IDList__alloc ();
	l->_length = 0;
	l->_buffer = CORBA_sequence_CORBA_unsigned_long_allocbuf (s.pictures);
	for (i = 0; i < s.pictures; i++) {
		cntrl_res = knc_get_image_info (d->priv->c, &cam_res, i, &info);
		if (cntrl_res || cam_res)
			continue;
		l->_buffer[l->_length] = info.id;
		l->_length++;
	}
	CORBA_sequence_set_release (l, CORBA_TRUE);
	return l;
}
Exemplo n.º 2
0
int
main (int argc, char **argv)
{
    GPPort *p;
    KncCntrl *c;
    KncCamRes r;
    KncInfo ki;
    KncImageInfo kii;
    KncBitRate br;
    KncBitFlag bf;
    GPPortSettings s;

    printf ("Connecting to camera...\n");
    c = gpknc_cntrl_new_from_path ("serial:/dev/ttyS0");
    if (!c) {
        printf ("... failed.\n");
        return 1;
    }
    knc_cntrl_set_func_data (c, test_data, NULL);
    knc_cntrl_set_func_log  (c, test_log , NULL);
    printf ("... done.\n");

    printf ("Setting speed to 115200...\n");
    p = gpknc_cntrl_get_port (c);
    br = KNC_BIT_RATE_115200;
    bf = KNC_BIT_FLAG_8_BITS;
    CR (knc_set_io_pref (c, NULL, &br, &bf));
    gp_port_get_settings (p, &s);
    s.serial.speed = 115200;
    gp_port_set_settings (p, s);

    printf ("Requesting information about the camera...\n");
    CR (knc_get_info (c, &r, &ki));
    if (r) printf ("### Error %i: '%s'!\n", r, knc_cam_res_name (r));
    else {
        printf (" - Model '%s'\n", ki.model);
        printf (" - Serial number '%s'\n", ki.serial_number);
        printf (" - Name '%s'\n", ki.name);
        printf (" - Manufacturer '%s'\n", ki.manufacturer);
    }

    printf ("Capturing preview...\n");
    CR (knc_get_preview (c, &r, KNC_PREVIEW_NO));

    printf ("Requesting information about the first image...\n");
    CR (knc_get_image_info (c, &r, 1, &kii));
    if (r) printf ("### Error 0x%04x: '%s!\n", r, knc_cam_res_name (r));
    else {
        printf (" - ID %li\n", kii.id);
        printf (" - Size %i\n", kii.size);
        printf (" - Protected: %s\n", kii.prot ? "yes" : "no");
    }

    printf ("Downloading preview of first image...\n");
    CR (knc_get_image (c, NULL, kii.id, KNC_SOURCE_CARD, KNC_IMAGE_THUMB));
    knc_cntrl_unref (c);

    return 0;
}
Exemplo n.º 3
0
static int
get_info (Camera *camera, unsigned int n, CameraFileInfo *info,
          CameraFile *file, GPContext *context)
{
        unsigned char *buffer = NULL;
	KncCamRes cr;
	KncCntrlRes cntrl_res;
	KncImageInfo i;

        /*
         * Remove the timeout, get the information and restart the
         * timeout afterwards.
         */
        gp_camera_stop_timeout (camera, camera->pl->timeout);
	knc_cntrl_set_func_data (camera->pl->c, data_func, file);
        cntrl_res = knc_get_image_info (camera->pl->c, &cr, n, &i);
        camera->pl->timeout = gp_camera_start_timeout (camera, PING_TIMEOUT,
                                                       timeout_func);
        CR (cntrl_res, context);

        info->audio.fields = GP_FILE_INFO_NONE;

        info->preview.fields = GP_FILE_INFO_TYPE;
        strcpy (info->preview.type, GP_MIME_JPEG);

        info->file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_PERMISSIONS |
                            GP_FILE_INFO_TYPE | GP_FILE_INFO_NAME;
        info->file.size = i.size * 1000;
        info->file.permissions = GP_FILE_PERM_READ;
        if (!i.prot) info->file.permissions |= GP_FILE_PERM_DELETE;
        strcpy (info->file.type, GP_MIME_JPEG);
        snprintf (info->file.name, sizeof (info->file.name),
                  "%06i.jpeg", (int) i.id);

        if (file) {
                gp_file_set_type (file, GP_FILE_TYPE_EXIF);
                gp_file_set_name (file, info->file.name);
        } else
                free (buffer);

        return (GP_OK);
}