2001-10-01 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* camlibs/konica/konica.[c,h]:
* camlibs/konica/library.c: Moving towards glib-free code...
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2340 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2001-10-01 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* camlibs/konica/konica.[c,h]:
|
||||
* camlibs/konica/library.c: Moving towards glib-free code...
|
||||
|
||||
2001-09-27 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* camlibs/sierra/protocol.c:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,50 +1,39 @@
|
||||
/****************************************************************/
|
||||
/* konica.c - Library giving access to all features of the */
|
||||
/* camera. */
|
||||
/* */
|
||||
/* Copyright (C) 2000 The Free Software Foundation */
|
||||
/* */
|
||||
/* Author: Lutz Müller <Lutz.Mueller@stud.uni-karlsruhe.de> */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it */
|
||||
/* and/or modify it under the terms of the GNU General Public */
|
||||
/* License as published by the Free Software Foundation; either */
|
||||
/* version 2 of the License, or (at your option) any later */
|
||||
/* version. */
|
||||
/* */
|
||||
/* This program 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 General Public License for more */
|
||||
/* details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public */
|
||||
/* License along with this program; if not, write to the Free */
|
||||
/* Software Foundation, Inc., 59 Temple Place, Suite 330, */
|
||||
/* Boston, MA 02111-1307, USA. */
|
||||
/****************************************************************/
|
||||
/* konica.h
|
||||
*
|
||||
* Copyright (C) 2001 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
*
|
||||
* 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., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
/* Type Definitions */
|
||||
/****************************************************************/
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
/* The following are the commands that are supported by the */
|
||||
/* camera. All other commands will be rejected as unsupported. */
|
||||
/* */
|
||||
/* 0x9200: On 'HP PhotoSmart C20', this command seems to */
|
||||
/* set the language by transferring huge amounts */
|
||||
/* of data. For 'Q-M100', this command is not */
|
||||
/* defined according to Konica. */
|
||||
/* 0x9e10: Used for development and testing of the camera. */
|
||||
/* 0x9e20: Used for development and testing of the camera. */
|
||||
/* */
|
||||
/* For those commands, no documentation is available. They are */
|
||||
/* therefore not implemented. */
|
||||
/****************************************************************/
|
||||
typedef enum {
|
||||
/*
|
||||
* The following are the commands that are supported by the
|
||||
* camera. All other commands will be rejected as unsupported.
|
||||
*
|
||||
* 0x9200: On 'HP PhotoSmart C20', this command seems to
|
||||
* set the language by transferring huge amounts
|
||||
* of data. For 'Q-M100', this command is not
|
||||
* defined according to Konica.
|
||||
* 0x9e10: Used for development and testing of the camera.
|
||||
* 0x9e20: Used for development and testing of the camera.
|
||||
*
|
||||
* For those commands, no documentation is available. They are
|
||||
* therefore not implemented.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
K_ERASE_IMAGE = 0x8000,
|
||||
K_FORMAT_MEMORY_CARD = 0x8010,
|
||||
K_ERASE_ALL = 0x8020,
|
||||
@@ -68,123 +57,115 @@ typedef enum {
|
||||
K_CANCEL = 0x9e00
|
||||
// ? = 0x9e10,
|
||||
// ? = 0x9e20,
|
||||
} k_command_t;
|
||||
} KCommand;
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
/* The following are the preferences that can be set. The */
|
||||
/* sixteen bits that identify the preference are as follows. */
|
||||
/* Low order byte: 0000 0aa0 */
|
||||
/* High order byte: 1x0b xxxx */
|
||||
/* x can be 1 or 0 with no effect on the command. The a and b */
|
||||
/* bits identify the preference and are as follows. */
|
||||
/* */
|
||||
/* b: 0 1 */
|
||||
/* aa: ---------------------------------------------------- */
|
||||
/* 00 | resolution flash */
|
||||
/* 01 | exposure focus / self timer */
|
||||
/* 10 | self timer time auto off time */
|
||||
/* 11 | slide show interval beep */
|
||||
/* */
|
||||
/* */
|
||||
/* A short explanation of the values of the preferences: */
|
||||
/* */
|
||||
/* */
|
||||
/* RESOLUTION (default: 2) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0: medium resolution (same as 2) */
|
||||
/* - 1: high resolution (1152 x 872) */
|
||||
/* - 2: medium resolution (1152 x 872) */
|
||||
/* - 3: low resolution ( 576 x 436) */
|
||||
/* Other values are accepted as well, produce however strange */
|
||||
/* results on the display, as the camera will calculate the */
|
||||
/* remaining pictures on the basis of this value. Those values */
|
||||
/* are at some point changed to 'normal' ones. */
|
||||
/* Each pixel has an area of 4.6um x 4.6 um. */
|
||||
/* */
|
||||
/* */
|
||||
/* EXPOSURE (default: 0) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0 to 255. */
|
||||
/* The behaviour is somewhat strange. Sending a value will */
|
||||
/* not necessarily set the value to exactly the sent one. */
|
||||
/* The following table gives an overview. */
|
||||
/* sent received sent received */
|
||||
/* ---------------- ---------------- */
|
||||
/* 0 - 0 128 129 */
|
||||
/* 1 0 129 130 */
|
||||
/* 2 1 131 - 131 */
|
||||
/* 3 2 132 133 */
|
||||
/* 4 3 133 134 */
|
||||
/* 5 - 5 134 135 */
|
||||
/* 6 5 135 136 */
|
||||
/* 7 6 136 - 136 */
|
||||
/* 8 7 (...) */
|
||||
/* 9 8 246 - 246 */
|
||||
/* 10 - 10 247 248 */
|
||||
/* (...) 248 249 */
|
||||
/* 120 - 120 249 250 */
|
||||
/* 121 120 250 251 */
|
||||
/* 122 121 251 - 251 */
|
||||
/* 123 122 252 253 */
|
||||
/* 124 123 253 254 */
|
||||
/* 125 - 125 254 255 */
|
||||
/* 126 125 255 0 */
|
||||
/* 127 126 */
|
||||
/* */
|
||||
/* Additional information from HP: */
|
||||
/* - Range: EV 6 to EV 16 (ISO 100). */
|
||||
/* - Exposure times: 1/500th to 2 (sec) */
|
||||
/* */
|
||||
/* */
|
||||
/* SELF_TIMER_TIME (default: 10) */
|
||||
/* - 3 to 40. Measured in seconds. */
|
||||
/* All other values are rejected. */
|
||||
/* */
|
||||
/* */
|
||||
/* SLIDE_SHOW_INTERVAL (default: 3) */
|
||||
/* - 1 to 30. Measured in seconds. */
|
||||
/* All other values are rejected. */
|
||||
/* */
|
||||
/* */
|
||||
/* FLASH (default: 2) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0: off */
|
||||
/* - 1: on */
|
||||
/* - 2: auto */
|
||||
/* - 5: on, redeye */
|
||||
/* - 6: auto, redeye */
|
||||
/* Other values are accepted as well, but will be changed to 2 */
|
||||
/* at some point. */
|
||||
/* */
|
||||
/* */
|
||||
/* FOCUS_SELF_TIMER (default: 0) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0: fixed, next picture in normal mode */
|
||||
/* - 1: fixed, next picture in self timer mode */
|
||||
/* - 2: auto, next picture in normal mode */
|
||||
/* - 3: auto, next picture in self timer mode */
|
||||
/* After the next picture has been taken in self timer mode, */
|
||||
/* the value is automatically changed to the next lower even */
|
||||
/* value (normal mode). */
|
||||
/* */
|
||||
/* Additional information from HP: */
|
||||
/* - Fixed: 2.6 feet to infinity */
|
||||
/* - Auto: 8 inches to infinity */
|
||||
/* */
|
||||
/* */
|
||||
/* AUTO_OFF_TIME (default: 5) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0: Will be changed by the camera to 255. */
|
||||
/* - 1 to 255. Measured in minutes. */
|
||||
/* */
|
||||
/* */
|
||||
/* BEEP (default: 1) */
|
||||
/* Only the low order byte is processed. */
|
||||
/* - 0: off */
|
||||
/* - 1 to 255: on */
|
||||
/****************************************************************/
|
||||
typedef enum {
|
||||
/*
|
||||
* The following are the preferences that can be set. The
|
||||
* sixteen bits that identify the preference are as follows.
|
||||
* Low order byte: 0000 0aa0
|
||||
* High order byte: 1x0b xxxx
|
||||
* x can be 1 or 0 with no effect on the command. The a and b
|
||||
* bits identify the preference and are as follows.
|
||||
*
|
||||
* b: 0 1
|
||||
* aa: ----------------------------------------------------
|
||||
* 00 | resolution flash
|
||||
* 01 | exposure focus / self timer
|
||||
* 10 | self timer time auto off time
|
||||
* 11 | slide show interval beep
|
||||
*
|
||||
* A short explanation of the values of the preferences:
|
||||
*
|
||||
* RESOLUTION (default: 2)
|
||||
* Only the low order byte is processed.
|
||||
* - 0: medium resolution (same as 2)
|
||||
* - 1: high resolution (1152 x 872)
|
||||
* - 2: medium resolution (1152 x 872)
|
||||
* - 3: low resolution ( 576 x 436)
|
||||
* Other values are accepted as well, produce however strange
|
||||
* results on the display, as the camera will calculate the
|
||||
* remaining pictures on the basis of this value. Those values
|
||||
* are at some point changed to 'normal' ones.
|
||||
* Each pixel has an area of 4.6um x 4.6 um.
|
||||
*
|
||||
* EXPOSURE (default: 0)
|
||||
* Only the low order byte is processed.
|
||||
* - 0 to 255.
|
||||
* The behaviour is somewhat strange. Sending a value will
|
||||
* not necessarily set the value to exactly the sent one.
|
||||
* The following table gives an overview.
|
||||
* sent received sent received
|
||||
* ---------------- ----------------
|
||||
* 0 - 0 128 129
|
||||
* 1 0 129 130
|
||||
* 2 1 131 - 131
|
||||
* 3 2 132 133
|
||||
* 4 3 133 134
|
||||
* 5 - 5 134 135
|
||||
* 6 5 135 136
|
||||
* 7 6 136 - 136
|
||||
* 8 7 (...)
|
||||
* 9 8 246 - 246
|
||||
* 10 - 10 247 248
|
||||
* (...) 248 249
|
||||
* 120 - 120 249 250
|
||||
* 121 120 250 251
|
||||
* 122 121 251 - 251
|
||||
* 123 122 252 253
|
||||
* 124 123 253 254
|
||||
* 125 - 125 254 255
|
||||
* 126 125 255 0
|
||||
* 127 126
|
||||
*
|
||||
* Additional information from HP:
|
||||
* - Range: EV 6 to EV 16 (ISO 100).
|
||||
* - Exposure times: 1/500th to 2 (sec)
|
||||
*
|
||||
* SELF_TIMER_TIME (default: 10)
|
||||
* - 3 to 40. Measured in seconds.
|
||||
* All other values are rejected.
|
||||
*
|
||||
* SLIDE_SHOW_INTERVAL (default: 3)
|
||||
* - 1 to 30. Measured in seconds.
|
||||
* All other values are rejected.
|
||||
*
|
||||
* FLASH (default: 2)
|
||||
* Only the low order byte is processed.
|
||||
* - 0: off
|
||||
* - 1: on
|
||||
* - 2: auto
|
||||
* - 5: on, redeye
|
||||
* - 6: auto, redeye
|
||||
* Other values are accepted as well, but will be changed to 2
|
||||
* at some point.
|
||||
*
|
||||
* FOCUS_SELF_TIMER (default: 0)
|
||||
* Only the low order byte is processed.
|
||||
* - 0: fixed, next picture in normal mode
|
||||
* - 1: fixed, next picture in self timer mode
|
||||
* - 2: auto, next picture in normal mode
|
||||
* - 3: auto, next picture in self timer mode
|
||||
* After the next picture has been taken in self timer mode,
|
||||
* the value is automatically changed to the next lower even
|
||||
* value (normal mode).
|
||||
*
|
||||
* Additional information from HP:
|
||||
* - Fixed: 2.6 feet to infinity
|
||||
* - Auto: 8 inches to infinity
|
||||
*
|
||||
* AUTO_OFF_TIME (default: 5)
|
||||
* Only the low order byte is processed.
|
||||
* - 0: Will be changed by the camera to 255.
|
||||
* - 1 to 255. Measured in minutes.
|
||||
*
|
||||
* BEEP (default: 1)
|
||||
* Only the low order byte is processed.
|
||||
* - 0: off
|
||||
* - 1 to 255: on
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
K_PREFERENCE_RESOLUTION,
|
||||
K_PREFERENCE_EXPOSURE,
|
||||
K_PREFERENCE_SELF_TIMER_TIME,
|
||||
@@ -196,100 +177,93 @@ typedef enum {
|
||||
} KPreference;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_POWER_LEVEL_LOW,
|
||||
K_POWER_LEVEL_NORMAL,
|
||||
K_POWER_LEVEL_HIGH
|
||||
} KPowerLevel;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_POWER_SOURCE_BATTERY,
|
||||
K_POWER_SOURCE_AC
|
||||
} KPowerSource;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_THUMBNAIL,
|
||||
K_IMAGE_JPEG,
|
||||
K_IMAGE_EXIF
|
||||
} KImageType;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_DISPLAY_BUILT_IN,
|
||||
K_DISPLAY_TV
|
||||
} KDisplay;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_CARD_STATUS_CARD,
|
||||
K_CARD_STATUS_NO_CARD
|
||||
} KCardStatus;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_DATE_FORMAT_MONTH_DAY_YEAR,
|
||||
K_DATE_FORMAT_DAY_MONTH_YEAR,
|
||||
K_DATE_FORMAT_YEAR_MONTH_DAY
|
||||
} KDateFormat;
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
K_TV_OUTPUT_FORMAT_NTSC,
|
||||
K_TV_OUTPUT_FORMAT_PAL,
|
||||
K_TV_OUTPUT_FORMAT_HIDE
|
||||
} KTVOutputFormat;
|
||||
|
||||
/*
|
||||
* Two flavours of Konica's protocol exist: One uses two bytes
|
||||
* for image IDs (qm100, unsigned int), the other one uses four
|
||||
* (qm200, unsigned long).
|
||||
*/
|
||||
int k_init (gp_port *device);
|
||||
|
||||
/****************************************************************/
|
||||
/* Functions */
|
||||
/****************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
K_BIT_RATE_300 = 1 << 0,
|
||||
K_BIT_RATE_600 = 1 << 1,
|
||||
K_BIT_RATE_1200 = 1 << 2,
|
||||
K_BIT_RATE_2400 = 1 << 3,
|
||||
K_BIT_RATE_4800 = 1 << 4,
|
||||
K_BIT_RATE_9600 = 1 << 5,
|
||||
K_BIT_RATE_19200 = 1 << 6,
|
||||
K_BIT_RATE_38400 = 1 << 7,
|
||||
K_BIT_RATE_57600 = 1 << 8,
|
||||
K_BIT_RATE_115200 = 1 << 9
|
||||
} KBitRate;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
K_BIT_FLAG_8_BITS = 1 << 0,
|
||||
K_BIT_FLAG_STOP_2_BITS = 1 << 1,
|
||||
K_BIT_FLAG_PARITY_ON = 1 << 2,
|
||||
K_BIT_FLAG_PARITY_ODD = 1 << 3,
|
||||
K_BIT_FLAG_HW_FLOW_CTRL = 1 << 4
|
||||
} KBitFlag;
|
||||
|
||||
/****************************************************************/
|
||||
/* Two flavours of Konica's protocol exist: One uses two bytes */
|
||||
/* for image IDs (qm100, unsigned int), the other one uses four */
|
||||
/* (qm200, unsigned long). */
|
||||
/****************************************************************/
|
||||
gint k_init (gp_port *device);
|
||||
|
||||
|
||||
gint k_get_io_capability (
|
||||
gp_port *device,
|
||||
gboolean *bit_rate_300,
|
||||
gboolean *bit_rate_600,
|
||||
gboolean *bit_rate_1200,
|
||||
gboolean *bit_rate_2400,
|
||||
gboolean *bit_rate_4800,
|
||||
gboolean *bit_rate_9600,
|
||||
gboolean *bit_rate_19200,
|
||||
gboolean *bit_rate_38400,
|
||||
gboolean *bit_rate_57600,
|
||||
gboolean *bit_rate_115200,
|
||||
gboolean *bit_flag_8_bits,
|
||||
gboolean *bit_flag_stop_2_bits,
|
||||
gboolean *bit_flag_parity_on,
|
||||
gboolean *bit_flag_parity_odd,
|
||||
gboolean *bit_flag_hw_flow_control);
|
||||
|
||||
|
||||
int k_set_io_capability (
|
||||
gp_port *device,
|
||||
guint bit_rate,
|
||||
gboolean bit_flag_7_or_8_bits,
|
||||
gboolean bit_flag_stop_2_bits,
|
||||
gboolean bit_flag_parity_on,
|
||||
gboolean bit_flag_parity_odd,
|
||||
gboolean bit_flag_use_hw_flow_control);
|
||||
|
||||
int k_get_io_capability (gp_port *, KBitRate *bit_rates, KBitFlag *bit_flags);
|
||||
int k_set_io_capability (gp_port *, KBitRate bit_rate, KBitFlag bit_flags);
|
||||
|
||||
int k_erase_all (gp_port *device, guint *number_of_images_not_erased);
|
||||
|
||||
|
||||
int k_format_memory_card (gp_port *device);
|
||||
|
||||
|
||||
int k_take_picture (
|
||||
gp_port *device,
|
||||
gboolean image_id_long,
|
||||
@@ -339,7 +313,8 @@ typedef struct {
|
||||
unsigned int card_size;
|
||||
unsigned int pictures, pictures_left;
|
||||
KDate date;
|
||||
unsigned int io_setting_bit_rate, io_setting_flags;
|
||||
unsigned int bit_rate;
|
||||
KBitFlag bit_flags;
|
||||
unsigned char flash, resolution, focus, exposure;
|
||||
unsigned char total_pictures, total_strobes;
|
||||
} KStatus;
|
||||
@@ -347,7 +322,7 @@ typedef struct {
|
||||
int k_get_status (gp_port *device, KStatus *status);
|
||||
|
||||
|
||||
gint k_get_information (
|
||||
int k_get_information (
|
||||
gp_port *device,
|
||||
gchar **model,
|
||||
gchar **serial_number,
|
||||
@@ -361,7 +336,7 @@ gint k_get_information (
|
||||
gchar **manufacturer);
|
||||
|
||||
|
||||
gint k_get_image_information (
|
||||
int k_get_image_information (
|
||||
gp_port *device,
|
||||
gboolean image_id_long,
|
||||
gulong image_number,
|
||||
@@ -388,11 +363,11 @@ int k_localization_tv_output_format_set (gp_port *device,
|
||||
KTVOutputFormat tv_output_format);
|
||||
|
||||
|
||||
gint k_localization_date_format_set (gp_port *device, KDateFormat date_format);
|
||||
int k_localization_date_format_set (gp_port *device, KDateFormat date_format);
|
||||
|
||||
|
||||
gint k_localization_data_put (gp_port *device, guchar *data, gulong data_size);
|
||||
int k_localization_data_put (gp_port *device, guchar *data, gulong data_size);
|
||||
|
||||
|
||||
gint k_cancel (gp_port *device, k_command_t *command);
|
||||
int k_cancel (gp_port *device, KCommand *command);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
#include <gphoto2-library.h>
|
||||
#include <gphoto2-core.h>
|
||||
#include <gphoto2-debug.h>
|
||||
#include <gphoto2-frontend.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -195,14 +196,10 @@ static gint
|
||||
init_serial_connection (Camera *camera)
|
||||
{
|
||||
gint i;
|
||||
gboolean bit_flag_8_bits, bit_flag_stop_2_bits, bit_flag_parity_on;
|
||||
gboolean bit_flag_parity_odd, bit_flag_use_hw_flow_control;
|
||||
KBitRate bit_rates;
|
||||
KBitFlag bit_flags;
|
||||
guint test_bit_rate [10] = {9600, 115200, 57600, 38400, 19200, 4800,
|
||||
2400, 1200, 600, 300};
|
||||
guint bit_rate [10] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400,
|
||||
57600, 115200};
|
||||
gboolean bit_rate_supported [10] = {FALSE, FALSE, FALSE, FALSE, FALSE,
|
||||
FALSE, FALSE, FALSE, FALSE, FALSE};
|
||||
gp_port_settings settings;
|
||||
guint speed;
|
||||
|
||||
@@ -248,53 +245,108 @@ init_serial_connection (Camera *camera)
|
||||
/* What are the camera's abilities? */
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "-> Getting IO "
|
||||
"capabilities...\n");
|
||||
CHECK (k_get_io_capability (camera->port, &bit_rate_supported [0],
|
||||
&bit_rate_supported [1], &bit_rate_supported [2],
|
||||
&bit_rate_supported [3], &bit_rate_supported [4],
|
||||
&bit_rate_supported [5], &bit_rate_supported [6],
|
||||
&bit_rate_supported [7], &bit_rate_supported [8],
|
||||
&bit_rate_supported [9], &bit_flag_8_bits,
|
||||
&bit_flag_stop_2_bits, &bit_flag_parity_on,
|
||||
&bit_flag_parity_odd, &bit_flag_use_hw_flow_control));
|
||||
|
||||
CHECK (k_get_io_capability (camera->port, &bit_rates, &bit_flags));
|
||||
if (!camera->port_info->speed) {
|
||||
|
||||
/* Set the highest possible speed */
|
||||
for (i = 9; i >= 0; i--)
|
||||
if (bit_rate_supported [i])
|
||||
break;
|
||||
if ((1 << i) & bit_rates)
|
||||
break;
|
||||
if (i < 0)
|
||||
return (GP_ERROR_IO_SERIAL_SPEED);
|
||||
camera->port_info->speed = bit_rate [i];
|
||||
bit_rates = (1 << i);
|
||||
switch (i) {
|
||||
case 0:
|
||||
camera->port_info->speed = 300;
|
||||
break;
|
||||
case 1:
|
||||
camera->port_info->speed = 600;
|
||||
break;
|
||||
case 2:
|
||||
camera->port_info->speed = 1200;
|
||||
break;
|
||||
case 3:
|
||||
camera->port_info->speed = 2400;
|
||||
break;
|
||||
case 4:
|
||||
camera->port_info->speed = 4800;
|
||||
break;
|
||||
case 5:
|
||||
camera->port_info->speed = 9600;
|
||||
break;
|
||||
case 6:
|
||||
camera->port_info->speed = 19200;
|
||||
break;
|
||||
case 7:
|
||||
camera->port_info->speed = 38400;
|
||||
break;
|
||||
case 8:
|
||||
camera->port_info->speed = 57600;
|
||||
break;
|
||||
case 9:
|
||||
camera->port_info->speed = 115200;
|
||||
break;
|
||||
default:
|
||||
return (GP_ERROR_IO_SERIAL_SPEED);
|
||||
}
|
||||
} else {
|
||||
|
||||
/* Does the camera allow us to set the bit rate to the
|
||||
* given one?
|
||||
*/
|
||||
speed = camera->port_info->speed;
|
||||
if (((speed == 300) && (!bit_rate_supported[0])) ||
|
||||
((speed == 600) && (!bit_rate_supported[1])) ||
|
||||
((speed == 1200) && (!bit_rate_supported[2])) ||
|
||||
((speed == 2400) && (!bit_rate_supported[3])) ||
|
||||
((speed == 4800) && (!bit_rate_supported[4])) ||
|
||||
((speed == 9600) && (!bit_rate_supported[5])) ||
|
||||
((speed == 19200) && (!bit_rate_supported[6])) ||
|
||||
((speed == 38400) && (!bit_rate_supported[7])) ||
|
||||
((speed == 57600) && (!bit_rate_supported[8])) ||
|
||||
((speed == 115200) && (!bit_rate_supported[9])) ||
|
||||
((speed != 300) && (speed != 600) &&
|
||||
(speed != 1200) && (speed != 2400) &&
|
||||
(speed != 4800) && (speed != 9600) &&
|
||||
(speed != 19200) && (speed != 38400) &&
|
||||
(speed != 57600) && (speed != 115200)))
|
||||
if (((speed == 300) && (!(bit_rates & (1 << 0)))) ||
|
||||
((speed == 600) && (!(bit_rates & (1 << 1)))) ||
|
||||
((speed == 1200) && (!(bit_rates & (1 << 2)))) ||
|
||||
((speed == 2400) && (!(bit_rates & (1 << 3)))) ||
|
||||
((speed == 4800) && (!(bit_rates & (1 << 4)))) ||
|
||||
((speed == 9600) && (!(bit_rates & (1 << 5)))) ||
|
||||
((speed == 19200) && (!(bit_rates & (1 << 6)))) ||
|
||||
((speed == 38400) && (!(bit_rates & (1 << 7)))) ||
|
||||
((speed == 57600) && (!(bit_rates & (1 << 8)))) ||
|
||||
((speed == 115200) && (!(bit_rates & (1 << 9)))))
|
||||
return (GP_ERROR_IO_SERIAL_SPEED);
|
||||
switch (speed) {
|
||||
case 300:
|
||||
bit_rates = 1 << 0;
|
||||
break;
|
||||
case 600:
|
||||
bit_rates = 1 << 1;
|
||||
break;
|
||||
case 1200:
|
||||
bit_rates = 1 << 2;
|
||||
break;
|
||||
case 2400:
|
||||
bit_rates = 1 << 3;
|
||||
break;
|
||||
case 4800:
|
||||
bit_rates = 1 << 4;
|
||||
break;
|
||||
case 9600:
|
||||
bit_rates = 1 << 5;
|
||||
break;
|
||||
case 19200:
|
||||
bit_rates = 1 << 6;
|
||||
break;
|
||||
case 38400:
|
||||
bit_rates = 1 << 7;
|
||||
break;
|
||||
case 57600:
|
||||
bit_rates = 1 << 8;
|
||||
break;
|
||||
case 115200:
|
||||
bit_rates = 1 << 9;
|
||||
break;
|
||||
default:
|
||||
return (GP_ERROR_IO_SERIAL_SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
/* Request the new speed */
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "-> Setting speed to "
|
||||
"%i...\n", camera->port_info->speed);
|
||||
CHECK (k_set_io_capability (camera->port, camera->port_info->speed,
|
||||
TRUE, FALSE, FALSE, FALSE, FALSE));
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "-> Setting new speed (%x)"
|
||||
"...", bit_rates);
|
||||
bit_flags = K_BIT_FLAG_8_BITS;
|
||||
CHECK (k_set_io_capability (camera->port, bit_rates, bit_flags));
|
||||
|
||||
/* Reconnect */
|
||||
settings.serial.speed = camera->port_info->speed;
|
||||
|
||||
Reference in New Issue
Block a user