| 1 | #if 0
 | 
|---|
| 2 |     STV driver
 | 
|---|
| 3 |     Copyright (C) 2006 Markus Wildi, markus.wildi@datacomm.ch
 | 
|---|
| 4 | 
 | 
|---|
| 5 |     This library is free software; you can redistribute it and/or
 | 
|---|
| 6 |     modify it under the terms of the GNU Lesser General Public
 | 
|---|
| 7 |     License as published by the Free Software Foundation; either
 | 
|---|
| 8 |     version 2.1 of the License, or (at your option) any later version.
 | 
|---|
| 9 | 
 | 
|---|
| 10 |     This library is distributed in the hope that it will be useful,
 | 
|---|
| 11 |     but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 12 |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
|---|
| 13 |     Lesser General Public License for more details.
 | 
|---|
| 14 | 
 | 
|---|
| 15 |     You should have received a copy of the GNU Lesser General Public
 | 
|---|
| 16 |     License along with this library; if not, write to the Free Software
 | 
|---|
| 17 |     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #define OFF 0 
 | 
|---|
| 21 | #define ON  1 
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #define REQUEST_DOWNLOAD              0x00
 | 
|---|
| 24 | #define REQUEST_DOWNLOAD_ALL          0x01
 | 
|---|
| 25 | #define DOWNLOAD_COMPLETE             0x02
 | 
|---|
| 26 | #define REQUEST_BUFFER_STATUS         0x03
 | 
|---|
| 27 | #define REQUEST_IMAGE_INFO            0x04
 | 
|---|
| 28 | #define REQUEST_IMAGE_DATA            0x05
 | 
|---|
| 29 | #define ACK                           0x06
 | 
|---|
| 30 | #define REQUEST_COMPRESSED_IMAGE_DATA 0x07
 | 
|---|
| 31 | #define SEND_KEY_PATTERN              0x08
 | 
|---|
| 32 | #define DISPLAY_ECHO                  0x09
 | 
|---|
| 33 | #define FILE_STATUS                   0x0b
 | 
|---|
| 34 | #define REQUEST_ACK                   0x10
 | 
|---|
| 35 | #define NACK                          0x15
 | 
|---|
| 36 | 
 | 
|---|
| 37 | /* Rotary Knob Key Patterns */
 | 
|---|
| 38 | #define LR_ROTARY_DECREASE_PATTERN    0x8000
 | 
|---|
| 39 | #define LR_ROTARY_INCREASE_PATTERN    0x4000
 | 
|---|
| 40 | #define UD_ROTARY_DECREASE_PATTERN    0x2000
 | 
|---|
| 41 | #define UD_ROTARY_INCREASE_PATTERN    0x1000
 | 
|---|
| 42 | #define SHIFT_PATTERN                 0x0008  /* increases rotary speed when 1 */
 | 
|---|
| 43 | 
 | 
|---|
| 44 | /* Mode Key Patterns */
 | 
|---|
| 45 | #define CAL_KEY_PATTERN               0x0100
 | 
|---|
| 46 | #define TRACK_KEY_PATTERN             0x0200
 | 
|---|
| 47 | #define DISPLAY_KEY_PATTERN           0x0400
 | 
|---|
| 48 | #define FILEOPS_KEY_PATTERN           0x0800
 | 
|---|
| 49 | #define A_KEY_PATTERN                 0x0010
 | 
|---|
| 50 | #define SETUP_KEY_PATTERN             0x0020
 | 
|---|
| 51 | #define B_KEY_PATTERN                 0x0040
 | 
|---|
| 52 | #define INT_KEY_PATTERN               0x0080
 | 
|---|
| 53 | #define FOCUS_KEY_PATTERN             0x0001
 | 
|---|
| 54 | #define IMAGE_KEY_PATTERN             0x0002
 | 
|---|
| 55 | #define MONITOR_KEY_PATTERN           0x0004
 | 
|---|
| 56 | 
 | 
|---|
| 57 | /* The following bit masks have been take from Sbig's documentation */
 | 
|---|
| 58 | #define  ID_BITS_MASK         0x0001 /* mask for no bits*/
 | 
|---|
| 59 | #define  ID_BITS_10           0x0001 /*       image is full 10 bits*/
 | 
|---|
| 60 | #define  ID_BITS_8            0x0000 /*       image from focus, only 8 bits*/
 | 
|---|
| 61 | #define  ID_UNITS_MASK        0x0002 /* mask for units for scope*/
 | 
|---|
| 62 | #define  ID_UNITS_INCHES      0x0002 /*       units were inches*/
 | 
|---|
| 63 | #define  ID_UNITS_CM          0x0000 /*       units were cm*/
 | 
|---|
| 64 | #define  ID_SCOPE_MASK        0x0004 /* mask for telescope type*/
 | 
|---|
| 65 | #define  ID_SCOPE_REFRACTOR   0x0004 /*       scope was refractor*/
 | 
