Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

hp215.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  Copyright (C) 2002  Jason Surprise <thesurprises1@attbi.com>             *
00003  *                2003  Enno Bartels   <ennobartels@t-online.de>             *
00004  *****************************************************************************
00005  *                                                                           *
00006  *  This program is free software; you can redistribute it and/or            *
00007  *  modify it under the terms of the GNU Library General Public              *
00008  *  License as published by the Free Software Foundation; either             *
00009  *  version 2 of the License, or (at your option) any later version.         *
00010  *                                                                           *
00011  *  This program is distributed in the hope that it will be useful,          *
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
00014  *  Library General Public License for more details.                         *
00015  *                                                                           *
00016  *  You should have received a copy of the GNU Library General Public        *
00017  *  License along with this program; see the file COPYING.LIB.  If not,      *
00018  *  write to the Free Software Foundation, Inc., 59 Temple Place -           *
00019  *  Suite 330,  Boston, MA 02111-1307, USA.                                  *
00020  *                                                                           *
00021  *****************************************************************************
00022  *                                                                           *
00023  *  Project name.....  hp215                                                 *
00024  *                                                                           *
00025  *  Modul name.......  hp215.h                                               *
00026  *                                                                           *
00027  *  Starting dates...  11.Nov.2002 (Enno Bartels)                            *
00028  *                     --.---.2002 (Jason Surprise)                          *
00029  *                                                                           *
00030  *  Version..........  0.2.3                                                 *
00031  *                                                                           *
00032  *  Author...........  - Options & autoconf/-make framework written & new    *
00033  *                       maintainer: Enno Bartels <ennobartels@t-online.de>  *
00034  *                     - Checksum code written by Roberto Ragusa             *
00035  *                     - Jason Surprise <thesurprises1@attbi.com>            *
00036  *                                                                           *
00037  *  Description......  Linux USB Driver for the HP Photosmart 215 Camera     *
00038  *                                                                           *
00039  *****************************************************************************/
00040 
00041 
00042 #ifndef _HP215_H
00043 #define _HP215_H
00044 
00045 /* Possible modes */
00046 #define NORMAL_MODE 1  /* Normal mode               */
00047 #define PRTCMD_MODE 2  /* Print camera command mode */
00048 #define TSTDAT_MODE 3  /* Test date string  mode    */
00049 
00050 /* Element types on the date string option */
00051 #define DATE  1 
00052 #define ASCII 2
00053 
00054 #define MAX_ITEMS 200
00055 
00056 
00057 #define PREVIEW_DIR  "preview"
00058 #define FULLSIZE_DIR "fullsize"
00059 
00060 /* Function call answers*/
00061 #define SUCCESS 0
00062 #define FAIL    1
00063 
00064 /* Mode of the getDateStr function */
00065 #define MUST_USE_A_PICTURE_NUMBER      1
00066 #define MUST_NOT_USE_A_PICTURE_NUMBER  2
00067 
00068 /* Maxlength of the format string */
00069 #define MAX_DS_STRLEN 1000
00070 
00071 /* Maximal pictures*/
00072 #define MAX_PICS 1000
00073 
00074 /* ACK hexcode */
00075 #define ACK 0x06
00076 
00077 #define HP_VENDOR_ID 0x3f0
00078 #define HP215_ID     0x6202
00079 
00080 /* General commands */
00081 #define HP_CMD_INIT            {0x02, 0xce, 0x80, 0x8a, 0x84, 0x8d, 0x83, 0x03}
00082 #define HP_CMD_DATETIME        {0x02, 0xc1, 0x80, 0x8b, 0x84, 0x8e, 0x8d, 0x03}
00083 #define HP_CMD_GET_PHOTO_ALBUM {0x02, 0xc6, 0x88, 0x80, 0x80, 0x83, 0x84, 0x38, 0x2f, 0x30, 0x32, 0x88, 0x84, 0x8e, 0x8b, 0x03}
00084 #define HP_CMD_DELETE_PICS     {0x02, 0xb1, 0x84, 0x8f, 0x8f, 0x8f, 0x8f, 0x86, 0x80, 0x8a, 0x86, 0x03}
00085 
00086 /* Enum for the date/time elements on the date string option */
00087 enum myCodes 
00088 {  
00089    N_02,        /* N_ = Number */
00090    N_03,
00091    N_02_PLUS1,
00092    N_03_PLUS1,
00093 
00094    SUM_PICS_02, /* Number of pictures */
00095    SUM_PICS_03, 
00096 
00097    D_02,        /* D_ = Day of month */
00098 
00099    M_LONG,      /* M_ = Months */
00100    M_SHORT,
00101    M_02,       
00102    M_,       
00103 
00104    Y_02,        /* Y_ = Years */
00105    Y_04,
00106 
00107    H_02_12,     /* H_ = Hours */
00108    H_02_24,
00109    H____12,     
00110    H____24,
00111    H_AMPM,
00112 
00113    K_02,        /* K_ = Minutes */
00114 };
00115 
00116 
00117 
00118 typedef struct 
00119 {
00120   unsigned int hour;
00121   unsigned int min;
00122   unsigned int sec;
00123 
00124   unsigned int day;
00125   unsigned int month;
00126   unsigned int year;
00127 
00128 } t_date;
00129 
00130 
00131 
00132 typedef struct  
00133 {
00134     char              name [1000];
00135     char              name_nsd [1000];
00136 
00137     char              preview_name [1000];
00138     char              preview_name_nsd [1000];
00139 
00140 
00141     unsigned long int size;
00142     unsigned char    *data;
00143     t_date            date; 
00144     char              date_time [20];
00145 } CamFile;
00146 
00147 
00148 typedef struct  
00149 {
00150     struct usb_device     *device;
00151     struct usb_dev_handle *dh;
00152     int                    num_pics;
00153     CamFile               *pic[MAX_PICS];
00154 } t_camera;
00155 
00156 
00157 
00158 
00159 typedef struct
00160 {
00161     /* Main mode */
00162     int main;           /* Was a mode selected (0=No;else yes) */
00163 
00164     /* Selected modes */
00165     int dateCam;        /* Mode: Get date of the camera ?    */
00166     int albm;           /* Mode: Get number of pictures ?    */
00167     int datePics;       /* Mode: Get date/time of pictures ? */
00168     int prev;           /* Mode: Get previews ?              */
00169     int pics;           /* Mode: Get pictures ?              */
00170     int delt;           /* Mode: Delete pictures ?           */
00171     int html;           /* Mode: Create a html page ?        */
00172     int tmp_html;
00173 
00174     /* Options */
00175     int  tryInitCamTwice;      /* Try cam init 2 times ?            */
00176     int  forceDeletion;        /* Do deletion without questions ?   */
00177     int  picNumbersAll;        /* Where all pictures selected ?     */
00178     int  picNumbers;           /* Number of selected pictures       */
00179     int  picNumber[MAX_PICS];  /* Selected pictures                 */  
00180 
00181     int  picNumbersRL;          /* Number of selected pictures      */
00182     int  picNumberRL[MAX_PICS]; /* Selected pictures                */ 
00183     int  picNumbersRR;          /* Number of selected pictures      */
00184     int  picNumberRR[MAX_PICS]; /* Selected pictures                */ 
00185     int  picNumbersRH;          /* Number of selected pictures      */
00186     int  picNumberRH[MAX_PICS]; /* Selected pictures                */ 
00187  
00188     char subDir[100];           /* Name of the sub directory        */
00189     int  subDirPrev;            /* A preview sub directory ?        */
00190     int  subDirFull;            /* A fullsize sub directory ?       */
00191 
00192     /*  char subDirPrev[100];  */    
00193     /*  char subDirFull[100];  */     /* Name of the preview sub directory */
00194 
00195     /* Options for the specital mode print command */
00196     int  printCmd_cmd;         /* Command code */
00197     int  printCmd_picNo;       /* Picture number */
00198 
00199     char dateStr[MAX_DS_STRLEN];
00200 
00201     int  dateInPic;             /* Date string inside the picture   */
00202     char dateInPicStr[MAX_DS_STRLEN]; /* Date string format inside pic.   */
00203 } t_mode;
00204 
00205 
00206 /* Function prototypes */
00207 void  dprint              (char    *);
00208 struct usb_device *
00209       find_device         (int, int);
00210 int   hp_open             (t_camera *, int);
00211 int   hp_init_sequence    (t_camera *);
00212 
00213 int   hp_new_file         (CamFile **);
00214 int   hp_append_file      (CamFile *, const unsigned char *, unsigned long int);
00215 
00216 int   hp_sent_ack         (t_camera *, int);
00217 int   hp_rcv_ack          (t_camera *, int);
00218 
00219 int   hp_gen_cmd          (int, int, unsigned char *);
00220 int   hp_get_timeDate_cam (t_camera *);
00221 int   hp_get_photo_album  (t_camera *);
00222 int   hp_get_timeDate_pics(t_camera *, int, int [MAX_PICS], char *, char *, int, int);
00223 int   hp_get_previews     (t_camera *, int, int [MAX_PICS], char *);
00224 int   hp_write_previews   (t_camera *, int, int [MAX_PICS]);
00225 int   hp_get_write_pics   (t_camera *, int, int [MAX_PICS], char *);
00226 int   hp_delete_pics      (t_camera *, int, int, int[MAX_PICS]);
00227 int   hp_delete_all_pics  (t_camera *);
00228 int   hp_delete_some_pics (t_camera *, int, int[MAX_PICS]);
00229 void  hp_create_html_page (t_camera *, int, int[MAX_PICS], char *, int, int, int);
00230 
00231 int   hp_close            (t_camera *);
00232 
00233 void  read_ini            (t_mode *mode);
00234 void  read_cmd            (int *, char ***, t_mode *);
00235 void  usage               (void);
00236 void  gen_subDirName      (char [100]);
00237 void  gen_subDir          (char [100]);
00238 void  read_number         (int *, int [1000], char *);
00239 void  getDateStr          (char *, unsigned int, unsigned int, t_date, char *,
00240                            int);
00241 void  test_dateString     (char *);
00242 void  check_dateStr       (char *); 
00243 void  test_cmd            (t_mode);
00244 void  ini_getNoElements   (int *, char *);
00245 void  ini_delComment      (char *);
00246 void  acceptOptions       (t_mode *, int *, char **[], int);
00247 void  init_modeValues     (t_mode *);
00248 void  checkPid            (void);
00249 void  myExit              (int, int);
00250 void  removeLockFile      (void);
00251 void  add_dateInsidePicture (char     *dateInPicStr,
00252                             int       picNumbers, 
00253                             int       picNumber[MAX_PICS],
00254                              t_camera *myCam);
00255 #endif

Generated on Tue Oct 21 18:10:51 2003 for hp_photosmart215 by doxygen 1.3.2