Example #1
0
    /* Regular commands always 8 bytes long */
int32_t soundvision_send_command(uint32_t command, uint32_t argument, 
				  CameraPrivateLibrary *dev) {

    uint8_t cmd[12];
    int result;
   
    htole32a(&cmd[0],8);        /* Length "8" in little-endian 32bits */
    htole32a(&cmd[4],command);  /* Command is a little-endian 32bits  */
    htole32a(&cmd[8],argument); /* Argument is a little-endian 32bits */
 
    result=gp_port_write(dev->gpdev,(char *)&cmd,sizeof(cmd));
    if (result<0) return result;
    return GP_OK;
}
Example #2
0
unsigned char *canon_fill_payload(int length, int word1, int word2, int word3, 
				  int word4)
{
  unsigned char *buffer;
  
  buffer = (unsigned char *)calloc(length, 1);
  htole32a(buffer, word1);
  if(length >= 8)
    htole32a(buffer + 4, word2);
  if(length >= 12)
    htole32a(buffer + 8, word3);
  if(length >= 16)
    htole32a(buffer + 12, word4);
  return buffer;
}
Example #3
0
    /* Filenames are always 12 bytes long */
int32_t soundvision_send_file_command(const char *filename, 
				       CameraPrivateLibrary *dev) {
    char file_cmd[16];

    htole32a(&file_cmd[0],0xc);        /* Length is 12 little-endian 32 bits */
    strncpy(&file_cmd[4],filename,12); /* Filename is 12 bytes at the end */
    return gp_port_write (dev->gpdev, file_cmd, sizeof(file_cmd));
}
Example #4
0
unsigned char *canon_fill_command(int length, int cmd1, unsigned char cmd2, 
				  unsigned char cmd3, unsigned char *payload,
				  int payload_length)
{
  unsigned char *buffer;
  
  buffer = (unsigned char *)calloc(length, 1);
  memset(buffer, 0, length);
  htole32a(buffer, 0x10 + payload_length);
  htole32a(buffer + 0x04, cmd1);
  buffer[0x40] = 2;
  buffer[0x44] = cmd2;
  buffer[0x47] = cmd3;
  htole32a(buffer + 0x48, 0x10 + payload_length);
  htole32a(buffer + 0x4c, 0x12345678);
  if(payload != NULL)
    memcpy(buffer + 0x50, payload, payload_length);
  return buffer;
}
    /* Yet uploaded file never appears.  Why??     */
int tiger_upload_file(CameraPrivateLibrary *dev, 
		      const char *filename,
		      const char *data,
		      long size) {
    int result=0;
    char return_value[4];
    
    uint32_t our_size;
    char *our_data=NULL;

       /* When we upload, the first 3 bytes are little-endian */
       /* File-size followed by the actual file               */
    our_size=size+4;
    our_data=calloc(our_size,sizeof(char));
    if (our_data==NULL) {
       goto upload_error;
    }
   
    htole32a(&our_data[0],size);
    memcpy(our_data+4,data,size);
   
   
    GP_DEBUG("File: %s Size=%ld\n",filename,size);
/*  for(result=0;result<our_size;result++) {
       printf("%x ",our_data[result]);
    }
*/  

    result=tiger_set_pc_mode(dev);
    if (result<0) goto upload_error;
   
    result=soundvision_get_revision(dev,NULL);
    if (result<0) goto upload_error;
   
    result=soundvision_send_command(SOUNDVISION_GET_MEM_FREE,0,dev);
    if (result<0) goto upload_error;
   
    result=soundvision_read(dev, &return_value, sizeof(return_value));        
    if (result<0) goto upload_error;
   
    result=soundvision_send_command(SOUNDVISION_PUT_FILE,size,dev);
    if (result<0) goto upload_error;
    
    result=soundvision_read(dev, &return_value, sizeof(return_value));        
    if (result<0) goto upload_error;
   
    result=gp_port_write(dev->gpdev,our_data,our_size);
    if (result<0) goto upload_error;
   
    free(our_data);
    our_data=NULL;

#if 0 
    /* Some traces show the following, though most likely */
    /* this is just the windows driver updating the file list */
   
    result=soundvision_photos_taken(dev);
    result=soundvision_get_file_list(dev);
    
    result=soundvision_send_command(SOUNDVISION_GET_PIC_SIZE,0,dev);
    if (result<0) goto upload_error;
    
    result=soundvision_read(dev, &return_value, sizeof(return_value));        
    if (result<0) goto upload_error;
   
    result=soundvision_send_file_command("000VINCE.JPG",dev);
    
   result=soundvision_read(dev, &return_value, sizeof(return_value));        
    if (result<0) goto upload_error;
   
    result=soundvision_send_command(SOUNDVISION_DONE_TRANSACTION,0,dev);
    if (result<0) goto upload_error;
#endif      
    return GP_OK;
   
upload_error:   
    if (our_data!=NULL) free(our_data);
    GP_DEBUG("Error in tiger_upload_file");
    return result;
}