Esempio n. 1
0
int
camera_init (Camera *camera, GPContext *context) 
{
	GPPortSettings settings;
	int speeds[] = { 115200, 9600, 19200, 38400, 57600, 115200 };
	int ret, i;
	char cmd[3], buf[1];

	/* First, set up all the function pointers. */
	camera->functions->capture              = camera_capture;
	camera->functions->about		= camera_about;
	camera->functions->get_config		= camera_get_config;
	camera->functions->set_config		= camera_set_config;
	camera->functions->summary		= camera_summary;
	camera->functions->manual		= camera_manual;


	/* Now, tell the filesystem where to get lists, files and info */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	/*
	 * The port is already provided with camera->port (and
	 * already open). You just have to use functions like
	 * gp_port_timeout_set, gp_port_settings_get, gp_port_settings_set.
	 */
	gp_port_get_settings (camera->port, &settings);
	settings.serial.speed	= 115200;
	settings.serial.bits	= 8;
	settings.serial.stopbits= 1;
	settings.serial.parity	= 0;
	gp_port_set_settings (camera->port, settings);
	/*
	 * Once you have configured the port, you should check if a 
	 * connection to the camera can be established.
	 */
	for (i=0;i<sizeof(speeds)/sizeof(speeds[0]);i++) {
		gp_port_get_settings (camera->port, &settings);
		settings.serial.speed	= speeds[i];
		gp_port_set_settings (camera->port, settings);
		if (GP_OK<=k_ping (camera->port))
			break;
	}
	if (i == sizeof(speeds)/sizeof(speeds[0]))
		return GP_ERROR;
	cmd[0] = ESC;
	cmd[1] = SETSPEED;
	cmd[2] = 0x30 + 4; /* speed nr 4:(9600, 19200, 38400, 57600, 115200) */
	ret = gp_port_write (camera->port, cmd, 3); 
	if (ret<GP_OK) return ret;
	ret = gp_port_read (camera->port, buf, 1);
	if (ret<GP_OK) return ret;
	if (buf[0] != ACK) return GP_ERROR;
	gp_port_get_settings (camera->port, &settings);
	settings.serial.speed	= 115200;
	gp_port_set_settings (camera->port, settings);
	return GP_OK;
}
Esempio n. 2
0
int camera_init(Camera *camera, GPContext *context){
  GPPortSettings settings;
  int ret = 0;
  camera->functions->exit         = camera_exit;
  camera->functions->summary      = camera_summary;
  camera->functions->about        = camera_about;
  gp_log (GP_LOG_DEBUG, "pccam", "Initializing the camera\n");
  switch (camera->port->type) 
    {
    case GP_PORT_USB:
      ret = gp_port_get_settings(camera->port,&settings);
      if (ret < 0) return ret;
      settings.usb.inep = 0x82;
      settings.usb.outep = 0x03;
      settings.usb.config = 1;
      settings.usb.interface = 1;
      settings.usb.altsetting = 0;
      ret=gp_port_set_settings(camera->port,settings);
      if (ret<0) return ret;
      break;
    case GP_PORT_SERIAL:
      return GP_ERROR_IO_SUPPORTED_SERIAL;
    default: 
      return GP_ERROR_NOT_SUPPORTED;
    }    
  ret = pccam600_init(camera->port, context);
  if (ret < 0) return ret;
  return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
}
Esempio n. 3
0
int
camera_init (Camera *camera, GPContext *context)
{
        /* First, set up all the function pointers */
        /* camera->functions->exit                 = camera_exit; */
        camera->functions->get_config		= camera_config_get;
        camera->functions->set_config		= camera_config_set;
        camera->functions->capture              = camera_capture;
        camera->functions->summary              = camera_summary;
        camera->functions->manual               = camera_manual;
        camera->functions->about                = camera_about;

	/* Now, tell the filesystem where to get lists, files and info */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	/* Configure port */
	gp_port_set_timeout(camera->port,MDC800_DEFAULT_COMMAND_RETRY_DELAY);
	if (camera->port->type == GP_PORT_SERIAL) {
	    GPPortSettings settings;
	    gp_port_get_settings(camera->port, &settings);
	    settings.serial.speed   = 57600;
	    settings.serial.bits    = 8;
	    settings.serial.parity  = 0;
	    settings.serial.stopbits= 1;
	    gp_port_set_settings(camera->port, settings);
	}
	return mdc800_openCamera(camera);
}
Esempio n. 4
0
/**
 * Set the camera speed.
 *
 * @param camera a #Camera
 * @param speed the speed
 * @return a gphoto2 error code
 *
 * This function is typically used prior first initialization 
 * using #gp_camera_init for debugging purposes. Normally, a camera driver
 * will try to figure out the current speed of the camera and set the speed
 * to the optimal one automatically. Note that this function only works with 
 * serial ports. In other words, you have to set the camera's port to a 
 * serial one (using #gp_camera_set_port_path or #gp_camera_set_port_name)
 * prior calling this function.
 *
 */
