diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-09-19 21:03:27 +0000 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2012-09-19 21:03:27 +0000 |
commit | 10f0aadd724ff62072293845d67d90c9e8e3bf96 (patch) | |
tree | dec7fa878575fbbe1101cc3aa811bda730333943 | |
parent | 2458f2bf83409079807ce4745e3b988ef942e31c (diff) | |
download | libgphoto2-10f0aadd724ff62072293845d67d90c9e8e3bf96.tar.gz |
ax203: add ax203_get_checksum() function
git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_4/libgphoto2@14112 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r-- | camlibs/ax203/README.ax203 | 2 | ||||
-rw-r--r-- | camlibs/ax203/ax203.c | 27 | ||||
-rw-r--r-- | camlibs/ax203/ax203.h | 1 |
3 files changed, 28 insertions, 2 deletions
diff --git a/camlibs/ax203/README.ax203 b/camlibs/ax203/README.ax203 index 05a50a872..a8f52229a 100644 --- a/camlibs/ax203/README.ax203 +++ b/camlibs/ax203/README.ax203 @@ -126,7 +126,7 @@ byte 5: 5 byte 6: 5 byte 7 - 8: size of area to checksum, byte 7 == MSB, 0 means 65536 byte 9 - 10: 0 -byte 11 - 13: address to start checksum, byte 7 == MSB +byte 11 - 13: address to start checksum, byte 11 == MSB And then readback 64 bytes of scsi data, where the first 2 are the 16 bit checksum of all the bytes in the area with byte 0 being the MSB. diff --git a/camlibs/ax203/ax203.c b/camlibs/ax203/ax203.c index 9317fd4cd..0eb5de425 100644 --- a/camlibs/ax203/ax203.c +++ b/camlibs/ax203/ax203.c @@ -1,6 +1,6 @@ /* Appotech ax203 picframe access library * - * Copyright (c) 2010 Hans de Goede <hdegoede@redhat.com> + * Copyright (c) 2010-2012 Hans de Goede <hdegoede@redhat.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -196,6 +196,31 @@ ax203_get_lcd_size(Camera *camera) #endif static int +ax203_get_checksum(Camera *camera, int address, int size) +{ + int ret; + char cmd_buffer[16]; + uint8_t buf[2]; + + memset (cmd_buffer, 0, sizeof (cmd_buffer)); + + cmd_buffer[0] = AX203_FROM_DEV; + cmd_buffer[5] = AX203_GET_CHECKSUM; + cmd_buffer[6] = AX203_GET_CHECKSUM; + cmd_buffer[7] = (size >> 8) & 0xff; + cmd_buffer[8] = size & 0xff; + cmd_buffer[11] = (address >> 16) & 0xff; + cmd_buffer[12] = (address >> 8) & 0xff; + cmd_buffer[13] = address & 0xff; + + ret = ax203_send_cmd (camera, 0, cmd_buffer, sizeof(cmd_buffer), + (char *)buf, 2); + if (ret < 0) return ret; + + return be16atoh(buf); +} + +static int ax3003_get_frame_id(Camera *camera) { int ret; diff --git a/camlibs/ax203/ax203.h b/camlibs/ax203/ax203.h index 70b920f77..1108f05b6 100644 --- a/camlibs/ax203/ax203.h +++ b/camlibs/ax203/ax203.h @@ -49,6 +49,7 @@ #define AX203_EEPROM_CMD 0x00 #define AX203_GET_VERSION 0x01 #define AX203_GET_LCD_SIZE 0x02 +#define AX203_GET_CHECKSUM 0x05 /* Note only seen on 206 sofar */ #define AX3003_FRAME_CMD 0xCA #define AX3003_SET_TIME 0x01 |