1 /* 2 $Id: eph_io.h,v 2.13 2001/08/28 06:28:01 crosser Exp $ 3 */ 4 5 /* 6 Copyright (c) 1997-2000 Eugene G. Crosser 7 Copyright (c) 1998 Bruce D. Lightner (DOS/Windows support) 8 9 You may distribute and/or use for any purpose modified or unmodified 10 copies of this software if you preserve the copyright notice above. 11 12 THIS SOFTWARE IS PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY 13 KIND, EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE 14 COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES RESULTING FROM THE 15 USE OF THIS SOFTWARE. 16 */ 17 18 /* 19 $Log: eph_io.h,v $ 20 Revision 2.13 2001/08/28 06:28:01 crosser 21 try make zoom working on newer Oly 22 23 Revision 2.12 2000/05/09 13:20:54 crosser 24 configure read() with alarm() better. 25 Address signed vs. unsigned arguments 26 other cleanups to make most notorious compilers happy 27 28 Revision 2.11 2000/05/02 22:26:35 crosser 29 A few things incorporated from John Bowman's Nikon specific diffs 30 31 Revision 2.10 2000/02/13 11:15:01 crosser 32 Kludge null setint for Nikon 33 34 Revision 2.9 1999/12/11 14:10:15 crosser 35 Support sgtty terminal control 36 Proper "fake speed" handling (needed two values) 37 38 Revision 2.8 1999/12/01 21:41:23 crosser 39 add "pseudo" speed 40 41 Revision 2.7 1998/10/18 13:18:27 crosser 42 Put RCS logs and I.D. into the source 43 44 Revision 2.6 1998/02/26 00:50:39 crosser 45 misc changes 46 47 Revision 2.5 1998/02/13 23:02:40 crosser 48 define type off_t for DOS 49 50 Revision 2.4 1998/02/08 19:58:38 crosser 51 Support low memory: chunked saving etc. 52 53 Revision 2.3 1998/02/03 18:47:51 lightner 54 Fix typo: definded -> defined 55 56 Revision 2.2 1998/01/18 02:16:45 crosser 57 DOS support 58 59 Revision 2.1 1998/01/04 13:55:57 crosser 60 add param for close mode 61 62 Revision 2.0 1998/01/02 19:20:11 crosser 63 Added support for Win32 64 65 Revision 1.1 1997/08/17 08:59:54 crosser 66 Initial revision 67 68 */ 69 70 #ifndef _EPH_IO_H 71 #define _EPH_IO_H 72 73 #include <sys/types.h> 74 #ifdef DOS 75 typedef long off_t; 76 #endif 77 #if defined(UNIX) 78 #if defined(USE_TERMIOS) 79 # include <termios.h> 80 #elif defined(USE_SGTTY) 81 # include <sgtty.h> 82 #elif defined(USE_TERMIO) 83 #include <termio.h> 84 # error "termio unsupported, sorry" 85 #else 86 # error "no termios, sgtty or termio defined, no way to control the tty" 87 #endif 88 #elif defined(MSWINDOWS) 89 #include <windows.h> 90 #endif 91 #include <stdlib.h> 92 93 #ifndef DC1 94 #define DC1 0x11 95 #endif 96 97 #define MAX_SPEED 115200 98 99 typedef struct _eph_iob { 100 void (*errorcb)(int errcode,char *errstr); 101 void *(*realloccb)(void *old,size_t length); 102 void (*runcb)(off_t count); 103 int (*storecb)(char *data,size_t size); 104 int debug; 105 #if defined(UNIX) 106 int fd; 107 #ifdef USE_ALARMED_READ 108 long flag; 109 #endif 110 #if defined(USE_TERMIOS) 111 struct termios savetios; 112 #elif defined(USE_SGTTY) 113 struct sgttyb savesgtty; 114 #elif defined(USE_TERMIO) 115 struct termio savetio; 116 #endif 117 #elif defined(MSWINDOWS) 118 HANDLE fd; 119 DCB savedcb; 120 COMMTIMEOUTS savetimeouts,worktimeouts; 121 #elif defined(DOS) 122 int fd; 123 #endif 124 long timeout; 125 } eph_iob; 126 127 eph_iob *eph_new(void (*errorcb)(int errcode,char *errstr), 128 void *(*realloccb)(void *old,size_t length), 129 void (*runcb)(off_t count), 130 int (*storecb)(char *data,size_t size), 131 int debug); 132 int eph_open(eph_iob *iob,char *device_name,long speed, 133 long defttspeed,long ttspeed); 134 int eph_close(eph_iob *iob,int newmodel); 135 void eph_free(eph_iob *iob); 136 137 int eph_setint(eph_iob *iob,int reg,long val); 138 int eph_setnullint(eph_iob *iob,int reg); 139 int eph_getint(eph_iob *iob,int reg,long *val); 140 int eph_action(eph_iob *iob,int reg,char *val,size_t length); 141 int eph_setvar(eph_iob *iob,int reg,char *val,off_t length); 142 int eph_getvar(eph_iob *iob,int reg,char **val,off_t *length); 143 144 #define ERR_BASE 10001 145 #define ERR_DATA_TOO_LONG 10001 146 #define ERR_TIMEOUT 10002 147 #define ERR_BADREAD 10003 148 #define ERR_BADDATA 10004 149 #define ERR_BADCRC 10005 150 #define ERR_BADSPEED 10006 151 #define ERR_NOMEM 10007 152 #define ERR_BADARGS 10008 153 #define ERR_EXCESSIVE_RETRY 10009 154 #define ERR_MAX 10010 155 156 #define REG_FRAME 4 157 #define REG_SPEED 17 158 #define REG_IMG 14 159 #define REG_TMN 15 160 #define REG_ZOOM 71 161 162 #endif 163