|---|
| 66 | #define  ID_SCOPE_REFLECTOR   0x0000 /*       scope was reflector*/
 | 
|---|
| 67 | #define  ID_DATETIME_MASK     0x0008 /* mask for date/time valid*/
 | 
|---|
| 68 | #define  ID_DATETIME_VALID    0x0008 /*       date/time was set*/
 | 
|---|
| 69 | #define  ID_DATETIME_INVALID  0x0000 /*       date/time was not set*/
 | 
|---|
| 70 | #define  ID_BIN_MASK          0x0030 /* mask for binning mode*/
 | 
|---|
| 71 | #define  ID_BIN_1X1           0x0010 /*       binning was 1x1*/
 | 
|---|
| 72 | #define  ID_BIN_2X2           0x0020 /*       binning was 2x2*/
 | 
|---|
| 73 | #define  ID_BIN_3X3           0x0030 /*       binning was 3x3*/
 | 
|---|
| 74 | #define  ID_PM_MASK           0x0400 /* mask for am/pm in time*/
 | 
|---|
| 75 | #define  ID_PM_PM             0x0400 /*       time was pm, add 12 hours*/
 | 
|---|
| 76 | #define  ID_PM_AM             0x0000 /*       time was am, don;t add 12 hours*/
 | 
|---|
| 77 | #define  ID_FILTER_MASK       0x0800 /* mask for filter status*/
 | 
|---|
| 78 | #define  ID_FILTER_LUNAR      0x0800 /*       lunar filter was used for image*/
 | 
|---|
| 79 | #define  ID_FILTER_NP         0x0000 /*       no filter was used for image*/
 | 
|---|
| 80 | #define  ID_DARKSUB_MASK      0x1000 /* mask for dark subtraction*/
 | 
|---|
| 81 | #define  ID_DARKSUB_YES       0x1000 /*       image was dark subtracted*/
 | 
|---|
| 82 | #define  ID_DARKSUB_NO        0x0000 /*       image was not dark subtracted*/
 | 
|---|
| 83 | #define  ID_MOSAIC_MASK       0x6000 /* mask for mosaic status*/
 | 
|---|
| 84 | #define  ID_MOSAIC_NONE       0x0000 /*       no mosaic, one image per frame*/
 | 
|---|
| 85 | #define  ID_MOSAIC_SMALL      0x2000 /*       small mosaic: 40x40 pixels/image*/
 | 
|---|
| 86 | #define  ID_MOSAIC_LARGE      0x4000 /*       large mosaic: 106x100 pixels/image*/
 | 
|---|
| 87 | 
 | 
|---|
| 88 | 
 | 
|---|
| 89 | /* IMAGE_INFO - data for the image
 | 
|---|
| 90 | 
 | 
|---|
| 91 |    Notes:
 | 
|---|
| 92 |    height     - 0 or 0xFFFF if no data present
 | 
|---|
| 93 |    exposure   - 100-60000 = 1.00 - 600 secs by 0.01
 | 
|---|
| 94 |                 60001-60999 = 0.001 - 0.999 secs by 0.001
 | 
|---|
| 95 |    packedDate - bits  6-0  = year - 1999 (0 -127)
 | 
|---|
| 96 |                 bits 11-7  = day ( 1-31)
 | 
|---|
| 97 |                 bits 15-12 = month (1-12)
 | 
|---|
| 98 |    packedTime - bits  6-0  = seconds (0-59)
 | 
|---|
| 99 |                 bits 7-12  = minutes (0-59)
 | 
|---|
| 100 |                 bits 15-13 = hours mod 12 (0-11)
 | 
|---|
| 101 |                              + bit in descriptor can add 12
 | 
|---|
| 102 | */
 | 
|---|
| 103 | 
 | 
