added serial uploading
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@943 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2000-08-22
|
||||
phil changed serial.c to the latest libusb from CVS (thanks Scott)
|
||||
philm changed serial.c to the latest libusb from CVS (thanks Scott)
|
||||
Got serial upload working. it should work at 115200 for S10
|
||||
and S20 but only 57600 for everyone else :-(. It is *very*
|
||||
slow.
|
||||
2000-08-21
|
||||
philm deleted unused functions from canon.c (old configure box
|
||||
and related functions).
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
- Uploading : I'm working on it but there are problems. I will soon
|
||||
include the preliminary support I got for people with S10 and S20 to test
|
||||
as it seems easier to get them working (s10sh does it).
|
||||
(08/22/2000 - done for serial but slow)
|
||||
- The configuration dialog has to be made with the new toolkit independent
|
||||
functions provided by gphoto2. It should use gp_config_get and
|
||||
gp_config_set to retrieve and store its configuration information.
|
||||
|
||||
@@ -940,11 +940,20 @@ int camera_file_delete(Camera *camera, char *folder, char *filename)
|
||||
|
||||
int camera_file_put(Camera *camera, CameraFile *file, char *folder)
|
||||
{
|
||||
struct canon_info *cs = (struct canon_info*)camera->camlib_data;
|
||||
char destpath[300], destname[300];
|
||||
int j;
|
||||
|
||||
if (cs->speed>57600 &&
|
||||
(strcmp(camera->model,"Canon PowerShot A50") == 0
|
||||
|| strcmp(camera->model, "Canon PowerShot Pro70") == 0)) {
|
||||
gp_camera_message(camera,
|
||||
"Speeds greater than 57600 are not supported for uploading to this camera");
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if (!check_readiness(camera)) {
|
||||
return 0;
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
strcpy(destname,file->name);
|
||||
@@ -954,17 +963,14 @@ int camera_file_put(Camera *camera, CameraFile *file, char *folder)
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* FIXME: Just a hack for testing purposes then we will have to
|
||||
find the suitable directory to create or to store in*/
|
||||
sprintf(destpath,"D:\\DCIM\\CANONMSC\\");
|
||||
sprintf(destname,"PLAY_00.MRK");
|
||||
/* end of FIXME */
|
||||
sprintf(destpath,"D:\\DCIM\\100CANON\\");
|
||||
|
||||
j = strrchr(destpath,'\\') - destpath;
|
||||
destpath[j] = '\0';
|
||||
|
||||
if(!psa50_directory_operations(camera,destpath, DIR_CREATE))
|
||||
return GP_ERROR;
|
||||
|
||||
psa50_delete_file(camera,destname,destpath);
|
||||
|
||||
destpath[j] = '\\';
|
||||
|
||||
@@ -75,7 +75,8 @@ int psa50_send_frame(Camera *camera, const unsigned char *pkt,int len)
|
||||
}
|
||||
}
|
||||
*p++ = CANON_FEND;
|
||||
return !canon_serial_send(camera, buffer,p-buffer,USLEEP2);
|
||||
|
||||
return !canon_serial_send(camera, buffer,p-buffer,USLEEP2);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +340,7 @@ static int psa50_send_msg(Camera *camera,unsigned char mtype,
|
||||
|
||||
total = pos-pkt;
|
||||
|
||||
if (mtype == 0x3 && dir == 0x11) {
|
||||
if (mtype == 0x3 && dir == 0x11) { // uploading
|
||||
pkt[MSG_LEN_LSB] = total & 0xff;
|
||||
pkt[MSG_LEN_MSB] = total >> 8;
|
||||
|
||||
@@ -1711,7 +1712,7 @@ int psa50_put_file_usb(Camera *camera, CameraFile *file, char *destname, char *d
|
||||
*/
|
||||
|
||||
#define HDR_FIXED_LEN 30
|
||||
#define DATA_BLOCK 512
|
||||
#define DATA_BLOCK 900
|
||||
int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char *destpath)
|
||||
{
|
||||
// struct canon_info *cs = (struct canon_info*)camera->camlib_data;
|
||||
@@ -1722,6 +1723,7 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char
|
||||
char offset2[4];
|
||||
int block_len;
|
||||
char block_len2[4];
|
||||
int sent=0;
|
||||
int i,j=0,len, hdr_len;
|
||||
// int okay, good_ack;
|
||||
|
||||
@@ -1730,24 +1732,39 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char
|
||||
filename[i]='\0';
|
||||
|
||||
hdr_len = HDR_FIXED_LEN + strlen(file->name) + strlen(destpath);
|
||||
|
||||
block_len = 118;
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
offset2[i] = (offset >> (8*i)) & 0xff;
|
||||
block_len2[i] = (block_len >> (8*i)) & 0xff;
|
||||
}
|
||||
while(sent<file->size) {
|
||||
|
||||
if(file->size < DATA_BLOCK)
|
||||
block_len = file->size;
|
||||
else if ((file->size - sent < DATA_BLOCK))
|
||||
block_len = file->size - sent;
|
||||
else
|
||||
block_len = DATA_BLOCK;
|
||||
|
||||
offset = sent;
|
||||
fprintf(stderr,"offset: %i, sent: %i\n",offset,sent);
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
offset2[i] = (offset >> (8*i)) & 0xff;
|
||||
block_len2[i] = (block_len >> (8*i)) & 0xff;
|
||||
}
|
||||
|
||||
for(i=0; i<DATA_BLOCK; i++) {
|
||||
buf[i] = file->data[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
msg = psa50_serial_dialogue(camera,0x3,0x11,&len,"\x02\x00\x00\x00",4,
|
||||
offset2,4,block_len2,4,
|
||||
destpath,strlen(destpath),destname,strlen(destname)+1,
|
||||
"<PRE>\r\nCIFF_VERSION=1.00\r\n<IMG SRC=\"../../DCIM/621CANON/AUT_2103.JPG\">\r\n<IMG SRC=\"../../DCIM/621CANON/AUT_2104.JPG\">\r\n",118,
|
||||
for(i=0; i<DATA_BLOCK; i++) {
|
||||
buf[i] = file->data[j];
|
||||
j++;
|
||||
}
|
||||
|
||||
msg = psa50_serial_dialogue(camera,0x3,0x11,&len,"\x02\x00\x00\x00",4,
|
||||
offset2,4,block_len2,4,
|
||||
destpath,strlen(destpath),destname,strlen(destname)+1,
|
||||
buf,block_len,
|
||||
NULL);
|
||||
|
||||
sent += block_len;
|
||||
|
||||
fprintf(stderr,"Message sent!\n");
|
||||
}
|
||||
|
||||
/*
|
||||
for(i=0; i<PUT_BLOCK1; i++) {
|
||||
@@ -1758,7 +1775,7 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char
|
||||
if(!okay)
|
||||
return GP_ERROR;
|
||||
*/
|
||||
fprintf(stderr,"Message sent!\n");
|
||||
|
||||
/*
|
||||
if (!psa50_send_packet(PKT_UPLOAD_EOT,seq_tx,psa50_eot+PKT_HDR_LEN,1))
|
||||
return 0;
|
||||
|
||||
@@ -304,16 +304,16 @@ int canon_serial_send(Camera *camera, const unsigned char *buf, int len, int sle
|
||||
|
||||
dump_hex(camera,"canon_serial_send()", buf, len);
|
||||
|
||||
/* the A50 does not like to get too much data in a row
|
||||
/* the A50 does not like to get too much data in a row at 115200
|
||||
* The S10 and S20 do not have this problem */
|
||||
if (sleep>0 && cs->model == CANON_PS_A50) {
|
||||
if (sleep>0 && cs->model == CANON_PS_A50 && cs->speed>57600) {
|
||||
for(i=0;i<len;i++) {
|
||||
gpio_write(cs->gdev,buf,1);
|
||||
gpio_write(cs->gdev,(char*)buf,1);
|
||||
buf++;
|
||||
usleep(sleep);
|
||||
}
|
||||
} else {
|
||||
gpio_write(cs->gdev,buf,len);
|
||||
gpio_write(cs->gdev,(char*)buf,len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user