int
gp_camera_set_port_speed (Camera *camera, int speed)
{
	GPPortSettings settings;

	CHECK_NULL (camera);

	if (!camera->port) {
		gp_log (GP_LOG_ERROR, "camera", "You need to set "
			"a port prior trying to set the speed");
		return (GP_ERROR_BAD_PARAMETERS);
	}

	if (camera->port->type != GP_PORT_SERIAL) {
		gp_log (GP_LOG_ERROR, "camera", "You can specify "
			"a speed only with serial ports");
		return (GP_ERROR_BAD_PARAMETERS);
	}

	/*
	 * If the camera is currently initialized, terminate that connection.
	 * We don't care if we are successful or not.
	 */
	if (camera->pc->lh)
		gp_camera_exit (camera, NULL);

	CR (camera, gp_port_get_settings (camera->port, &settings), NULL);
	settings.serial.speed = speed;
	CR (camera, gp_port_set_settings (camera->port, settings), NULL);
	camera->pc->speed = speed;

	return (GP_OK);
}
Esempio n. 5
0
int camera_init (Camera *camera, GPContext *context) 
{
	GPPortSettings settings;

        /* First, set up all the function pointers */
        camera->functions->summary              = camera_summary;
        camera->functions->about                = camera_about;
	camera->functions->capture_preview	= camera_capture_preview;
	camera->functions->capture		= camera_capture;

	gp_port_get_settings(camera->port, &settings);
	switch(camera->port->type) {
	case GP_PORT_SERIAL:		
        	gp_port_set_timeout(camera->port, 1000);
		settings.serial.speed = 115200;
        	settings.serial.bits = 8;
        	settings.serial.parity = 0;
        	settings.serial.stopbits = 1;
		break;
	case GP_PORT_USB:
		/* Use the defaults the core parsed */
		break;
	default:
		return (GP_ERROR_UNKNOWN_PORT);
		break;
	}
	gp_port_set_settings(camera->port, settings);

	/* Set up the filesystem */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

        /* test camera */
        return stv0680_ping(camera->port);
}
Esempio n. 6
0
int digita_usb_open(CameraPrivateLibrary *dev, Camera *camera)
{
	GPPortSettings settings;
	unsigned char buffer[128];
	int ret;

	ret = gp_port_get_settings(camera->port, &settings);
	if (ret < 0)
		return ret;

	/* We'll take the defaults. The core should have the done what's */
	/* necessary to find the config, interface, altsetting and endpoints */

	ret = gp_port_set_settings(dev->gpdev, settings);
	if (ret < 0)
		return ret;

	dev->send = digita_usb_send;
	dev->read = digita_usb_read;

	gp_port_set_timeout(camera->port, 100);

	/* Mop up anything still pending */
	while (gp_port_read(dev->gpdev, buffer, sizeof(buffer)) > 0)
		;

	gp_port_set_timeout(camera->port, 10000);

	return GP_OK;
}
Esempio n. 7
0
int
camera_init(Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	CameraAbilities abilities;
	int ret = 0;

	/* First, set up all the function pointers */
	camera->functions->summary      = camera_summary;
	camera->functions->about        = camera_about;
	camera->functions->exit	    = camera_exit;

	GP_DEBUG ("Initializing the camera\n");
	ret = gp_port_get_settings(camera->port,&settings);
	if (ret < 0) return ret; 

        ret = gp_camera_get_abilities(camera,&abilities);                       
        if (ret < 0) return ret;                                                
        GP_DEBUG("product number is 0x%x\n", abilities.usb_product);

	switch (camera->port->type) {
		case GP_PORT_SERIAL:
			return ( GP_ERROR );
		case GP_PORT_USB:
			settings.usb.config = 1;
			settings.usb.altsetting = 0;
			settings.usb.interface = 1;
			settings.usb.inep = 0x84;
			settings.usb.outep =0x05;
			break;
		default:
			return ( GP_ERROR );
	}

	ret = gp_port_set_settings(camera->port,settings);
	if (ret < 0) return ret; 

	GP_DEBUG("interface = %i\n", settings.usb.interface);
	GP_DEBUG("inep = %x\n", settings.usb.inep);	
	GP_DEBUG("outep = %x\n", settings.usb.outep);

        /* Tell the CameraFilesystem where to get lists from */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl) return GP_ERROR_NO_MEMORY;
	memset (camera->pl, 0, sizeof (CameraPrivateLibrary));

	switch(abilities.usb_product) {
	case 0x2130:
		camera->pl->model = AOX_MODEL_DMAX;
		break;
	default:
		camera->pl->model = AOX_MODEL_MINI;
	}
	/* Connect to the camera */
	aox_init (camera->port, &camera->pl->model, camera->pl->info);

	return GP_OK;
}
Esempio n. 8
0
/**
 * Set the camera speed.
 *
 * @param camera a #Camera
 * @param speed the speed
 * @return a gphoto2 error code
 *
 * This function is typically used prior first initialization 
 * using #gp_camera_init for debugging purposes. Normally, a camera driver
 * will try to figure out the current speed of the camera and set the speed
 * to the optimal one automatically. Note that this function only works with 
 * serial ports. In other words, you have to set the camera's port to a 
 * serial one (using #gp_camera_set_port_path or #gp_camera_set_port_name)
 * prior calling this function.
 *
 */
