libgphoto2 photo camera library (libgphoto2) API
2.5.24
|
Documented source code template for a camera driver (camlib).
More...
#include "config.h"
#include <string.h>
#include <gphoto2/gphoto2-library.h>
#include <gphoto2/gphoto2-result.h>
|
#define | _(String) (String) |
|
#define | N_(String) (String) |
|
|
|
The prototypes for these functions are defined in gphoto2-camera.h
|
int | camera_exit (Camera *camera, GPContext *context) |
|
int | camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) |
|
int | camera_config_set (Camera *camera, CameraWidget *window, GPContext *context) |
|
int | camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context) |
|
int | camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) |
|
int | camera_summary (Camera *camera, CameraText *summary, GPContext *context) |
|
int | camera_manual (Camera *camera, CameraText *manual, GPContext *context) |
|
int | camera_about (Camera *camera, CameraText *about, GPContext *context) |
|
|
int | get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context) |
|
int | put_file_func (CameraFilesystem *fs, const char *folder, const char *name, CameraFileType type, CameraFile *file, void *data, GPContext *context) |
|
int | delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) |
|
int | delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context) |
|
int | get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context) |
|
int | set_info_func (CameraFilesystem *fs, const char *folder, const char *file, CameraFileInfo info, void *data, GPContext *context) |
|
int | folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) |
|
int | file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) |
|
int | storage_info_func (CameraFilesystem *fs, CameraStorageInformation **storageinformations, int *nrofstorageinformations, void *data, GPContext *context) |
|
Documented source code template for a camera driver (camlib).
- Author
- Copyright 2001 Lutz Mueller lutz@.nosp@m.user.nosp@m.s.sou.nosp@m.rcef.nosp@m.orge..nosp@m.net
-
Copyright 2005 Hans Ulrich Niedermann gp@n-.nosp@m.dime.nosp@m.nsion.nosp@m.al.d.nosp@m.e
- This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Introduction to camera drivers (camlibs)
Every camlib must implement the following three function groups:
- Camera object member functions
- CameraFilesystem object member functions
- camlib API functions
We implement the camlib API functions last in this file because camera_init() must reference all the object member functions and by making camera_init() the last function in this file, we can avoid the need for forward declarations of the object member functions.
Note about "static" functions and exporting symbols
The build system uses libtool to explicitly specify the list of exported symbols. Only the three functions of the camlib API (camera_init(), camera_id(), and camera_abilities()) are exported.
Therefore it doesn't matter whether you declare your other functions static or not - regardless of whether they are object member functions or internal camlib functions.
We do not define the object member functions as static in this template in order to have autogenerated documentation about them.
◆ camera_abilities()
Get a list of abilities of all supported cameras.
Fill list with abilities of the cameras supported by this camlib.
For each camera, fill a CameraAbilities structure with data about that camera and append it to the list.
The job of this function is basically to extract data from a camlib specific database and insert it into the libgphoto2 camera database. Due to redundant data and other issues, we may decide to revise that database mechanism and replace it by something more flexible and efficient.
This is a camlib API function.
References CameraAbilities::file_operations, CameraAbilities::folder_operations, gp_abilities_list_append(), GP_CAPTURE_IMAGE, GP_DRIVER_STATUS_PRODUCTION, GP_FILE_OPERATION_DELETE, GP_FILE_OPERATION_PREVIEW, GP_FOLDER_OPERATION_NONE, GP_OK, GP_OPERATION_CAPTURE_PREVIEW, GP_PORT_SERIAL, GP_PORT_USB, CameraAbilities::model, CameraAbilities::operations, CameraAbilities::port, CameraAbilities::speed, and CameraAbilities::status.
◆ camera_about()
Return "About" content as textual description. Will be translated.
This function is a method of the Camera object.
References CameraText::text.
Referenced by camera_init().
◆ camera_capture()
Capture an image and tell libgphoto2 where to find it by filling out the path.
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ camera_capture_preview()
Capture a preview and return the data in the given file (again, use gp_file_set_data_and_size, gp_file_set_mime_type, etc.). libgphoto2 assumes that previews are NOT stored on the camera's disk. If your camera does, please delete it from the camera.
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ camera_config_get()
◆ camera_config_set()
Set parts of the configuration tree. Note that you get back the whole tree, but should only set the modified values.
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ camera_exit()
Finish up the camera communication and free private data. You do not need to close the port.
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ camera_id()
Get a unique camera id.
Set library ID string.
Probably redundant and to be removed shortly, being replaced by the libtool module name defined in the build system.
This is a camlib API function.
References GP_OK, and CameraText::text.
◆ camera_init()
Initialize a Camera object.
Sets up all the proper object function pointers, initialize camlib internal data structures, and probably establish a connection to the camera.
This is a camlib API function.
References _CameraFunctions::about, camera_about(), camera_capture(), camera_capture_preview(), camera_config_get(), camera_config_set(), camera_exit(), camera_manual(), camera_summary(), _CameraFunctions::capture, _CameraFunctions::capture_preview, _CameraFunctions::exit, fsfuncs, _CameraFunctions::get_config, gp_filesystem_set_funcs(), GP_OK, _CameraFunctions::manual, _CameraFunctions::set_config, and _CameraFunctions::summary.
◆ camera_manual()
Return the camera drivers manual. If you would like to tell the user some information about how to use the camera or the driver, this is the place to do.
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ camera_summary()
Fill out the summary with textual information about the current state of the camera (like pictures taken, etc.).
This function is a method of the Camera object.
References GP_OK.
Referenced by camera_init().
◆ delete_all_func()
Delete all files from the camera.
This function is a CameraFilesystem method.
References GP_OK.
◆ delete_file_func()
Delete a file from the camera.
This function is a CameraFilesystem method.
References GP_OK.
◆ file_list_func()
List available files in the specified folder.
This function is a CameraFilesystem method.
References GP_OK.
◆ folder_list_func()
List available folders in the specified folder.
This function is a CameraFilesystem method.
References GP_OK.
◆ get_file_func()
Get the file from the camera.
This function is a CameraFilesystem method.
References GP_OK.
◆ get_info_func()
Get the file info here and write it to space provided by caller.
- Parameters
-
info | Space provided by caller in which file info is written. |
This function is a CameraFilesystem method.
References GP_OK.
◆ put_file_func()
Put a file onto the camera.
This function is a CameraFilesystem method.
References GP_OK.
◆ set_info_func()
FIXME.
This function is a CameraFilesystem method.
References GP_OK.
◆ storage_info_func()
Get information on all available storages in the camera.
This function is a CameraFilesystem method.
References GP_ERROR_NOT_SUPPORTED.
◆ fsfuncs
Initial value:All filesystem accessor functions.
This should contain all filesystem accessor functions available in the camera library. Non-present fields are NULL.
Referenced by camera_init().
int gp_system_closedir(gp_system_dir dir)
closedir UNIX functionality
Definition: gphoto2-port-portability.c:249
enum _GPLevel GPLevel
Level to pull specific lines.
char * name
The name of this port (usb:)
Definition: gphoto2-port-info.h:34
Internal logging function entry.
Definition: gphoto2-port-log.c:57
Definition: gphoto2-port-info.h:32
int gp_port_usb_msg_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB control message with output data.
Definition: gphoto2-port.c:864
void gp_log(GPLogLevel level, const char *domain, const char *format,...)
Log a debug or error message.
Definition: gphoto2-port-log.c:331
int gp_port_get_timeout(GPPort *port, int *timeout)
Get the current port timeout.
Definition: gphoto2-port.c:568
int gp_port_usb_msg_class_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB class control message with output data.
Definition: gphoto2-port.c:1015
GPPortSerialParity parity
Definition: gphoto2-port.h:70
void gp_logv(GPLogLevel level, const char *domain, const char *format, va_list args)
Log a debug or error message with va_list.
Definition: gphoto2-port-log.c:299
int put_file_func(CameraFilesystem *fs, const char *folder, const char *name, CameraFileType type, CameraFile *file, void *data, GPContext *context)
Definition: template.c:274
char path[128]
Definition: gphoto2-port.h:105
void gp_log_data(const char *domain, const char *data, unsigned int size, const char *format,...)
Log data.
Definition: gphoto2-port-log.c:205
const char * gp_system_filename(gp_system_dirent de)
retrieve UNIX filename out of a directory entry
Definition: gphoto2-port-portability.c:237
#define GP_ERROR_IO
Generic I/O error.
Definition: gphoto2-port-result.h:58
DTR line.
Definition: gphoto2-port.h:186
int file_list_func(CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context)
Definition: template.c:399
int gp_port_check_int(GPPort *port, char *data, int size)
Check for intterupt.
Definition: gphoto2-port.c:463
GPPortType type
The type of this port.
Definition: gphoto2-port-info.h:33
#define GP_ERROR_FIXED_LIMIT_EXCEEDED
Buffer overflow of internal structure.
Definition: gphoto2-port-result.h:62
void(* GPLogFunc)(GPLogLevel level, const char *domain, const char *str, void *data)
Logging function hook.
Definition: gphoto2-port-log.h:61
#define HEXDUMP_INIT_Y
Definition: gphoto2-port-log.c:168
Log message is a data hex dump.
Definition: gphoto2-port-log.h:34
gp_system_dirent gp_system_readdir(gp_system_dir d)
readdir UNIX functionality
Definition: gphoto2-port-portability.c:225
#define GP_ERROR_UNKNOWN_PORT
Unknown libgphoto2 port passed.
Definition: gphoto2-port-result.h:50
int gp_port_set_error(GPPort *port, const char *format,...)
Set verbose port error message.
Definition: gphoto2-port.c:1180
int delete_file_func(CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context)
Definition: template.c:296
int gp_port_usb_msg_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB control message with input data.
Definition: gphoto2-port.c:897
int gp_port_get_info(GPPort *port, GPPortInfo *info)
Retreives information about the port.
Definition: gphoto2-port.c:255
int gp_port_seek(GPPort *port, int offset, int whence)
Seek on a port (for usb disk direct ports)
Definition: gphoto2-port.c:1084
int gp_port_close(GPPort *port)
Close a port.
Definition: gphoto2-port.c:297
#define GP_ERROR_IO_READ
I/O during read.
Definition: gphoto2-port-result.h:84
int storage_info_func(CameraFilesystem *fs, CameraStorageInformation **storageinformations, int *nrofstorageinformations, void *data, GPContext *context)
Definition: template.c:420
GPLogLevel level
Definition: gphoto2-port-log.c:59
GPPortSettingsUsbDiskDirect usbdiskdirect
usb disk direct port specific settings
Definition: gphoto2-port.h:117
int gp_port_send_scsi_cmd(GPPort *port, int to_dev, char *cmd, int cmd_size, char *sense, int sense_size, char *data, int data_size)
Send a SCSI command to a port (for usb scsi ports)
Definition: gphoto2-port.c:1118
int gp_port_write(GPPort *port, const char *data, int size)
Writes a specified amount of data to a port.
Definition: gphoto2-port.c:392
lt_dlhandle lh
Definition: gphoto2-port.c:78
#define GP_ERROR_IO_INIT
Error initialising I/O.
Definition: gphoto2-port-result.h:80
int folder_list_func(CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context)
Definition: template.c:379
GPPortPrivateCore * pc
Port library private data pointer.
Definition: gphoto2-port.h:153
int gp_port_usb_msg_interface_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB interface control message with input data.
Definition: gphoto2-port.c:972
#define GP_ERROR_NO_MEMORY
Out of memory.
Definition: gphoto2-port-result.h:42
#define HEXDUMP_COMPLETE_LINE
Definition: gphoto2-port-log.c:181
int gp_system_is_file(const char *filename)
check if passed filename is a file
Definition: gphoto2-port-portability.c:263
#define GP_ERROR_HAL
Unspecified error when talking to HAL.
Definition: gphoto2-port-result.h:120
int gp_port_usb_clear_halt(GPPort *port, int ep)
Clear USB endpoint HALT condition.
Definition: gphoto2-port.c:836
#define HEXDUMP_LINE_WIDTH
Definition: gphoto2-port-log.c:171
int gp_port_new(GPPort **port)
Create new GPPort.
Definition: gphoto2-port.c:94
int gp_port_flush(GPPort *port, int direction)
Flush data on serial port.
Definition: gphoto2-port.c:762
DSR line.
Definition: gphoto2-port.h:188
int gp_port_set_info(GPPort *port, GPPortInfo info)
Configure a port.
Definition: gphoto2-port.c:149
CTS line.
Definition: gphoto2-port.h:187
#define GP_ERROR_IO_LOCK
Error when trying to lock the device.
Definition: gphoto2-port-result.h:115
int gp_system_rmdir(const char *dirname)
rmdir UNIX functionality
Definition: gphoto2-port-portability.c:194
char error[2048]
Definition: gphoto2-port.c:74
RING (Modem) line.
Definition: gphoto2-port.h:190
int gp_port_settings_set(GPPort *, GPPortSettings)
Definition: gphoto2-port.c:617
int config
USB bConfigurationValue used.
Definition: gphoto2-port.h:82
#define GP_ERROR_IO_WRITE
I/O during write.
Definition: gphoto2-port-result.h:88
The GPhoto port structure.
Definition: gphoto2-port.h:143
GPPortSettings settings_pending
Settings to be committed.
Definition: gphoto2-port.h:148
int gp_port_usb_find_device_by_class(GPPort *port, int mainclass, int subclass, int protocol)
Find USB device by interface class.
Definition: gphoto2-port.c:814
GPPortSettingsSerial serial
Serial specific settings.
Definition: gphoto2-port.h:115
int gp_port_get_settings(GPPort *port, GPPortSettings *settings)
Get the current port settings.
Definition: gphoto2-port.c:632
const char * gp_port_result_as_string(int result)
Definition: gphoto2-port-result.c:54
char * path
The path of this port (usb:001,023)
Definition: gphoto2-port-info.h:35
Carrier Detect line.
Definition: gphoto2-port.h:189
USB port.
Definition: gphoto2-port-info-list.h:37
#define GP_ERROR_IO_USB_CLEAR_HALT
Error during USB Clear HALT.
Definition: gphoto2-port-result.h:102
GPPortSettingsUSB usb
USB specific settings.
Definition: gphoto2-port.h:116
USB Mass Storage raw SCSI port.
Definition: gphoto2-port-info-list.h:41
#define GP_ERROR_BAD_PARAMETERS
Bad parameters passed.
Definition: gphoto2-port-result.h:38
Internal private libgphoto2_port data. This structure contains private data.
Definition: gphoto2-port.c:73
int gp_system_mkdir(const char *dirname)
mkdir UNIX functionality
Definition: gphoto2-port-portability.c:180
int inep
Bulk IN endpoint used.
Definition: gphoto2-port.h:79
#define GP_OK
Everything is OK.
Definition: gphoto2-port-result.h:30
RTS line.
Definition: gphoto2-port.h:185
int gp_port_read(GPPort *port, char *data, int size)
Read data from port.
Definition: gphoto2-port.c:427
unsigned int id
Definition: gphoto2-port-log.c:58
#define GP_ERROR_IO_SUPPORTED_USB
USB ports not supported.
Definition: gphoto2-port-result.h:75
int get_info_func(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context)
Definition: template.c:341
int gp_port_usb_msg_interface_write(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB interface control message with output data.
Definition: gphoto2-port.c:937
#define HEXDUMP_INIT_X
Definition: gphoto2-port-log.c:165
#define GP_ERROR_IO_USB_FIND
Error when trying to find USB device.
Definition: gphoto2-port-result.h:106
#define GP_ERROR_IO_USB_CLAIM
Error when trying to claim the USB device.
Definition: gphoto2-port-result.h:110
int gp_port_check_int_fast(GPPort *port, char *data, int size)
Check for interrupt without wait.
Definition: gphoto2-port.c:496
void * data
Definition: gphoto2-port-log.c:61
Direct IO to an usb mass storage device.
Definition: gphoto2-port-info-list.h:40
GPLogLevel
Logging level Specifies the logging severity level.
Definition: gphoto2-port-log.h:30
#define GP_ERROR
Generic Error.
Definition: gphoto2-port-result.h:34
int outep
Bulk OUT endpoint used.
Definition: gphoto2-port.h:80
gp_system_dir gp_system_opendir(const char *dirname)
opendir UNIX functionality
Definition: gphoto2-port-portability.c:211
Serial port.
Definition: gphoto2-port-info-list.h:36
enum _GPPin GPPin
Serial pins.
int gp_port_settings_get(GPPort *, GPPortSettings *)
Definition: gphoto2-port.c:611
char port[64]
USB Portname. Specific to lowlevel USB.
Definition: gphoto2-port.h:91
int gp_port_set_settings(GPPort *port, GPPortSettings settings)
Set port settings.
Definition: gphoto2-port.c:590
int gp_port_timeout_set(GPPort *, int)
Definition: gphoto2-port.c:546
int get_file_func(CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *data, GPContext *context)
Definition: template.c:250
Union of port settings.
Definition: gphoto2-port.h:114
int gp_port_timeout_get(GPPort *, int *)
Definition: gphoto2-port.c:553
Pull to high (nV)
Definition: gphoto2-port.h:200
GPPortSettingsUsbScsi usbscsi
usb scsi port specific settings
Definition: gphoto2-port.h:118
struct _GPPortInfo info
Definition: gphoto2-port.c:76
GPLogFunc func
Definition: gphoto2-port-log.c:60
int gp_port_send_break(GPPort *port, int duration)
Send a break over a serial port.
Definition: gphoto2-port.c:737
int gp_port_set_pin(GPPort *port, GPPin pin, GPLevel level)
Set specified serial PIN to value.
Definition: gphoto2-port.c:703
#define GP_ERROR_IO_SERIAL_SPEED
Specified serial speed not possible.
Definition: gphoto2-port-result.h:97
int gp_port_open(GPPort *port)
Open a port.
Definition: gphoto2-port.c:273
Pull to low (0V)
Definition: gphoto2-port.h:199
int gp_port_free(GPPort *port)
Free the port structure.
Definition: gphoto2-port.c:341
int gp_log_add_func(GPLogLevel level, GPLogFunc func, void *data)
Add a function to get logging information.
Definition: gphoto2-port-log.c:82
int gp_port_usb_msg_class_read(GPPort *port, int request, int value, int index, char *bytes, int size)
Send a USB class control message with input data.
Definition: gphoto2-port.c:1050
int gp_system_is_dir(const char *dirname)
check if passed filename is a directory
Definition: gphoto2-port-portability.c:280
char * library_filename
Internal pathname of the port driver. Do not use outside of the port library.
Definition: gphoto2-port-info.h:38
char path[128]
Definition: gphoto2-port.h:98
#define GP_ERROR_LIBRARY
Error in the camera driver.
Definition: gphoto2-port-result.h:46
int gp_port_set_timeout(GPPort *port, int timeout)
Set timeout of port.
Definition: gphoto2-port.c:534
int set_info_func(CameraFilesystem *fs, const char *folder, const char *file, CameraFileInfo info, void *data, GPContext *context)
Definition: template.c:359
#define GP_ERROR_IO_UPDATE
I/O during update of settings.
Definition: gphoto2-port-result.h:92
int altsetting
USB Alternative Setting used.
Definition: gphoto2-port.h:84
int bits
Definition: gphoto2-port.h:69
#define FAST_TIMEOUT
Definition: gphoto2-port.c:482
int timeout
Port timeout in milliseconds.
Definition: gphoto2-port.h:150
void gp_log(GPLogLevel level, const char *domain, const char *format,...)
Log a debug or error message.
Definition: gphoto2-port-log.c:331
GPPortSettings settings
Current port settings.
Definition: gphoto2-port.h:147
#define GP_ERROR_TIMEOUT
Operation timed out.
Definition: gphoto2-port-result.h:66
The port operations.
Definition: gphoto2-port-library.h:39
GPPortOperations * ops
Definition: gphoto2-port.c:77
int gp_log_remove_func(int id)
Remove a logging receiving function.
Definition: gphoto2-port-log.c:138
GPPortType type
Actual type of this port.
Definition: gphoto2-port.h:145
#define GP_ERROR_IO_SUPPORTED_SERIAL
Serial ports not supported.
Definition: gphoto2-port-result.h:71
int stopbits
Definition: gphoto2-port.h:72
const char * gp_port_get_error(GPPort *port)
Get verbose port error message.
Definition: gphoto2-port.c:1210
int gp_port_get_pin(GPPort *port, GPPin pin, GPLevel *level)
Get setting of specific serial PIN.
Definition: gphoto2-port.c:651
int gp_port_usb_find_device(GPPort *port, int idvendor, int idproduct)
Find USB device by vendor/product.
Definition: gphoto2-port.c:790
int gp_port_reset(GPPort *port)
Reset a port.
Definition: gphoto2-port.c:319
int interface
USB Interface number used.
Definition: gphoto2-port.h:83
const char * gp_port_result_as_string(int result)
Definition: gphoto2-port-result.c:54
#define GP_ERROR_NOT_SUPPORTED
Functionality not supported.
Definition: gphoto2-port-result.h:54
int delete_all_func(CameraFilesystem *fs, const char *folder, void *data, GPContext *context)
Definition: template.c:316
int speed
Definition: gphoto2-port.h:68