|---|
| 104 | typedef struct {
 | 
|---|
| 105 | 
 | 
|---|
| 106 |   unsigned int descriptor ;    /* set of bits*/
 | 
|---|
| 107 |   unsigned int height, width;  /* image sze */
 | 
|---|
| 108 |   unsigned int top, left ;     /* position in buffer */
 | 
|---|
| 109 |   double       exposure ;      /* exposure time */
 | 
|---|
| 110 |   unsigned int noExposure ;    /* number of exposures added */
 | 
|---|
| 111 |   unsigned int analogGain ;    /*analog gain */
 | 
|---|
| 112 |   int          digitalGain ;   /* digital gain */
 | 
|---|
| 113 |   unsigned int focalLength ;   /*focal length of telescope */
 | 
|---|
| 114 |   unsigned int aperture ;      /* aperture diameter */
 | 
|---|
| 115 |   unsigned int packedDate ;    /* date of image */
 | 
|---|
| 116 |   unsigned int year ;
 | 
|---|
| 117 |   unsigned int month ;
 | 
|---|
| 118 |   unsigned int day ;
 | 
|---|
| 119 |   unsigned int packedTime ;    /* time of image */
 | 
|---|
| 120 |   unsigned int seconds  ;      /* time of image */
 | 
|---|
| 121 |   unsigned int minutes ;       /* time of image */
 | 
|---|
| 122 |   unsigned int hours ;         /* time of image */
 | 
|---|
| 123 |   double       ccdTemp ;       /* temperature of ccd in 1/100 deg C */
 | 
|---|
| 124 |   unsigned int siteID;         /* site id */
 | 
|---|
| 125 |   unsigned int eGain ;         /* eGain in 1/100th e/ADU */
 | 
|---|
| 126 |   unsigned int background ;    /* background for display */
 | 
|---|
| 127 |   unsigned int range ;         /* range for display */
 | 
|---|
| 128 |   unsigned int pedestal ;      /* Track and Accumulate pedestal */
 | 
|---|
| 129 |   unsigned int ccdTop, ccdLeft ; /* position of pixels on CCD array */
 | 
|---|
| 130 |   unsigned int adcResolution ; /* value, 8 or 10 bits */
 | 
|---|
| 131 |   unsigned int units ;         /* 0= cm, 1=inch */
 | 
|---|
| 132 |   unsigned int telescopeType ; /* 0=refractor, 1= reflector */
 | 
|---|
| 133 |   unsigned int dateTimeValid ; /* 0= valid */
 | 
|---|
| 134 |   unsigned int binning ;       /* 1x1=1, 2x2=2, 3x3=3 */ 
 | 
|---|
| 135 |   unsigned int filterStatus ;  /* 0= no filter, 1= lunar filter */
 | 
|---|
| 136 |   unsigned int darkFrameSuntracted ; /* 0= no, 1= yes */
 | 
|---|
| 137 |   unsigned int imageIsMosaic ; /* 0=no, 1=40x40 pixels, 2=106x100 pixels */
 | 
|---|
| 138 |   double       pixelSize ;     /* 7.4 um */
 | 
|---|
| 139 |   double       minValue ;      /* Pixel Contents */
 | 
|---|
| 140 |   double       maxValue ; 
 | 
|---|
| 141 |   
 | 
|---|
| 142 | } IMAGE_INFO ;
 | 
|---|
| 143 | /*
 | 
|---|
| 144 |  * $Id: serial.h 49 2006-08-25 18:07:14Z lukas $
 | 
|---|
| 145 |  *
 | 
|---|
| 146 |  * Copyright (C) 2006, Lukas Zimmermann, Basel, Switzerland.
 | 
|---|
| 147 |  *
 | 
|---|
| 148 |  *
 | 
|---|
| 149 |    This program is free software; you can redistribute it and/or modify
 | 
|---|
| 150 |    it under the terms of the GNU General Public License as published by
 | 
|---|
| 151 |    the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 152 |    any later version.
 | 
|---|
| 153 | 
 | 
|---|
| 154 |    This program is distributed in the hope that it will be useful,
 | 
|---|
| 155 |    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 156 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 157 |    GNU General Public License for more details.
 | 
|---|
| 158 | 
 | 
|---|
| 159 |    You should have received a copy of the GNU General Public License
 | 
|---|
| 160 |    along with this program; if not, write to the Free Software Foundation,
 | 
|---|
| 161 |    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 | 
|---|
| 162 | 
 | 
|---|
| 163 |    Or visit http://www.gnu.org/licenses/gpl.html.
 | 
|---|
| 164 | */
 | 
|---|
| 165 | 
 | 
|---|
| 166 | #ifndef __serial_h__
 | 
|---|
| 167 | #define __serial_h__
 | 
|---|
| 168 | 
 | 
|---|
| 169 | #define PARITY_NONE    0
 | 
|---|
| 170 | #define PARITY_EVEN    1
 | 
|---|
| 171 | #define PARITY_ODD     2
 | 
|---|
| 172 | 
 | 
|---|
| 173 | typedef unsigned char byte;         /* define byte type */
 | 
|---|
| 174 | 
 | 
|---|
| 175 | /* Restores terminal settings of open serial port device and close the file. */
 | 
|---|
| 176 | void shutdown_serial(int fd);
 | 
|---|
| 177 | 
 | 
|---|
| 178 | /* Opens and initializes a serial device and returns it's file descriptor. */
 | 
|---|
| 179 | int init_serial(char *device_name, int bit_rate, int word_size,
 | 
|---|
| 180 |                 int parity, int stop_bits);
 | 
|---|
| 181 | 
 | 
|---|
| 182 | /* Calculates the 16 bit CRC of an array of bytes and returns it. */
 | 
|---|
| 183 | unsigned int calc_crc(byte byte_array[], int size);
 | 
|---|
| 184 | 
 | 
|---|
| 185 | 
 | 
|---|
| 186 | #endif          /*#ifndef __serial_h__*/
 | 
|---|
| 187 | 
 | 
|---|
| 188 | 
 | 
|---|