int
gp_camera_set_port_speed (Camera *camera, int speed)
{
	GPPortSettings settings;

	C_PARAMS (camera);

	C_PARAMS_MSG (camera->port,
		      "You need to set a port prior trying to set the speed");
	C_PARAMS_MSG (camera->port->type == GP_PORT_SERIAL,
		      "You can specify a speed only with serial ports");

	/*
	 * If the camera is currently initialized, terminate that connection.
	 * We don't care if we are successful or not.
	 */
	if (camera->pc->lh)
		gp_camera_exit (camera, NULL);

	CR (camera, gp_port_get_settings (camera->port, &settings), NULL);
	settings.serial.speed = speed;
	CR (camera, gp_port_set_settings (camera->port, settings), NULL);
	camera->pc->speed = speed;

	return (GP_OK);
}
Esempio n. 9
0
/*
 * OK, lets get serious !
 */
int 
camera_init(Camera *camera,GPContext *context)
{
 GPPortSettings settings;
 CameraAbilities abilities;
 /* try to contact the camera ...*/
 /*CR(gp_port_get_settings(camera->port,&settings));*/
 
 camera->functions->about=camera_about; 
 camera->functions->exit=camera_exit;
 gp_port_get_settings(camera->port,&settings);
 if (camera->port->type!=GP_PORT_USB)
 {
  gp_context_error(context,_("sx330z is USB only"));
  return(GP_ERROR_UNKNOWN_PORT);
 }
/* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/
 CR(gp_port_set_settings(camera->port,settings));
 CR(gp_port_set_timeout(camera->port,TIMEOUT)); 

 CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera));
 
 camera->pl=malloc(sizeof(CameraPrivateLibrary));
 if (!camera->pl) 
   return(GP_ERROR_NO_MEMORY);

 CR(gp_camera_get_abilities(camera, &abilities));
 camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */
/* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */
 return(sx330z_init(camera,context));

} /* camera init */
Esempio n. 10
0
/*
 * Send the Initial Command. If the device is rs232 this
 * function will probe for the baudrate.
 */
static int
mdc800_sendInitialCommand (Camera *camera, unsigned char* answer)
{
	int	baud_rates[3]={19200,57600,115200};
	int	rate,ret;
	unsigned char	command [8]={COMMAND_BEGIN,COMMAND_INIT_CONNECT,0,0,0,COMMAND_END,0,0};

	if (camera->port->type == GP_PORT_USB)
	    return mdc800_io_sendCommand_with_retry(camera->port,command,answer,8,1,1);
	for (rate=0;rate<3;rate++)
	{
	    GPPortSettings settings;

	    ret = gp_port_get_settings(camera->port,&settings);
	    if (ret != GP_OK) return ret;
	    settings.serial.speed = baud_rates[rate];
	    ret = gp_port_set_settings(camera->port, settings);
	    if (ret != GP_OK) return ret;
	    if (GP_OK==mdc800_io_sendCommand_with_retry(camera->port,command,answer,8,1,1)) {
		printCoreNote("RS232 Baudrate probed at %d.\n",baud_rates[rate]);
		return GP_OK;
	    }
	    printCoreError("Probing RS232 Baudrate with %d fails.\n",baud_rates[rate]);
	}
	printCoreError ("Probing failed completely.\n");
	return GP_ERROR_IO;
}
Esempio n. 11
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;
}
Esempio n. 12
0
/*
 * l859_connect - try hand shake with camera and establish connection
 */
