Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_camera_set_port_speed ( Camera camera,
int  speed 

Set the camera speed.

camera a Camera
speed the speed
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.

Definition at line 470 of file gphoto2-camera.c.

References CHECK_NULL, gp_camera_exit(), GP_ERROR_BAD_PARAMETERS, gp_log(), GP_LOG_ERROR, GP_OK, gp_port_get_settings(), GP_PORT_SERIAL, gp_port_set_settings(), _GPPortSettings::serial, and _GPPortSettingsSerial::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);

Generated by  Doxygen 1.6.0   Back to index