diff --git a/camlibs/barbie/barbie.c b/camlibs/barbie/barbie.c index 14bea79a5..d7348e2db 100644 --- a/camlibs/barbie/barbie.c +++ b/camlibs/barbie/barbie.c @@ -265,11 +265,7 @@ int camera_abilities (CameraAbilities *abilities, int *count) { /* What models do we support? */ strcpy(abilities[0].model, "Barbie Camera"); - abilities[0].serial = 1; - abilities[0].parallel = 1; - abilities[0].usb = 0; - abilities[0].ieee1394 = 0; - + abilities[0].port = GP_PORT_SERIAL; abilities[0].speed[0] = 57600; abilities[0].speed[1] = 0; diff --git a/camlibs/directory/directory.c b/camlibs/directory/directory.c index e1645df1f..0e8d803a0 100644 --- a/camlibs/directory/directory.c +++ b/camlibs/directory/directory.c @@ -37,11 +37,7 @@ int camera_abilities (CameraAbilities *abilities, int *count) { *count = 1; strcpy(abilities[0].model, "Directory Browse"); - abilities[0].serial = 0; - abilities[0].parallel = 0; - abilities[0].usb = 0; - abilities[0].ieee1394 = 0; - + abilities[0].port = GP_PORT_NONE; abilities[0].speed[0] = 0; abilities[0].capture = 0; diff --git a/camlibs/fujitsu/fujitsu.c b/camlibs/fujitsu/fujitsu.c index 7f94feb25..3136ba361 100644 --- a/camlibs/fujitsu/fujitsu.c +++ b/camlibs/fujitsu/fujitsu.c @@ -98,11 +98,7 @@ int camera_abilities (CameraAbilities *abilities, int *count) { /* Fill in a template */ strcpy(a.model, ""); - a.serial = 1; - a.parallel = 0; - a.usb = 0; - a.ieee1394 = 0; - a.network = 0; + a.port = GP_PORT_SERIAL; a.speed[0] = 9600; a.speed[1] = 19200; a.speed[2] = 38400; diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c index 1b6aac925..74a4a077a 100644 --- a/camlibs/konica/library.c +++ b/camlibs/konica/library.c @@ -149,10 +149,7 @@ int camera_abilities (CameraAbilities *abilities, int *count) int x = 0; CameraAbilities a; - a.serial = 1; - a.parallel = 0; - a.usb = 0; - a.ieee1394 = 0; + a.port = GP_PORT_SERIAL; a.speed[0] = 300; a.speed[1] = 600; a.speed[2] = 1200; @@ -641,4 +638,3 @@ int camera_config_set (CameraSetting *conf, int count) return (GP_ERROR); } - diff --git a/camlibs/panasonic/dc1580.c b/camlibs/panasonic/dc1580.c index 1bb538b01..03a885a87 100644 --- a/camlibs/panasonic/dc1580.c +++ b/camlibs/panasonic/dc1580.c @@ -365,10 +365,7 @@ int camera_abilities (CameraAbilities *abilities, int *count) { if a camera supported multiple ways. */ strcpy(abilities[0].model, "Panasonic DC1580"); - abilities[0].serial = 1; - abilities[0].parallel = 0; - abilities[0].usb = 0; - abilities[0].ieee1394 = 0; + abilities[0].port = GP_PORT_SERIAL; abilities[0].speed[0] = 9600; abilities[0].speed[1] = 19200; abilities[0].speed[2] = 38400; diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 8e22a7206..36bb2cdbe 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -185,33 +185,35 @@ OPTION_CALLBACK(abilities) { /* Output a parsing friendly abilities table. Split on ":" */ - printf("Abilities for camera: : %s\n", + printf("Abilities for camera: : %s\n", glob_abilities.model); - printf("Serial port support : %s\n", - glob_abilities.serial == 0? "no":"yes"); - printf("Parallel port support : %s\n", - glob_abilities.parallel == 0? "no":"yes"); - printf("USB support : %s\n", - glob_abilities.usb == 0? "no":"yes"); - printf("IEEE1394 support : %s\n", - glob_abilities.ieee1394 == 0? "no":"yes"); + printf("Serial port support : %s\n", + SERIAL_SUPPORTED(glob_abilities.port)? "yes":"no"); + printf("Parallel port support : %s\n", + PARALLEL_SUPPORTED(glob_abilities.port)? "yes":"no"); + printf("USB support : %s\n", + USB_SUPPORTED(glob_abilities.port)? "yes":"no"); + printf("IEEE1394 support : %s\n", + IEEE1394_SUPPORTED(glob_abilities.port)? "yes":"no"); + printf("Network support : %s\n", + NETWORK_SUPPORTED(glob_abilities.port)? "yes":"no"); if (glob_abilities.speed[0] != 0) { - printf("Transfer speeds supported :\n"); + printf("Transfer speeds supported :\n"); do { - printf(" : %i\n", glob_abilities.speed[x]); + printf(" : %i\n", glob_abilities.speed[x]); x++; } while (glob_abilities.speed[x]!=0); } - printf("Capture from computer support : %s\n", + printf("Capture from computer support : %s\n", glob_abilities.capture == 0? "no":"yes"); - printf("Configuration support : %s\n", + printf("Configuration support : %s\n", glob_abilities.config == 0? "no":"yes"); - printf("Delete files on camera support : %s\n", + printf("Delete files on camera support : %s\n", glob_abilities.file_delete == 0? "no":"yes"); - printf("File preview (thumbnail) support : %s\n", + printf("File preview (thumbnail) support : %s\n", glob_abilities.file_preview == 0? "no":"yes"); - printf("File upload support : %s\n", + printf("File upload support : %s\n", glob_abilities.file_put == 0? "no":"yes"); return (GP_OK); diff --git a/include/gphoto2-datatypes.h b/include/gphoto2-datatypes.h index 50e633fa6..9e365aee1 100644 --- a/include/gphoto2-datatypes.h +++ b/include/gphoto2-datatypes.h @@ -15,18 +15,25 @@ /* Physical Connection Types */ typedef enum { - GP_PORT_NONE, - GP_PORT_SERIAL, - GP_PORT_PARALLEL, - GP_PORT_USB, - GP_PORT_IEEE1394, - GP_PORT_NETWORK + GP_PORT_NONE = 1 << 0, + GP_PORT_SERIAL = 1 << 1, + GP_PORT_PARALLEL = 1 << 2, + GP_PORT_USB = 1 << 3, + GP_PORT_IEEE1394 = 1 << 4, + GP_PORT_NETWORK = 1 << 5 } CameraPortType; +/* Some macros for determining what type of ports the camera supports */ +#define SERIAL_SUPPORTED(_a) ((_a >> 1)&&0x01) +#define PARALLEL_SUPPORTED(_a) ((_a >> 2)&&0x01) +#define USB_SUPPORTED(_a) ((_a >> 3)&&0x01) +#define IEEE1394_SUPPORTED(_a) ((_a >> 4)&&0x01) +#define NETWORK_SUPPORTED(_a) ((_a >> 5)&&0x01) + typedef enum { - GP_CAPTURE_IMAGE, - GP_CAPTURE_AUDIO, - GP_CAPTURE_VIDEO + GP_CAPTURE_IMAGE = 1 << 0, + GP_CAPTURE_AUDIO = 1 << 1, + GP_CAPTURE_VIDEO = 1 << 2 } CameraCaptureType; typedef enum { @@ -103,6 +110,8 @@ typedef struct { char model[128]; /* can the library support the following: */ + int port; + int serial; int parallel; int usb; diff --git a/libgphoto2/util.c b/libgphoto2/util.c index a33f28f18..3c666061d 100644 --- a/libgphoto2/util.c +++ b/libgphoto2/util.c @@ -10,15 +10,15 @@ int gp_abilities_dump (CameraAbilities *abilities) { printf("core: Abilities for camera : %s\n", abilities->model); printf("core: Serial port support : %s\n", - abilities->serial == 0? "no":"yes"); + SERIAL_SUPPORTED(abilities->port)? "yes":"no"); printf("core: Parallel port support : %s\n", - abilities->parallel == 0? "no":"yes"); + PARALLEL_SUPPORTED(abilities->port)? "yes":"no"); printf("core: USB support : %s\n", - abilities->usb == 0? "no":"yes"); + USB_SUPPORTED(abilities->port)? "yes":"no"); printf("core: IEEE1394 support : %s\n", - abilities->ieee1394 == 0? "no":"yes"); + IEEE1394_SUPPORTED(abilities->port)? "yes":"no"); printf("core: Network support : %s\n", - abilities->network == 0? "no":"yes"); + NETWORK_SUPPORTED(abilities->port)? "yes":"no"); if (abilities->speed[0] != 0) { printf("core: Transfer speeds supported :\n"); do { @@ -43,11 +43,7 @@ int gp_abilities_dump (CameraAbilities *abilities) { int gp_abilities_clear (CameraAbilities *abilities) { strcpy(abilities->model, ""); - abilities->serial = 0; - abilities->parallel = 0; - abilities->ieee1394 = 0; - abilities->usb = 0; - abilities->network = 0; + abilities->port = 0; abilities->speed[0] = 0; abilities->capture = 0; abilities->config = 0;