static int l859_connect(Camera *camera) {

	GPPortSettings settings;
	uint8_t	bps;
	int ret;

	GP_DEBUG ("Connecting to a camera.");

	ret = l859_sendcmd(camera, L859_CMD_CONNECT);
	if (ret < GP_OK)
		return ret;
	if (l859_retrcmd(camera) == GP_ERROR) {
		if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK)
			return GP_ERROR;
		if (l859_sendcmd(camera, L859_CMD_CONNECT)!= GP_OK)
			return GP_ERROR;
		if (l859_retrcmd(camera) == GP_ERROR)
			return GP_ERROR;
	}

	switch (camera->pl->speed) {
		case 19200:
			bps = L859_CMD_SPEED_19200;
			break;
		case 57600:
			bps = L859_CMD_SPEED_57600;
			break;
		case 115200:
			bps = L859_CMD_SPEED_115200;
			break;
		default:
			bps = L859_CMD_SPEED_DEFAULT;
			break;
	}

	if (bps != L859_CMD_SPEED_DEFAULT) {

		if (l859_sendcmd(camera, bps) != GP_OK)
			return GP_ERROR;

		gp_port_get_settings(camera->port, &settings);
		settings.serial.speed = camera->pl->speed;
		gp_port_set_settings(camera->port, settings);

		if (l859_retrcmd(camera) == GP_ERROR)
			return GP_ERROR;
	}

	if (l859_sendcmd(camera, L859_CMD_INIT) != GP_OK)
		return GP_ERROR;
	if (l859_retrcmd(camera) == GP_ERROR)
		return GP_ERROR;

	GP_DEBUG ("Camera connected successfully.");

	return GP_OK;
}
Esempio n. 13
0
static int 
set_usb_in_endpoint	(Camera *camera, int inep) 
{
	GPPortSettings settings;
	gp_port_get_settings ( camera ->port, &settings);
	settings.usb.inep = inep;
	GP_DEBUG("inep reset to %02X\n", inep);
	return gp_port_set_settings ( camera ->port, settings);
}	
Esempio n. 14
0
static int
pre_func (Camera *camera, GPContext *context)
{
	int r;
	unsigned int i;
	GPPortSettings settings;

	GP_DEBUG ("Initializing connection...");

	CR (gp_port_get_settings (camera->port, &settings));
	CR (fuji_ping (camera, context));
	if (!camera->pl->speed) {

		/* Set to the highest possible speed. */
		for (i = 0; Speeds[i].bit_rate; i++) {
			r = fuji_set_speed (camera, Speeds[i].speed, NULL);
			if (r >= 0)
				break;
		}

		/*
		 * Change the port's speed and check if the camera is
		 * still there.
		 */
		settings.serial.speed = Speeds[i].bit_rate;
		CR (gp_port_set_settings (camera->port, settings));
		GP_DEBUG("Pinging to check new speed %i.", Speeds[i].bit_rate);
		CR (fuji_ping (camera, context));

	} else {

		/* User specified a speed. Check if the speed is possible */
		for (i = 0; Speeds[i].bit_rate; i++)
			if (Speeds[i].bit_rate == camera->pl->speed)
				break;
		if (!Speeds[i].bit_rate) {
			gp_context_error (context, _("Bit rate %ld is not "
					"supported."), camera->pl->speed);
			return (GP_ERROR_NOT_SUPPORTED);
		}

		/* Change the speed if necessary. */
		if (camera->pl->speed != Speeds[i].bit_rate) {
			CR (fuji_set_speed (camera, Speeds[i].speed, context));

			/*
			 * Change the port's speed and check if the camera is 
			 * still there.
			 */
			settings.serial.speed = Speeds[i].bit_rate;
			CR (gp_port_set_settings (camera->port, settings));
			CR (fuji_ping (camera, context));
		}
	}

	return (GP_OK);
}
Esempio n. 15
0
int
camera_init(Camera *camera, GPContext *context)
{
    GPPortSettings settings;
    int ret = 0;

    /* First, set up all the function pointers */
    camera->functions->manual	= camera_manual;
    camera->functions->summary      = camera_summary;
    camera->functions->about        = camera_about;
    camera->functions->exit	    = camera_exit;

    GP_DEBUG ("Initializing the camera\n");
    ret = gp_port_get_settings(camera->port,&settings);
    if (ret < 0) return ret;

    switch (camera->port->type) {
    case GP_PORT_SERIAL:
        return ( GP_ERROR );
    case GP_PORT_USB:
        settings.usb.config = 1;
        settings.usb.altsetting = 0;
        settings.usb.interface = 0;
        /* inep 0x84 used to initialize. Then switch to 0x82! */
        settings.usb.inep = 0x84;
        settings.usb.outep = 0x03;
        break;
    default:
        return ( GP_ERROR );
    }

    ret = gp_port_set_settings(camera->port,settings);
    if (ret < 0) return ret;

    GP_DEBUG("interface = %i\n", settings.usb.interface);
    GP_DEBUG("inep = %x\n", settings.usb.inep);
    GP_DEBUG("outep = %x\n", settings.usb.outep);

    /* Tell the CameraFilesystem where to get lists from */
    gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

    camera->pl = malloc (sizeof (CameraPrivateLibrary));
    if (!camera->pl) return GP_ERROR_NO_MEMORY;
    memset (camera->pl, 0, sizeof (CameraPrivateLibrary));
    /* Connect to the camera */
    camera->pl->total_data_in_camera=0;
    camera->pl->data_to_read = 0;
    camera->pl->bytes_put_away = 0;
    camera->pl->data_reg_opened = 0;
    camera->pl->data_cache = NULL;
    camera->pl->init_done = 0;
    jl2005c_init (camera,camera->port, camera->pl);

    return GP_OK;
}
Esempio n. 16
0
/* set camera serial port speed, then our local port speed */
int
mesa_set_speed( GPPort *port, int speed )
{
	uint8_t	b[2];
	gp_port_settings settings;

	if (speed == 0)
		speed = 115200;		/* use default speed */

	GP_DEBUG( 
	 "mesa_set_speed: speed %d", speed);

	b[0] = SET_SPEED;

	switch( speed )
	{
	case 9600:
		b[1] = 1;
		break;
	case 14400:
		b[1] = 2;
		break;
	case 19200:
		b[1] = 3;
		break;
	case 38400:
		b[1] = 4;
		break;
	case 57600:
		b[1] = 5;
		break;
	case 76800:
		b[1] = 6;
		break;
	case 115200:
		b[1] = 7;
		break;
	case 230400:
		b[1] = 8;
		break;
	case 460800:
		b[1] = 9;
		break;
	default:
		return GP_ERROR_BAD_PARAMETERS;
	}
	CHECK (mesa_send_command( port, b, sizeof( b ), 10 ));

	gp_port_get_settings(port, &settings);
	settings.serial.speed = speed;
	return gp_port_set_settings(port, settings);
}
Esempio n. 17
0
int
camera_init (Camera *camera, GPContext *context)
{
	int ret;
	GPPortSettings settings;

	/* First, set up all the function pointers */
	camera->functions->exit = camera_exit;
	camera->functions->summary = camera_summary;
	camera->functions->about = camera_about;

	CHECK (gp_port_get_settings (camera->port, &settings));
	switch (camera->port->type) {
		case GP_PORT_USB:
			settings.usb.inep = 0x82;
			settings.usb.outep = 0x03;
			settings.usb.config = 1;
			settings.usb.interface = 0;
			settings.usb.altsetting = 0;

			CHECK (gp_port_set_settings (camera->port, settings));
			CHECK (gp_port_set_timeout (camera->port, TIMEOUT));

			break;
		default:
			gp_context_error (context,
					  _("Unsupported port type: %d. "
					    "This driver only works with USB "
					    "cameras.\n"), camera->port->type);
			return (GP_ERROR);
			break;
	}

	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl)
		return (GP_ERROR_NO_MEMORY);
	memset (camera->pl, 0, sizeof (CameraPrivateLibrary));
	camera->pl->gpdev = camera->port;
	camera->pl->dirty = 1;

	ret = gsmart300_reset (camera->pl);

	if (ret < 0) {
		gp_context_error (context, _("Could not reset camera.\n"));
		free (camera->pl);
		camera->pl = NULL;

		return (ret);
	}
	/* Set up the CameraFilesystem */
	return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
}
Esempio n. 18
0
int
camera_init (Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	unsigned int i;

	/* Setup all function pointers */
	camera->functions->pre_func   = pre_func;
	camera->functions->post_func  = post_func;
	camera->functions->about      = camera_about;
	camera->functions->exit       = camera_exit;
	camera->functions->get_config = camera_get_config;
	camera->functions->set_config = camera_set_config;
	camera->functions->summary    = camera_summary;

	/* We need to store some data */
	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl)
		return (GP_ERROR_NO_MEMORY);
	memset (camera->pl, 0, sizeof (CameraPrivateLibrary));

	/* Set up the port, but remember the current speed. */
	CR (gp_port_set_timeout (camera->port, 1000));
	CR (gp_port_get_settings (camera->port, &settings));
	camera->pl->speed = settings.serial.speed;
	settings.serial.speed    = 9600;
	settings.serial.bits     = 8;
	settings.serial.parity   = GP_PORT_SERIAL_PARITY_EVEN;
	settings.serial.stopbits = 1;
	CR (gp_port_set_settings (camera->port, settings));

	/* Set up the filesystem. */
	CR (gp_filesystem_set_funcs   (camera->fs, &fsfuncs, camera));

	/* Initialize the connection */
	CR (pre_func (camera, context));
	/*
	 * What commands does this camera support? The question is not
	 * easy to answer, as "One issue the DS7 has is that the 
	 * supported command list command is not supported" 
	 * (Matt Martin <*****@*****.**>).
	 */
	if (fuji_get_cmds (camera, camera->pl->cmds, context) >= 0) {
		GP_DEBUG ("Your camera supports the following command(s):");
		for (i = 0; i < 0xff; i++)
			if (camera->pl->cmds[i])
				GP_DEBUG (" - 0x%02x: '%s'", i,
					  cmd_get_name (i));
	}

	return (GP_OK);
}
Esempio n. 19
0
int
camera_init(Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	int ret = 0;

	/* First, set up all the function pointers */
	camera->functions->summary      = camera_summary;
	camera->functions->about        = camera_about;
	camera->functions->exit	    = camera_exit;
   
	GP_DEBUG ("Initializing the camera\n");
	ret = gp_port_get_settings(camera->port,&settings);
	if (ret < 0) 
		return ret; 

	switch (camera->port->type) {
		case GP_PORT_SERIAL:
			return GP_ERROR;
		case GP_PORT_USB:
			settings.usb.config = 1;
			settings.usb.altsetting = 0;
			settings.usb.interface = 1;
			settings.usb.inep = 0x81;
			settings.usb.outep =0x02;
			break;
		default:
			return GP_ERROR;
	}

	ret = gp_port_set_settings(camera->port,settings);
	if (ret < 0) 
		return ret; 

	GP_DEBUG("interface = %i\n", settings.usb.interface);
	GP_DEBUG("inep = %x\n", settings.usb.inep);	
	GP_DEBUG("outep = %x\n", settings.usb.outep);

        /* Tell the CameraFilesystem where to get lists from */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl) 
		return GP_ERROR_NO_MEMORY;
	memset (camera->pl, 0, sizeof (CameraPrivateLibrary));

	/* Connect to the camera */
	lg_gsm_init (camera->port, &camera->pl->model, camera->pl->info);
	return GP_OK;
}
Esempio n. 20
0
int
camera_init(Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	int ret = 0;

	/* First, set up all the function pointers */
	camera->functions->summary      = camera_summary;
        camera->functions->manual	= camera_manual;
	camera->functions->about        = camera_about;
	camera->functions->exit	    	= camera_exit;

	GP_DEBUG ("Initializing the camera\n");

	ret = gp_port_get_settings(camera->port,&settings);
	if (ret < 0) return ret;
	switch (camera->port->type) {
		case GP_PORT_SERIAL:
			return ( GP_ERROR );
		case GP_PORT_USB:
			settings.usb.config = 1;
			settings.usb.altsetting = 0;
			settings.usb.inep = 0x82;
			settings.usb.outep =0x03;
			break;
		default:
			return ( GP_ERROR );
	}



	ret = gp_port_set_settings(camera->port,settings);
	if (ret < 0) return ret;

        /* Tell the CameraFilesystem where to get lists from */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl) return GP_ERROR_NO_MEMORY;
	camera->pl->catalog = NULL;
	camera->pl->num_pics = 0;

	/* Connect to the camera */
	ret = clicksmart_init (camera->port, camera->pl);
	if (ret != GP_OK) {
		free(camera->pl);
		return ret;
	};
	return GP_OK;
}
Esempio n. 21
0
static int
post_func (Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	GP_DEBUG ("Terminating connection...");

	/* Put the camera back to 9600 bps if necessary. */
	CR (gp_port_get_settings (camera->port, &settings));
	if (settings.serial.speed != 9600) {
		CR (fuji_set_speed (camera, FUJI_SPEED_9600, context));
		settings.serial.speed = 9600;
		CR (gp_port_set_settings (camera->port, settings));
	}

	return (GP_OK);
}
Esempio n. 22
0
static int
set_speed (Camera *camera, int speed, GPContext *context)
{
        GPPortSettings s;
	KncCamRes cr;
        KncBitRate br;
        KncBitFlag bf;
        int i;
        int speeds[] = {300, 600, 1200, 2400, 4800, 9600, 19200,
                                 38400, 57600, 115200};

        C (gp_port_get_settings (camera->port, &s));
        if ((s.serial.speed == speed) || (s.serial.speed == 115200))
                return (GP_OK);

        switch (speed) {
        case 0:

                /* Set the highest possible speed */
                CR (knc_get_io_pref (camera->pl->c, &cr, &br, &bf), context);
		CCR (cr, context);
                for (i = 9; i >= 0; i--) if ((1 << i) & br) break;
                if (i < 0) return (GP_ERROR_IO_SERIAL_SPEED);
		speed = speeds[i];
                     br = 1 << i;  break;
        case 300   : br = 1 << 0; break;
        case 600   : br = 1 << 1; break;
        case 1200  : br = 1 << 2; break;
        case 2400  : br = 1 << 3; break;
        case 4800  : br = 1 << 4; break;
        case 9600  : br = 1 << 5; break;
        case 19200 : br = 1 << 6; break;
        case 38400 : br = 1 << 7; break;
        case 57600 : br = 1 << 8; break;
        case 115200: br = 1 << 9; break;
        default: return (GP_ERROR_IO_SERIAL_SPEED);
        }

        /* Request the new speed */
        bf = KNC_BIT_FLAG_8_BITS;
        CR (knc_set_io_pref (camera->pl->c, &cr, &br, &bf), context);
	CCR (cr, context);
        s.serial.speed = speed;
        C (gp_port_set_settings (camera->port, s));

        return (GP_OK);
}
Esempio n. 23
0
/* Open the serial port and configure it */
int
mesa_port_open( GPPort *port )
{
	GPPortSettings settings;

	debuglog("mesa_port_open()");
	gp_port_set_timeout(port, 5000);

	gp_port_get_settings(port, &settings);

	settings.serial.speed   = 115200;
	settings.serial.bits    = 8;
	settings.serial.parity  = 0;
	settings.serial.stopbits= 1;

	return gp_port_set_settings(port, settings);
}
Esempio n. 24
0
static
int init(Camera *camera)
{
	GPPortSettings settings;
	int ret, selected_speed;

	ret = gp_port_get_settings (camera->port, &settings);
	if (ret < 0)
		return (ret);

	/* Remember the selected speed 0 == fastest */
	selected_speed = settings.serial.speed == 0 ? 115200 : settings.serial.speed;

	settings.serial.speed    = 9600;
	settings.serial.bits     = 8;
	settings.serial.parity   = 0;
	settings.serial.stopbits = 1;

	ret = gp_port_set_settings (camera->port, settings);
	if (ret < 0)
		return (ret);

	gp_port_set_timeout (camera->port, TIMEOUT);

	if (dc3200_set_speed (camera, selected_speed) == GP_ERROR)
		return GP_ERROR;

	/* Set the new speed */
	settings.serial.speed = selected_speed;
	ret = gp_port_set_settings (camera->port, settings);
	if (ret < 0)
		return (ret);

	/* Wait for it to update */
	sleep(1);

	/* Try to talk after speed change */
	if (dc3200_keep_alive(camera) == GP_ERROR)
		return GP_ERROR;

	/* setup the camera */
	if (dc3200_setup(camera) == GP_ERROR)
		return GP_ERROR;		

	return GP_OK;
}
Esempio n. 25
0
int camera_init (Camera *camera, GPContext *context)
{
	int count;
	GPPortSettings settings;

	GP_DEBUG ("* camera_init");
	GP_DEBUG ("   * jamcam library for Gphoto2 by Chris Pinkham <*****@*****.**>");
	GP_DEBUG ("   * jamcam library v%s, %s", JAMCAM_VERSION, JAMCAM_LAST_MOD );

	/* First, set up all the function pointers */
	camera->functions->exit 	= camera_exit;
	camera->functions->summary	= camera_summary;
	camera->functions->about 	= camera_about;

	CHECK (gp_port_get_settings (camera->port, &settings));
	switch( camera->port->type ) {
	case GP_PORT_SERIAL:
		settings.serial.speed 	 = 57600;
		settings.serial.bits 	 = 8;
		settings.serial.parity 	 = 0;
		settings.serial.stopbits = 1;
		break;
	case GP_PORT_USB:
		/* Use the defaults the core parsed */
		break;
	default:
		fprintf( stderr, "Unknown port type: %d\n", camera->port->type );
		return ( GP_ERROR );
		break;
	}
	CHECK (gp_port_set_settings (camera->port, settings));
	CHECK (gp_port_set_timeout (camera->port, TIMEOUT));

	/* check to see if camera is really there */
	CHECK (jamcam_enq (camera));

	/* get number of images */
	CHECK (count = jamcam_file_count (camera));

	/* Set up the CameraFilesystem */
	return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
}
Esempio n. 26
0
int
camera_init (Camera *camera, GPContext *context) 
{
	GPPortSettings settings;

        camera->functions->about        = enigma13_about;

	CHECK(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera));
	CHECK(gp_port_get_settings( camera->port, &settings));
        settings.usb.inep = 0x82;
        settings.usb.outep = 0x03;
        settings.usb.config = 1;
        settings.usb.interface = 0;
        settings.usb.altsetting = 0;
        CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS));
	CHECK(gp_port_set_settings( camera->port, settings));
	return GP_OK;


}
Esempio n. 27
0
int
camera_init(Camera *camera, GPContext *context)
{
	GPPortSettings settings;
	int ret = 0;

	/* First, set up all the function pointers */
	camera->functions->summary	= camera_summary;
	camera->functions->manual	= camera_manual;
	camera->functions->about	= camera_about;
	camera->functions->capture_preview
					= camera_capture_preview;
	camera->functions->exit		= camera_exit;

	GP_DEBUG ("Initializing the camera\n");

	ret = gp_port_get_settings(camera->port,&settings);
	if (ret < 0) return ret;
 
	ret = gp_port_set_settings(camera->port,settings);
	if (ret < 0) return ret;

	/* Tell the CameraFilesystem where to get lists from */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
	camera->pl = malloc (sizeof (CameraPrivateLibrary));
	if (!camera->pl) return GP_ERROR_NO_MEMORY;
	camera->pl->model = 0;
	camera->pl->catalog = NULL;
	camera->pl->nb_entries = 0;
	camera->pl->last_fetched_entry = -1;
	camera->pl->last_fetched_data = NULL;

	/* Connect to the camera */
	ret = sq_init (camera->port, camera->pl);
	if (ret != GP_OK) {
		free(camera->pl);
		return ret;
	};

	return GP_OK;
}
Esempio n. 28
0
int camera_init (Camera *camera, GPContext *context) {

        GPPortSettings settings;
	int speed;

        /* First, set up all the function pointers */
	camera->functions->capture 	= camera_capture;
	camera->functions->summary 	= camera_summary;
        camera->functions->manual       = camera_manual;
        camera->functions->about        = camera_about;

	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	/* Configure the port (remember the speed) */
	gp_port_get_settings (camera->port, &settings);
	speed = settings.serial.speed;
        settings.serial.speed    = 9600;
        settings.serial.bits     = 8;
        settings.serial.parity   = 0;
        settings.serial.stopbits = 1;
        gp_port_set_settings (camera->port, settings);
        gp_port_set_timeout (camera->port, TIMEOUT);

        /* Reset the camera to 9600 */
        gp_port_send_break (camera->port, 2);

        /* Wait for it to update */
        GP_SYSTEM_SLEEP(1500);

	if (dc120_set_speed (camera, speed) == GP_ERROR) {
                return (GP_ERROR);
        }

        /* Try to talk after speed change */
        if (dc120_get_status(camera, NULL, context) == GP_ERROR) {
                return (GP_ERROR);
        }

        return (GP_OK);
}
Esempio n. 29
0
int
camera_init (Camera *camera, GPContext *context) 
{
	GPPortSettings settings;

        /* First, set up all the function pointers */
        camera->functions->about                = camera_about;

	/* Now, tell the filesystem where to get lists and info */
	gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);

	/* Some settings */
	CHECK_RESULT (gp_port_get_settings (camera->port, &settings));
	settings.serial.speed   = 115200;
	settings.serial.bits    = 8;
	settings.serial.parity  = 0;
	settings.serial.stopbits= 1;
	CHECK_RESULT (gp_port_set_settings (camera->port, settings));
	CHECK_RESULT (gp_port_set_timeout (camera->port, SDSC_TIMEOUT));
	/* Open the port and check if the camera is there */
	CHECK_RESULT (SDSC_initialize (camera->port));
	return (GP_OK);
}
Esempio n. 30
0
int camera_init (Camera *camera, GPContext *context)
{
    GPPortSettings settings;
    int ret;

    /* First, set up all the function pointers */
    camera->functions->summary              = camera_summary;
    camera->functions->about                = camera_about;
    camera->functions->capture_preview	= camera_capture_preview;
    camera->functions->capture		= camera_capture;

    gp_port_get_settings(camera->port, &settings);
    switch(camera->port->type) {
    case GP_PORT_USB:
	/* Modify the default settings the core parsed */
	settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */
	settings.usb.inep=2;
	settings.usb.intep=3;
	settings.usb.outep=5;

	/* Use the defaults the core parsed */
	break;
    default:
	return (GP_ERROR_UNKNOWN_PORT);
	break;
    }

    ret = gp_port_set_settings (camera->port, settings);
    if (ret != GP_OK) {
	gp_context_error (context, _("Could not apply USB settings"));
	return ret;
    }
    /* Set up the filesystem */
    gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera);
    /* test camera */
    return stv0674_ping(camera->port);
}