Localization fixes for konica driver

git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2819 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Lutz Mueller
2001-10-27 22:25:49 +00:00
parent fdc5e2a5b5
commit 4b1c56eaeb
5 changed files with 47 additions and 21 deletions

View File

@@ -1313,6 +1313,9 @@ k_localization_data_put (GPPort *device,
static unsigned int packet_size = 1024;
unsigned char sb[16 + packet_size];
gp_log (GP_LOG_DEBUG, "konica", "Uploading %i bytes localization "
"data...", data_size);
CHECK_NULL (data);
if (data_size < 512)
return (GP_ERROR_BAD_PARAMETERS);

View File

@@ -211,7 +211,7 @@ init_serial_connection (Camera *camera)
GPPortSettings settings;
unsigned int speed;
CHECK (camera, gp_port_settings_get (camera->port, &settings));
CHECK (camera, gp_port_get_settings (camera->port, &settings));
/* Speed:
*
@@ -244,7 +244,7 @@ init_serial_connection (Camera *camera)
gp_log (GP_LOG_DEBUG, "konica", "Testing speed %d",
test_bit_rate [i]);
settings.serial.speed = test_bit_rate [i];
gp_port_settings_set (camera->port, settings);
gp_port_set_settings (camera->port, settings);
if (k_init (camera->port) == GP_OK)
break;
}
@@ -366,7 +366,7 @@ init_serial_connection (Camera *camera)
/* Reconnect */
gp_log (GP_LOG_DEBUG, "konica", "Reconnecting at speed %d", speed);
settings.serial.speed = speed;
CHECK (camera, gp_port_settings_set (camera->port, settings));
CHECK (camera, gp_port_set_settings (camera->port, settings));
CHECK (camera, k_init (camera->port));
return (GP_OK);
@@ -962,9 +962,11 @@ camera_set_config (Camera *camera, CameraWidget *window)
gp_widget_get_child_by_label (window, _("Localization"), &section);
/* Localization File */
gp_widget_get_child_by_label (section, _("Language"), &widget);
if (gp_widget_changed (widget)) {
gp_widget_get_value (widget, &c);
CHECK (camera, gp_widget_get_child_by_label (section, _("Language"),
&widget));
CHECK (camera, result = gp_widget_changed (widget));
if (result) {
CHECK (camera, gp_widget_get_value (widget, &c));
if (strcmp (c, _("None selected"))) {
data = NULL;
data_size = 0;
@@ -1099,9 +1101,13 @@ localization_file_read (Camera *camera, const char *file_name,
strcpy (path, LOCALIZATION);
strcat (path, "/");
strcat (path, file_name);
gp_log (GP_LOG_DEBUG, "konica", "Uploading '%s'...", path);
file = fopen (path, "r");
if (!file)
if (!file) {
gp_camera_set_error (camera, _("Could not find localization "
"data at '%s'"), path);
return (GP_ERROR_FILE_NOT_FOUND);
}
/* Allocate the memory */
*data_size = 0;
@@ -1178,21 +1184,21 @@ localization_file_read (Camera *camera, const char *file_name,
/* Calculate and check checksum. */
checksum = 0;
gp_debug_printf (GP_DEBUG_HIGH, "core", "Checksum not implemented!");
gp_log (GP_LOG_DEBUG, "konica", "Checksum not implemented!");
/*FIXME: There's a checksum at (*data)[100]. I could not
figure out how it is calculated. */
/* Calculate and check frame check sequence. */
fcs = 0;
gp_debug_printf (GP_DEBUG_LOW, "konica", "Frame check sequence "
"not implemented!");
gp_log (GP_LOG_DEBUG, "konica", "Frame check sequence "
"not implemented!");
/* FIXME: There's a frame check sequence at (*data)[108]
and (*data)[109]. I could not figure out how it is
calculated. */
gp_debug_printf (GP_DEBUG_LOW, "konica", "-> %i bytes read.\n",
(int) *data_size);
return (TRUE);
gp_log (GP_LOG_DEBUG, "konica", "-> %i bytes read.\n",
(int) *data_size);
return (GP_OK);
}
int
@@ -1226,7 +1232,7 @@ camera_init (Camera* camera)
outep = konica_cameras [i].outep;
/* Initiate the connection */
CHECK (camera, gp_port_settings_get (camera->port, &settings));
CHECK (camera, gp_port_get_settings (camera->port, &settings));
switch (camera->port->type) {
case GP_PORT_SERIAL:
@@ -1234,7 +1240,7 @@ camera_init (Camera* camera)
settings.serial.bits = 8;
settings.serial.parity = 0;
settings.serial.stopbits = 1;
CHECK (camera, gp_port_settings_set (camera->port, settings));
CHECK (camera, gp_port_set_settings (camera->port, settings));
/* Initiate the serial connection */
CHECK (camera, init_serial_connection (camera));
@@ -1248,7 +1254,7 @@ camera_init (Camera* camera)
settings.usb.config = 1;
settings.usb.interface = 0;
settings.usb.altsetting = 0;
CHECK (camera, gp_port_settings_set (camera->port, settings));
CHECK (camera, gp_port_set_settings (camera->port, settings));
/* Initiate the connection */
CHECK (camera, k_init (camera->port));

View File

@@ -85,6 +85,7 @@ show_section (CmdConfig *cmd_config, CameraWidget *section)
gp_widget_get_label (child, &label);
items[x + 1] = copyChar ((char *) label);
}
count++;
scroll = newCDKScroll (cmd_config->screen, CENTER, CENTER, RIGHT,
10, 50, title,
items, count, NUMBERS, A_REVERSE, TRUE, FALSE);
@@ -163,17 +164,30 @@ show_radio (CmdConfig *cmd_config, CameraWidget *radio)
CDKITEMLIST *list = NULL;
const char *label, *value, *current_value;
char title[1024], *items[100];
int x, count, current = 0, selection;
int x, count, current = 0, selection, found;
gp_widget_get_label (radio, &label);
snprintf (title, sizeof (title), "<C></U>%s", label);
gp_widget_get_value (radio, &current_value);
count = gp_widget_count_choices (radio);
/* Check if the current value is in the list */
current = found = 0;
for (x = 0; x < count; x++) {
gp_widget_get_choice (radio, x, &value);
items[x] = copyChar ((char *) value);
if (!strcmp (current_value, value))
if (!strcmp (value, current_value)) {
current = x;
found = 1;
break;
}
}
if (!found)
items[0] = copyChar ((char *) current_value);
/* Add all items */
for (x = 0; x < count; x++) {
gp_widget_get_choice (radio, x, &value);
items[x + 1 - found] = copyChar ((char *) value);
}
list = newCDKItemlist (cmd_config->screen, CENTER, CENTER,

View File

@@ -359,7 +359,7 @@ gp_camera_set_message_func (Camera *camera, CameraMessageFunc func,
int
gp_camera_status (Camera *camera, const char *format, ...)
{
char buffer[1024];
char buffer[2048];
va_list arg;
CHECK_NULL (camera && format);

View File

@@ -24,6 +24,7 @@
#include <string.h>
#include <gphoto2-result.h>
#include <gphoto2-port-log.h>
#define CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
@@ -349,8 +350,10 @@ gp_widget_set_value (CameraWidget *widget, void *value)
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
gp_log (GP_LOG_DEBUG, "gphoto2-widget", "Setting value to "
"'%s'...", (char*) value);
if (widget->value_string) {
if (strcmp (widget->value_string, (char*)value) != 0)
if (strcmp (widget->value_string, (char*) value))
widget->changed = 1;
free (widget->value_string);
} else