libfli-2.0+20221221182632/0000755000175100017510000000000014350647731013433 5ustar debiandebianlibfli-2.0+20221221182632/libfli-filter-focuser.c0000644000175100017510000011412514174600256017766 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifdef _WIN32 //#include #else #include #include #include #endif #include #include #include #include #include #include #include "libfli-libfli.h" #include "libfli-mem.h" #include "libfli-debug.h" #include "libfli-filter-focuser.h" //#define SHOWFUNCTIONS extern double dconvert(void *buf); /* From libfli-camera-usb.c */ static long fli_homedevice(flidev_t dev, long block); static long fli_getstepperstatus(flidev_t dev, flistatus_t *status); /* Array of filterwheel info Pos = # of filters Off = Offset of 0 filter from magnetic stop, X - y = number of steps from filter x to filter y */ static const wheeldata_t wheeldata[] = { /* POS OFF 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9 9-A A-B B-C C-D D-E F-F F-0 */ { 3, 48, { 80, 80, 80, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 0 */ { 5, 0, { 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 1 */ { 7, 14, { 34, 34, 35, 34, 34, 35, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 2 */ { 8, 18, { 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 3 */ {10, 0, { 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0, 0} }, /* Index 4 */ {12, 6, { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0} }, /* Index 5 */ {15, 0, { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48} }, /* Index 6 */ { 7, 14, { 52, 52, 52, 52, 52, 52, 52, 52, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 7 */ {20, 494, { 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29} }, /* Index 7 */ {12, 35, { 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0} }, /* Index 7 */ }; #define FLI_BLOCK (1) #define FLI_NON_BLOCK (0) static long fli_stepmotor(flidev_t dev, long steps, long block); static long fli_getsteppos(flidev_t dev, long *pos); static long fli_setfilterpos(flidev_t dev, long pos); static long fli_getstepsremaining(flidev_t dev, long *pos); static long fli_focuser_getfocuserextent(flidev_t dev, long *extent); static long fli_focuser_readtemperature(flidev_t dev, flichannel_t channel, double *temperature); static long fli_getfilterpos(flidev_t dev, long *cslot); static long fli_getfiltername(flidev_t dev, long filter, char *name, size_t len); static long fli_filter_focuser_read_flash(flidev_t dev, long address, long length, void *buf) { long ret = 0; long addr; long len; unsigned char b[64]; for (addr = 0; (addr < length); addr += 16) { unsigned char eelen = (unsigned char) (((length - addr) > 16)?16:(length - addr)); b[0] = 0x00; b[1] = 0x00; b[2] = 0x02; b[3] = 0x00; b[4] = (unsigned char) (((address + addr) >> 8) & 0xff); b[5] = (unsigned char) (((address + addr)) & 0xff); b[6] = 0x00; b[7] = eelen; len = 8; /* Send the command */ if ((ret = FLIUsbBulkIO(dev, 0x02, b, &len)) != 0) { // debug(FLIDEBUG_WARN, " error %d!", GetLastError()); break; } len = eelen; /* Receive the reply */ if (((ret = FLIUsbBulkIO(dev, 0x82, b, &len)) != 0) || (len != eelen) ) { // debug(FLIDEBUG_WARN, " error %d!", GetLastError()); ret = 1; break; } memcpy(&((unsigned char *) buf)[addr], b, eelen); } return ret; } long fli_filter_focuser_probe(flidev_t dev) { int err = 0; long rlen, wlen; unsigned short buf[16]; CHKDEVICE(dev); DEVICE->io_timeout = 200; wlen = 2; rlen = 2; buf[0] = htons(0x8000); IO(dev, buf, &wlen, &rlen); if (ntohs(buf[0]) != 0x8000) { debug(FLIDEBUG_WARN, "Invalid echo, no FLI serial device found."); err = -ENODEV; } return err; } long fli_filter_focuser_open(flidev_t dev) { int err = 0; long rlen, wlen; unsigned short buf[16]; flifilterfocuserdata_t *fdata = NULL; CHKDEVICE(dev); DEVICE->io_timeout = 2000; wlen = 2; rlen = 2; buf[0] = htons(0x8000); IO(dev, buf, &wlen, &rlen); if (ntohs(buf[0]) != 0x8000) { debug(FLIDEBUG_WARN, "Invalid echo, device not recognized, got %04x instead of %04x.", ntohs(buf[0]), 0x8000); err = -ENODEV; goto done; } wlen = 2; rlen = 2; buf[0] = htons(0x8001); IO(dev, buf, &wlen, &rlen); DEVICE->devinfo.fwrev = ntohs(buf[0]); if ((DEVICE->devinfo.fwrev & 0xf000) != 0x8000) { debug(FLIDEBUG_WARN, "Invalid echo, device not recognized."); err = -ENODEV; goto done; } if ((DEVICE->device_data = xmalloc(sizeof(flifilterfocuserdata_t))) == NULL) { err = -ENOMEM; goto done; } memset(DEVICE->device_data, 0, sizeof(flifilterfocuserdata_t)); fdata = DEVICE->device_data; fdata->nameinfobuf = NULL; fdata->tableindex = -1; fdata->stepspersec = 100; fdata->currentslot = -1; // fdata->numslots = 0; // fdata->numslotswheel[0] = 0; // fdata->numslotswheel[1] = 0; if (DEVICE->devinfo.fwrev == 0x8001) /* Old level of firmware */ { if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { debug(FLIDEBUG_INFO, "Device detected is not filterwheel, old firmware?"); err = -ENODEV; goto done; } debug(FLIDEBUG_INFO, "Device is old fashioned filter wheel."); fdata->tableindex = 1; // FIX: should model info be set first? return 0; } debug(FLIDEBUG_INFO, "New version of hardware found."); debug(FLIDEBUG_INFO, "Internal FW Rev: 0x%04x", DEVICE->devinfo.fwrev); wlen = 2; rlen = 2; buf[0] = htons(0x8002); IO(dev, buf, &wlen, &rlen); fdata->hwtype = ntohs(buf[0]); if ((fdata->hwtype & 0xff00) != 0x8000) { err = -ENODEV; goto done; } /* ndev is either jumper settings or FW return code */ fdata->hwtype &= 0x00ff; switch (fdata->hwtype) { case 0x00: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 1; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x01: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 0; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x02: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 2; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x03: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 3; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x04: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 6; fdata->stepspersec= 16; // 1 /.06 fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x05: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 5; fdata->stepspersec= 16; // 1/.06 fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x06: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 4; fdata->stepspersec= 16; // 1/.06 fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x07: if (DEVICE->devinfo.type != FLIDEVICE_FOCUSER) { err = -ENODEV; goto done; } if ((DEVICE->devinfo.fwrev & 0x00ff) < 0x30) { fdata->extent = 2100; fdata->numtempsensors = 0; } else if ((DEVICE->devinfo.fwrev & 0x00ff) == 0x30) { fdata->extent = 7000; fdata->numtempsensors = 1; } else { fdata->extent = 7000; fdata->numtempsensors = 2; } debug(FLIDEBUG_INFO, "Extent: %d Steps/sec: %d Temp Sensors: %d", fdata->extent, fdata->stepspersec, fdata->numtempsensors); break; case 0x08: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 7; fdata->stepspersec= 20; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x09: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 8; fdata->stepspersec= 20; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0x0a: if (DEVICE->devinfo.type != FLIDEVICE_FILTERWHEEL) { err = -ENODEV; goto done; } fdata->tableindex = 9; fdata->stepspersec= 20; fdata->numslots = wheeldata[fdata->tableindex].n_pos; break; case 0xfe: case 0xff: /* This is a newer FLI filter or focuser wheen PCB */ if (DEVICE->devinfo.type == FLIDEVICE_FILTERWHEEL) { iobuf_t _buf[IOBUF_MAX_SIZ]; /* Get the number of filters */ if ((DEVICE->devinfo.fwrev & 0x00ff) < 0x43) { wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, 0x8008); IO(dev, _buf, &wlen, &rlen); IOREAD_U8(_buf, 1, fdata->numslots); fdata->numslotswheel[0] = fdata->numslots; fdata->numwheels = 1; fdata->activewheel = 0; } else { long status; CLEARIO; wlen = 4; rlen = 4; IOWRITE_U16(_buf, 0, 0x8008); IO(dev, _buf, &wlen, &rlen); IOREAD_U8(_buf, 1, fdata->numslots); IOREAD_U8(_buf, 2, fdata->numslotswheel[0]); IOREAD_U8(_buf, 3, fdata->numslotswheel[1]); fdata->numwheels = 0; if (fdata->numslotswheel[0] > 0) fdata->numwheels ++; if (fdata->numslotswheel[1] > 0) fdata->numwheels ++; fdata->activewheel = 0; /* Get the status, we may not need to re-home */ wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, 0xb000); IO(dev, _buf, &wlen, &rlen); IOREAD_U16(_buf, 0, status); if (status & FLI_FILTER_STATUS_HOME_SUCCEEDED) { debug(FLIDEBUG_INFO, "Filter wheel has previously been homed, no need to re-home."); /* We have successfully homed */ fdata->currentslot = 0; } } } else if (DEVICE->devinfo.type == FLIDEVICE_FOCUSER) { iobuf_t _buf[IOBUF_MAX_SIZ]; /* Pre-Atlas */ if ((DEVICE->devinfo.fwrev & 0x00ff) < 0x40) { wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, 0x8006); IO(dev, _buf, &wlen, &rlen); IOREAD_U16(_buf, 0, fdata->extent); } else /* Post-Atlas */ { wlen = 4; rlen = 4; IOWRITE_U16(_buf, 0, 0x8006); IOWRITE_U16(_buf, 2, 0); IO(dev, _buf, &wlen, &rlen); IOREAD_U32(_buf, 0, fdata->extent); } /* Get the number of temperature sensors */ wlen = 2; rlen = 2; buf[0] = htons(0x800a); IO(dev, buf, &wlen, &rlen); fdata->numtempsensors = ntohs(buf[0]) & 0x00ff; } else { err = -ENODEV; goto done; } /* Step rate */ wlen = 2; rlen = 2; buf[0] = htons(0x8009); IO(dev, buf, &wlen, &rlen); fdata->stepspersec = ntohs(buf[0]) & 0x7fff; debug(FLIDEBUG_INFO, "Extent: %d Steps/sec: %d Temp Sensors: %d", fdata->extent, fdata->stepspersec, fdata->numtempsensors); fdata->tableindex = (-1); break; default: debug(FLIDEBUG_FAIL, "Unknown device %d attached.", fdata->hwtype); err = -ENODEV; goto done; } /* Now get the model name, either construct it or get it from device. */ if (err == 0) { if (fdata->hwtype < 0xfe) /* Older style hardware */ { if (DEVICE->devinfo.type == FLIDEVICE_FILTERWHEEL) { if ((DEVICE->devinfo.fwrev & 0x00ff) <= 0x30) { if (xasprintf(&DEVICE->devinfo.model, "Filter Wheel (%ld position)", fdata->numslots) < 0) { debug(FLIDEBUG_WARN, "Could not allocate memory for model information."); } } if ((DEVICE->devinfo.fwrev & 0x00ff) >= 0x31) { if ((DEVICE->devinfo.model = (char *) xmalloc(33)) == NULL) { debug(FLIDEBUG_WARN, "Could not allocate memory for model information."); } else { memset(DEVICE->devinfo.model, '\0', 33); wlen = 2; rlen = 32; DEVICE->devinfo.model[0] = 0x80; DEVICE->devinfo.model[1] = 0x03; IO(dev, DEVICE->devinfo.model, &wlen, &rlen); } } } if (DEVICE->devinfo.type == FLIDEVICE_FOCUSER) { if (xasprintf(&DEVICE->devinfo.model, "FLI Focuser") < 0) { debug(FLIDEBUG_WARN, "Could not allocate memory for model information."); } } } else /* Newer style hardware */ { if ((DEVICE->devinfo.model = (char *) xmalloc(33)) == NULL) { debug(FLIDEBUG_WARN, "Could not allocate memory for model information."); } else { memset(DEVICE->devinfo.model, '\0', 33); wlen = 2; rlen = 32; DEVICE->devinfo.model[0] = 0x80; DEVICE->devinfo.model[1] = 0x03; IO(dev, DEVICE->devinfo.model, &wlen, &rlen); } } } done: if (err) { if (DEVICE->devinfo.model != NULL) { xfree(DEVICE->devinfo.model); DEVICE->devinfo.model = NULL; } if (DEVICE->device_data != NULL) { xfree(DEVICE->device_data); DEVICE->device_data = NULL; } return err; } debug(FLIDEBUG_INFO, "Found '%s'", DEVICE->devinfo.model); return 0; } long fli_filter_focuser_close(flidev_t dev) { CHKDEVICE(dev); if (DEVICE->devinfo.model != NULL) { xfree(DEVICE->devinfo.model); DEVICE->devinfo.model = NULL; } if (DEVICE->device_data != NULL) { flifilterfocuserdata_t *fdata; fdata = DEVICE->device_data; if (fdata->nameinfobuf != NULL) { xfree(fdata->nameinfobuf); fdata->nameinfobuf = NULL; } xfree(DEVICE->device_data); DEVICE->device_data = NULL; } return 0; } long fli_filter_command(flidev_t dev, int cmd, int argc, ...) { flifilterfocuserdata_t *fdata; long r; va_list ap; va_start(ap, argc); CHKDEVICE(dev); fdata = DEVICE->device_data; switch (cmd) { case FLI_SET_FILTER_POS: if (argc != 1) r = -EINVAL; else { long pos; pos = *va_arg(ap, long *); r = fli_setfilterpos(dev, pos); } break; case FLI_GET_FILTER_POS: if (argc != 1) r = -EINVAL; else { long *cslot; cslot = va_arg(ap, long *); // *cslot = fdata->currentslot; // r = 0; r = fli_getfilterpos(dev, cslot); } break; case FLI_GET_FILTER_COUNT: if (argc != 1) r = -EINVAL; else { long *nslots; nslots = va_arg(ap, long *); *nslots = 0; r = 0; if (fdata->activewheel == 0) { *nslots = fdata->numslots; } else { if ((fdata->activewheel & 0xff) < fdata->numwheels) { *nslots = fdata->numslotswheel[fdata->activewheel & 0xff]; } else { r = -EINVAL; } } } break; case FLI_STEP_MOTOR: if (argc != 1) r = -EINVAL; else { long *steps; steps = va_arg(ap, long *); r = fli_stepmotor(dev, *steps, FLI_BLOCK); } break; case FLI_STEP_MOTOR_ASYNC: if (argc != 1) r = -EINVAL; else { long *steps; steps = va_arg(ap, long *); r = fli_stepmotor(dev, *steps, FLI_NON_BLOCK); } break; case FLI_GET_STEPPER_POS: if (argc != 1) r = -EINVAL; else { long *pos; pos = va_arg(ap, long *); r = fli_getsteppos(dev, pos); } break; case FLI_GET_ACTIVE_WHEEL: if (argc != 1) r = -EINVAL; else { long *wheel; wheel = va_arg(ap, long *); *wheel = fdata->activewheel; r = 0; } break; case FLI_SET_ACTIVE_WHEEL: if (argc != 1) r = -EINVAL; else { long wheel; wheel = *va_arg(ap, long *); r = 0; if (wheel & FLI_FILTER_WHEEL_PHYSICAL) { if ((wheel & 0xff) < fdata->numwheels) { fdata->activewheel = wheel; } else { r = -EINVAL; } } else { if (wheel & 0xff) r = -EINVAL; else { fdata->activewheel = wheel; } } } break; case FLI_GET_STEPS_REMAINING: if (argc != 1) r = -EINVAL; else { long *pos; pos = va_arg(ap, long *); r = fli_getstepsremaining(dev, pos); } break; case FLI_HOME_DEVICE: if (argc != 0) r = -EINVAL; else r = fli_homedevice(dev, FLI_NON_BLOCK); break; case FLI_GET_STATUS: if (argc != 1) r = -EINVAL; else { flistatus_t *status; status = va_arg(ap, flistatus_t *); r = fli_getstepperstatus(dev, status); } break; case FLI_GET_FILTER_NAME: if (argc != 3) r = -EINVAL; else { long filter; char *name; size_t len; filter = va_arg(ap, flimode_t); name = va_arg(ap, char *); len = va_arg(ap, size_t); memset(name, '\0', len); r = fli_getfiltername(dev, filter, name, len); } break; default: r = -EINVAL; } va_end(ap); return r; } long fli_focuser_command(flidev_t dev, int cmd, int argc, ...) { long r; va_list ap; va_start(ap, argc); CHKDEVICE(dev); switch (cmd) { case FLI_STEP_MOTOR: if (argc != 1) r = -EINVAL; else { long *steps; steps = va_arg(ap, long *); r = fli_stepmotor(dev, *steps, FLI_BLOCK); } break; case FLI_STEP_MOTOR_ASYNC: if (argc != 1) r = -EINVAL; else { long *steps; steps = va_arg(ap, long *); r = fli_stepmotor(dev, *steps, FLI_NON_BLOCK); } break; case FLI_GET_STEPPER_POS: if (argc != 1) r = -EINVAL; else { long *pos; pos = va_arg(ap, long *); r = fli_getsteppos(dev, pos); } break; case FLI_GET_STEPS_REMAINING: if (argc != 1) r = -EINVAL; else { long *pos; pos = va_arg(ap, long *); r = fli_getstepsremaining(dev, pos); } break; case FLI_GET_FOCUSER_EXTENT: if (argc != 1) r = -EINVAL; else { long *extent; extent = va_arg(ap, long *); r = fli_focuser_getfocuserextent(dev, extent); } break; case FLI_HOME_FOCUSER: if (argc != 0) r = -EINVAL; else r = fli_homedevice(dev, FLI_BLOCK); break; case FLI_HOME_DEVICE: if (argc != 0) r = -EINVAL; else r = fli_homedevice(dev, FLI_NON_BLOCK); break; case FLI_READ_TEMPERATURE: if (argc != 2) r = -EINVAL; else { double *temperature; flichannel_t channel; channel = va_arg(ap, flichannel_t); temperature = va_arg(ap, double *); r = fli_focuser_readtemperature(dev, channel, temperature); } break; case FLI_GET_STATUS: if (argc != 1) r = -EINVAL; else { flistatus_t *status; status = va_arg(ap, flistatus_t *); r = fli_getstepperstatus(dev, status); } break; default: r = -EINVAL; } va_end(ap); return r; } static long fli_stepmotor(flidev_t dev, long steps, long block) { flifilterfocuserdata_t *fdata; long dir, timeout, move, stepsleft; long rlen, wlen; unsigned short buf[16]; iobuf_t _buf[IOBUF_MAX_SIZ]; clock_t begin; fdata = DEVICE->device_data; /* Let's take care of old hardware first */ if ((fdata->hwtype < 0xfe) || ((fdata->hwtype >= 0xfe) && ((DEVICE->devinfo.fwrev & 0x00ff) < 0x43)) ) { if (steps == 0) /* Support HALT operation when steps == 0 */ { rlen = 2; wlen = 2; buf[0] = htons((unsigned short) 0xa000); IO(dev, buf, &wlen, &rlen); if ((ntohs(buf[0]) & 0xf000) != 0xa000) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } return 0; } dir = steps; steps = labs(steps); while (steps > 0) { if ((steps > 4095) && (fdata->extent < 10000)) move = 4095; else move = steps; steps -= move; timeout = (move / fdata->stepspersec) + 2; rlen = 2; wlen = 2; if (dir < 0) { if (move > 4095) { wlen = 4; rlen = 2; IOWRITE_U16(_buf, 0, (0xa000 | ((move >> 16) & 0x00ff))); IOWRITE_U16(_buf, 2, (move & 0x00ffff)); } else { wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, (0xa000 | (move & 0x0fff))); } IO(dev, _buf, &wlen, &rlen); if (_buf[0] != 0xa0) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } } else { if (move > 4095) { wlen = 4; rlen = 2; IOWRITE_U16(_buf, 0, (0x9000 | ((move >> 16) & 0x00ff))); IOWRITE_U16(_buf, 2, (move & 0x00ffff)); } else { wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, (0x9000 | (move & 0x0fff))); } IO(dev, _buf, &wlen, &rlen); if (_buf[0] != 0x90) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } // buf[0] = htons((unsigned short) (0x9000 | (unsigned short) move)); // IO(dev, buf, &wlen, &rlen); // if ((ntohs(buf[0]) & 0xf000) != 0x9000) // { // debug(FLIDEBUG_WARN, "Invalid echo."); // return -EIO; // } } if (fdata->extent >= 10000) /* Atlas or other */ { /* Old Atlas have race condition which will result in error on return * indicating that the device is not moving when it is. */ // debug(FLIDEBUG_INFO, "FWREV: 0x%02x", DEVICE->devinfo.fwrev); if ((DEVICE->devinfo.fwrev & 0x0fff) < 0x42) { #ifdef _WIN32 Sleep(50); #else usleep(50000); #endif } } begin = clock(); stepsleft = 0; while ( (stepsleft != 0x7000) && (block != 0) ) { #ifdef _WIN32 Sleep(100); #else usleep(100000); #endif buf[0] = htons(0x7000); IO(dev, buf, &wlen, &rlen); stepsleft = ntohs(buf[0]); if (((clock() - begin) / CLOCKS_PER_SEC) > (clock_t)timeout) { debug(FLIDEBUG_WARN, "A device timeout has occurred."); return -EIO; } } } } else /* Newer firmware */ { unsigned short cmd; dir = steps; steps = labs(steps); if (dir < 0) { cmd = 0xa000; } else { cmd = 0x9000; } /* This is a hack, clean it up sometime */ wlen = 8; rlen = 2; if ((fdata->activewheel & 0xff) == 0) { IOWRITE_U16(_buf, 0, (cmd | ((steps >> 16) & 0x00ff))); IOWRITE_U16(_buf, 2, (steps & 0x00ffff)); IOWRITE_U32(_buf, 4, 0); } else { IOWRITE_U16(_buf, 0, cmd); IOWRITE_U16(_buf, 2, 0); IOWRITE_U32(_buf, 4, (steps & 0x00ffffff)); } IO(dev, _buf, &wlen, &rlen); if (_buf[0] != ((cmd >> 8) & 0xff)) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } stepsleft = -1; while ( (stepsleft != 0) && (block != 0) ) { #ifdef _WIN32 Sleep(100); #else usleep(100000); #endif CLEARIO; wlen = 12; rlen = 12; IOWRITE_U16(_buf, 0, 0x7000); IO(dev, _buf, &wlen, &rlen); IOREAD_U32(_buf, 0, stepsleft); stepsleft &= 0x00ffffff; // if (((clock() - begin) / CLOCKS_PER_SEC) > timeout) // { // debug(FLIDEBUG_WARN, "A device timeout has occurred."); // return -EIO; // } } } return 0; } static long fli_getsteppos(flidev_t dev, long *pos) { long poslow, poshigh; long rlen, wlen; unsigned short buf[16]; /* Pre-Atlas */ if ((DEVICE->devinfo.fwrev & 0x00ff) < 0x40) { rlen = 2; wlen = 2; buf[0] = htons(0x6000); IO(dev, buf, &wlen, &rlen); poslow = ntohs(buf[0]); if ((poslow & 0xf000) != 0x6000) return -EIO; buf[0] = htons(0x6001); IO(dev, buf, &wlen, &rlen); poshigh = ntohs(buf[0]); if ((poshigh & 0xf000) != 0x6000) return -EIO; if ((poshigh & 0x0080) > 0) { *pos = ((~poslow) & 0xff) + 1; *pos += (256 * ((~poshigh) & 0xff)); *pos = -(*pos); } else { *pos = (poslow & 0xff) + 256 * (poshigh & 0xff); } } else /* Post-Atlas */ { iobuf_t _buf[IOBUF_MAX_SIZ]; wlen = 4; rlen = 4; IOWRITE_U16(_buf, 0, 0x6000); IOWRITE_U16(_buf, 2, 0); IO(dev, _buf, &wlen, &rlen); IOREAD_U32(_buf, 0, *pos); } return 0; } static long fli_getstepsremaining(flidev_t dev, long *pos) { long rlen = 2, wlen = 2; unsigned short buf[16]; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif if ( (DEVICE->devinfo.fwrev & 0x00ff) < 0x40) { buf[0] = htons(0x7000); IO(dev, buf, &wlen, &rlen); *pos = ntohs(buf[0]) & 0x0fff; } else { iobuf_t _buf[IOBUF_MAX_SIZ]; wlen = 4; rlen = 4; IOWRITE_U16(_buf, 0, 0x7000); IOWRITE_U16(_buf, 2, 0); IO(dev, _buf, &wlen, &rlen); IOREAD_U32(_buf, 0, *pos); *pos &= 0x0fffffff; } return 0; } static long fli_homedevice(flidev_t dev, long block) { flifilterfocuserdata_t *fdata; long rlen, wlen; unsigned short buf[16]; fdata = DEVICE->device_data; /* Older hardware */ if (fdata->hwtype < 0xfe) { debug(FLIDEBUG_INFO, "Home filter wheel/focuser."); if (DEVICE->devinfo.type == FLIDEVICE_FILTERWHEEL) { switch (fdata->numslots) { case 12: case 10: DEVICE->io_timeout = 120000; break; case 15: DEVICE->io_timeout = 200000; break; default: DEVICE->io_timeout = 5000; break; } } else { DEVICE->io_timeout = 30000; } wlen = 2; rlen = 2; buf[0] = htons(0xf000); IO(dev, buf, &wlen, &rlen); if (ntohs(buf[0]) != 0xf000) return -EIO; /* Reduce overall timeout to speed operations with serial port */ DEVICE->io_timeout = 200; /* This is required to prevent offsetting the focuser */ if (DEVICE->devinfo.type != FLIDEVICE_FOCUSER) { debug(FLIDEBUG_INFO, "Moving %d steps to home position.", wheeldata[fdata->tableindex].n_offset); COMMAND(fli_stepmotor(dev, - (wheeldata[fdata->tableindex].n_offset), FLI_BLOCK)); fdata->currentslot = 0; } } else /* New HW */ { clock_t begin; unsigned short stepsleft; rlen = 2; wlen = 2; buf[0] = htons((unsigned short) 0xf000); IO(dev, buf, &wlen, &rlen); if ((ntohs(buf[0]) & 0xf000) != 0xf000) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } begin = clock(); stepsleft = 0x04; while ( ((stepsleft & 0x04) != 0) && (block != 0) ) { #ifdef _WIN32 Sleep(100); #else usleep(100000); #endif buf[0] = htons(0xb000); IO(dev, buf, &wlen, &rlen); stepsleft = ntohs(buf[0]); } fdata->currentslot = 0; } return 0; } static long fli_getstepperstatus(flidev_t dev, flistatus_t *status) { flifilterfocuserdata_t *fdata; long rlen, wlen, r = 0; unsigned char buf[16]; fdata = DEVICE->device_data; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif /* Older hardware */ if (fdata->hwtype < 0xfe) { long pos = 0; if ((r = fli_getstepsremaining(dev, &pos)) == 0) { *status = FLI_FOCUSER_STATUS_LEGACY; if (pos != 0) { /* We can't be sure of the direction */ *status |= FLI_FOCUSER_STATUS_MOVING_IN | FLI_FOCUSER_STATUS_MOVING_OUT; } } else { *status = FLI_FOCUSER_STATUS_UNKNOWN; } } else /* New HW */ { wlen = 2; rlen = 2; buf[0] = 0xb0; buf[1] = 0x00; IO(dev, buf, &wlen, &rlen); *status = ((long) buf[1]) & 0xff; } return r; } static long fli_setfilterpos(flidev_t dev, long pos) { flifilterfocuserdata_t *fdata; long rlen, wlen; // unsigned short buf[16]; long move, i, steps; fdata = DEVICE->device_data; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif if (pos == FLI_FILTERPOSITION_HOME) fdata->currentslot = FLI_FILTERPOSITION_HOME; if (fdata->currentslot < 0) { fli_homedevice(dev, FLI_BLOCK); } if (pos == FLI_FILTERPOSITION_HOME) return 0; /* This is for very old hardware, let's not tread here too much */ if (fdata->hwtype < 0xfe) { if (pos >= fdata->numslots) { debug(FLIDEBUG_WARN, "Requested slot (%d) exceeds number of slots.", pos); return -EINVAL; } if (pos == fdata->currentslot) return 0; move = pos - fdata->currentslot; if (move < 0) move += fdata->numslots; steps = 0; if (fdata->numslots != 0) for (i=0; i < move; i++) steps += wheeldata[fdata->tableindex].n_steps[i % fdata->numslots]; debug(FLIDEBUG_INFO, "Move filter wheel %d steps.", steps); if (steps != 0) COMMAND(fli_stepmotor(dev, - (steps), FLI_BLOCK)); fdata->currentslot = pos; } else /* This is for newer hardware. The newer hardware is in general asynchronous which is a good thing, this allows this function to also be asyncronous... */ { unsigned short stepsleft; iobuf_t _buf[IOBUF_MAX_SIZ]; CLEARIO; if ( ((DEVICE->devinfo.fwrev & 0x00ff) < 0x43) || /* Older style CFW */ ((fdata->activewheel & FLI_FILTER_WHEEL_PHYSICAL) == 0) ) /* Table indexed wheel */ { if (pos >= fdata->numslots) { debug(FLIDEBUG_WARN, "Requested slot (%d) exceeds number of slots.", pos); return -EINVAL; } /* We shouldn't need to double check that we are at that slot. */ // if (pos == fdata->currentslot) // return 0; wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, (0xc000 | (unsigned short) pos)); IO(dev, _buf, &wlen, &rlen); IOREAD_U16(_buf, 0, stepsleft); if ((stepsleft & 0xf000) != 0xc000) { debug(FLIDEBUG_WARN, "Invalid echo."); return -EIO; } } else /* Individual wheel control */ { wlen = 4; rlen = 2; IOWRITE_U16(_buf, 0, 0xc000); if ((fdata->activewheel & 0xff) == 0) { if (pos >= fdata->numslotswheel[0]) { debug(FLIDEBUG_WARN, "Requested slot (%d) exceeds number of slots.", pos); } IOWRITE_U8(_buf, 2, pos); IOWRITE_U8(_buf, 3, FLI_FILTER_POSITION_UNKNOWN); } else { if (pos >= fdata->numslotswheel[1]) { debug(FLIDEBUG_WARN, "Requested slot (%d) exceeds number of slots.", pos); } IOWRITE_U8(_buf, 2, FLI_FILTER_POSITION_UNKNOWN); IOWRITE_U8(_buf, 3, pos); } IO(dev, _buf, &wlen, &rlen); } stepsleft = 0; while (stepsleft != 0x7000) { #ifdef _WIN32 Sleep(100); #else usleep(100000); #endif CLEARIO; wlen = 2; rlen = 2; IOWRITE_U16(_buf, 0, 0x7000); IO(dev, _buf, &wlen, &rlen); IOREAD_U16(_buf, 0, stepsleft); } fdata->currentslot = pos; } return 0; } long fli_focuser_getfocuserextent(flidev_t dev, long *extent) { flifilterfocuserdata_t *fdata; fdata = DEVICE->device_data; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif *extent = fdata->extent; return 0; } long fli_focuser_readtemperature(flidev_t dev, flichannel_t channel, double *temperature) { flifilterfocuserdata_t *fdata; long rlen, wlen; short buf[64]; short b; int i; fdata = DEVICE->device_data; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif if (fdata->numtempsensors == 0) { debug(FLIDEBUG_WARN, "This device does not support temperature reading."); return -EINVAL; } if (channel > fdata->numtempsensors) { debug(FLIDEBUG_WARN, "Device has %d channels, %d channel requested.", fdata->numtempsensors, channel); return -EINVAL; } if (fdata->hwtype == 0xff) { wlen = 2; rlen = 2; buf[0] = htons(0x1000 | (unsigned short) channel); IO(dev, buf, &wlen, &rlen); *temperature = (double) ((signed char) (buf[0] & 0x00ff)) + ((double) ((buf[0] >> 8) & 0x00ff) / 256); debug(FLIDEBUG_INFO, "Temperature: %f", *temperature); } else if (fdata->hwtype == 0x07) { if ((DEVICE->devinfo.fwrev & 0x00ff) == 0x30) { wlen = 2; rlen = 2; buf[0] = htons(0x1000 | (unsigned short) channel); IO(dev, buf, &wlen, &rlen); b = ntohs(buf[0]); *temperature = (double) b / 256.0; if (*temperature < -45.0) { return -EINVAL; } } if ((DEVICE->devinfo.fwrev & 0x00ff) > 0x30) { /* Ok, some constants are sent back with each temperature reading */ wlen = 2; rlen = 2 + 4 * 7; buf[0] = htons(0x1000 | (unsigned short) channel); IO(dev, buf, &wlen, &rlen); b = ntohs(buf[0]); *temperature = 0.0; for (i = 0; i < 7; i++) { *temperature += dconvert(((char *) buf) + (2 + i * 4)) * pow((double) b, (double) i); } if (*temperature < (-45.0)) { debug(FLIDEBUG_WARN, "External sensor not plugged in."); return -EINVAL; } } } return 0; } static long fli_getfiltername(flidev_t dev, long filter, char *name, size_t len) { flifilterfocuserdata_t *fdata; long r = 0; fdata = DEVICE->device_data; /* Clear the destination */ memset(name, '\0', len); /* Older Hardware */ if ((fdata->hwtype < 0xfe) || ((fdata->hwtype >= 0xfe) && ((DEVICE->devinfo.fwrev & 0x00ff) < 0x43)) ) { if (filter == FLI_FILTER_POSITION_CURRENT) { if (fdata->currentslot >= 0) { snprintf(name, len - 1, "Slot %ld", filter); } else { snprintf(name, len - 1, "Unknown"); } } else if (filter < fdata->numslots) { snprintf(name, len - 1, "Slot %ld", filter); } } else { long _filter = FLI_FILTER_POSITION_UNKNOWN; /* Ok, we need to download information from the filter wheel */ if (fdata->nameinfobuf == NULL) { /* Allocate the storage */ if ((fdata->nameinfobuf = xmalloc(1024)) == NULL) { r = -ENOMEM; goto done; } debug(FLIDEBUG_INFO, "Downloading name table from filter wheel."); if ((r = fli_filter_focuser_read_flash(dev, 0x3000, 1024, fdata->nameinfobuf)) != 0) { xfree(fdata->nameinfobuf); fdata->nameinfobuf = NULL; goto done; } } if (filter == FLI_FILTER_POSITION_CURRENT) { /* Let's get the wheel we want to know */ r = fli_getfilterpos(dev, &_filter); if (r) goto done; } else { _filter = filter & 0xff; } /* Physical filter */ if (fdata->activewheel & FLI_FILTER_WHEEL_PHYSICAL) { if (_filter < fdata->numslotswheel[fdata->activewheel & 0x01]) { long to; to = 256 * (fdata->activewheel & 0x01) + (8 * _filter); strncpy(name, fdata->nameinfobuf + to, (len < 8)?len:8); } else { r = -EINVAL; goto done; } } else /* Virtual filter */ { long wp0, wp1, to, ti; long bi = 0; if (_filter >= fdata->numslots) { r = -EINVAL; goto done; } to = 512 + (_filter * 2); wp0 = *(fdata->nameinfobuf + to); wp1 = *(fdata->nameinfobuf + to + 1); if (wp0 < fdata->numslotswheel[0]) { to = 0 + wp0 * 8; ti = 0; while ((ti < 8) && (bi < (long) len) && (*(fdata->nameinfobuf + to + ti) != '\0')) { *(name + bi) = *(fdata->nameinfobuf + to + ti); bi ++; ti ++; } } if ((wp1 < fdata->numslotswheel[1]) && (bi < (long) len)) { to = 256 + wp1 * 8; if ((bi != 0) && (*(fdata->nameinfobuf + to) != '\0')) { name[bi] = '/'; bi ++; } ti = 0; while ((ti < 8) && (bi < (long) len) && (*(fdata->nameinfobuf + to + ti) != '\0')) { *(name + bi) = *(fdata->nameinfobuf + to + ti); bi ++; ti ++; } } } } done: return r; } static long fli_getfilterpos(flidev_t dev, long *cslot) { flifilterfocuserdata_t *fdata; iobuf_t buf[IOBUF_MAX_SIZ]; long r = 0; fdata = DEVICE->device_data; memset (buf, 0, IOBUF_MAX_SIZ); *cslot = 0; /* Centerline and more recent filter wheels support an actual query from the hardware for this */ if ((fdata->hwtype < 0xfe) || ((fdata->hwtype >= 0xfe) && ((DEVICE->devinfo.fwrev & 0x00ff) < 0x43)) ) { *cslot = fdata->currentslot; } else { long rlen, wlen; wlen = 12; rlen = 12; IOWRITE_U16(buf, 0, 0x6000); IO(dev, buf, &wlen, &rlen); if (fdata->activewheel & FLI_FILTER_WHEEL_PHYSICAL) /* Simple or virtual wheel */ { switch (fdata->activewheel & 0xff) { case 0: IOREAD_U8(buf, 10, *cslot); break; case 1: IOREAD_U8(buf, 11, *cslot); break; default: r = -EINVAL; break; } } else if ((fdata->activewheel & 0xff) == 0) { IOREAD_U8(buf, 9, *cslot); } else { r = -EINVAL; } } return r; } libfli-2.0+20221221182632/.cproject0000644000175100017510000007462314174600256015254 0ustar debiandebian libfli-2.0+20221221182632/docxx.sty0000644000175100017510000007726714174600256015337 0ustar debiandebian\usepackage{pslatex} \newif\ifpdf \ifx\pdfoutput\undefined \pdffalse \else \pdfoutput=1 \pdfcompresslevel=9 \pdftrue \fi \ifpdf %% \usepackage[pdftex]{hyperref} % % \hypersetup{bookmarks=false} % \hypersetup{pdfpagemode=None} % \hypersetup{pdfstartview=FitH} % \hypersetup{pdfview=FitH} \else %% \usepackage[dvips]{hyperref} \fi % docxx.sty % % Copyright (c) 1996 Roland Wunderling, Malte Zoeckler % Copyright (c) 1999-2000 Dragos Acostachioaie % % This file is part of DOC++. % % DOC++ is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public % License as published by the Free Software Foundation; either % version 2 of the license, or (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % % You should have received a copy of the GNU General Public % License along with this program; if not, write to the Free % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. % % % Switch off special characters except {}\ for the rest of the text. % \def\cxxtilde{{\tt\~\relax}} \addtolength{\parskip}{6pt} \catcode`\,=\active% \def,{\char`\,\penalty-8\ } %\def,{++ } \catcode`\,=12 \def\<{{\tt <}} \def\>{{\tt >}} \def\TEX{} \def\cxxExceptionsStr{} \def\cxxParameterStr{} \def\cxxReturnStr{} \def\cxxInvariantsStr{} \def\cxxPreconditionsStr{} \def\cxxPostconditionsStr{} \def\cxxSeeStr{} \def\cxxAuthorStr{} \def\cxxVersionStr{} \def\cxxDeprecatedStr{} \def\cxxSinceStr{} \def\cxxFileStr{} \def\cxxExceptions#1{\def\cxxExceptionsStr{#1}} \def\cxxParameter#1{\def\cxxParameterStr{#1}} \def\cxxReturn#1{\def\cxxReturnStr{#1}} \def\cxxInvariants#1{\def\cxxInvariantsStr{#1}} \def\cxxPreconditions#1{\def\cxxPreconditionsStr{#1}} \def\cxxPostconditions#1{\def\cxxPostconditionsStr{#1}} \def\cxxSee#1{\def\cxxSeeStr{#1}} \def\cxxAuthor#1{\def\cxxAuthorStr{#1}} \def\cxxVersion#1{\def\cxxVersionStr{#1}} \def\cxxDeprecated#1{\def\cxxDeprecatedStr{#1}} \def\cxxSince#1{\def\cxxSinceStr{#1}} \def\cxxFile#1{\def\cxxFileStr{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Define ... to do verbatim listing % \catcode`\=\active \catcode`\=\active {\obeyspaces\gdef {\ }} \def\ccverbatim{\strut\begingroup \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\$=12 \catcode`\&=12 \catcode`\#=12 \catcode`\%=12 \catcode`\~=12 \catcode`\_=12 \catcode`\^=12 \catcode`\|=12 \catcode`\/=12 \obeyspaces\tt} \def{\let\par=\endgraf \ccverbatim \parskip=0pt \ccfinish} {\catcode`\=0 catcode`\=12 gdefccfinish#1{#1endgroup}} % % Definition of structuring comands. % \newcommand{\Section}[1]{\section{#1}} \newcommand{\SubSection}[1]{\subsection{#1}} \newcommand{\SubSubSection}[1]{\subsubsection{#1}} \newcommand{\Paragraph}[1]{\paragraph{#1}} \newcommand{\Ref}[1]{{\bf #1} ($\rightarrow$ \ref{#1})} \newcommand{\URL}[2][]{% \def\name{#1}% \def\empty{}% \ifx\name\empty% {\tt #2}% \else% #1 ({\tt #2})% \fi% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % printing line #1 of code #2 % \newdimen\cxxcodewidth \cxxcodewidth=\textwidth \advance\cxxcodewidth by -21pt \def\cxxCodeLine#1#2{% {\hbox to 20pt{\tiny\hss#1}\parbox[t]{\cxxcodewidth}{\small#2}}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for listing manual entries % \newdimen\cxxIdWidth \newdimen\cxxTypeWidth \newdimen\cxxProtoWidth \newdimen\cxxMemoWidth \newdimen\cxxPageWidth \cxxIdWidth=0.1\textwidth \cxxTypeWidth=0.15\textwidth \cxxProtoWidth=0.25\textwidth \cxxMemoWidth=0.43\textwidth \cxxPageWidth=\textwidth \advance\cxxPageWidth by-\cxxIdWidth \advance\cxxPageWidth by-\cxxTypeWidth \advance\cxxPageWidth by-\cxxProtoWidth \advance\cxxPageWidth by-\cxxMemoWidth \newdimen\cxxProtoMemoWidth \cxxProtoMemoWidth=\cxxProtoWidth \advance\cxxProtoMemoWidth by\cxxMemoWidth \def\cxxStrut{\vrule width0pt height0pt depth9pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1: type % 2: name % 3: args % 4: memo % 5: id \def\cxxitem#1#2#3#4#5{\noindent{% \setbox5\hbox{#5 }% \ifdim\wd5>\cxxIdWidth% \setbox5\hbox{\hbox to \cxxIdWidth{\hss#5}}% \else \setbox5\hbox{\hbox to \cxxIdWidth{#5\hss}}% \fi% \setbox1\hbox{{% \catcode`\&=4% \catcode`\_=8% \def{\ccverbatim \ccfinish}#1% }}% \setbox2\hbox{{% \catcode`\&=4% \catcode`\_=8% \def{\ccverbatim \ccfinish}\textbf{#2} #3% }}% \setbox4\hbox{\parbox[t]{\cxxMemoWidth}{{% \raggedright\sloppy% \catcode`\&=4% \catcode`\_=8% \def{\ccverbatim \ccfinish}{\em #4} \cxxStrut% \def\page{#5}% \ifx\page\empty% \hss% \else% \ \dotfill% \hbox to 0pt{\hbox to \cxxPageWidth{\hss% \pageref{cxx.#5}% }\hss}% \fi% }}}% % \ifdim\wd1>\cxxTypeWidth% \hbox to \hsize{\unhbox5\hbox to \cxxTypeWidth{\unhbox1\hss}\hss}\\\nopagebreak% \setbox5\hbox{\hskip\cxxIdWidth}% \setbox1\hbox{\hskip\cxxTypeWidth}% \else% \setbox1\hbox{\hbox to \cxxTypeWidth{\unhbox1\hss}}% \fi% \ifdim\wd2>\cxxProtoWidth% \ifdim\wd2<\cxxProtoMemoWidth% \def\tmp{#4}% \ifx\tmp\empty% \def\tmp{#5}% \ifx\tmp\empty% \hbox to \hsize{\unhbox5\unhbox1\unhbox2\hss\cxxStrut}\\% \else% \hbox to \hsize{\unhbox5\unhbox1\unhbox2 \dotfill\hbox to \cxxPageWidth{\hss\pageref{cxx.#5}}% \cxxStrut}\\% \fi% \else% \hbox to \hsize{\unhbox5\unhbox1\unhbox2\hss}\\\nopagebreak% \hbox to \hsize{% \hskip\cxxIdWidth% \hskip\cxxTypeWidth% \hskip\cxxProtoWidth% \unhbox4\hss% }\\% \fi% \else% \hbox to \hsize{% \unhbox5% \unhbox1% \parbox[t]{\cxxProtoMemoWidth}{% \setbox255\hbox{\textbf{#2} (}% \hangindent=\wd255\hangafter=1% \raggedright\sloppy% {\catcode`\&=4\catcode`\_=8% \def{\ccverbatim \ccfinish}\textbf{#2} #3\strut}% }\hss% }\\\nopagebreak% \hbox to \hsize{% \hskip\cxxIdWidth% \hskip\cxxTypeWidth% \hskip\cxxProtoWidth% \unhbox4\hss% }\\% \fi% \else% \hbox to \hsize{% \unhbox5% \unhbox1% \hbox to \cxxProtoWidth{\unhbox2\hss}% \unhbox4\hss% }\\% \fi% }} \newdimen\cxxtypestart \cxxtypestart=0.05\textwidth %\advance\cxxtypestart by \labelsep \newdimen\cxxnamestart \cxxnamestart=\cxxtypestart \advance\cxxnamestart by 0.25\textwidth \newdimen\cxxargsstart \cxxargsstart=\cxxnamestart \advance\cxxargsstart by 0.2\textwidth \newdimen\cxxargswidth \cxxargswidth=\textwidth \advance\cxxargswidth by -\cxxargsstart \advance\cxxargswidth by -\spaceskip \newdimen\cxxmemostart \cxxmemostart=\cxxargsstart \advance\cxxmemostart by 0.12\textwidth \newenvironment{cxxlist}[1]{ \begingroup \catcode`\,=\active% \paragraph{#1}\strut\smallskip\\ }{ \endgroup } \newenvironment{cxxnames}{\begin{cxxlist}{Names}}{\end{cxxlist}} \newenvironment{cxxpublic}{\begin{cxxlist}{Public Members}}{\end{cxxlist}} \newenvironment{cxxprivate}{\begin{cxxlist}{Private Members}}{\end{cxxlist}} \newenvironment{cxxprotected}{\begin{cxxlist}{Protected Members}}{\end{cxxlist}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Numbered Frame box % \newlength{\cxxBoxLen}% \newlength{\cxxBoxHt}% \newlength{\cxxBoxDp}% \newlength{\cxxSideHt}% \newlength{\cxxSideLen}% \newlength{\cxxTitleLen}% \def\empty{} \def\idPos{1cm} % % box with id and name [optional width] % \newcommand{\aBox}[3][1pt]{{% \small% \def\width{#1}% \def\num{#2}% \def\name{#3}% \setbox0\hbox{\hskip\width{ \strut\name\strut} \hskip\width}% % \setlength{\cxxBoxLen}{\wd0}% \addtolength{\cxxBoxLen}{\width}% \addtolength{\cxxBoxLen}{\width}% \setbox2\hbox{\normalsize\strut\rule{\cxxBoxLen}{\width}}% % \ifx\num\empty% \setbox1\hbox{\strut}% \else% \setbox1\hbox{\rule{\idPos}{\width} { \sf\bf\strut #2 } }% \fi% \addtolength{\cxxBoxLen}{-\wd1}% \setbox1\hbox{\unhbox1\rule{\cxxBoxLen}{\width}}% % \setlength{\cxxSideHt}{\dp0}% \addtolength{\cxxSideHt}{\width}% \setlength{\cxxSideLen}{\dp0}% \addtolength{\cxxSideLen}{\ht0}% \addtolength{\cxxSideLen}{\dp1}% \addtolength{\cxxSideLen}{\width}% \addtolength{\cxxSideLen}{\width}% \setbox3\hbox{\hbox to 0pt{\hss\rule[-\cxxSideHt]{\width}{\cxxSideLen}}}% \setbox4\hbox{\hbox to 0pt{\rule[-\cxxSideHt]{\width}{\cxxSideLen}\hss}}% % \setlength{\cxxBoxHt}{\dp1}% \addtolength{\cxxBoxHt}{1pt}% \setlength{\cxxBoxDp}{\ht2}% \addtolength{\cxxBoxDp}{-\width}% \addtolength{\cxxBoxDp}{1pt}% % \setlength{\cxxBoxLen}{\ht3}% \addtolength{\cxxBoxLen}{\ht1}% % \vbox to \cxxBoxLen{% \hbox{\unhbox1}% \vskip-\cxxBoxHt% \hbox{\hskip\width\unhbox3\unhbox0\unhbox4}% %\vskip-\ht2% \vskip-\cxxBoxDp% \hbox{\unhbox2}% \vss% }% }} % % box with id and name [optional width] of size #4 % \newcommand{\sizeBox}[4][3pt]{{% \setbox0\hbox{ }% \setlength{\cxxSideLen}{#4}% \addtolength{\cxxSideLen}{-\wd0}% \addtolength{\cxxSideLen}{-\wd0}% \addtolength{\cxxSideLen}{-#1}% \addtolength{\cxxSideLen}{-#1}% \addtolength{\cxxSideLen}{-#1}% \addtolength{\cxxSideLen}{-#1}% \aBox[#1]{#2}{\hbox to \cxxSideLen{#3}}% }} % % centered box with id and name [optional width] of size #4 % \newcommand{\cBox}[4][3pt]{{% \setbox0\hbox{\aBox[#1]{#2}{#3}}% \ifdim\wd0<#4% \sizeBox[#1]{#2}{\hss#3\hss}{#4}% \else% \setlength{\cxxSideLen}{\wd0}% \advance\cxxSideLen by -#4% \hskip -0.5\cxxSideLen% \unhbox0% \fi% }} % % right expanding box with id and name [optional width] of size at least #4 % \newcommand{\rBox}[4][3pt]{{% \setbox0\hbox{\aBox[#1]{#2}{#3}\hss}% \ifdim\wd0>#4% \unhbox0% \else% \sizeBox[#1]{#2}{\hss#3\hss}{#4}% \fi% }} % % left expanding box with id and name [optional width] of size at least #4 % \newcommand{\lBox}[4][3pt]{{% \setbox0\hbox{\aBox[#1]{#2}{#3}\hss}% \ifdim\wd0>#4% \setlength{\cxxSideLen}{\wd0}% \advance\cxxSideLen by -#4% \hskip -\cxxSideLen% \unhbox0% \else% \sizeBox[#1]{#2}{\hss#3\hss}{#4}% \fi% }} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Pagestyle for documentation. % \newsavebox{\cxxHeadName} \newcommand{\ps@docxx}{% \renewcommand{\@oddhead}{\headlinetext}% \renewcommand{\@evenhead}{\headlinetext}% \renewcommand{\@oddfoot}{\footlinetext}% \renewcommand{\@evenfoot}{\footlinetext}% } \newcommand{\makeHeadLine}[2]{ \global\sbox{\cxxHeadName}{\vbox to 0pt{\vss% \hbox to \textwidth{% \hbox to 0pt{\strut\hbox to 1cm{\hss}\quad#1\hss}% \hfil#2\hfil% }% \vskip 1pt% \hbox to \textwidth{\hrulefill}% }}% } \newcommand{\headlinetext}{\usebox{\cxxHeadName}} \providecommand{\cxxCopyright}{% \vtop{% \hbox to \textwidth{{ \tiny\sf This page was generated with the help of DOC++ \hss}}% \vskip -20pt \hbox to \textwidth{ \hbox{{\tiny\sf http://www.linuxsupportline.com/{\cxxtilde}doc++ }} \hss}% }% } \def\footlinetext{\hbox to \textwidth{ \vtop{% \hbox to \textwidth{\hrulefill}% \vskip -20pt% \cxxCopyright% }% \hss\vtop{\vskip 10pt\hbox{\today\hspace*{3cm}\textrm{\thepage} }} }} \pagestyle{docxx} \def\cxxTitle#1#2#3#4#5{\noindent{% \thispagestyle{empty} \vfill \begin{center} \Huge\bf \catcode`\&=4% \catcode`\_=8% \def{\ccverbatim \ccfinish}#1% \strut\\ \def{\ccverbatim \ccfinish}#2% \strut\\ \def{\ccverbatim \ccfinish}#3% \strut\\ \end{center} \if\cxxVersionStr\empty% \else% \begin{center} \small\sf --- Version \cxxVersionStr\ --- \end{center} \global\def\cxxVersionStr{} \fi \vfill \large \begin{center} \Large\em \def{\ccverbatim \ccfinish}#4% \end{center} \vfill \if\cxxAuthorStr\empty% \else% \begin{center} \sf\cxxAuthorStr \end{center} \global\def\cxxAuthorStr{} \vfill \fi \pagebreak \makeHeadLine{}{#2} }} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for contents % \newcounter{cxxContentsDepth} \setcounter{cxxContentsDepth}{0} \newdimen\cxxContentsLengthIncr \cxxContentsLengthIncr=18pt \newdimen\cxxContentsLength \cxxContentsLength=\textwidth \advance\cxxContentsLength by -\cxxContentsLengthIncr \makeHeadLine{}{Contents} \newenvironment{cxxContents}{ \ifcase \value{cxxContentsDepth} \vskip 40pt \hbox to \hsize{\hskip 8pt\hskip\cxxContentsLengthIncr\Huge\bf Contents\hss} \vskip 40pt \bf \else % >1 \rm \fi \begingroup \addtocounter{cxxContentsDepth}{1} \advance\cxxContentsLengthIncr by 8pt \advance\cxxContentsLength by -\cxxContentsLengthIncr }{ \addtocounter{cxxContentsDepth}{-1} \advance\cxxContentsLength by \cxxContentsLengthIncr \advance\cxxContentsLengthIncr by -8pt \ifcase \value{cxxContentsDepth} \vskip 12pt \or \vskip 9pt \else \vskip 3pt \fi \endgroup } \newcommand{\cxxContentsEntry}[3]{{ \def\emtpty{} \def\memo{#3} \ifx\memo\empty \setbox0\hbox{\parbox[t]{\cxxContentsLength}{\strut#2 \dotfill }} \else \setbox0\hbox{\parbox[t]{\cxxContentsLength}{\strut#2 --- {\em #3} \dotfill }} \fi \setbox1\hbox{\vtop{\vskip\dp0\vskip-\ht0\vskip-1.5pt\hbox to 20pt{\hss\rm \pageref{cxx.#1}}}} \hbox to \textwidth{% \hss\hbox to \cxxContentsLengthIncr{#1\hss}% \unhbox0\unhbox1% } }} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for class graph % \newdimen\cxxClassGraphShift \newdimen\cxxClassGraphLength \newdimen\cxxClassGraphHeight \newdimen\cxxClassGraphDepth \newdimen\cxxClassGraphTotV \setlength{\cxxClassGraphLength}{0.23\hsize} \setlength{\cxxClassGraphShift}{30pt} \setbox0\vbox{\aBox[5pt]{\strut}{\strut}} \setlength{\cxxClassGraphHeight}{\ht0} \setlength{\cxxClassGraphDepth}{\dp0} \addtolength{\cxxClassGraphDepth}{10pt} \setlength{\cxxClassGraphTotV}{\dp0} \addtolength{\cxxClassGraphTotV}{\ht0} \newenvironment{cxxInheritance}{ \par\medskip \begingroup \newcommand{\cxxCGSpace}[1]{% \vtop to \cxxClassGraphTotV{\hbox to \cxxClassGraphShift{% \vrule width0pt height \cxxClassGraphHeight depth \cxxClassGraphDepth% ##1}}% } \newcommand{\cxxSlashHline}{% \vrule width 0.1\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.1\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.1\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.1\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.1\cxxClassGraphShift height 3.5pt depth -3pt% } \newcommand{\cxxDotHline}{% \vrule width 0.06\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.05\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.06\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.05\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.06\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.05\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.06\cxxClassGraphShift height 3.5pt depth -3pt% \vrule width 0.05\cxxClassGraphShift height 0pt depth 0pt% \vrule width 0.06\cxxClassGraphShift height 3.5pt depth -3pt% } \newcommand{\cxxHline}{% \vrule width 0.5\cxxClassGraphShift height 3.5pt depth -3pt% } \newcommand{\cxxVup}{\hbox to 0pt{\hss% \vrule width 0.5pt height \cxxClassGraphHeight depth -3pt% \hss}} \newcommand{\cxxVlow}{\hbox to 0pt{\hss% \vtop to 0pt{\vskip-3pt% \hbox{\vrule width 0.5pt height 13pt depth \cxxClassGraphDepth}% \vss}% \hss}} \newcommand{\cxxLinkUp}{\hbox to 0pt{\hss\hskip 0.5\cxxClassGraphShift% \raise0.7\cxxClassGraphHeight\hbox to 0pt{\hss\textbf{\symbol{94}}\hss}}}% \newcommand{\cxxLinkDown}{\hbox to 0pt{\hss\hskip 0.5\cxxClassGraphShift% \raise-0.6\cxxClassGraphHeight\vbox to 0pt{% \hbox to 0pt{\hss\textbf{$\lor$}\hss}\vss}}}% \newcommand{\cxxLinkLeft}{\hbox to 0pt{\hss\hskip 0.0\cxxClassGraphShift% \raise0.0\cxxClassGraphHeight\hbox to 0pt{\textbf{\tt\<}\hss}}}% \newcommand{\cxxLinkRight}{\hbox to 0pt{\hss\hskip 1.0\cxxClassGraphShift% \raise0.0\cxxClassGraphHeight\hbox to 0pt{\hss\textbf{\tt\>}}}}% \newcommand{\cxxInheritanceEntry}[5][]{ \hbox to \hsize{\hss% \vrule width0pt height \cxxClassGraphHeight depth \cxxClassGraphDepth% ##2% \def\tmp{##1}% \ifx\tmp\empty% \def\tmp{##5}% \ifx\tmp\empty% \rBox[1pt]{##3}{##4}{0.24\hsize}% \else% \lBox[1pt]{##3}{##4}{0.24\hsize}% \fi% \else% \cBox[2pt]{##3}{##4}{0.24\hsize}% \fi% ##5\hfill% }\vskip-1pt } \newcommand{\cxxNone}{\cxxCGSpace{\hss}} \newcommand{\cxxLong}{\cxxCGSpace{\hss\cxxVup\cxxVlow\hss}} % \newcommand{\cxxPubLeft}{\cxxCGSpace{\cxxHline\cxxVup\cxxVlow\hss}} \newcommand{\cxxProLeft}{\cxxCGSpace{\cxxSlashHline\cxxVup\cxxVlow\hss}} \newcommand{\cxxPriLeft}{\cxxCGSpace{\cxxDotHline\cxxVup\cxxVlow\hss}} \newcommand{\cxxPubleft}{\cxxCGSpace{\cxxHline\cxxVlow\hss}} \newcommand{\cxxProleft}{\cxxCGSpace{\cxxSlashHline\cxxVlow\hss}} \newcommand{\cxxPrileft}{\cxxCGSpace{\cxxDotHline\cxxVlow\hss}} \newcommand{\cxxLastPubLeft}{\cxxCGSpace{\cxxHline% \cxxVup\cxxLinkDown\cxxVlow\hss}} \newcommand{\cxxLastProLeft}{\cxxCGSpace{\cxxSlashHline% \cxxVup\cxxLinkDown\cxxVlow\hss}} \newcommand{\cxxLastPriLeft}{\cxxCGSpace{\cxxDotHline% \cxxVup\cxxLinkDown\cxxVlow\hss}} \newcommand{\cxxLastPubleft}{\cxxCGSpace{\cxxHline% \cxxVlow\cxxLinkDown\hss}} \newcommand{\cxxLastProleft}{\cxxCGSpace{\cxxSlashHline% \cxxVlow\cxxLinkDown\hss}} \newcommand{\cxxLastPrileft}{\cxxCGSpace{\cxxDotHline% \cxxVlow\cxxLinkDown\hss}} \newcommand{\cxxLinkPubLeft}{\cxxCGSpace{\cxxLinkLeft\cxxHline\cxxVup\cxxVlow\hss}} \newcommand{\cxxLinkProLeft}{\cxxCGSpace{\cxxLinkLeft\cxxSlashHline% \cxxVup\cxxVlow\hss}} \newcommand{\cxxLinkPriLeft}{\cxxCGSpace{\cxxLinkLeft\cxxDotHline% \cxxVup\cxxVlow\hss}} \newcommand{\cxxLinkPubleft}{\cxxCGSpace{\cxxLinkLeft\cxxHline\cxxVlow\hss}} \newcommand{\cxxLinkProleft}{\cxxCGSpace{\cxxLinkLeft\cxxSlashHline\cxxVlow\hss}} \newcommand{\cxxLinkPrileft}{\cxxCGSpace{\cxxLinkLeft\cxxDotHline\cxxVlow\hss}} % \newcommand{\cxxPubRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow\cxxHline}} \newcommand{\cxxProRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow\cxxSlashHline}} \newcommand{\cxxPriRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow\cxxDotHline}} \newcommand{\cxxPubright}{\cxxCGSpace{\hss\cxxVup\cxxHline}} \newcommand{\cxxProright}{\cxxCGSpace{\hss\cxxVup\cxxSlashHline}} \newcommand{\cxxPriright}{\cxxCGSpace{\hss\cxxVup\cxxDotHline}} \newcommand{\cxxLinkPubRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow\cxxHline\cxxLinkRight}} \newcommand{\cxxLinkProRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow% \cxxSlashHline\cxxLinkRight}} \newcommand{\cxxLinkPriRight}{\cxxCGSpace{\hss\cxxVup\cxxVlow% \cxxDotHline\cxxLinkRight}} \newcommand{\cxxLinkPubright}{\cxxCGSpace{\hss\cxxVup\cxxHline\cxxLinkRight}} \newcommand{\cxxLinkProright}{\cxxCGSpace{\hss\cxxVup\cxxSlashHline\cxxLinkRight}} \newcommand{\cxxLinkPriright}{\cxxCGSpace{\hss\cxxVup\cxxDotHline\cxxLinkRight}} \newcommand{\cxxFirstPubRight}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxVlow\cxxHline}} \newcommand{\cxxFirstProRight}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxVlow% \cxxSlashHline}} \newcommand{\cxxFirstPriRight}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxVlow\cxxDotHline}} \newcommand{\cxxFirstPubright}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxHline}} \newcommand{\cxxFirstProright}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxSlashHline}} \newcommand{\cxxFirstPriright}{\cxxCGSpace{\hss\cxxVup\cxxLinkUp\cxxDotHline}} }{ \endgroup } \newenvironment{cxxClassGraph}{ \begin{cxxInheritance} \newcommand{\cxxClassGraphEntry}[4]{ \hbox to \hsize{\hss% \vrule width0pt height \cxxClassGraphHeight depth \cxxClassGraphDepth% ##1% \def\tmp{##4}% \rBox[1pt]{##2}{##3}{0.24\hsize}% ##4% \hskip\cxxClassGraphShift\dotfill% \hbox to \cxxClassGraphShift{\hss\pageref{cxx.##2}}% }\vskip-1pt } \newcommand{\cxxClassGraphEntryUnknownPackage}[3]{ \hbox to \hsize{\hss% \vrule width0pt height \cxxClassGraphHeight depth \cxxClassGraphDepth% ##1% \def\tmp{##3}% \rBox[1pt]{}{##2}{0.24\hsize}% ##3% \hskip\cxxClassGraphShift\hfill% }\vskip-1pt } \clearpage \pagebreak\strut \makeHeadLine{}{Class Graph} \vskip 20pt \hbox to \hsize{\Huge\bf \quad Class Graph\hss} \vskip 40pt } { \end{cxxInheritance} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for generic manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newdimen\cxxgenericstart \cxxgenericstart=\labelwidth \advance\cxxgenericstart by \labelsep \newdimen\cxxgenericwidth \cxxgenericwidth=\textwidth \advance\cxxgenericwidth by -\cxxgenericstart \newcounter{cxxDepth} \setcounter{cxxDepth}{0} \newlength{\cxxSize} \newenvironment{cxxgeneric}[5]{ % % some local definitions % \def\empty{} \def\type{#1} \def\args{#3} \def\memo{#4} \def\id {#5} % % pagebreak ? % \ifcase \value{cxxDepth} \clearpage % 0 \pagebreak \makeHeadLine{#5}{#2} \setlength{\cxxSize}{2pt} \or % 1 \strut\bigskip\bigskip\goodbreak% \setlength{\cxxSize}{1pt} \else % >2 \strut\bigskip\bigskip\goodbreak% \setlength{\cxxSize}{0.5pt} \fi \addtocounter{cxxDepth}{1} % % write synopsis % \setbox0\hbox{ }% \setbox1\hbox{\strut\large #1 {\bf#2} }% \setbox3\hbox{\strut\large #1 {\bf#2} #3}% % % box with id and name [optional width] over entire page width % \setlength{\cxxSideLen}{\hsize}% \addtolength{\cxxSideLen}{-4\cxxSize}% \addtolength{\cxxSideLen}{-2\wd0}% \setlength{\cxxTitleLen}{\cxxSideLen}% \addtolength{\cxxTitleLen}{-8\wd0}% \hbox{\aBox[\cxxSize]{\id}{\vbox{\vskip 1.5\parskip% \hbox to \cxxSideLen{\strut% \hbox to 4\wd0{}% \ifdim\wd3<\cxxTitleLen% \parbox[b]{\cxxTitleLen}{% \begin{raggedright} \noindent\large #1 {\bf#2} #3 \end{raggedright} } \else% \ifdim\wd1>0.7\cxxTitleLen% \parbox[b]{\cxxTitleLen}{% \begin{raggedright} \noindent\large #1 {\bf#2} #3 \end{raggedright} } \else% \addtolength{\cxxTitleLen}{-\wd1}% \unhbox1% \parbox[t]{\cxxTitleLen}{% \advance\lineskip 7pt% \begin{raggedright} \noindent\large\strut #3 \end{raggedright} } \fi% \fi% \hss\strut% }\vskip\parskip}% }} % \parbox[b]{\cxxSideLen}{\begingroup % \catcode`\&=12% % \catcode`\_=12% % \begin{flushleft} % \quad\large% % \ifx\type\empty % \ifx\args\empty % \strut{\bf #2}\\ % \else % \strut{\bf #2}\ \args % \fi % \else % \strut\type\ {\bf #2}\ \args % \fi % \end{flushleft} % \endgroup}}}% \ifx\memo\empty\else \vskip 10pt \begin{flushright} \it\memo \end{flushright} \fi \label{cxx.\id} \begingroup \def\cxxExceptionsStr{} \def\cxxParameterStr{} \def\cxxReturnStr{} \def\cxxInvariantsStr{} \def\cxxPreconditionsStr{} \def\cxxPostconditionsStr{} \def\cxxSeeStr{} \def\cxxAuthorStr{} \def\cxxVersionStr{} \def\cxxDeprecatedStr{} \def\cxxSinceStr{} \def\cxxFileStr{} \def\cxxExceptions##1{\def\cxxExceptionsStr{##1}} \def\cxxParameter##1{\def\cxxParameterStr{##1}} \def\cxxReturn##1{\def\cxxReturnStr{##1}} \def\cxxInvariants##1{\def\cxxInvariantsStr{##1}} \def\cxxPreconditions##1{\def\cxxPreconditionsStr{##1}} \def\cxxPostconditions##1{\def\cxxPostconditionsStr{##1}} \def\cxxSee##1{\def\cxxSeeStr{##1}} \def\cxxAuthor##1{\def\cxxAuthorStr{##1}} \def\cxxVersion##1{\def\cxxVersionStr{##1}} \def\cxxDeprecated##1{\def\cxxDeprecatedStr{##1}} \def\cxxSince##1{\def\cxxSinceStr{##1}} \def\cxxFile##1{\def\cxxFileStr{##1}} }{ \endgroup \addtocounter{cxxDepth}{-1} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for function manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxfunction}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5} \renewenvironment{cxxnames}{\begin{cxxlist}{Arguments}}{\end{cxxlist}} }{ \end{cxxgeneric} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxentry}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5}}{\end{cxxgeneric}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for union manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxunion}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5} \renewenvironment{cxxnames}{\begin{cxxlist}{Members}}{\end{cxxlist}} }{ \end{cxxgeneric} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for typedef manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxtypedef}[5]{ \begin{cxxgeneric}{#1}{#2}{}{#4}{#5} \renewenvironment{cxxnames}{\begin{cxxlist}{Members}}{\end{cxxlist}} }{ \end{cxxgeneric} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for macro manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxmacro}[5]{ \begin{cxxgeneric}{\#define}{#2}{#3}{#4}{#5}}{\end{cxxgeneric}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for class manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxclass}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5}}{\end{cxxgeneric}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for namespace manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxnamespace}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5}}{\end{cxxgeneric}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for interface manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxinterface}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5}}{\end{cxxgeneric}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for variable manual entries % arguments are: % #1 type % #2 name % #3 args % #4 memo % #5 number % \newenvironment{cxxvariable}[5]{ \begin{cxxgeneric}{#1}{#2}{#3}{#4}{#5} \renewenvironment{cxxnames}{\begin{cxxlist}{Names}}{\end{cxxlist}} }{ \end{cxxgeneric} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for documentation % \newenvironment{cxxdocumentation}{ % % switch on special characters for documentation section % \begingroup \catcode`\&=4 \catcode`\_=8 }{ \endgroup } \newenvironment{cxxdoc}{ % % switch on special characters for documentation section % \begin{cxxdocumentation} \strut\\\noindent% }{ \smallskip \def\empty{}% \ifx\cxxReturnStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Return Value:}\hss}% \parbox[t]{0.7\textwidth}{\cxxReturnStr}\\ \fi \ifx\cxxParameterStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Parameters:}\hss}% \parbox[t]{0.7\textwidth}{\cxxParameterStr}\\ \fi \ifx\cxxExceptionsStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Exceptions:}\hss}% \parbox[t]{0.7\textwidth}{\cxxExceptionsStr}\\ \fi \ifx\cxxInvariantsStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Invariants:}\hss}% \parbox[t]{0.7\textwidth}{\cxxInvariantsStr}\\ \fi \ifx\cxxPreconditionsStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Preconditions:}\hss}% \parbox[t]{0.7\textwidth}{\cxxPreconditionsStr}\\ \fi \ifx\cxxPostconditionsStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Postconditions:}\hss}% \parbox[t]{0.7\textwidth}{\cxxPostconditionsStr}\\ \fi \ifx\cxxSeeStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf See Also:}\hss}% \parbox[t]{0.7\textwidth}{\cxxSeeStr}\\ \fi \ifx\cxxAuthorStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Author:}\hss}% \parbox[t]{0.7\textwidth}{\cxxAuthorStr}\\ \fi \ifx\cxxVersionStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Version:}\hss}% \parbox[t]{0.7\textwidth}{\cxxVersionStr}\\ \fi \ifx\cxxDeprecatedStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf\it Deprecated:}\hss}% \parbox[t]{0.7\textwidth}{\cxxDeprecatedStr}\\ \fi \ifx\cxxSinceStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf Since:}\hss}% \parbox[t]{0.7\textwidth}{\cxxSinceStr}\\ \fi \ifx\cxxFileStr\empty\else \noindent\hbox to 0.3\textwidth{{\bf File:}\hss}% \parbox[t]{0.7\textwidth}{\cxxFileStr}\\ \fi \end{cxxdocumentation} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % environment for commented listing % arguments are: % #1 Section title % \newenvironment{cxximplementation}[1]{ \goodbreak \begin{cxxdocumentation} }{ \end{cxxdocumentation} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\cxxCodeLine#1{ \strut\hbox to 20pt{\tiny\hss #1}\small %\advance\leftmargin by 20pt %\advance\textwidth by -20pt \ccverbatim \parskip=0pt \cxxCodeFinish} {\catcode`\=0 catcode`\=12 gdefcxxCodeFinish#1{hbox{#1}endgroup}} libfli-2.0+20221221182632/libfli-debug.h0000644000175100017510000000413014174600256016122 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_DEBUG_H_ #define _LIBFLI_DEBUG_H_ #ifdef _DEBUG #define _DEBUGSTRING #define _DEBUG_IO #endif #define _DEBUG_IO /* Debug functions */ int debugclose(void); int debugopen(char *host); void debug(int level, char *format, ...); void setdebuglevel(char *host, long level); #endif /* _LIBFLI_DEBUG_H_ */ libfli-2.0+20221221182632/libfli-camera-parport.c0000644000175100017510000004731314174600256017756 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifdef _WIN32 #include #else #include #include #endif #include #include #include #include "libfli-libfli.h" #include "libfli-mem.h" #include "libfli-debug.h" #include "libfli-camera.h" #include "libfli-camera-parport.h" long fli_camera_parport_open(flidev_t dev) { flicamdata_t *cam; long rlen, wlen; unsigned short buf; int id; cam = DEVICE->device_data; cam->removebias = 1; cam->biasoffset = 200; /* Set timeout values */ cam->readto = 1000; cam->writeto = 1000; cam->dirto = 1000; rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_ECHO)); IO(dev, &buf, &wlen, &rlen); if (buf != htons(C_ADDRESS(1, EPARAM_ECHO))) { debug(FLIDEBUG_FAIL, "Echo back from camera failed."); return -EIO; } rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_DEVICE)); IO(dev, &buf, &wlen, &rlen); DEVICE->devinfo.hwrev = ntohs(buf) & 0x00ff; rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_CCDID)); IO(dev, &buf, &wlen, &rlen); DEVICE->devinfo.devid = ntohs(buf) & 0x00ff; for (id = 0; knowndev[id].index != 0; id++) if (knowndev[id].index == DEVICE->devinfo.devid) break; if (knowndev[id].index == 0) return -ENODEV; cam->ccd.array_area.ul.x = knowndev[id].array_area.ul.x; cam->ccd.array_area.ul.y = knowndev[id].array_area.ul.y; cam->ccd.array_area.lr.x = knowndev[id].array_area.lr.x; cam->ccd.array_area.lr.y = knowndev[id].array_area.lr.y; cam->ccd.visible_area.ul.x = knowndev[id].visible_area.ul.x; cam->ccd.visible_area.ul.y = knowndev[id].visible_area.ul.y; cam->ccd.visible_area.lr.x = knowndev[id].visible_area.lr.x; cam->ccd.visible_area.lr.y = knowndev[id].visible_area.lr.y; cam->ccd.pixelwidth = knowndev[id].pixelwidth; cam->ccd.pixelheight = knowndev[id].pixelheight; if ((DEVICE->devinfo.model = (char *)xmalloc(strlen(knowndev[id].model) + 1)) == NULL) return -ENOMEM; strcpy(DEVICE->devinfo.model, knowndev[id].model); debug(FLIDEBUG_INFO, " Name: %s", DEVICE->devinfo.devnam); debug(FLIDEBUG_INFO, " Array: (%4d,%4d),(%4d,%4d)", cam->ccd.array_area.ul.x, cam->ccd.array_area.ul.y, cam->ccd.array_area.lr.x, cam->ccd.array_area.lr.y); debug(FLIDEBUG_INFO, " Visible: (%4d,%4d),(%4d,%4d)", cam->ccd.visible_area.ul.x, cam->ccd.visible_area.ul.y, cam->ccd.visible_area.lr.x, cam->ccd.visible_area.lr.y); rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_SNHIGH)); IO(dev, &buf, &wlen, &rlen); DEVICE->devinfo.serno = (ntohs(buf) & 0x00ff) << 8; rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_SNLOW)); IO(dev, &buf, &wlen, &rlen); DEVICE->devinfo.serno |= (ntohs(buf) & 0x00ff); rlen = 2; wlen = 2; buf = htons(C_ADDRESS(1, EPARAM_FIRM)); IO(dev, &buf, &wlen, &rlen); DEVICE->devinfo.fwrev = (ntohs(buf) & 0x00ff); /* Initialize all varaibles to something */ switch(DEVICE->devinfo.hwrev) { case 0x01: cam->tempslope = (100.0 / 201.1); cam->tempintercept = (-61.613); break; case 0x02: cam->tempslope = (70.0 / 215.75); cam->tempintercept = (-52.5681); break; default: debug(FLIDEBUG_WARN, "Could not set temperature parameters."); break; } cam->vflushbin = 4; cam->hflushbin = 4; cam->vbin = 1; cam->hbin = 1; cam->image_area.ul.x = cam->ccd.visible_area.ul.x; cam->image_area.ul.y = cam->ccd.visible_area.ul.y; cam->image_area.lr.x = cam->ccd.visible_area.lr.x; cam->image_area.lr.y = cam->ccd.visible_area.lr.y; cam->exposure = 100; cam->frametype = FLI_FRAME_TYPE_NORMAL; cam->flushes = 0; cam->bitdepth = FLI_MODE_16BIT; cam->exttrigger = 0; cam->grabrowwidth = (cam->image_area.lr.x - cam->image_area.ul.x) / cam->hbin; cam->grabrowcount = 1; cam->grabrowcounttot = cam->grabrowcount; cam->grabrowindex = 0; cam->grabrowbatchsize = 1; cam->grabrowbufferindex = cam->grabrowcount; cam->flushcountbeforefirstrow = 0; cam->flushcountafterlastrow = 0; return 0; } long fli_camera_parport_get_array_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y) { flicamdata_t *cam; cam = DEVICE->device_data; *ul_x = cam->ccd.array_area.ul.x; *ul_y = cam->ccd.array_area.ul.y; *lr_x = cam->ccd.array_area.lr.x; *lr_y = cam->ccd.array_area.lr.y; return 0; } long fli_camera_parport_get_visible_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y) { flicamdata_t *cam; cam = DEVICE->device_data; *ul_x = cam->ccd.visible_area.ul.x; *ul_y = cam->ccd.visible_area.ul.y; *lr_x = cam->ccd.visible_area.lr.x; *lr_y = cam->ccd.visible_area.lr.y; return 0; } long fli_camera_parport_set_exposure_time(flidev_t dev, long exptime) { flicamdata_t *cam; cam = DEVICE->device_data; if (exptime < 0) return -EINVAL; cam->exposure = exptime; if (exptime <= 15000) /* Less than thirty seconds..., 8.192e-3 sec */ { cam->expdur = 1; cam->expmul = (long) (((double) exptime) / 8.192); } else if (exptime <= 2000000) /* Less than one hour */ { cam->expdur = (long) (1.0 / 8.192e-3); cam->expmul = (long) (exptime / 1000); } else { cam->expdur = (long) (10.0 / 8.192e-3); cam->expmul = (long) (exptime / 10000); } return 0; } long fli_camera_parport_set_image_area(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y) { flicamdata_t *cam; cam = DEVICE->device_data; if ((ul_x < cam->ccd.visible_area.ul.x) || (ul_y < cam->ccd.visible_area.ul.y) || (lr_x > cam->ccd.visible_area.lr.x) || (lr_y > cam->ccd.visible_area.lr.y)) return -EINVAL; cam->image_area.ul.x = ul_x; cam->image_area.ul.y = ul_y; cam->image_area.lr.x = lr_x; cam->image_area.lr.y = lr_y; return 0; } long fli_camera_parport_set_hbin(flidev_t dev, long hbin) { flicamdata_t *cam; cam = DEVICE->device_data; if ((hbin < 1) || (hbin > 16)) return -EINVAL; cam->hbin = hbin; return 0; } long fli_camera_parport_set_vbin(flidev_t dev, long vbin) { flicamdata_t *cam; cam = DEVICE->device_data; if ((vbin < 1) || (vbin > 16)) return -EINVAL; cam->vbin = vbin; return 0; } long fli_camera_parport_get_exposure_status(flidev_t dev, long *timeleft) { flicamdata_t *cam; long rlen, wlen; unsigned short buf; cam = DEVICE->device_data; rlen = 2; wlen = 2; buf = htons(C_SHUTTER(1,0)); IO(dev, &buf, &wlen, &rlen); if ((ntohs(buf) & 0xf000) != C_SHUTTER(0,0)) { debug(FLIDEBUG_FAIL, "(exposurestatus) echo back from camera failed."); return -EIO; } *timeleft = (long)((double)(ntohs(buf) & 0x07ff) * ((double)cam->expdur * 8.192)); return 0; } long fli_camera_parport_set_temperature(flidev_t dev, double temperature) { flicamdata_t *cam; long rlen, wlen; unsigned short buf; cam = DEVICE->device_data; rlen = 2; wlen = 2; buf = (unsigned short)((temperature - cam->tempintercept) / cam->tempslope); buf = htons((unsigned short) C_TEMP(buf)); IO(dev, &buf, &wlen, &rlen); if ((ntohs(buf) & 0xf000) != C_TEMP(0)) { debug(FLIDEBUG_FAIL, "(settemperature) echo back from camera failed."); return -EIO; } return 0; } long fli_camera_parport_get_temperature(flidev_t dev, double *temperature) { flicamdata_t *cam; long rlen, wlen; unsigned short buf; cam = DEVICE->device_data; rlen = 2; wlen = 2; buf = htons(C_TEMP(0x0800)); IO(dev, &buf, &wlen, &rlen); if ((ntohs(buf) & 0xf000) != C_TEMP(0)) { debug(FLIDEBUG_FAIL, "(settemperature) echo back from camera failed."); return -EIO; } *temperature = cam->tempslope * (double)(ntohs(buf) & 0x00ff) + cam->tempintercept; return 0; } long fli_camera_parport_grab_row(flidev_t dev, void *buff, size_t width) { flicamdata_t *cam; long r; double dTm; long rlen, wlen; unsigned short buf; long grabwidth; cam = DEVICE->device_data; if (cam->flushcountbeforefirstrow > 0) { if ((r = fli_camera_parport_flush_rows(dev, cam->flushcountbeforefirstrow, 1))) return r; cam->flushcountbeforefirstrow = 0; } dTm = (25.0e-6) * cam->ccd.array_area.lr.x + 1e-3; dTm = dTm / 1e-6; cam->readto = (long)dTm; cam->writeto = (long)dTm; if (cam->removebias) { // grabwidth = cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x + (50 + 64) - cam->image_area.ul.x; grabwidth = (cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x + (5 + 64) - cam->image_area.ul.x) / cam->hbin; } else { grabwidth = cam->grabrowwidth; } rlen = 0; wlen = 2; buf = htons((unsigned short) C_SEND(grabwidth)); IO(dev, &buf, &wlen, &rlen); if (cam->bitdepth == FLI_MODE_8BIT) { unsigned char *cbuf; int x; if ((cbuf = xmalloc(grabwidth)) == NULL) { debug(FLIDEBUG_FAIL, "Failed memory allocation during row grab."); return -ENOMEM; } rlen = grabwidth; wlen = 0; r = DEVICE->fli_io(dev, cbuf, &wlen, &rlen); if (r != 0) { debug(FLIDEBUG_WARN, "Couldn't grab entire row (8-bit), got %d of %d bytes.", r, grabwidth); } for (x = 0; x < (int)width; x++) { ((char *)buff)[x] = (((cbuf[x]) + 128) & 0x00ff); } xfree(cbuf); } else { unsigned short *sbuf; int x; if ((sbuf = xmalloc(grabwidth * sizeof(unsigned short))) == NULL) { debug(FLIDEBUG_FAIL, "Failed memory allocation during row grab."); return -ENOMEM; } rlen = grabwidth * sizeof(unsigned short); wlen = 0; r = DEVICE->fli_io(dev, sbuf, &wlen, &rlen); if (r != 0) { debug(FLIDEBUG_WARN, "Couldn't grab entire row (16-bit), got %d of %d bytes.", r, grabwidth); } for (x = 0; x < (int)width; x++) { if (DEVICE->devinfo.hwrev == 0x01) /* IMG camera */ { ((unsigned short *)buff)[x] = ntohs(sbuf[x]) + 32768; } else { ((unsigned short *)buff)[x] = ntohs(sbuf[x]); } } if (cam->removebias) { for (x = grabwidth - (64 / cam->hbin); x < grabwidth; x++) { unsigned short d; if (DEVICE->devinfo.hwrev == 0x01) /* IMG camera */ d = ntohs(sbuf[x]) + 32768; else d = ntohs(sbuf[x]); cam->pix_sum += (double) d; cam->pix_cnt += 1.0; } for (x = 0; x < (int)width; x++) { ((unsigned short *)buff)[x] = ((unsigned short *)buff)[x] - (unsigned short) ((cam->pix_sum / cam->pix_cnt) - cam->biasoffset); } debug(FLIDEBUG_INFO, "Overscan bias average: %g (%d)", (cam->pix_sum / cam->pix_cnt), (unsigned short) ((cam->pix_sum / cam->pix_cnt) - 200.0)); } xfree(sbuf); } rlen = 2; wlen = 0; IO(dev, &buf, &wlen, &rlen); if (cam->removebias) { if (ntohs(buf) != C_SEND(grabwidth)) { debug(FLIDEBUG_WARN, "Width: %d, requested %d.", width, grabwidth * sizeof(unsigned short)); debug(FLIDEBUG_WARN, "Got 0x%04x instead of 0x%04x.", ntohs(buf), C_SEND(grabwidth)); debug(FLIDEBUG_WARN, "Didn't get command echo at end of row."); } } else { if (ntohs(buf) != C_SEND(width)) { debug(FLIDEBUG_WARN, "Width: %d, requested %d.", width, grabwidth * sizeof(unsigned short)); debug(FLIDEBUG_WARN, "Got 0x%04x instead of 0x%04x.", ntohs(buf), C_SEND(width)); debug(FLIDEBUG_WARN, "Didn't get command echo at end of row."); } } if (cam->grabrowcount > 0) { cam->grabrowcount--; if (cam->grabrowcount == 0) { if ((r = fli_camera_parport_flush_rows(dev, cam->flushcountafterlastrow, 1))) return r; cam->flushcountafterlastrow = 0; cam->grabrowbatchsize = 1; } } cam->readto = 1000; cam->writeto = 1000; return 0; } long fli_camera_parport_expose_frame(flidev_t dev) { flicamdata_t *cam; long rlen, wlen; unsigned short buf; cam = DEVICE->device_data; debug(FLIDEBUG_INFO, "Setting X Row Offset."); rlen = 2; wlen = 2; buf = htons((unsigned short) D_XROWOFF(cam->image_area.ul.x)); IO(dev, &buf, &wlen, &rlen); if (cam->removebias) { debug(FLIDEBUG_INFO, "Setting X Row Width to %d.", cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x + 5 + 64); buf = htons((unsigned short) D_XROWWID(cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x + 5 + 64)); IO(dev, &buf, &wlen, &rlen); } else { debug(FLIDEBUG_INFO, "Setting X Row Width to %d.", cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x); buf = htons((unsigned short) D_XROWWID(cam->ccd.array_area.lr.x - cam->ccd.array_area.ul.x)); IO(dev, &buf, &wlen, &rlen); } debug(FLIDEBUG_INFO, "Setting X Flush Bin."); buf = htons((unsigned short) D_XFLBIN(cam->hflushbin)); IO(dev, &buf, &wlen, &rlen); debug(FLIDEBUG_INFO, "Setting Y Flush Bin."); buf = htons((unsigned short) D_YFLBIN(cam->vflushbin)); IO(dev, &buf, &wlen, &rlen); debug(FLIDEBUG_INFO, "Setting X Bin."); buf = htons((unsigned short) D_XBIN(cam->hbin)); IO(dev, &buf, &wlen, &rlen); debug(FLIDEBUG_INFO, "Setting Y Bin."); buf = htons((unsigned short) D_YBIN(cam->vbin)); IO(dev, &buf, &wlen, &rlen); debug(FLIDEBUG_INFO, "Setting Exposure Duration."); buf = htons((unsigned short) D_EXPDUR(cam->expdur)); IO(dev, &buf, &wlen, &rlen); if (cam->bitdepth == FLI_MODE_8BIT) { debug(FLIDEBUG_INFO, "Eight Bit."); buf = htons((unsigned short)((cam->exttrigger > 0) ? C_RESTCFG(0,0,1,7) : C_RESTCFG(0,0,0,7))); } else { debug(FLIDEBUG_INFO, "Sixteen Bit."); buf = htons((unsigned short)((cam->exttrigger > 0) ? C_RESTCFG(0,0,1,15) : C_RESTCFG(0,0,0,15))); } IO(dev, &buf, &wlen, &rlen); if (cam->flushes > 0) { int r; debug(FLIDEBUG_INFO, "Flushing array."); if ((r = fli_camera_parport_flush_rows(dev, cam->ccd.array_area.lr.y - cam->ccd.array_area.ul.y, cam->flushes))) return r; } debug(FLIDEBUG_INFO, "Exposing."); buf = htons((unsigned short) C_SHUTTER((cam->frametype & FLI_FRAME_TYPE_DARK)?0:1, cam->expmul)); IO(dev, &buf, &wlen, &rlen); cam->grabrowwidth = cam->image_area.lr.x - cam->image_area.ul.x; cam->flushcountbeforefirstrow = cam->image_area.ul.y; cam->flushcountafterlastrow = (cam->ccd.array_area.lr.y - cam->ccd.array_area.ul.y) - ((cam->image_area.lr.y - cam->image_area.ul.y) * cam->vbin) - cam->image_area.ul.y; if (cam->flushcountafterlastrow < 0) cam->flushcountafterlastrow = 0; cam->pix_sum = 0.0; cam->pix_cnt = 0.0; cam->grabrowcount = cam->image_area.lr.y - cam->image_area.ul.y; return 0; } long fli_camera_parport_flush_rows(flidev_t dev, long rows, long repeat) { flicamdata_t *cam; double dTm; long rlen, wlen; unsigned short buf; if (rows < 0) return -EINVAL; if (rows == 0) return 0; cam = DEVICE->device_data; dTm = ((25e-6) / (cam->hflushbin / 2)) * cam->ccd.array_area.lr.x + 1e-3; dTm = dTm * rows; dTm = dTm / 1e-6; cam->readto = (long)dTm; cam->writeto = (long)dTm; while (repeat>0) { long retval; rlen = 2; wlen = 2; buf = htons((unsigned short) C_FLUSH(rows)); retval = DEVICE->fli_io(dev, &buf, &wlen, &rlen); if (retval != 0) { cam->readto = 1000; cam->writeto = 1000; return retval; } repeat--; } return 0; } long fli_camera_parport_set_bit_depth(flidev_t dev, flibitdepth_t bitdepth) { flicamdata_t *cam; cam = DEVICE->device_data; if (DEVICE->devinfo.type != 0x01) /* IMG cameras only support this */ return -EINVAL; if ((bitdepth != FLI_MODE_8BIT) && (bitdepth != FLI_MODE_16BIT)) { debug(FLIDEBUG_FAIL, "Invalid bit depth setting."); return -EINVAL; } cam->bitdepth = bitdepth; return 0; } static void correctioportdatawrite(flidev_t dev, unsigned short *Data) { unsigned short data; data = 0; switch(DEVICE->devinfo.hwrev) { case 0x01: data |= (*Data & FLICCD_IO_P0)?0x01:0; data |= (*Data & FLICCD_IO_P1)?0x02:0; data |= (*Data & FLICCD_IO_P2)?0x04:0; data |= (*Data & FLICCD_IO_P3)?0x80:0; break; case 0x02: data |= (*Data & FLICCD_IO_P0)?0x08:0; data |= (*Data & FLICCD_IO_P1)?0x10:0; data |= (*Data & FLICCD_IO_P2)?0x20:0; data |= (*Data & FLICCD_IO_P3)?0x40:0; break; default: break; } *Data = data; return; } static void correctioportdataread(flidev_t dev, unsigned short *Data) { unsigned short data; data = 0; switch (DEVICE->devinfo.hwrev) { case 0x01: data |= (*Data & 0x01)?FLICCD_IO_P0:0; data |= (*Data & 0x02)?FLICCD_IO_P1:0; data |= (*Data & 0x04)?FLICCD_IO_P2:0; data |= (*Data & 0x80)?FLICCD_IO_P3:0; break; case 0x02: data |= (*Data & 0x08)?FLICCD_IO_P0:0; data |= (*Data & 0x10)?FLICCD_IO_P1:0; data |= (*Data & 0x20)?FLICCD_IO_P2:0; data |= (*Data & 0x40)?FLICCD_IO_P3:0; break; default: break; } *Data = data; return; } long fli_camera_parport_read_ioport(flidev_t dev, long *ioportset) { long rlen, wlen; unsigned short buf; rlen = 2; wlen = 2; buf = htons(0x7900); IO(dev, &buf, &wlen, &rlen); *ioportset = ntohs(buf) & 0x00ff; correctioportdataread(dev, (unsigned short *) ioportset); return 0; } long fli_camera_parport_write_ioport(flidev_t dev, long ioportset) { long rlen, wlen; unsigned short buf; unsigned short _ioportset = (unsigned short) ioportset; correctioportdatawrite(dev, &_ioportset); buf = htons((unsigned short) (0x7100 | (ioportset & 0x00ff))); rlen = 2; wlen = 2; IO(dev, &buf, &wlen, &rlen); return 0; } long fli_camera_parport_configure_ioport(flidev_t dev, long ioportset) { long rlen, wlen; unsigned short buf; unsigned short _ioportset = (unsigned short) ioportset; correctioportdatawrite(dev, &_ioportset); buf = htons((unsigned short) (0x7000 | (ioportset & 0x00ff))); rlen = 2; wlen = 2; IO(dev, &buf, &wlen, &rlen); return 0; } long fli_camera_parport_control_shutter(flidev_t dev, long shutter) { long rlen, wlen; unsigned short buf; rlen = 2; wlen = 2; buf = htons(D_EXPDUR(0)); IO(dev, &buf, &wlen, &rlen); switch (shutter) { case FLI_SHUTTER_CLOSE: debug(FLIDEBUG_INFO, "Closing shutter."); buf = htons(C_SHUTTER(0, 0)); IO(dev, &buf, &wlen, &rlen); break; case FLI_SHUTTER_OPEN: buf = htons(C_SHUTTER(1, 1)); IO(dev, &buf, &wlen, &rlen); break; default: return -EINVAL; } return 0; } libfli-2.0+20221221182632/libfli-camera-usb.c0000644000175100017510000022672114174600256017062 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifdef _WIN32 #include #define strncasecmp _strnicmp #else #include #include #include #endif #include #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-mem.h" #include "libfli-camera.h" #include "libfli-camera-usb.h" #include "libfli-usb.h" #include "indimacros.h" double dconvert(void *buf) { unsigned char *fnum = (unsigned char *) buf; double sign, exponent, mantissa, result; sign = (double) ((fnum[3] & 0x80)?(-1):(1)); exponent = (double) ((fnum[3] & 0x7f) << 1 | ((fnum[2] & 0x80)?1:0)); mantissa = 1.0 + ((double) ((fnum[2] & 0x7f) << 16 | fnum[1] << 8 | fnum[0]) / pow(2, 23)); result = sign * (double) pow(2, (exponent - 127.0)) * mantissa; return result; } long fli_camera_usb_open(flidev_t dev) { flicamdata_t *cam; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; // long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); cam = DEVICE->device_data; #ifdef __linux__ /* Linux needs this page aligned, hopefully this is 512 byte aligned too... */ cam->max_usb_xfer = (USB_READ_SIZ_MAX / getpagesize()) * getpagesize(); cam->gbuf_siz = 2 * cam->max_usb_xfer; if ((cam->gbuf = xmemalign(getpagesize(), cam->gbuf_siz)) == NULL) return -ENOMEM; #else /* Just 512 byte align it... */ cam->max_usb_xfer = (USB_READ_SIZ_MAX & 0xfffffe00); cam->gbuf_siz = 2 * cam->max_usb_xfer; if ((cam->gbuf = xmalloc(cam->gbuf_siz)) == NULL) return -ENOMEM; #endif if ((DEVICE->devinfo.devid >= 0x0100) && (DEVICE->devinfo.devid < 0x0110)) DEVICE->devinfo.devid = FLIUSB_PROLINE_ID; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { short camtype; IOWRITE_U16(buf, 0, FLI_USBCAM_HARDWAREREV); rlen = 2; wlen = 2; IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, DEVICE->devinfo.hwrev); IOWRITE_U16(buf, 0, FLI_USBCAM_DEVICEID); rlen = 2; wlen = 2; IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, camtype); IOWRITE_U16(buf, 0, FLI_USBCAM_SERIALNUM); rlen = 2; wlen = 2; IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, DEVICE->devinfo.serno); /* The following devices need information downloaded to them */ if (DEVICE->devinfo.fwrev < 0x0201) { int id; for (id = 0; knowndev[id].index != 0; id++) if (knowndev[id].index == camtype) break; if (knowndev[id].index == 0) return -ENODEV; cam->ccd.pixelwidth = knowndev[id].pixelwidth; cam->ccd.pixelheight = knowndev[id].pixelheight; wlen = 14; rlen = 0; IOWRITE_U16(buf, 0, FLI_USBCAM_DEVINIT); IOWRITE_U16(buf, 2, (unsigned short) knowndev[id].array_area.lr.x); IOWRITE_U16(buf, 4, (unsigned short) knowndev[id].array_area.lr.y); IOWRITE_U16(buf, 6, (unsigned short) (knowndev[id].visible_area.lr.x - knowndev[id].visible_area.ul.x)); IOWRITE_U16(buf, 8, (unsigned short) (knowndev[id].visible_area.lr.y - knowndev[id].visible_area.ul.y)); IOWRITE_U16(buf, 10, (unsigned short) knowndev[id].visible_area.ul.x); IOWRITE_U16(buf, 12, (unsigned short) knowndev[id].visible_area.ul.y); IO(dev, buf, &wlen, &rlen); DEVICE->devinfo.model = xstrndup(knowndev[id].model, 31); switch(DEVICE->devinfo.fwrev & 0xff00) { case 0x0100: cam->tempslope = (70.0 / 215.75); cam->tempintercept = (-52.5681); break; case 0x0200: cam->tempslope = (100.0 / 201.1); cam->tempintercept = (-61.613); break; default: cam->tempslope = 1e-12; cam->tempintercept = 0; } } /* Here, all the parameters are stored on the camera */ else if (DEVICE->devinfo.fwrev >= 0x0201) { rlen = 64; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_READPARAMBLOCK); IO(dev, buf, &wlen, &rlen); IOREAD_LF(buf, 31, cam->ccd.pixelwidth); IOREAD_LF(buf, 35, cam->ccd.pixelheight); IOREAD_LF(buf, 23, cam->tempslope); IOREAD_LF(buf, 27, cam->tempintercept); } rlen = 32; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_DEVICENAME); IO(dev, buf, &wlen, &rlen); /* Hack to make old software happy */ DEVICE->devinfo.devnam = xcalloc(1, 32); DEVICE->devinfo.model = xcalloc(1, 32); strncpy(DEVICE->devinfo.devnam, (char *) buf, 30); strncpy(DEVICE->devinfo.model, (char *) buf, 30); rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_ARRAYSIZE); IO(dev, buf, &wlen, &rlen); cam->ccd.array_area.ul.x = 0; cam->ccd.array_area.ul.y = 0; IOREAD_U16(buf, 0, cam->ccd.array_area.lr.x); IOREAD_U16(buf, 2, cam->ccd.array_area.lr.y); rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_IMAGEOFFSET); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, cam->ccd.visible_area.ul.x); IOREAD_U16(buf, 2, cam->ccd.visible_area.ul.y); rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_IMAGESIZE); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, cam->ccd.visible_area.lr.x); cam->ccd.visible_area.lr.x += cam->ccd.visible_area.ul.x; IOREAD_U16(buf, 2, cam->ccd.visible_area.lr.y); cam->ccd.visible_area.lr.y += cam->ccd.visible_area.ul.y; /* This is added as a hack to allow for overscan of CCD * this should be moved somewhere else */ #ifdef _WIN32 /* Check the registry to determine if we are overriding any settings */ { HKEY hKey; DWORD overscan_x = 0, overscan_y = 0; DWORD whole_array = 0; DWORD len; if (RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Finger Lakes Instrumentation\\libfli", &hKey) == ERROR_SUCCESS) { /* Check for overscan data */ len = sizeof(DWORD); if (RegQueryValueEx(hKey, "overscan_x", NULL, NULL, (LPBYTE) &overscan_x, &len) == ERROR_SUCCESS) { debug(FLIDEBUG_INFO, "Found a request for horizontal overscan of %d pixels.", overscan_x); } len = sizeof(DWORD); if (RegQueryValueEx(hKey, "overscan_y", NULL, NULL, (LPBYTE) &overscan_y, &len) == ERROR_SUCCESS) { debug(FLIDEBUG_INFO, "Found a request for vertical overscan of %d pixels.", overscan_y); } len = sizeof(DWORD); RegQueryValueEx(hKey, "whole_array", NULL, NULL, (LPBYTE) &whole_array, &len); cam->ccd.array_area.ul.x = 0; cam->ccd.array_area.ul.y = 0; cam->ccd.array_area.lr.x += overscan_x; cam->ccd.array_area.lr.y += overscan_y; if (whole_array == 0) { cam->ccd.visible_area.lr.x += overscan_x; cam->ccd.visible_area.lr.y += overscan_y; } else { cam->ccd.visible_area.ul.x = 0; cam->ccd.visible_area.ul.y = 0; cam->ccd.visible_area.lr.x = cam->ccd.array_area.lr.x; cam->ccd.visible_area.lr.y = cam->ccd.array_area.lr.y; } RegCloseKey(hKey); } else { debug(FLIDEBUG_INFO, "Could not find registry key."); } } #endif /* Initialize all variables to something */ cam->vflushbin = 4; cam->hflushbin = 4; cam->vbin = 1; cam->hbin = 1; cam->image_area.ul.x = cam->ccd.visible_area.ul.x; cam->image_area.ul.y = cam->ccd.visible_area.ul.y; cam->image_area.lr.x = cam->ccd.visible_area.lr.x; cam->image_area.lr.y = cam->ccd.visible_area.lr.y; cam->exposure = 100; cam->frametype = FLI_FRAME_TYPE_NORMAL; cam->flushes = 0; cam->bitdepth = FLI_MODE_16BIT; cam->exttrigger = 0; cam->exttriggerpol = 0; cam->background_flush = 1; cam->grabrowwidth = (cam->image_area.lr.x - cam->image_area.ul.x) / cam->hbin; cam->grabrowcount = 1; cam->grabrowcounttot = cam->grabrowcount; cam->grabrowindex = 0; cam->grabrowbatchsize = 1; cam->grabrowbufferindex = cam->grabrowcount; cam->flushcountbeforefirstrow = 0; cam->flushcountafterlastrow = 0; #ifdef _SETUPDEFAULTS /* Now to set up the camera defaults */ rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFRAMEOFFSET); IOWRITE_U16(buf, 2, cam->image_area.ul.x); IOWRITE_U16(buf, 4, cam->image_area.ul.y); IO(dev, buf, &wlen, &rlen); rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETBINFACTORS); IOWRITE_U16(buf, 2, cam->hbin); IOWRITE_U16(buf, 4, cam->vbin); IO(dev, buf, &wlen, &rlen); rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFLUSHBINFACTORS); IOWRITE_U16(buf, 2, cam->hflushbin); IOWRITE_U16(buf, 4, cam->vflushbin); IO(dev, buf, &wlen, &rlen); #endif } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { DEVICE->devinfo.devid = FLIUSB_PROLINE_ID; /* Let's get information about the hardware */ wlen = 2; rlen = 6; IOWRITE_U16(buf, 0, PROLINE_GET_HARDWAREINFO); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, DEVICE->devinfo.hwrev); IOREAD_U16(buf, 2, DEVICE->devinfo.serno); IOREAD_U16(buf, 4, rlen); /* Configuration data from ProLine is little endian, I can't believe * that I did this oh well, I'll deal with it! (Well, SDCC did it...) */ if (DEVICE->devinfo.hwrev >= 0x0100) { wlen = 2; IOWRITE_U16(buf, 0, PROLINE_GET_CAMERAINFO); IO(dev, buf, &wlen, &rlen); cam->ccd.array_area.ul.x = 0; cam->ccd.array_area.ul.y = 0; cam->ccd.array_area.lr.x = (buf[1] << 8) + buf[0]; cam->ccd.array_area.lr.y = (buf[3] << 8) + buf[2]; cam->ccd.visible_area.ul.x = (buf[9] << 8) + buf[8]; cam->ccd.visible_area.ul.y = (buf[11] << 8) + buf[10]; cam->ccd.visible_area.lr.x = (buf[5] << 8) + buf[4] + cam->ccd.visible_area.ul.x; cam->ccd.visible_area.lr.y = (buf[7] << 8) + buf[6] + cam->ccd.visible_area.ul.y; cam->ccd.pixelwidth = dconvert(&buf[12]); cam->ccd.pixelheight = dconvert(&buf[16]); cam->capabilities = buf[21] + (buf[22] << 8) + (buf[23] << 16) + (buf[24] << 24); rlen = 64; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_GET_DEVICESTRINGS); IO(dev, buf, &wlen, &rlen); DEVICE->devinfo.devnam = xstrndup((char *) &buf[0], 32); DEVICE->devinfo.model = xstrndup((char *) &buf[32], 32); } //#ifdef _WIN32_ // /* Check the registry to determine if we are overriding any settings */ // { // HKEY hKey; // DWORD t = 0; // DWORD len; // // if (RegOpenKey(HKEY_CURRENT_USER, // "SOFTWARE\\Finger Lakes Instrumentation\\libfli", // &hKey) == ERROR_SUCCESS) // { // len = sizeof(DWORD); // if (RegQueryValueEx(hKey, "fw_rev", NULL, NULL, (LPBYTE) &t, &len) == ERROR_SUCCESS) // { // debug(FLIDEBUG_INFO, "Found a request to override camera FWREV."); // } // RegCloseKey(hKey); // DEVICE->devinfo.fwrev = t; // } // } //#endif if (DEVICE->devinfo.fwrev == 0x0100) DEVICE->devinfo.fwrev = 0x0101; /* FW dependent capabilities */ if (DEVICE->devinfo.fwrev >= 0x0110) { cam->capabilities |= CAPABILITY_TDI; cam->capabilities |= CAPABILITY_BGFLUSH; } if (strncasecmp(DEVICE->devinfo.model, "MicroLine ML4022", 16) == 0) { debug(FLIDEBUG_INFO, "ML4022, overriding pixel size."); cam->ccd.pixelheight = 7.4e-6; cam->ccd.pixelwidth = 7.4e-6; } debug(FLIDEBUG_INFO, "Device has following capabilities:"); if SUPPORTS_VIDEO(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_VIDEO"); if SUPPORTS_TDI(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_TDI"); if SUPPORTS_BGFLUSH(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_BGFLUSH"); if SUPPORTS_END_EXPOSURE(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_END_EXPOSURE"); if SUPPORTS_SOFTWARE_TRIGGER(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_SOFTWARE_TRIGGER"); if SUPPORTS_VERTICAL_TABLE(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_VERTICAL_TABLE"); if SUPPORTS_16BIT_VBIN(DEVICE) debug(FLIDEBUG_INFO, " SUPPORTS_16BIT_VBIN"); /* Initialize all varaibles to something */ cam->vflushbin = 0; cam->hflushbin = 0; cam->vbin = 1; cam->hbin = 1; cam->image_area.ul.x = cam->ccd.visible_area.ul.x; cam->image_area.ul.y = cam->ccd.visible_area.ul.y; cam->image_area.lr.x = cam->ccd.visible_area.lr.x; cam->image_area.lr.y = cam->ccd.visible_area.lr.y; cam->exposure = 100; cam->frametype = FLI_FRAME_TYPE_NORMAL; cam->flushes = 0; cam->bitdepth = FLI_MODE_16BIT; cam->exttrigger = 0; cam->exttriggerpol = 0; cam->background_flush = 1; cam->tempslope = 1.0; cam->tempintercept = 0.0; cam->vertical_table = 0; cam->grabrowwidth = (cam->image_area.lr.x - cam->image_area.ul.x) / cam->hbin; cam->grabrowcount = 1; cam->grabrowcounttot = cam->grabrowcount; cam->grabrowindex = 0; cam->grabrowbatchsize = 1; cam->grabrowbufferindex = cam->grabrowcount; cam->flushcountbeforefirstrow = 0; cam->flushcountafterlastrow = 0; /* Now to set up the camera defaults */ } break; default: return -ENODEV; } debug(FLIDEBUG_INFO, "DeviceID %d", DEVICE->devinfo.devid); debug(FLIDEBUG_INFO, "SerialNum %d", DEVICE->devinfo.serno); debug(FLIDEBUG_INFO, "HWRev %04x", DEVICE->devinfo.hwrev); debug(FLIDEBUG_INFO, "FWRev %04x", DEVICE->devinfo.fwrev); debug(FLIDEBUG_INFO, " Name: %s", DEVICE->devinfo.devnam); debug(FLIDEBUG_INFO, " Array: (%4d,%4d),(%4d,%4d)", cam->ccd.array_area.ul.x, cam->ccd.array_area.ul.y, cam->ccd.array_area.lr.x, cam->ccd.array_area.lr.y); debug(FLIDEBUG_INFO, " Visible: (%4d,%4d),(%4d,%4d)", cam->ccd.visible_area.ul.x, cam->ccd.visible_area.ul.y, cam->ccd.visible_area.lr.x, cam->ccd.visible_area.lr.y); debug(FLIDEBUG_INFO, " Pix Size: (%g, %g)", cam->ccd.pixelwidth, cam->ccd.pixelheight); debug(FLIDEBUG_INFO, " Temp.: T = AD x %g + %g", cam->tempslope, cam->tempintercept); #ifdef BADCOLUMN { char b[128]; int index = 0; FILE *fp = NULL; fp = fopen("C:\\badcolumns.txt", "r"); if (fp != NULL) { debug(FLIDEBUG_INFO, "Loading bad column list."); memset(b, '\0', 128); while ((index < 1023) && (fgets(b, 127, fp) != NULL)) { if (!isdigit(b[0])) continue; cam->badcolumns[index] = strtol(b, NULL, 0); debug(FLIDEBUG_INFO, "Adding bad column %d to list", cam->badcolumns[index]); index++; } fclose(fp); } cam->badcolumns[index] = (-1); } #endif return 0; } long fli_camera_usb_get_array_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y) { flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } *ul_x = cam->ccd.array_area.ul.x; *ul_y = cam->ccd.array_area.ul.y; *lr_x = cam->ccd.array_area.lr.x; *lr_y = cam->ccd.array_area.lr.y; return 0; } long fli_camera_usb_get_visible_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y) { flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } *ul_x = cam->ccd.visible_area.ul.x; *ul_y = cam->ccd.visible_area.ul.y; *lr_x = cam->ccd.visible_area.lr.x; *lr_y = cam->ccd.visible_area.lr.y; return 0; } long fli_camera_usb_set_exposure_time(flidev_t dev, unsigned long exptime) { flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { long rlen, wlen; iobuf_t buf[8]; rlen = 0; wlen = 8; IOWRITE_U16(buf, 0, FLI_USBCAM_SETEXPOSURE); IOWRITE_U32(buf, 4, exptime); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } cam->exposure = exptime; return 0; } long fli_camera_usb_set_image_area(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y) { flicamdata_t *cam = DEVICE->device_data; int r = 0; cam->vertical_table = 0; if( (DEVICE->devinfo.fwrev < 0x0300) && ((DEVICE->devinfo.hwrev & 0xff00) == 0x0100) && (DEVICE->devinfo.devid != FLIUSB_PROLINE_ID)) { if( (lr_x > (cam->ccd.visible_area.lr.x * cam->hbin)) || (lr_y > (cam->ccd.visible_area.lr.y * cam->vbin)) ) { debug(FLIDEBUG_WARN, "Area out of bounds: (%4d,%4d),(%4d,%4d)", ul_x, ul_y, lr_x, lr_y); return -EINVAL; } } if( (ul_x < 0) || (ul_y < 0) ) { debug(FLIDEBUG_FAIL, "Area out of bounds: (%4d,%4d),(%4d,%4d)", ul_x, ul_y, lr_x, lr_y); return -EINVAL; } debug(FLIDEBUG_INFO, "Setting image area to: (%4d,%4d),(%4d,%4d)", ul_x, ul_y, lr_x, lr_y); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { long rlen, wlen; iobuf_t buf[IOBUF_MAX_SIZ]; memset(buf, 0x00, IOBUF_MAX_SIZ); rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFRAMEOFFSET); IOWRITE_U16(buf, 2, ul_x); IOWRITE_U16(buf, 4, ul_y); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { /* JIM! perform some bounds checking... */ /* Remember TDI imaging does not have a limit on vertical height */ } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } if (r == 0) { cam->image_area.ul.x = ul_x; cam->image_area.ul.y = ul_y; cam->image_area.lr.x = lr_x; cam->image_area.lr.y = lr_y; cam->grabrowwidth = (cam->image_area.lr.x - cam->image_area.ul.x) / cam->hbin; } return 0; } long fli_camera_usb_set_hbin(flidev_t dev, long hbin) { iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; // long r = 0; flicamdata_t *cam = DEVICE->device_data; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if ((hbin < 1) || (hbin > 16)) return -EINVAL; rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETBINFACTORS); IOWRITE_U16(buf, 2, hbin); IOWRITE_U16(buf, 4, cam->vbin); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if ((hbin < 1) || (hbin > 255)) return -EINVAL; /* We do nothing here, h_bin is sent with start exposure command this may be a bug, TDI imaging will require this */ } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } cam->hbin = hbin; cam->grabrowwidth = (cam->image_area.lr.x - cam->image_area.ul.x) / cam->hbin; return 0; } long fli_camera_usb_set_vbin(flidev_t dev, long vbin) { iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; // long r = 0; flicamdata_t *cam = DEVICE->device_data; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if ((vbin < 1) || (vbin > 16)) return -EINVAL; rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETBINFACTORS); IOWRITE_U16(buf, 2, cam->hbin); IOWRITE_U16(buf, 4, vbin); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { /* We do nothing here, h_bin is sent with start exposure command this may be a bug, TDI imaging will require this */ if SUPPORTS_16BIT_VBIN(DEVICE) { if ((vbin < 1) || (vbin > 32767)) return -EINVAL; } else { if ((vbin < 1) || (vbin > 255)) return -EINVAL; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } cam->vbin = vbin; return 0; } long fli_camera_usb_get_exposure_status(flidev_t dev, long *timeleft) { switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { long rlen, wlen; iobuf_t buf[4]; rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_EXPOSURESTATUS); IO(dev, buf, &wlen, &rlen); IOREAD_U32(buf, 0, *timeleft); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { long rlen, wlen; iobuf_t buf[IOBUF_MAX_SIZ]; rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_EXPOSURE_STATUS); IO(dev, buf, &wlen, &rlen); *timeleft = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return 0; } long fli_camera_usb_cancel_exposure(flidev_t dev) { flicamdata_t *cam = DEVICE->device_data; cam->tdirate = 0; cam->tdiflags = 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { long rlen, wlen; iobuf_t buf[IOBUF_MAX_SIZ]; rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_ABORTEXPOSURE); IO(dev, buf, &wlen, &rlen); /* MaxCam (bug in firmware prevents shutter closing), so issue quick exposure... */ rlen = 0; wlen = 8; /* Bias frame */ IOWRITE_U16(buf, 0, FLI_USBCAM_SETEXPOSURE); IOWRITE_U32(buf, 4, 10); IO(dev, buf, &wlen, &rlen); /* Expose the bias frame */ rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_STARTEXPOSURE); IOWRITE_U16(buf, 2, 0); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { long rlen = 2, wlen = 2; iobuf_t buf[IOBUF_MAX_SIZ]; IOWRITE_U16(buf, 0, PROLINE_COMMAND_CANCEL_EXPOSURE); IO(dev, buf, &wlen, &rlen); cam->video_mode = VIDEO_MODE_OFF; } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return 0; } long fli_camera_usb_set_temperature(flidev_t dev, double temperature) { flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { unsigned short ad; long rlen, wlen; iobuf_t buf[4]; if(DEVICE->devinfo.fwrev < 0x0200) return 0; if(cam->tempslope == 0.0) ad = 255; else ad = (unsigned short) ((temperature - cam->tempintercept) / cam->tempslope); debug(FLIDEBUG_INFO, "Temperature slope, intercept, AD val, %f %f %f %d", temperature, cam->tempslope, cam->tempintercept, ad); rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_TEMPERATURE); IOWRITE_U16(buf, 2, ad); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { long rlen, wlen; iobuf_t buf[IOBUF_MAX_SIZ]; unsigned short a; short s_temp; s_temp = (short) (temperature * 256.0); rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_TEMPERATURE); IOWRITE_U16(buf, 2, s_temp); IO(dev, buf, &wlen, &rlen); a = (buf[0] << 8) + buf[1]; debug(FLIDEBUG_INFO, "Got %d from camera.", a); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return 0; } long fli_camera_usb_read_temperature(flidev_t dev, flichannel_t channel, double *temperature) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if (channel == 0) { rlen = 2; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_TEMPERATURE); IO(dev, buf, &wlen, &rlen); *temperature = cam->tempslope * ((double) buf[1]) + cam->tempintercept; } else { *temperature = (0.0); } } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { double base, ccd; rlen = 14; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_TEMPERATURE); IO(dev, buf, &wlen, &rlen); ccd = (double) ((signed char) buf[0]) + ((double) buf[1] / 256); base = (double) ((signed char) buf[2]) + ((double) buf[3] / 256); switch (channel) { case FLI_TEMPERATURE_CCD: *temperature = ccd; break; case FLI_TEMPERATURE_BASE: *temperature = base; break; default: r = -EINVAL; break; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_get_temperature(flidev_t dev, double *temperature) { return fli_camera_usb_read_temperature(dev, 0, temperature); } long fli_camera_usb_grab_row(flidev_t dev, void *buff, size_t width) { flicamdata_t *cam = DEVICE->device_data; int abort = 0; if(width > (size_t) (cam->image_area.lr.x - cam->image_area.ul.x)) { debug(FLIDEBUG_FAIL, "Requested row too wide, truncating."); debug(FLIDEBUG_FAIL, " Requested width: %d", width); debug(FLIDEBUG_FAIL, " Set width: %d", cam->image_area.lr.x - cam->image_area.ul.x); width = cam->image_area.lr.x - cam->image_area.ul.x; } if (cam->gbuf == NULL) return -ENOMEM; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { long x; long r; if (cam->flushcountbeforefirstrow > 0) { debug(FLIDEBUG_INFO, "Flushing %d rows before image download.", cam->flushcountbeforefirstrow); if ((r = fli_camera_usb_flush_rows(dev, cam->flushcountbeforefirstrow, 1))) return r; cam->flushcountbeforefirstrow = 0; } if (cam->grabrowbufferindex >= cam->grabrowbatchsize) { /* We don't have the row in memory */ long rlen, wlen; /* Do we have less than GrabRowBatchSize rows to grab? */ if (cam->grabrowbatchsize > (cam->grabrowcounttot - cam->grabrowindex)) { cam->grabrowbatchsize = cam->grabrowcounttot - cam->grabrowindex; if (cam->grabrowbatchsize < 1) cam->grabrowbatchsize = 1; } debug(FLIDEBUG_INFO, "Grabbing %d rows of width %d.", cam->grabrowbatchsize, cam->grabrowwidth); rlen = cam->grabrowwidth * 2 * cam->grabrowbatchsize; wlen = 6; cam->gbuf[0] = htons(FLI_USBCAM_SENDROW); cam->gbuf[1] = htons((unsigned short) cam->grabrowwidth); cam->gbuf[2] = htons((unsigned short) cam->grabrowbatchsize); IO(dev, cam->gbuf, &wlen, &rlen); for (x = 0; x < (cam->grabrowwidth * cam->grabrowbatchsize); x++) { if ((DEVICE->devinfo.hwrev & 0xff00) == 0x0100) { cam->gbuf[x] = ntohs(cam->gbuf[x]) + 32768; } else { cam->gbuf[x] = ntohs(cam->gbuf[x]); } } cam->grabrowbufferindex = 0; } for (x = 0; x < (long)width; x++) { ((unsigned short *)buff)[x] = cam->gbuf[x + (cam->grabrowbufferindex * cam->grabrowwidth)]; } cam->grabrowbufferindex++; cam->grabrowindex++; if (cam->grabrowcount > 0) { cam->grabrowcount--; if (cam->grabrowcount == 0) { if (cam->flushcountafterlastrow > 0) { debug(FLIDEBUG_INFO, "Flushing %d rows after image download.", cam->flushcountafterlastrow); if ((r = fli_camera_usb_flush_rows(dev, cam->flushcountafterlastrow, 1))) return r; } cam->flushcountafterlastrow = 0; cam->grabrowbatchsize = 1; } } } break; #ifdef OLD_PROLINE /* Proline/Microline Camera */ case FLIUSB_PROLINE_ID+1: { long rlen, rtotal; int abort = 0; /* First we need to determine if the row is in memory */ while ( (cam->grabrowcounttot < cam->grabrowwidth) && (abort == 0) ) { int loadindex = 0; long rowsleft, bytesleft, wordsleft; /* Ring buffer for image download... ideally this should just * swap from top to bottom as 1/2 the buffer is filled each time. * For single row grabs * * cam->gbuf_siz -- size of the grab buffer (bytes) * cam->max_usb_xfer -- size of the maximum USB transfer (bytes) * cam->grabrowindex -- current row being grabbed * cam->grabrowcounttot -- number of words left in buffer (words) * cam->grabrowbufferindex -- location of the beginning of the row in the buffer in words * */ /* Let's fill the buffer */ rlen = (cam->gbuf_siz / 2) - (cam->grabrowbufferindex + cam->grabrowcounttot); /* Words to bytes */ rlen *= 2; if (rlen < 0) { debug(FLIDEBUG_FAIL, "READ, rlen < 0!"); abort = 1; continue; } else if (rlen == 0) { /* For this to be true we must have the buffer completely filled * so we start back at the beginning */ rlen = cam->max_usb_xfer; loadindex = 0; } else { loadindex = cam->grabrowbufferindex + cam->grabrowcounttot; } /* At this point rlen is positive and non-zero * we should constrain its limit to no more than the * data we are expecting from the camera. Furthermore, * we may just need to fill to the top of the buffer then * wrap around... */ if (cam->tdirate == 0) { rowsleft = cam->grabrowcount - cam->grabrowindex; wordsleft = (rowsleft * cam->grabrowwidth) - cam->grabrowcounttot; bytesleft = wordsleft * 2; } else { /* For TDI imaging we only want one row at a time, must be rounded up * to 512 bytes wide */ bytesleft = (cam->grabrowwidth - cam->grabrowcounttot) * 2; if (bytesleft & 0x1ff) { debug(FLIDEBUG_WARN, "TDI row width must be multiple of 512 bytes!"); abort = 1; continue; } } if (rlen > bytesleft) rlen = bytesleft; if (rlen > cam->max_usb_xfer) rlen = cam->max_usb_xfer; memset(&cam->gbuf[loadindex], 0x00, rlen); rtotal = rlen; debug(FLIDEBUG_INFO, "Transfer, Base: %p Start: %p End: %p Size: %d", &cam->gbuf[0], &cam->gbuf[loadindex], &cam->gbuf[loadindex + rlen / 2], rlen); #ifdef CHECK_STATUS do { } while (status & #endif if ((usb_bulktransfer(dev, 0x82, &cam->gbuf[loadindex], &rlen)) != 0) /* Grab the buffer */ { debug(FLIDEBUG_FAIL, "Read failed..."); abort = 1; } if ((rlen < rtotal) && (cam->grabrowindex > 0)) { char b[2048]; #ifdef _WIN32 sprintf(b, "Pad, L:%d\n", cam->grabrowindex); OutputDebugString(b); #endif debug(FLIDEBUG_FAIL, "Transfer did not complete, padding..."); memset(&cam->gbuf[cam->grabrowcounttot], 0x00, (rtotal - rlen)); } cam->grabrowcounttot += (rlen / 2); } /* Double check that row is in memory (an IO operation could have failed.) */ if ( (abort == 0) && (cam->grabrowcounttot >= cam->grabrowwidth) ) { long l = 0; while (l < cam->grabrowwidth) { /* Are we at the end of the buffer? */ if ((cam->grabrowbufferindex + cam->grabrowwidth) < ((cam->max_usb_xfer / 2) * 2) ) { /* Not near end of buffer */ while (l < cam->grabrowwidth) { if (l < width) ((unsigned short *) buff)[l] = ((cam->gbuf[cam->grabrowbufferindex] << 8) & 0xff00) | ((cam->gbuf[cam->grabrowbufferindex] >> 8) & 0x00ff); cam->grabrowbufferindex ++; l ++; } } else { /* Near end of buffer */ while (cam->grabrowbufferindex < ((cam->max_usb_xfer / 2) * 2)) { if (l < width) ((unsigned short *) buff)[l] = ((cam->gbuf[cam->grabrowbufferindex] << 8) & 0xff00) | ((cam->gbuf[cam->grabrowbufferindex] >> 8) & 0x00ff); cam->grabrowbufferindex ++; l ++; } cam->grabrowbufferindex = 0; } } cam->grabrowcounttot -= cam->grabrowwidth; cam->grabrowindex ++; } } break; #endif /* New code */ case FLIUSB_PROLINE_ID: { long rlen = 0, rtotal = 0; int index = 0; /* * cam->gbuf_siz -- size of the grab buffer (bytes) * cam->ibuf_siz -- size of image buffer (bytes) * cam->max_usb_xfer -- size of the maximum USB transfer (bytes) * cam->grabrowindex -- current row being grabbed * cam->grabrowcounttot -- * cam->grabrowbufferindex -- * cam->bytesleft -- number of bytes left to acquire from camera */ long top = 1; long di = 1; long row_idx; long to, bo, lo, ro; long th, bh, lw, rw; long w; unsigned short *left, *right, *ibuf; /* Normalize the offsets */ to = cam->top_offset - MIN(cam->top_offset, cam->bottom_offset); bo = cam->bottom_offset - MIN(cam->top_offset, cam->bottom_offset); lo = cam->left_offset - MIN(cam->left_offset, cam->right_offset); ro = cam->right_offset - MIN(cam->left_offset, cam->right_offset); /* Make these nicer to use */ th = cam->top_height; bh = cam->bottom_height; lw = cam->left_width; rw = cam->right_width; row_idx = cam->grabrowindex; w = lw + rw; left = (unsigned short *) buff; right = (unsigned short *) buff + w; ibuf = cam->ibuf; /* Fix these so that data is "contiguous" */ if (bo > th) bo = th; /* Bottom data starts immediately after top data */ if (to > bh) to = bh; /* Top data starts immediately after bottom data */ /* Top data is first */ if (to == 0) /* Top is first data (bo can be zero also without a problem) */ { /* Now determine bottom or top */ if (row_idx < th) /* Top */ { if (row_idx < bo) /* No Bottom Data yet */ { ibuf += w * row_idx; di = 1; } else /* Bottom Data mixed in */ { ibuf += w * bo; /* Take us to where the bottom data starts */ if (row_idx < (bo + bh)) /* Still with bottom data around */ { ibuf += w * 2 * (row_idx - bo); di = 2; } else /* Past bottom data */ { ibuf += w * 2 * bh; ibuf += w * (row_idx - (bo + bh)); di = 1; } } } else if (row_idx < (th + bh)) /* Bottom */ { top = 0; /* Bottom Data */ row_idx -= th; /* Normalize */ ibuf = cam->ibuf + ((th + bh) * w); /* End of buffer */ if (row_idx < ((bo + bh) - th)) /* No Top Data yet */ { ibuf -= w * row_idx; di = 1; } else /* Top Data mixed in */ { if (((bo + bh) - th) > 0) { ibuf -= w * ((bo + bh) - th); /* Take us to where the bottom data starts */ row_idx -= ((bo + bh) - th); } if (row_idx < (to + th)) /* Still with bottom data around */ { ibuf -= w * 2 * (row_idx - to); // ibuf ++; /* Re-align */ di = 2; } else /* Past top data */ { ibuf -= w * 2 * th; ibuf -= w * (row_idx - (to + th)); di = 1; } } ibuf -= w * di; /* Position at the beginning of the row */ } else { /* We shouldn't be here */ } } else /* to != 0, bottom data has started */ { /* Now determine bottom or top */ if (row_idx < th) /* Top */ { ibuf = cam->ibuf + w * to; /* Beginning of data */ if (row_idx < (bh - to)) /* Bottom data intermixed */ { ibuf += w * 2 * row_idx; di = 2; } else /* Past bottom data */ { if ((bh - to) >= 0) { ibuf += w * 2 * (bh - to); /* Move past shared data */ ibuf += w * (row_idx - (bh - to)); di = 1; } else { ibuf += w * row_idx; di = 1; } } } else if (row_idx < (th + bh)) /* Bottom */ { top = 0; row_idx -= th; /* Normalize the index in terms of top rows */ ibuf = cam->ibuf + ((th + bh) * w); /* End of buffer */ if (row_idx < (bh - (to + th))) /* Past Top Data */ { ibuf -= w * row_idx; di = 1; } else if (row_idx < (bh - to)) /* Mixed Data */ { if ((bh - (to + th)) > 0) /* Position ourselves */ { ibuf -= w * (bh - (to + th)); row_idx -= (bh - (to + th)); } ibuf -= w * 2 * row_idx; di = 2; } else { if ((bh - (to + th)) > 0) /* Position ourselves */ { ibuf -= w * (bh - (to + th)); row_idx -= (bh - (to + th)); } if ((bh - to) > 0) { ibuf -= w * 2 * (bh - to); row_idx -= (bh - to); } ibuf -= w * row_idx; di = 1; } ibuf -= w * di; /* Position at the beginning of the row */ } else { /* We shouldn't be here */ } } /* First we need to determine if the row is in memory */ while ((cam->ibuf_wr_idx < (ibuf + w * di)) && (abort == 0) && (cam->bytesleft > 0)) { /* Let's get some more from the camera */ /* Not performing TDI */ if (cam->tdirate == 0) { rlen = (long) MIN(cam->bytesleft, (size_t) cam->max_usb_xfer); } else /* For TDI imaging we only want one row at a time, must be rounded up * to 512 bytes wide */ { rlen = cam->grabrowwidth * 2; if (rlen & 0x1ff) { debug(FLIDEBUG_WARN, "TDI row download width must be multiple of 512 bytes!"); abort = 1; continue; } } memset(cam->gbuf, 0x00, rlen); rtotal = rlen; if ((usb_bulktransfer(dev, 0x82, cam->gbuf, &rlen)) != 0) /* Grab the buffer */ { debug(FLIDEBUG_FAIL, "Read failed..."); abort = 1; } if (rlen < rtotal) { debug(FLIDEBUG_FAIL, "Transfer did not complete..."); } if (rlen == 0x03) /* This is a special case, the camera is telling us there * is no more data, something went wrong */ { cam->bytesleft = 0; } else { cam->bytesleft -= rlen; } for (index = 0; index < (rlen / (long) sizeof(unsigned short)); index ++) { *cam->ibuf_wr_idx = ((cam->gbuf[index] << 8) & 0xff00) | ((cam->gbuf[index] >> 8) & 0x00ff); cam->ibuf_wr_idx++; } } memset(left, 0x00, width * sizeof(unsigned short)); /* Double check that row is in memory (an IO operation could have failed.) */ if (cam->ibuf_wr_idx >= (ibuf + w * di)) { /* Top data only */ if (top == 1) { // long r = row_idx; /* Beginning of row, left portion of data */ while ( (ro > 0) && (left < right) ) { *left = *ibuf; left++; lw--; ro--; ibuf += di; } /* Beginning of row, right portion of data */ while ( (lo > 0) && (left < right) ) { right--; *right = *ibuf; rw--; lo--; ibuf += di; } /* Both portions of data, middle of the row */ while ( ((rw > 0) && (lw > 0)) && (left < right) ) { *left = *ibuf; left ++; lw --; ibuf += di; --right; *right = *ibuf; rw --; ibuf += di; } /* Remaining left data */ while ( (lw > 0) && (left < right) ) { *left = *ibuf; left++; lw--; ibuf += di; } /* Remaining right data */ while ( (rw > 0) && (left < right) ) { right--; *right = *ibuf; rw--; ibuf += di; } } else /* Bottom Data */ { // long r = row_idx; /* Re-align */ if (di == 2) { ibuf ++; di = 2; } /* Beginning of row, left portion of data */ while ( (ro > 0) && (left < right) ) { *left = *ibuf; left++; lw--; ro--; ibuf += di; } /* Beginning of row, right portion of data */ while ( (lo > 0) && (left < right) ) { right--; *right = *ibuf; rw--; lo--; ibuf += di; } /* Both portions of data, middle of the row */ while ( ((rw > 0) && (lw > 0)) && (left < right) ) { *left = *ibuf; left ++; lw --; ibuf += di; --right; *right = *ibuf; rw --; ibuf += di; } /* Remaining left data */ while ( (lw > 0) && (left < right) ) { *left = *ibuf; left++; lw--; ibuf += di; } /* Remaining right data */ while ( (rw > 0) && (left < right) ) { right--; *right = *ibuf; rw--; ibuf += di; } } } cam->grabrowindex ++; } #ifdef BADCOLUMN /* Only do this bin 1 */ if ( (cam->hbin == 1) && (width > 1) ) { int index = 0; long t; int column; unsigned short *row = (unsigned short *) buff; while ((index < 1024) && ((column = cam->badcolumns[index]) >= 0)) { index++; /* Subtract the offset */ column -= cam->image_area.ul.x; if (column < 0) continue; if (column == 0) /* Right at the edge */ { row[0] = row[1]; // row[0] = 65535; } else if (column < ((long) width - 1)) /* Somewhere in between */ { t = (row[column - 1] + row[column + 1]) >> 1; row[column] = (unsigned short) t; // row[column] = 65535; } else if (column == (width - 1)) /* Last column */ { row[column] = row[column - 1]; // row[column] = 65535; } } } #endif break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } if(abort) { return -EIO; } return 0; } long fli_camera_usb_stop_video_mode(flidev_t dev) { flicamdata_t *cam = DEVICE->device_data; /* This function only works on specific prolines, use this function to * determine if video mode is available on the camera. If it succeeds, then * video mode is supported, if it fails, then it isn't. */ if (!SUPPORTS_VIDEO(DEVICE)) { debug(FLIDEBUG_FAIL, "Video mode not supported."); return -EINVAL; } if (cam->video_mode == VIDEO_MODE_OFF) { debug(FLIDEBUG_WARN, "Video mode not started."); } return fli_camera_usb_cancel_exposure(dev); } long fli_camera_usb_start_video_mode(flidev_t dev) { flicamdata_t *cam = DEVICE->device_data; /* This function only works on specific prolines */ if (!SUPPORTS_VIDEO(DEVICE)) { debug(FLIDEBUG_FAIL, "Video mode not supported."); return -EINVAL; } if (cam->video_mode != VIDEO_MODE_OFF) { debug(FLIDEBUG_WARN, "Video mode already started, restarting..."); fli_camera_usb_stop_video_mode(dev); } cam->video_mode = VIDEO_MODE_BEGIN; return fli_camera_usb_expose_frame(dev); } //long fli_camera_usb_prepare_video_frame(flidev_t dev) //{ // flicamdata_t *cam = DEVICE->device_data; // // /* This function only works on specific cameras */ // if (!SUPPORTS_VIDEO(cam)) // { // debug(FLIDEBUG_FAIL, "Video mode not supported."); // return -EINVAL; // } // // if (cam->video_mode != VIDEO_MODE_ON) // { // debug(FLIDEBUG_FAIL, "Video mode not started."); // return -EINVAL; // } // // debug(FLIDEBUG_INFO, "Prepare Video Frame."); // // /* Video mode is supported and started, for now implement with FLIGrabRow(), // this may not be fast enough in the future... */ // // /* Since this is proline/microline only, this is hacked from fli_camera_usb_expose_frame() // * in the proline section, this is done only so that I can use // * fli_camera_usb_grab_row() (YES! this is a hack!) */ // // cam->grabrowcount = cam->image_area.lr.y - cam->image_area.ul.y; // Rows High // cam->grabrowwidth = cam->image_area.lr.x - cam->image_area.ul.x; // Pixels Wide // cam->flushcountbeforefirstrow = cam->image_area.ul.y; // Vertical Offset // cam->grabrowindex = 0; // cam->grabrowbatchsize = 0; // cam->grabrowcounttot = 0; // cam->grabrowbufferindex = 0; // cam->flushcountafterlastrow = 0; // cam->ibuf_wr_idx = cam->ibuf; // cam->bytesleft = (cam->top_height + cam->bottom_height) * // (cam->left_width + cam->right_width) * sizeof(unsigned short); // // return 0; //} long fli_camera_usb_grab_video_frame(flidev_t dev, void *buff, size_t size) { flicamdata_t *cam = DEVICE->device_data; long y = 0; long status = 0; /* This function only works on specific cameras */ if (!SUPPORTS_VIDEO(DEVICE)) { debug(FLIDEBUG_FAIL, "Video mode not supported."); return -EINVAL; } if (cam->video_mode != VIDEO_MODE_ON) { debug(FLIDEBUG_FAIL, "Video mode not started."); return -EINVAL; } debug(FLIDEBUG_INFO, "Grab Video Frame."); /* Video mode is supported and started, for now implement with FLIGrabRow(), this may not be fast enough in the future... */ /* Since this is proline/microline only, this is hacked from fli_camera_usb_expose_frame() * in the proline section, this is done only so that I can use * fli_camera_usb_grab_row() (YES! this is a hack!) */ cam->grabrowcount = cam->image_area.lr.y - cam->image_area.ul.y; // Rows High cam->grabrowwidth = cam->image_area.lr.x - cam->image_area.ul.x; // Pixels Wide cam->flushcountbeforefirstrow = cam->image_area.ul.y; // Vertical Offset cam->grabrowindex = 0; cam->grabrowbatchsize = 0; cam->grabrowcounttot = 0; cam->grabrowbufferindex = 0; cam->flushcountafterlastrow = 0; cam->ibuf_wr_idx = cam->ibuf; cam->bytesleft = (cam->top_height + cam->bottom_height) * (cam->left_width + cam->right_width) * sizeof(unsigned short); if (size < (cam->grabrowcount * cam->grabrowwidth * sizeof(unsigned short))) { debug(FLIDEBUG_FAIL, "Buffer not large enough to receive frame."); return -ENOMEM; } status = 0; while ((status == 0) && (y < cam->grabrowcount)) { // debug(FLIDEBUG_INFO, "Grabbing row %d of %d of width %d.", y, cam->grabrowcount, cam->grabrowwidth); status = fli_camera_usb_grab_row(dev, buff, cam->grabrowwidth); // ((unsigned short *) buff) += cam->grabrowwidth; buff = ((unsigned short *) buff) + cam->grabrowwidth; y++; } return status; } long fli_camera_usb_set_tdi(flidev_t dev, flitdirate_t rate, flitdiflags_t flags) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); /* Some of these don't support TDI */ if ( !SUPPORTS_TDI(DEVICE) || (rate < 0) ) { return -EINVAL; } switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { /* These cameras don't support TDI */ r = -EINVAL; } break; case FLIUSB_PROLINE_ID: { cam->tdirate = rate; cam->tdiflags = flags; rlen = 2; wlen = 6; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_TDI_MODE); /* TDI Rate */ IOWRITE_U32(buf, 2, cam->tdirate); /* Enable */ IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_expose_frame(flidev_t dev) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); if (cam->video_mode == VIDEO_MODE_ON) { debug(FLIDEBUG_FAIL, "Video mode has started."); return -EINVAL; } switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { short flags = 0; rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFRAMEOFFSET); IOWRITE_U16(buf, 2, cam->image_area.ul.x); IOWRITE_U16(buf, 4, cam->image_area.ul.y); IO(dev, buf, &wlen, &rlen); rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETBINFACTORS); IOWRITE_U16(buf, 2, cam->hbin); IOWRITE_U16(buf, 4, cam->vbin); IO(dev, buf, &wlen, &rlen); rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFLUSHBINFACTORS); IOWRITE_U16(buf, 2, cam->hflushbin); IOWRITE_U16(buf, 4, cam->vflushbin); IO(dev, buf, &wlen, &rlen); rlen = 0; wlen = 8; IOWRITE_U16(buf, 0, FLI_USBCAM_SETEXPOSURE); IOWRITE_U32(buf, 4, cam->exposure); IO(dev, buf, &wlen, &rlen); /* What flags do we need to send... */ /* Dark Frame */ flags |= (cam->frametype & FLI_FRAME_TYPE_DARK) ? 0x01 : 0x00; /* External trigger */ flags |= (cam->exttrigger != 0) ? 0x04 : 0x00; flags |= (cam->exttriggerpol != 0) ? 0x08 : 0x00; debug(FLIDEBUG_INFO, "Exposure flags: %04x", flags); debug(FLIDEBUG_INFO, "Flushing %d times.", cam->flushes); if (cam->flushes > 0) { long r; if ((r = fli_camera_usb_flush_rows(dev, cam->ccd.array_area.lr.y - cam->ccd.array_area.ul.y, cam->flushes))) return r; } debug(FLIDEBUG_INFO, "Starting exposure..."); rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_STARTEXPOSURE); IOWRITE_U16(buf, 2, flags); IO(dev, buf, &wlen, &rlen); cam->grabrowcount = cam->image_area.lr.y - cam->image_area.ul.y; cam->grabrowcounttot = cam->grabrowcount; cam->grabrowwidth = cam->image_area.lr.x - cam->image_area.ul.x; cam->grabrowindex = 0; if (cam->grabrowwidth > 0){ cam->grabrowbatchsize = USB_READ_SIZ_MAX / (cam->grabrowwidth * 2); } else { return -1; } /* Lets put some bounds on this... */ if (cam->grabrowbatchsize > cam->grabrowcounttot) cam->grabrowbatchsize = cam->grabrowcounttot; if (cam->grabrowbatchsize > 64) cam->grabrowbatchsize = 64; /* We need to get a whole new buffer by default */ cam->grabrowbufferindex = cam->grabrowbatchsize; cam->flushcountbeforefirstrow = cam->image_area.ul.y; cam->flushcountafterlastrow = (cam->ccd.array_area.lr.y - cam->ccd.array_area.ul.y) - ((cam->image_area.lr.y - cam->image_area.ul.y) * cam->vbin) - cam->image_area.ul.y; if (cam->flushcountbeforefirstrow < 0) cam->flushcountbeforefirstrow = 0; if (cam->flushcountafterlastrow < 0) cam->flushcountafterlastrow = 0; } break; case FLIUSB_PROLINE_ID: { short h_offset; size_t numpix; cam->grabrowcount = cam->image_area.lr.y - cam->image_area.ul.y; // Rows High cam->grabrowwidth = cam->image_area.lr.x - cam->image_area.ul.x; // Pixels Wide /* Row width in bytes must be multiple of 512 (256 pixels) so that * single rows can be grabbed by FLIGrabRow */ if (cam->tdirate != 0) { if ((cam->grabrowwidth % 256) != 0) cam->grabrowwidth += (256 - (cam->grabrowwidth % 256)); } cam->flushcountbeforefirstrow = cam->image_area.ul.y; // Vertical Offset h_offset = cam->image_area.ul.x; // Horizontal Offset cam->grabrowindex = 0; cam->grabrowbatchsize = 0; cam->grabrowcounttot = 0; cam->grabrowbufferindex = 0; cam->flushcountafterlastrow = 0; if (cam->grabrowwidth <= 0) return -EINVAL; /* Check FW revision, >= 2.0 returns a structure defining * image parameters */ if (DEVICE->devinfo.fwrev >= 0x0200) { rlen = 64; wlen = 64; } else { rlen = 0; wlen = 32; } IOWRITE_U16(buf, 0, PROLINE_COMMAND_EXPOSE); /* Number of pixels wide */ IOWRITE_U16(buf, 2, cam->grabrowwidth); /* Horizontal offset */ IOWRITE_U16(buf, 4, h_offset); /* Number of vertical rows to grab */ IOWRITE_U16(buf, 6, cam->grabrowcount); /* Vertical offset */ IOWRITE_U16(buf, 8, cam->flushcountbeforefirstrow); /* Horizontal bin */ IOWRITE_U8(buf, 10, cam->hbin); /* Vertical bin */ IOWRITE_U8(buf, 11, cam->vbin); IOWRITE_U8(buf, 18, (((unsigned) cam->vbin) >> 8)); /* Allow for 16-bit vbin */ /* Exposure */ IOWRITE_U32(buf, 12, cam->exposure); /* Now the exposure flags (16, 17 will be for them) */ buf[16] = (cam->frametype & FLI_FRAME_TYPE_DARK) ? 0x01 : 0x00; buf[16] |= (cam->frametype & FLI_FRAME_TYPE_FLOOD) ? 0x08 : 0x00; buf[16] |= ((cam->exttrigger != 0) && (cam->exttriggerpol == 0)) ? 0x02 : 0x00; buf[16] |= ((cam->exttrigger != 0) && (cam->exttriggerpol != 0)) ? 0x04 : 0x00; buf[16] |= (cam->extexposurectrl != 0) ? 0x20 : 0x00; buf[16] |= (cam->vertical_table != 0) ? 0x40 : 0x00; if ((cam->video_mode == VIDEO_MODE_BEGIN) && SUPPORTS_VIDEO(DEVICE)) { buf[16] |= 0x10; /* Enable video mode */ cam->video_mode = VIDEO_MODE_ON; } /* Perform the transation */ IO(dev, buf, &wlen, &rlen); /* Newer Proline/Microline */ if (DEVICE->devinfo.fwrev >= 0x0200) { IOREAD_U16L(buf, 0, cam->top_height) IOREAD_U16L(buf, 2, cam->top_offset) IOREAD_U16L(buf, 44, cam->bottom_height) IOREAD_U16L(buf, 4, cam->bottom_offset) IOREAD_U16L(buf, 11, cam->left_width) IOREAD_U16L(buf, 13, cam->left_offset) IOREAD_U16L(buf, 15, cam->right_width) IOREAD_U16L(buf, 17, cam->right_offset) } else { cam->top_height = cam->grabrowcount; cam->top_offset = 0; cam->bottom_height = 0; cam->bottom_offset = cam->grabrowcount; cam->left_width = cam->grabrowwidth; cam->left_offset = 0; cam->right_width = 0; cam->right_offset =cam->grabrowwidth; } debug(FLIDEBUG_INFO, " Grab Height: %d", cam->top_height); debug(FLIDEBUG_INFO, " Top Flush: %d", cam->top_offset); debug(FLIDEBUG_INFO, " Bottom Height: %d", cam->bottom_height); debug(FLIDEBUG_INFO, " Bottom Flush: %d", cam->bottom_offset); debug(FLIDEBUG_INFO, " Left Width: %d", cam->left_width); debug(FLIDEBUG_INFO, " Left Offset: %d", cam->left_offset); debug(FLIDEBUG_INFO, " Right Width: %d", cam->right_width); debug(FLIDEBUG_INFO, " Right Offset: %d", cam->right_offset); numpix = (cam->top_height + cam->bottom_height) * (cam->left_width + cam->right_width); cam->dl_index = 0; cam->bytesleft = numpix * sizeof(unsigned short); /* Let's reallocate the image buffer if needed, this will * allow us to build the entire image in memory. This is needed * for top/bottom (four quadrant) detectors. */ if (cam->ibuf_siz < (numpix * sizeof(unsigned short))) { if (cam->ibuf != NULL) xfree(cam->ibuf); cam->ibuf = NULL; cam->ibuf_siz = numpix * sizeof(unsigned short); #ifdef __linux__ /* Linux needs this page aligned, hopefully this is 512 byte aligned too... */ cam->ibuf_siz = ((cam->ibuf_siz / getpagesize()) + 1) * getpagesize(); if ((cam->ibuf = xmemalign(getpagesize(), cam->ibuf_siz)) == NULL) r = -ENOMEM; #else /* Just 512 byte align it... */ if ((cam->ibuf = xmalloc(cam->ibuf_siz)) == NULL) r = -ENOMEM; #endif if (r != 0) cam->ibuf_siz = 0; } /* Initialize all the buffer pointers */ cam->ibuf_wr_idx = cam->ibuf; } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_flush_rows(flidev_t dev, long rows, long repeat) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); if (rows < 0) return -EINVAL; if (rows == 0) return 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { rlen = 0; wlen = 6; IOWRITE_U16(buf, 0, FLI_USBCAM_SETFLUSHBINFACTORS); IOWRITE_U16(buf, 2, cam->hflushbin); IOWRITE_U16(buf, 4, cam->vflushbin); IO(dev, buf, &wlen, &rlen); while (repeat > 0) { debug(FLIDEBUG_INFO, "Flushing %d rows.", rows); rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_FLUSHROWS); IOWRITE_U16(buf, 2, rows); IO(dev, buf, &wlen, &rlen); repeat--; } } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_set_bit_depth(flidev_t dev, flibitdepth_t bitdepth) { INDI_UNUSED(bitdepth); // flicamdata_t *cam = DEVICE->device_data; // iobuf_t buf[IOBUF_MAX_SIZ]; // long rlen = 0, wlen = 0; long r = 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EINVAL; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { r = -EINVAL; } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_read_ioport(flidev_t dev, long *ioportset) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { rlen = 1; wlen = 2; IOWRITE_U16(buf, 0, FLI_USBCAM_READIO); IO(dev, buf, &wlen, &rlen); IOREAD_U8(buf, 0, *ioportset); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { rlen = 2; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_READ_IOPORT); IO(dev, buf, &wlen, &rlen); IOREAD_U8(buf, 1, *ioportset); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_write_ioport(flidev_t dev, long ioportset) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { rlen = 0; wlen = 3; IOWRITE_U16(buf, 0, FLI_USBCAM_WRITEIO); IOWRITE_U8(buf, 2, ioportset); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_WRITE_IOPORT); IOWRITE_U16(buf, 2, ioportset); IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_configure_ioport(flidev_t dev, long ioportset) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { rlen = 0; wlen = 3; IOWRITE_U16(buf, 0, FLI_USBCAM_WRITEDIR); IOWRITE_U8(buf, 2, ioportset); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_CONFIGURE_IOPORT); IOWRITE_U16(buf, 2, ioportset); IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_control_shutter(flidev_t dev, long shutter) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { rlen = 0; wlen = 3; IOWRITE_U16(buf, 0, FLI_USBCAM_SHUTTER); IOWRITE_U8(buf, 2, shutter); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { unsigned char c = 0; switch (shutter) { case FLI_SHUTTER_CLOSE: c = 0x00; break; case FLI_SHUTTER_OPEN: c = 0x01; break; default: r = -EINVAL; break; } if (r != 0) break; rlen = 2; wlen = 3; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_SHUTTER); IOWRITE_U8(buf, 2, c); debug(FLIDEBUG_INFO, "%s shutter.", (buf[2] == 0)? "Closing":"Opening"); IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_control_bgflush(flidev_t dev, long bgflush) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); if( (bgflush != FLI_BGFLUSH_STOP) && (bgflush != FLI_BGFLUSH_START) ) return -EINVAL; cam->background_flush = (bgflush == FLI_BGFLUSH_STOP)? 0 : 1; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if(DEVICE->devinfo.fwrev < 0x0300) { debug(FLIDEBUG_WARN, "Background flush commanded on early firmware."); return -EFAULT; } rlen = 0; wlen = 4; IOWRITE_U16(buf, 0, FLI_USBCAM_BGFLUSH); IOWRITE_U16(buf, 2, bgflush); IO(dev, buf, &wlen, &rlen); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if(DEVICE->devinfo.fwrev < 0x0110) { debug(FLIDEBUG_WARN, "Background flush commanded on early firmware."); return -EFAULT; } rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_BGFLUSH); IOWRITE_U16(buf, 2, bgflush); IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_get_cooler_power(flidev_t dev, double *power) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); *power = 0.0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { short pwm; if (DEVICE->devinfo.fwrev == 0x0100) { r = -EFAULT; } else { rlen = 14; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_TEMPERATURE); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 4, pwm); *power = (double) pwm; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_get_camera_status(flidev_t dev, long *camera_status) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (DEVICE->devinfo.fwrev == 0x0100) { *camera_status = FLI_CAMERA_STATUS_UNKNOWN; } else { rlen = 4; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_STATUS); IO(dev, buf, &wlen, &rlen); IOREAD_U32(buf, 0, *camera_status); } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_get_camera_mode(flidev_t dev, flimode_t *camera_mode) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { *camera_mode = 0; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (DEVICE->devinfo.fwrev == 0x0100) { *camera_mode = 0; } else { rlen = 2; wlen = 2; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_CURRENT_MODE); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, *camera_mode); } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_set_camera_mode(flidev_t dev, flimode_t camera_mode) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if (camera_mode > 0) r = -EINVAL; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { flimode_t mode; if (DEVICE->devinfo.fwrev >= 0x0101) { rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_MODE); IOWRITE_U16(buf, 2, camera_mode); IO(dev, buf, &wlen, &rlen); IOREAD_U16(buf, 0, mode); if (mode != camera_mode) { debug(FLIDEBUG_FAIL, "Error setting camera mode, tried %d, performed %d.", camera_mode, mode); r = -EINVAL; } } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_get_camera_mode_string(flidev_t dev, flimode_t camera_mode, char *dest, size_t siz) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { if (camera_mode > 0) r = -EINVAL; else strncpy((char *) dest, "Default Mode", siz - 1); } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (DEVICE->devinfo.fwrev == 0x0100) { if (camera_mode > 0) r = -EINVAL; else strncpy((char *) dest, "Default Mode", siz - 1); } else { rlen = 32; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_MODE_STRING); IOWRITE_U16(buf, 2, camera_mode); IO(dev, buf, &wlen, &rlen); strncpy((char *) dest, (char *) buf, MIN(siz - 1, 31)); if (dest[0] == '\0') r = -EINVAL; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_end_exposure(flidev_t dev) { long r = 0; // flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EINVAL; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { long rlen = 4, wlen = 4; iobuf_t buf[IOBUF_MAX_SIZ]; if (SUPPORTS_END_EXPOSURE(DEVICE) != 0) { IOWRITE_U16(buf, 0, PROLINE_COMMAND_UPDATE_EXPOSURE); IOWRITE_U16(buf, 2, 0x0001); IO(dev, buf, &wlen, &rlen); /* The camera returns status at this point, I dunno what we want to do with it so nothing. */ } else { r = -EINVAL; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_trigger_exposure(flidev_t dev) { long r = 0; // flicamdata_t *cam = DEVICE->device_data; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EINVAL; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { long rlen = 4, wlen = 4; iobuf_t buf[IOBUF_MAX_SIZ]; if (SUPPORTS_SOFTWARE_TRIGGER(DEVICE) != 0) { IOWRITE_U16(buf, 0, PROLINE_COMMAND_UPDATE_EXPOSURE); IOWRITE_U16(buf, 2, 0x0002); IO(dev, buf, &wlen, &rlen); /* The camera returns status at this point, I dunno what we want to do with it so nothing. */ } else { r = -EINVAL; } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_set_fan_speed(flidev_t dev, long fan_speed) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if(DEVICE->devinfo.fwrev < 0x0122) { debug(FLIDEBUG_WARN, "Fan speed control with early firmware."); return -EFAULT; } rlen = 2; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_FAN_SPEED); IOWRITE_U16(buf, 2, (short) fan_speed); IO(dev, buf, &wlen, &rlen); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_set_vertical_table_entry(flidev_t dev, long index, long height, long bin, long mode) { flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (!SUPPORTS_VERTICAL_TABLE(DEVICE)) { debug(FLIDEBUG_WARN, "Camera does not support vertical table."); return -EFAULT; } if (cam->vertical_table == 0) { debug(FLIDEBUG_FAIL, "Vertical tables not enabled."); return -EFAULT; } rlen = 6; wlen = 8; IOWRITE_U16(buf, 0, PROLINE_COMMAND_SET_VERTICAL_TABLE_ENTRY); IOWRITE_U16(buf, 2, (short) index); IOWRITE_U16(buf, 4, height); IOWRITE_U8(buf, 6, bin); IOWRITE_U8(buf, 7, mode); IO(dev, buf, &wlen, &rlen); /* Reset our dimensions */ cam->image_area.ul.y = 0; IOREAD_U16(buf, 4, cam->image_area.lr.y); debug(FLIDEBUG_INFO, "Vertical table updated, new overall height %d.", cam->image_area.lr.y); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_read_eeprom(flidev_t dev, long loc, long address, long length, void *rbuf) { iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; int ret = 0; long addr; int pagesize = 32; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if ( (loc < 0) || (loc > 1) ) { debug(FLIDEBUG_FAIL, "Read EEPRPOM invalid Location"); return (-EINVAL); } for (addr = 0; (addr < length); addr += pagesize) { unsigned char eelen = (unsigned char) (((length - addr) > pagesize)?pagesize:(length - addr)); rlen = eelen + 1; wlen = 6; IOWRITE_U16(buf, 0, PROLINE_COMMAND_READ_USER_EEPROM); IOWRITE_U16(buf, 2, (address + addr)); IOWRITE_U8(buf, 4, loc); IOWRITE_U8(buf, 5, eelen); debug(FLIDEBUG_INFO, "Reading %d bytes starting at %#04x", (int) eelen, address + addr); IO(dev, buf, &wlen, &rlen); memcpy(&((unsigned char *) rbuf)[addr], &buf[1], eelen); } } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return ret; } long fli_camera_usb_write_eeprom(flidev_t dev, long loc, long address, long length, void *wbuf) { iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; int ret = 0; long addr; int pagesize = 32; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if ( (loc < 0) || (loc > 1) ) { debug(FLIDEBUG_FAIL, "Read EEPRPOM invalid location"); return (-EINVAL); } for (addr = 0; (addr < length); addr += pagesize) { unsigned char eelen; if ((addr % pagesize) == 0) /* On page boundary */ { eelen = (unsigned char) (((length - addr) > pagesize)?pagesize:(length - addr)); } else { eelen = (unsigned char) (pagesize - (addr % pagesize)); eelen = (unsigned char) (((length - addr) > eelen)?eelen:(length - addr)); } rlen = eelen + 6; wlen = 6 + eelen; IOWRITE_U16(buf, 0, PROLINE_COMMAND_WRITE_USER_EEPROM); IOWRITE_U16(buf, 2, (address + addr)); IOWRITE_U8(buf, 4, loc); IOWRITE_U8(buf, 5, eelen); memcpy(&buf[6], &((unsigned char *) wbuf)[addr], eelen); debug(FLIDEBUG_INFO, "Writing %d bytes starting at %#04x", (int) eelen, address + addr); IO(dev, buf, &wlen, &rlen); } } break; } return ret; } long fli_camera_usb_get_vertical_table_entry(flidev_t dev, long index, long *height, long *bin, long *mode) { // flicamdata_t *cam = DEVICE->device_data; iobuf_t buf[IOBUF_MAX_SIZ]; long rlen, wlen; long r = 0; memset(buf, 0x00, IOBUF_MAX_SIZ); if (height != NULL) *height = 0; if (bin != NULL) *bin = 0; if (mode != NULL) *mode = 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (!SUPPORTS_VERTICAL_TABLE(DEVICE)) { debug(FLIDEBUG_WARN, "Camera does not support vertical table."); return -EFAULT; } rlen = 6; wlen = 4; IOWRITE_U16(buf, 0, PROLINE_COMMAND_GET_VERTICAL_TABLE_ENTRY); IOWRITE_U16(buf, 2, (short) index); IO(dev, buf, &wlen, &rlen); if (height != NULL) IOREAD_U16(buf, 0, *height); if (bin != NULL) IOREAD_U8(buf, 2, *bin); if (mode != NULL) IOREAD_U8(buf, 3, *mode); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } long fli_camera_usb_enable_vertical_table(flidev_t dev, long width, long offset, long flags) { INDI_UNUSED(flags); flicamdata_t *cam = DEVICE->device_data; long r = 0; switch (DEVICE->devinfo.devid) { /* MaxCam and IMG cameras */ case FLIUSB_CAM_ID: { r = -EFAULT; } break; /* Proline Camera */ case FLIUSB_PROLINE_ID: { if (!SUPPORTS_VERTICAL_TABLE(DEVICE)) { debug(FLIDEBUG_WARN, "Camera does not support vertical table."); return -EFAULT; } cam->vertical_table = 1; cam->image_area.ul.x = offset; cam->image_area.lr.x = offset + width; r = fli_camera_usb_set_vertical_table_entry(dev, 63, 0, 0, 0); } break; default: debug(FLIDEBUG_WARN, "Hmmm, shouldn't be here, operation on NO camera..."); break; } return r; } libfli-2.0+20221221182632/libfli-camera.h0000644000175100017510000001152214174600256016267 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_CAMERA_H_ #define _LIBFLI_CAMERA_H_ #define CAPABILITY_VIDEO (0x00010000) #define CAPABILITY_TDI (0x00000001) #define CAPABILITY_BGFLUSH (0x00000002) #define CAPABILITY_VERTICAL_TABLE (0x00020000) #define SUPPORTS_VIDEO(x) ((((flicamdata_t *) (x->device_data))->capabilities & CAPABILITY_VIDEO) != 0) #define SUPPORTS_TDI(x) ((((flicamdata_t *) (x->device_data))->capabilities & CAPABILITY_TDI) != 0) #define SUPPORTS_VERTICAL_TABLE(x) ((((flicamdata_t *) (x->device_data))->capabilities & CAPABILITY_VERTICAL_TABLE) != 0) #define SUPPORTS_BGFLUSH(x) ((((flicamdata_t *) (x->device_data))->capabilities & CAPABILITY_BGFLUSH) != 0) #define SUPPORTS_END_EXPOSURE(x) ((x->devinfo.fwrev >= 0x0120) && (x->devinfo.devid == FLIUSB_PROLINE_ID) != 0) #define SUPPORTS_SOFTWARE_TRIGGER(x) ((x->devinfo.fwrev >= 0x0120) && (x->devinfo.devid == FLIUSB_PROLINE_ID) != 0) #define SUPPORTS_16BIT_VBIN(x) (((x->devinfo.fwrev < 0x0200) && (x->devinfo.fwrev >= 0x0130)) && (x->devinfo.devid == FLIUSB_PROLINE_ID) != 0) /* Video mode stuff */ typedef enum { VIDEO_MODE_OFF = 0, VIDEO_MODE_BEGIN, VIDEO_MODE_ON } video_mode_t; typedef struct { int x; /* X coordinate */ int y; /* Y coordinate */ } point_t; typedef struct { point_t ul; /* Upper-left */ point_t lr; /* Lower-right */ } area_t; /* CCD Parameter list */ typedef struct { short index; char *model; area_t array_area; area_t visible_area; double fillfactor; double pixelwidth; double pixelheight; } fliccdinfo_t; typedef struct { long readto; long writeto; long dirto; fliccdinfo_t ccd; /* Acquisistion parameters */ area_t image_area; long vbin; long hbin; long vflushbin; long hflushbin; long exposure; long expdur; long expmul; long frametype; long flushes; long bitdepth; long exttrigger; long exttriggerpol; long extexposurectrl; long tdirate; long tdiflags; #ifdef BADCOLUMN int badcolumns[1024]; #endif double tempslope; double tempintercept; long grabrowcount; long grabrowcounttot; long grabrowindex; long grabrowwidth; long grabrowbatchsize; long grabrowbufferindex; long flushcountbeforefirstrow; long flushcountafterlastrow; double pix_sum; double pix_cnt; /* Variables for Proline/Microline readout */ long top_height; long top_offset; long bottom_height; long bottom_offset; long left_width; long left_offset; long right_width; long right_offset; long dl_index; size_t bytesleft; unsigned short *ibuf_wr_idx; /* Booleans and state variables */ int removebias; int biasoffset; int background_flush; int force_overscan; video_mode_t video_mode; int vertical_table; /* Capability flags */ long capabilities; unsigned short *gbuf; unsigned short *ibuf; size_t gbuf_siz; size_t ibuf_siz; long max_usb_xfer; } flicamdata_t; extern const fliccdinfo_t knowndev[]; long fli_camera_open(flidev_t dev); long fli_camera_close(flidev_t dev); long fli_camera_command(flidev_t dev, int cmd, int argc, ...); #endif /* _LIBFLI_CAMERA_H_ */ libfli-2.0+20221221182632/unix/0000755000175100017510000000000014174600256014411 5ustar debiandebianlibfli-2.0+20221221182632/unix/libfli-usb.c0000644000175100017510000000527714174600256016620 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-sys.h" #include "libfli-usb.h" long unix_usbio(flidev_t dev, void *buf, long *wlen, long *rlen) { int err = 0, locked = 0; long org_wlen = *wlen, org_rlen = *rlen; if ((err = unix_fli_lock(dev))) { debug(FLIDEBUG_WARN, "Lock failed"); goto done; } locked = 1; if (*wlen > 0) { if ((err = unix_bulkwrite(dev, buf, wlen))) { debug(FLIDEBUG_WARN, "Bulkwrite failed, wrote %d of %d bytes", *wlen, org_wlen); goto done; } } if (*rlen > 0) { if ((err = unix_bulkread(dev, buf, rlen))) { debug(FLIDEBUG_WARN, "Bulkread failed, read %d of %d bytes", *rlen, org_rlen); goto done; } } done: if (locked) { int r; if ((r = unix_fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/unix/osx/0000755000175100017510000000000014174600256015222 5ustar debiandebianlibfli-2.0+20221221182632/unix/osx/libfli-usb-sys.c0000644000175100017510000006644314174600256020247 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include "libfli-usb-sys.h" //========================================================================== // MAC_FLI_LIST // Function to enumerate connected devices // //========================================================================== long mac_fli_list(flidomain_t domain, char ***names) { char **list = NULL; if((list = malloc((MAX_SEARCH + 1) * sizeof(char *))) == NULL) { return -ENOMEM; } int id = 0; kern_return_t kret; IOReturn ioret; io_name_t deviceName; UInt16 usbProduct, usbVendor; UInt32 locationID; SInt32 score; io_service_t usbDevice; io_iterator_t dev_iterator; IOUSBDeviceInterface182 **dev_int; IOCFPlugInInterface **plugInInterface; CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBDeviceClassName); if(!matchingDict) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get matching dictionary"); return -1; } IONotificationPortRef gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault); CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort); CFRunLoopRef gRunLoop = CFRunLoopGetCurrent(); CFRunLoopAddSource(gRunLoop, runLoopSource, kCFRunLoopDefaultMode); kret = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &dev_iterator); if(kret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get Matching Services"); return -1; } while((usbDevice = IOIteratorNext(dev_iterator))) { ioret = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if(ioret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get Plug In Interface"); return -1; } kret = IORegistryEntryGetName(usbDevice, deviceName); if(kret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get Registry Entry Name"); return -1; } kret = IOObjectRelease(usbDevice); if(kret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not release device"); return -1; } ioret = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID182), (LPVOID*)&dev_int); if(ioret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not Query Plug In Interface"); return -1; } (*plugInInterface)->Release(plugInInterface); ioret = (*dev_int)->GetDeviceVendor(dev_int, &usbVendor); if(ioret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get Device Vendor"); return -1; } // Check if its an FLI device if(usbVendor == FLI_VENDOR_ID) { ioret = (*dev_int)->GetDeviceProduct(dev_int, &usbProduct); if(ioret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get Device Product"); return -1; } switch(usbProduct) { FLIUSB_PRODUCTS break; default: continue; } ioret = (*dev_int)->GetLocationID(dev_int, &locationID); if(ioret) { debug(FLIDEBUG_FAIL, "mac_fli_list: could not get location id"); return -1; } asprintf(&list[id], "%08x;%s", (unsigned int)locationID, deviceName); id++; } } IOObjectRelease(dev_iterator); if(id == 0) { *names = NULL; free(list); return 0; } list[id] = NULL; *names = list; return 0; } //------------------------------------------------------------------------- //========================================================================== // MAC_FLI_CONNECT // Function to enumerate and establish connection to device // //========================================================================== long mac_fli_connect(flidev_t dev, char *name, long domain) { debug(FLIDEBUG_INFO, "mac_fli_connect"); CHKDEVICE(dev); fli_unixio_t *io; if(name == NULL) { return -EINVAL; } /* Lock functions should be set before any other functions used */ DEVICE->fli_lock = mac_fli_lock; DEVICE->fli_unlock = mac_fli_unlock; DEVICE->domain = domain & 0x00ff; DEVICE->devinfo.type = domain & 0xff00; if((io = calloc(1, sizeof(fli_unixio_t))) == NULL) { return -ENOMEM; } if(!(io->fd = open(name, O_RDWR))) { return -ENOMEM; } int r; // Note: unix_usb_connect is defined to mac_usb_connect in OSX if((r = mac_usb_connect(dev, io, name)) != 0) { close(io->fd); free(io); return r; } DEVICE->fli_io = unix_usbio; switch(DEVICE->devinfo.type) { case FLIDEVICE_CAMERA: //0x100 DEVICE->fli_open = fli_camera_open; DEVICE->fli_close = fli_camera_close; DEVICE->fli_command = fli_camera_command; break; case FLIDEVICE_FOCUSER: //0x300 DEVICE->fli_open = fli_focuser_open; DEVICE->fli_close = fli_focuser_close; DEVICE->fli_command = fli_focuser_command; break; case FLIDEVICE_FILTERWHEEL: //0x200 DEVICE->fli_open = fli_filter_open; DEVICE->fli_close = fli_filter_close; DEVICE->fli_command = fli_filter_command; break; default: mac_usb_disconnect(dev,io); close(io->fd); free(io); return -EINVAL; } DEVICE->io_data = io; //char *nameCopy = NULL; //asprintf(&nameCopy, "%s", name); // xstrdup(name); DEVICE->name = strdup(name); //nameCopy; DEVICE->io_timeout = 3000; // 60 * 1000; /* 1 min. */ debug(FLIDEBUG_INFO, "mac_fli_connect: connected"); return 0; } //------------------------------------------------------------------------- //========================================================================== // MAC_FLI_DISCONNECT // Disconnect device // //========================================================================== long mac_fli_disconnect(flidev_t dev, fli_unixio_t *io) { int err = 0; CHKDEVICE(dev); if((io = DEVICE->io_data) == NULL) { debug(FLIDEBUG_FAIL, "mac_fli_disconnect: io data error"); return -EINVAL; } switch(DEVICE->domain) { case FLIDOMAIN_USB: err = mac_usb_disconnect(dev,io); break; default: break; } if(close(io->fd)) { if(!err) { err = -errno; } } free(DEVICE->io_data); free(DEVICE->sys_data); DEVICE->io_data = NULL; DEVICE->sys_data = NULL; DEVICE->fli_lock = NULL; DEVICE->fli_unlock = NULL; DEVICE->fli_io = NULL; DEVICE->fli_open = NULL; DEVICE->fli_close = NULL; DEVICE->fli_command = NULL; free(DEVICE->name); DEVICE->name = NULL; debug(FLIDEBUG_INFO, "mac_fli_disconnect: disconnected"); return err; } //------------------------------------------------------------------------- //========================================================================== // MAC_USB_CONNECT // connect device // //========================================================================== long mac_usb_connect(flidev_t dev, fli_unixio_t *io, char *name) { bool found = false; kern_return_t kret; IOReturn ioret; io_name_t deviceName; UInt16 usbRelease, usbProduct, usbVendor; UInt32 locationID; SInt32 score; io_service_t usbDevice; io_iterator_t dev_iterator; IOUSBDeviceInterface182 **dev_int; IOCFPlugInInterface **plugInInterface; CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOUSBDeviceClassName); if(!matchingDict) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get matching dictionary"); return -ENODEV; } IONotificationPortRef gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault); CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort); CFRunLoopRef gRunLoop = CFRunLoopGetCurrent(); CFRunLoopAddSource(gRunLoop, runLoopSource, kCFRunLoopDefaultMode); kret = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &dev_iterator); if(kret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Matching Services"); return -ENODEV; } while((usbDevice = IOIteratorNext(dev_iterator))) { ioret = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Plug In Interface"); return -ENODEV; } kret = IORegistryEntryGetName(usbDevice, deviceName); if(kret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Registry Entry Name"); return -ENODEV; } kret = IOObjectRelease(usbDevice); if(kret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not release device"); return -ENODEV; } ioret = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID182), (LPVOID*)&dev_int); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not Query Plug In Interface"); return -ENODEV; } (*plugInInterface)->Release(plugInInterface); ioret = (*dev_int)->GetDeviceVendor(dev_int, &usbVendor); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Device Vendor"); return -ENODEV; } // Check if its an FLI device if(usbVendor == FLI_VENDOR_ID) { ioret = (*dev_int)->GetDeviceProduct(dev_int, &usbProduct); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Device Product"); return -ENODEV; } switch(usbProduct) { FLIUSB_PRODUCTS break; default: continue; } ioret = (*dev_int)->GetDeviceReleaseNumber(dev_int, &usbRelease); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get Device Release Number"); return -ENODEV; } ioret = (*dev_int)->GetLocationID(dev_int, &locationID); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: could not get location id"); return -ENODEV; } char *deviceLocIDName = NULL; asprintf(&deviceLocIDName, "%08x", (unsigned int)locationID); if(strcmp(name, deviceLocIDName) == 0) { found = true; debug(FLIDEBUG_INFO, "mac_usb_connect: connecting to usb device"); //asprintf(&DEVICE->devinfo.model, "%s", deviceName); //asprintf(&DEVICE->devinfo.devnam, "%08x", locationID); DEVICE->devinfo.devid = usbProduct; DEVICE->devinfo.fwrev = usbRelease; ioret = (*dev_int)->USBDeviceOpenSeize(dev_int); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: USBDeviceOpenSeize failed"); return -ENODEV; } // Reset the usb device so you will be able to fully configure the device ioret = (*dev_int)->ResetDevice(dev_int); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_connect: ResetDevice failed"); return -ENODEV; } if(mac_usb_find_interfaces(dev, dev_int) != kIOReturnSuccess) { debug(FLIDEBUG_FAIL, "mac_usb_connect: mac_usb_find_interfaces failed"); (*dev_int)->USBDeviceClose(dev_int); (*dev_int)->Release(dev_int); return -ENODEV; } debug(FLIDEBUG_INFO, "mac_usb_connect: connected to usb device!"); break; } } } IOObjectRelease(dev_iterator); if(!found) { return -ENODEV; } return 0; } IOReturn mac_usb_configure_device(IOUSBDeviceInterface182 **dev) { //UInt8 numConfig; // configNum IOReturn kr; IOUSBConfigurationDescriptorPtr configDesc; /* kr = (*dev)->GetConfiguration(dev, &configNum); if(kr) { debug(FLIDEBUG_FAIL, "mac_usb_configure_device: could not get configuration"); return -1; } */ // Device is already configured (Was already plugged in and connected to in the past, reconfiguring will break it) /*if(configNum == 0) { debug(FLIDEBUG_INFO, "mac_usb_configure_device: already configured %d", configNum); return kIOReturnSuccess; }*/ /* kr = (*dev)->GetNumberOfConfigurations(dev, &numConfig); if(!numConfig) { debug(FLIDEBUG_FAIL, "mac_usb_configure_device: could not get number of configurations"); return -1; } */ kr = (*dev)->GetConfigurationDescriptorPtr(dev, 0, &configDesc); if(kr) { debug(FLIDEBUG_FAIL, "mac_usb_configure_device: could not get configuration descriptor"); return -1; } kr = (*dev)->SetConfiguration(dev, configDesc->bConfigurationValue); if(kr) { debug(FLIDEBUG_FAIL, "mac_usb_configure_device: could not set configuration"); return -1; } /* UInt8 configNum2; kr = (*dev)->GetConfiguration(dev, &configNum2); if(kr) { debug(FLIDEBUG_FAIL, "mac_usb_configure_device: could not get configuration"); return -1; }*/ debug(FLIDEBUG_INFO, "mac_usb_configure_device: Configured to %d", configDesc->bConfigurationValue); //debug(FLIDEBUG_INFO, "mac_usb_configure_device: %d %d %d %d", configNum, configNum2, numConfig, configDesc->bConfigurationValue); return kIOReturnSuccess; } IOReturn mac_usb_find_interfaces(flidev_t dev, IOUSBDeviceInterface182 **device) { IOReturn kr; IOUSBFindInterfaceRequest request; io_iterator_t iterator; io_service_t usbInterface; IOCFPlugInInterface **plugInInterface = NULL; IOUSBInterfaceInterface190 **interface = NULL; HRESULT result; SInt32 score; UInt8 interfaceClass; UInt8 interfaceSubClass; UInt8 interfaceNumEndpoints; request.bInterfaceClass = kIOUSBFindInterfaceDontCare; request.bInterfaceSubClass = kIOUSBFindInterfaceDontCare; request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare; request.bAlternateSetting = kIOUSBFindInterfaceDontCare; kr = (*device)->CreateInterfaceIterator(device, &request, &iterator); while((usbInterface = IOIteratorNext(iterator))) { kr = IOCreatePlugInInterfaceForService(usbInterface, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); kr = IOObjectRelease(usbInterface); if((kr != kIOReturnSuccess) || !plugInInterface) { debug(FLIDEBUG_FAIL, "mac_usb_find_interfaces: Unable to create a plugin"); return kr; } result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID190), (LPVOID *) &interface); (*plugInInterface)->Release(plugInInterface); if(result || !interface) { debug(FLIDEBUG_FAIL, "mac_usb_find_interfaces: Couldn’t create a device interface"); return kr; } kr = (*interface)->GetInterfaceClass(interface, &interfaceClass); kr = (*interface)->GetInterfaceSubClass(interface, &interfaceSubClass); kr = (*interface)->USBInterfaceOpen(interface); if(kr != kIOReturnSuccess) { debug(FLIDEBUG_FAIL, "mac_usb_find_interfaces: Unable to open interface (%08x)", kr); (*interface)->Release(interface); return kr; } kr = (*interface)->GetNumEndpoints(interface, &interfaceNumEndpoints); if(kr != kIOReturnSuccess) { debug(FLIDEBUG_FAIL, "mac_usb_find_interfaces: Unable to get number of endpoints (%08x)", kr); (*interface)->USBInterfaceClose(interface); (*interface)->Release(interface); return kr; } mac_device_info *deviceInfo = (mac_device_info*) malloc(sizeof(mac_device_info)); DEVICE->sys_data = deviceInfo; DEVICE_DATA->interface = interface; DEVICE_DATA->device = device; DEVICE_DATA->interfaceNumEndpoints = interfaceNumEndpoints; if(DEVICE->devinfo.devid == FLIUSB_PROLINECAM) { DEVICE_DATA->epRead = 2; DEVICE_DATA->epWrite = 1; DEVICE_DATA->epReadBulk = 3; } else if(DEVICE->devinfo.devid == FLIUSB_MAXCAM) { DEVICE_DATA->epRead = 2; DEVICE_DATA->epWrite = 3; DEVICE_DATA->epReadBulk = 2; } else if(DEVICE->devinfo.devid == FLIUSB_FILTERWHEEL || FLIUSB_FOCUSER || FLIUSB_STEPPER) { DEVICE_DATA->epRead = 1; DEVICE_DATA->epWrite = 2; DEVICE_DATA->epReadBulk = 1; } // Debug pipes /* int pipeRef; for (pipeRef = 1; pipeRef <= interfaceNumEndpoints; pipeRef++) { IOReturn kr2; UInt8 direction; UInt8 number; UInt8 transferType; UInt16 maxPacketSize; UInt8 interval; char *message; kr2 = (*interface)->GetPipeProperties(interface, pipeRef, &direction, &number, &transferType, &maxPacketSize, &interval); if (kr2 != kIOReturnSuccess) printf("Unable to get properties of pipe %d (%08x)\n", pipeRef, kr2); else { printf("PipeRef %d: ", pipeRef); switch (direction) { case kUSBOut: message = "out"; break; case kUSBIn: message = "in"; break; case kUSBNone: message = "none"; break; case kUSBAnyDirn: message = "any"; break; default: message = "???"; } printf("direction %s, ", message); switch (transferType) { case kUSBControl: message = "control"; break; case kUSBIsoc: message = "isoc"; break; case kUSBBulk: message = "bulk"; break; case kUSBInterrupt: message = "interrupt"; break; case kUSBAnyType: message = "any"; break; default: message = "???"; } printf("transfer type %s, maxPacketSize %d\n", message, maxPacketSize); } } */ // We only need 1 interface for FLI devices return kIOReturnSuccess; } debug(FLIDEBUG_WARN, "mac_usb_find_interfaces: Found 0 interfaces, setting configuration"); if(mac_usb_configure_device(device) == kIOReturnSuccess) { return mac_usb_find_interfaces(dev, device); } return -1; } //========================================================================== // MAC_USB_DISCONNECT // Delete USB interface Data // //========================================================================== long mac_usb_disconnect(flidev_t dev, fli_unixio_t *io) { debug(FLIDEBUG_INFO, "mac_usb_disconnect"); (*DEVICE_DATA->interface)->USBInterfaceClose(DEVICE_DATA->interface); (*DEVICE_DATA->interface)->Release(DEVICE_DATA->interface); (*DEVICE_DATA->device)->USBDeviceClose(DEVICE_DATA->device); (*DEVICE_DATA->device)->Release(DEVICE_DATA->device); return 0; } //------------------------------------------------------------------------- //========================================================================== // MAC_BULKTRANSFER // IO control call to start piperead/pipewrite // //========================================================================== long mac_bulktransfer(flidev_t dev, int ep, void *buf, long *tlen) { if(ep & USB_DIR_IN) { mac_usb_piperead(dev, buf, *tlen, DEVICE_DATA->epReadBulk, DEVICE->io_timeout); } else { mac_usb_pipewrite(dev, buf, *tlen, DEVICE_DATA->epWrite, DEVICE->io_timeout); } return 0; } //========================================================================== // MAC_BULKREAD // IO control call to read // //========================================================================== long mac_bulkread(flidev_t dev, void *buf, long *rlen) { mac_usb_piperead(dev, buf, *rlen, DEVICE_DATA->epRead, DEVICE->io_timeout); return 0; } //------------------------------------------------------------------------- //========================================================================== // MAC_BULKWRITE // IO control call to write // //========================================================================== long mac_bulkwrite(flidev_t dev, void *buf, long *wlen) { mac_usb_pipewrite(dev, buf, *wlen, DEVICE_DATA->epWrite, DEVICE->io_timeout); return 0; } //========================================================================== // PIPEREAD // Function to Read input calls ReadPipeTO // // //========================================================================== ssize_t mac_usb_piperead(flidev_t dev, void *buf, size_t size, unsigned pipe, unsigned timeout) { CHKDEVICE(dev); IOReturn ioret; if(pipe <= 0 || pipe > DEVICE_DATA->interfaceNumEndpoints) { debug(FLIDEBUG_FAIL, "mac_usb_piperead: invalid pipe number (%u of %u)", pipe, DEVICE_DATA->interfaceNumEndpoints); return -EINVAL; } ioret = (*DEVICE_DATA->interface)->ReadPipeTO(DEVICE_DATA->interface, pipe, buf, (UInt32*) &size, 0, timeout); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_piperead: read error: %x, size: %d", ioret, (int)size); if(ioret != kIOReturnSuccess) { debug(FLIDEBUG_FAIL, "mac_usb_piperead: aborted"); ioret = (*DEVICE_DATA->interface)->ClearPipeStallBothEnds(DEVICE_DATA->interface, pipe); //ioret = (*DEVICE_DATA->interface)->ClearPipeStall(DEVICE_DATA->interface, true); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_piperead: Pipe Stalled: %x", ioret); } } return -EINVAL; } return size; } //------------------------------------------------------------------------- //========================================================================== // PIPEWRITE // Function to write data to device calls WritePipeTo // //========================================================================== ssize_t mac_usb_pipewrite(flidev_t dev, void *buf, size_t size, unsigned pipe, unsigned timeout) { CHKDEVICE(dev); IOReturn ioret; int piperef = DEVICE_DATA->epWrite; if(piperef <= 0 || piperef > DEVICE_DATA->interfaceNumEndpoints) { debug(FLIDEBUG_FAIL, "mac_usb_pipewrite: invalid pipe number (%u of %u)", piperef, DEVICE_DATA->interfaceNumEndpoints); return -EINVAL; } ioret = (*DEVICE_DATA->interface)->WritePipeTO(DEVICE_DATA->interface, piperef, buf, size, timeout, 0); if(ioret) { debug(FLIDEBUG_FAIL, "mac_usb_pipewrite: write error %x", ioret); return -EINVAL; } return size; } //------------------------------------------------------------------------- //========================================================================== // MAC_FLI_LOCK // Function to lock access to device // //========================================================================== long mac_fli_lock(flidev_t dev) { fli_unixio_t *io = DEVICE->io_data; if(io == NULL) { return -ENODEV; } if(!flock(io->fd, LOCK_EX)) { return -errno; } return 0; } //------------------------------------------------------------------------- //========================================================================== // MAC_FLI_UNLOCK // Function to unlock access to device // //========================================================================== long mac_fli_unlock(flidev_t dev) { fli_unixio_t *io = DEVICE->io_data; if(io == NULL) { return -ENODEV; } if(!flock(io->fd, LOCK_UN)) { return -errno; } return 0; } //------------------------------------------------------------------------- libfli-2.0+20221221182632/unix/osx/libfli-usb-sys.h0000644000175100017510000001330414174600256020240 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ //========================================================================== // Include Files for Mac OSX IO // //========================================================================== #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "libfli.h" #include "libfli-libfli.h" #include "libfli-usb.h" #include "libfli-camera.h" #include "libfli-filter-focuser.h" //------------------------------------------------------------------------- /* Structure to describe string descriptor transfers */ typedef struct { unsigned int index; char buf[64]; } fliusb_string_descriptor_t; /* Structure to describe bulk transfers */ typedef struct { u_int8_t ep; void *buf; size_t count; unsigned int timeout; /* in msec */ } fliusb_bulktransfer_t; /* 8-bit special value to identify ioctl 'type' */ #define FLIUSB_IOC_TYPE 0xf1 /* Recognized ioctl commands */ #define FLIUSB_GETRDEPADDR _IOR(FLIUSB_IOC_TYPE, 1, u_int8_t) #define FLIUSB_SETRDEPADDR _IOW(FLIUSB_IOC_TYPE, 2, u_int8_t) #define FLIUSB_GETWREPADDR _IOR(FLIUSB_IOC_TYPE, 3, u_int8_t) #define FLIUSB_SETWREPADDR _IOW(FLIUSB_IOC_TYPE, 4, u_int8_t) #define FLIUSB_GETBUFFERSIZE _IOR(FLIUSB_IOC_TYPE, 5, size_t) #define FLIUSB_SETBUFFERSIZE _IOW(FLIUSB_IOC_TYPE, 6, size_t) #define FLIUSB_GETTIMEOUT _IOR(FLIUSB_IOC_TYPE, 7, unsigned int) #define FLIUSB_SETTIMEOUT _IOW(FLIUSB_IOC_TYPE, 8, unsigned int) #define FLIUSB_BULKREAD _IOW(FLIUSB_IOC_TYPE, 9, fliusb_bulktransfer_t) #define FLIUSB_BULKWRITE _IOW(FLIUSB_IOC_TYPE, 10, fliusb_bulktransfer_t) #define FLIUSB_GET_DEVICE_DESCRIPTOR _IOR(FLIUSB_IOC_TYPE, 11, struct usb_device_descriptor) #define FLIUSB_GET_STRING_DESCRIPTOR _IOR(FLIUSB_IOC_TYPE, 12, struct usb_device_descriptor) #define FLIUSB_IOC_MAX 12 #define FLIUSB_PROD(name,id) case id: #define FLIUSB_PRODUCTS \ FLIUSB_PROD(FLIUSB_MAXCAM, 0x0002) \ FLIUSB_PROD(FLIUSB_STEPPER, 0x0005) \ FLIUSB_PROD(FLIUSB_FOCUSER, 0x0006) \ FLIUSB_PROD(FLIUSB_FILTERWHEEL,0x0007) \ FLIUSB_PROD(FLIUSB_PROLINECAM, 0x000A) #undef FLIUSB_PROD enum { #define FLIUSB_PROD(name,id) name=id, FLIUSB_PRODUCTS #undef FLIUSB_PROD }; #define FLIUSB_PROD(name,id) case id: #define USB_DIR_OUT (0x00) #define USB_DIR_IN (0x80) #define BUFFERSIZE 65536 #define FLI_VENDOR_ID 0x0f18 #define MAX_SEARCH 32 //------------------------------------------------------------------------- typedef struct _mac_device_info { IOUSBInterfaceInterface190 **interface; // Requires >= 10.2 IOUSBDeviceInterface182 **device; UInt8 interfaceNumEndpoints; unsigned int epWrite, epRead, epReadBulk; } mac_device_info; #define DEVICE_DATA ((mac_device_info*)DEVICE->sys_data) long mac_fli_list(flidomain_t domain, char ***names); long mac_fli_connect(flidev_t dev, char *name, long domain); long mac_fli_disconnect(flidev_t dev, fli_unixio_t *io); long mac_usb_connect(flidev_t dev, fli_unixio_t *io, char *name); IOReturn mac_usb_configure_device(IOUSBDeviceInterface182 **dev); IOReturn mac_usb_find_interfaces(flidev_t dev, IOUSBDeviceInterface182 **device); long mac_usb_disconnect(flidev_t dev, fli_unixio_t *io); long mac_bulktransfer(flidev_t dev, int ep, void *buf, long *len); long mac_bulkread(flidev_t dev, void *buf, long *rlen); long mac_bulkwrite(flidev_t dev, void *buf, long *wlen); ssize_t mac_usb_piperead(flidev_t dev, void *buf,size_t size, unsigned pipe, unsigned timeout); ssize_t mac_usb_pipewrite(flidev_t dev, void *buf, size_t size, unsigned pipe, unsigned timeout); long mac_fli_lock(flidev_t dev); long mac_fli_unlock(flidev_t dev); libfli-2.0+20221221182632/unix/libusb/0000755000175100017510000000000014174600256015671 5ustar debiandebianlibfli-2.0+20221221182632/unix/libusb/libfli-usb-sys.c0000644000175100017510000004175514174600256020715 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include "libfli-libfli.h" #include "libfli-sys.h" #include "libfli-mem.h" #include "libfli-usb.h" #include "indimacros.h" #define FLIUSB_MIN_TIMEOUT (5000) libusb_device_handle * libusb_fli_find_handle(struct libusb_context *usb_ctx, char *name); long libusb_usb_connect(flidev_t dev, fli_unixio_t *io, char *name) { int r; libusb_device *usb_dev; libusb_device_handle *usb_han; struct libusb_device_descriptor usbdesc; unsigned char strdesc[64]; r = libusb_init(NULL); if(r < 0) { debug(FLIDEBUG_FAIL, "%s: Could not initialize LibUSB: %s", __PRETTY_FUNCTION__, libusb_error_name(r)); return -ENODEV; } // libusb_set_debug(NULL,LIBUSB_LOG_LEVEL_DEBUG); usb_han = libusb_fli_find_handle(NULL, name); io->han = usb_han; if (io->han == NULL) { return -errno; } debug(FLIDEBUG_INFO, "%s: Found Handle", __PRETTY_FUNCTION__); usb_dev = libusb_get_device(io->han); debug(FLIDEBUG_INFO, "%s: LibUSB Device found from Handle", __PRETTY_FUNCTION__); r = libusb_get_device_descriptor(usb_dev, &usbdesc); if (r < 0) { debug(FLIDEBUG_FAIL, "%s: Could not read descriptor: %s", __PRETTY_FUNCTION__, strerror(errno)); return -EIO; } if (usbdesc.idVendor != FLIUSB_VENDORID) { debug(FLIDEBUG_INFO, "%s: Not a FLI device!", __PRETTY_FUNCTION__); return -ENODEV; } switch (usbdesc.idProduct) { /* These are valid product IDs */ case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: case FLIUSB_PROLINE_ID: break; default: /* Anything else is unknown */ return -ENODEV; } DEVICE->devinfo.devid = usbdesc.idProduct; DEVICE->devinfo.fwrev = usbdesc.bcdDevice; if (usbdesc.iSerialNumber != 0) { memset(strdesc, '\0', sizeof(strdesc)); if (libusb_get_string_descriptor_ascii(io->han, usbdesc.iSerialNumber, strdesc, sizeof(strdesc) - 1) < 0) { debug(FLIDEBUG_FAIL, "%s: Could not read descriptor ascii: %s", __PRETTY_FUNCTION__, strerror(errno)); } else { DEVICE->devinfo.serial = xstrndup((const char *)strdesc, sizeof(strdesc)); debug(FLIDEBUG_INFO, "Serial Number: %s", strdesc); } } else { debug(FLIDEBUG_INFO, "Device is not serialized."); } if((r = libusb_kernel_driver_active(io->han, 0)) == 1) { debug(FLIDEBUG_INFO, "Kernel Driver Active."); if(libusb_detach_kernel_driver(io->han, 0) == 0) { debug(FLIDEBUG_INFO, "Kernel Driver Detached."); } } #ifdef LIBUSB_SETCONFIGURATION /* This is #defined out per notes on linux kernel USBFS documentation */ /* Set the USB device configuration to index 0 */ if ((r = libusb_set_configuration(io->han, 1)) != 0) { debug(FLIDEBUG_FAIL, "%s: Could not set device configuration: %s", __PRETTY_FUNCTION__, libusb_error_name(r)); } #endif if ((r = libusb_claim_interface(io->han, 0)) != 0) { debug(FLIDEBUG_FAIL, "%s: Could not claim interface: %s", __PRETTY_FUNCTION__, libusb_error_name(r)); return -ENODEV; } #ifdef CLEAR_HALT /* Clear the halt/stall condition for all endpoints in this configuration */ { struct libusb_config_descriptor *dsc; { if ((r = libusb_get_active_config_descriptor(usb_dev, &dsc)) == 0) { int numep; int ep; int epaddr; numep = dsc->interface[0].altsetting[0].bNumEndpoints; debug(FLIDEBUG_INFO, "Config Desc: %d", dsc->bConfigurationValue); debug(FLIDEBUG_INFO, "NumEP: %d", dsc->interface[0].altsetting[0].bNumEndpoints); for (ep = 0; ep < numep; ep++) { epaddr = dsc->interface[0].altsetting[0].endpoint[ep].bEndpointAddress; debug(FLIDEBUG_INFO, "EP: %d %02x", ep, epaddr); libusb_clear_halt(io->han, epaddr); } libusb_free_config_descriptor(dsc); } else { debug(FLIDEBUG_FAIL, "%s: Could not obtain configuration descriptor: %s", __PRETTY_FUNCTION__, libusb_error_name(r)); } } } #endif return 0; } long libusb_bulktransfer(flidev_t dev, int ep, void *buf, long *len) { fli_unixio_t *io; unsigned int remaining; int r, err = 0; #define _DEBUG #ifdef _DEBUG debug(FLIDEBUG_INFO, "%s: attempting %ld bytes %s", __PRETTY_FUNCTION__, *len, (ep & LIBUSB_ENDPOINT_IN) ? "in" : "out"); #endif io = DEVICE->io_data; #ifdef _DEBUG if ((ep & 0xf0) == 0) { char buffer[1024]; int i; sprintf(buffer, "OUT %6ld: ", *len); for (i = 0; i < ((*len > 16)?16:*len); i++) { sprintf(buffer + strlen(buffer), "%02x ", ((unsigned char *) buf)[i]); } debug(FLIDEBUG_INFO, buffer); } #endif /* _DEBUG */ remaining = *len; while (remaining) /* read up to USB_READ_SIZ_MAX bytes at a time */ { int bytes; int count; count = MIN(remaining, USB_READ_SIZ_MAX); r = libusb_bulk_transfer(io->han, ep, (unsigned char *) (buf + *len - remaining), count, &bytes, (DEVICE->io_timeout < FLIUSB_MIN_TIMEOUT)?FLIUSB_MIN_TIMEOUT:DEVICE->io_timeout); if( r != 0) { debug(FLIDEBUG_WARN, "LibUSB Error: %s", libusb_error_name(r)); break; } remaining -= bytes; if (bytes < count) break; } /* Set *len to the number of bytes actually transferred */ if (remaining) err = -errno; *len -= remaining; #ifdef _DEBUG if ((ep & 0xf0) != 0) { char buffer[1024]; int i; sprintf(buffer, " IN %6ld: ", *len); for (i = 0; i < ((*len > 16)?16:*len); i++) { sprintf(buffer + strlen(buffer), "%02x ", ((unsigned char *) buf)[i]); } debug(FLIDEBUG_INFO, buffer); } #endif /* _DEBUG */ return err; } long libusb_bulkwrite(flidev_t dev, void *buf, long *wlen) { int ep; switch (DEVICE->devinfo.devid) { case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: ep = 0x02; break; case FLIUSB_PROLINE_ID: ep = 0x01; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); return -EINVAL; } return libusb_bulktransfer(dev, ep | LIBUSB_ENDPOINT_OUT, buf, wlen); } long libusb_bulkread(flidev_t dev, void *buf, long *rlen) { INDI_UNUSED(dev); int ep; switch (DEVICE->devinfo.devid) { case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: ep = 0x02; break; case FLIUSB_PROLINE_ID: ep = 0x01; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); return -EINVAL; } return libusb_bulktransfer(dev, ep | LIBUSB_ENDPOINT_IN, buf, rlen); } long libusb_usb_disconnect(flidev_t dev, fli_unixio_t *io) { INDI_UNUSED(dev); long err = 0; debug(FLIDEBUG_INFO, "Disconnecting"); if (io->han != NULL) { libusb_release_interface(io->han, 0); libusb_close(io->han); } io->han = NULL; libusb_exit(NULL); return err; } int libusb_fli_get_serial(libusb_device *usb_dev, char *serial, size_t max_serial) { struct libusb_device_descriptor usb_desc; libusb_device_handle *usb_han; int r = (-1); if (libusb_get_device_descriptor(usb_dev, &usb_desc) == LIBUSB_SUCCESS) { if (usb_desc.iSerialNumber != 0) { r = libusb_open(usb_dev, &usb_han); if(r == 0) { libusb_get_string_descriptor_ascii(usb_han, usb_desc.iSerialNumber, (unsigned char *) serial, max_serial); libusb_close(usb_han); } } } /* Handle no serial */ if (r != 0) { if (max_serial > 0) serial[0] = '\0'; } return r; } int libusb_fli_create_name(libusb_device *usb_dev, char *name, size_t max_name) { uint8_t addr, port_nums[7]; int numports; size_t len = 0; char name_prefix[] = "FLI-"; char *p, *s; int port; if (name == NULL) { return 0; } numports = libusb_get_port_numbers(usb_dev, port_nums, sizeof(port_nums)); addr = libusb_get_device_address(usb_dev); if ( (size_t)numports > sizeof(port_nums) ) { return 0; } p = name; /* Copy over the prefix */ for (s = name_prefix; (*s != '\0') && (len < max_name); p++, s++, len ++) { *p = *s; } /* Now append the port numbers as hexadecimal strings */ for (port = 0; (len < max_name) && (port < numports); port ++) { /* Most significant nybble */ if (len < max_name) { uint8_t c = port_nums[port] >> 4; *p = (c > 9)?c - 10 + 'A':c + '0'; p++; len ++; } /* Least significant nybble */ if (len < max_name) { uint8_t c = port_nums[port]; *p = (c > 9)?c - 10 + 'A':c + '0'; p++; len ++; } } #ifdef ADD_ADDRESS /* Add a delimiter to the end of the name to prevent false detection */ if (len < max_name) { *p = 'A'; p++; len ++; } /* Now append the address */ /* Most significant nybble */ if (len < max_name) { uint8_t c = addr >> 4; *p = (c > 9)?c - 10 + 'A':c + '0'; p++; len ++; } /* Least significant nybble */ if (len < max_name) { uint8_t c = addr; *p = (c > 9)?c - 10 + 'A':c + '0'; p++; len ++; } #endif if (len < max_name) { *p = '\0'; } return len; } long libusb_list(char *pattern, flidomain_t domain, char ***names) { INDI_UNUSED(pattern); int r, i; char **list; libusb_device **usb_devs; libusb_device *usb_dev; struct libusb_device_descriptor usb_desc; int num_usb_devices, num_fli_devices=0; r = libusb_init(NULL); if(r < 0) { debug(FLIDEBUG_FAIL, "%s: Could not initialize LibUSB: %s", __PRETTY_FUNCTION__, libusb_error_name(r)); libusb_exit(NULL); return -ENODEV; } num_usb_devices = libusb_get_device_list(NULL, &usb_devs); if(num_usb_devices < 0) { debug(FLIDEBUG_WARN, "LibUSB Get Device List Failed"); libusb_free_device_list(usb_devs, 1); libusb_exit(NULL); return -ENODEV; } list = xmalloc(sizeof(*list)); *list = NULL; num_fli_devices = 0; i = -1; while((usb_dev = usb_devs[++i]) != NULL) { flidev_t dev; char fli_usb_name[32]; char fli_serial_name[32]; char * fli_device_name = NULL; char fli_model_name[32]; if(libusb_get_device_descriptor(usb_dev, &usb_desc) != LIBUSB_SUCCESS) { debug(FLIDEBUG_WARN, "USB Device Descriptor not obtained."); continue; } /* FLI device? */ if(usb_desc.idVendor != FLIUSB_VENDORID) continue; /* Determine if device matches domain */ switch(domain & FLIDOMAIN_DEVICE_MASK) { case FLIDEVICE_CAMERA: if (!((usb_desc.idProduct == FLIUSB_CAM_ID) || (usb_desc.idProduct == FLIUSB_PROLINE_ID))) { continue; } break; case FLIDEVICE_FOCUSER: if (usb_desc.idProduct != FLIUSB_FOCUSER_ID) { continue; } break; case FLIDEVICE_FILTERWHEEL: if (!((usb_desc.idProduct == FLIUSB_FILTER_ID) || (usb_desc.idProduct == FLIUSB_CFW4_ID))) { continue; } break; default: continue; break; } memset(fli_usb_name, '\0', sizeof(fli_usb_name)); memset(fli_serial_name, '\0', sizeof(fli_serial_name)); memset(fli_model_name, '\0', sizeof(fli_model_name)); libusb_fli_create_name(usb_dev, fli_usb_name, sizeof(fli_usb_name) - 1); libusb_fli_get_serial(usb_dev, fli_serial_name, sizeof(fli_serial_name) - 1); if ((domain & FLIDEVICE_ENUMERATE_BY_SERIAL) && (fli_serial_name[0] != '\0')) { fli_device_name = fli_serial_name; } else { fli_device_name = fli_usb_name; } debug(FLIDEBUG_INFO, "Device Name: '%s'", fli_device_name); /* FLIOpen is needed for a proper description (model) from the device. If the device is opened by * another process and clamied, this will fail, so we will return the second string descriptor. * * Another option is to move libusb_clam_xxx to the IO functions, but since there doesn't seem to * be a straightforward method to wait for a device to become available... */ if (FLIOpen(&dev, fli_device_name, domain) == 0) /* Opened and should have model */ { if(DEVICE->devinfo.model == NULL) DEVICE->devinfo.model = strdup("DEVICE->devinfo.model is NULL"); strncpy(fli_model_name, DEVICE->devinfo.model, sizeof(fli_model_name) - 1); FLIClose(dev); } else { libusb_device_handle *usb_han; if( (libusb_open(usb_dev, &usb_han) == 0) && (usb_desc.iProduct > 0) ) { libusb_get_string_descriptor_ascii(usb_han, usb_desc.iProduct, (unsigned char *) fli_model_name, sizeof(fli_model_name) - 1); libusb_close(usb_han); } else { strncpy(fli_model_name, "Model unavailable", sizeof(fli_model_name) - 1); } } /* Add it to the list */ if ((list[num_fli_devices] = xmalloc(strlen(fli_device_name) + strlen(fli_model_name) + 2)) == NULL) { int j; /* Free the list */ for (j = 0; j < num_fli_devices; j++) xfree(list[j]); xfree(list); libusb_exit(NULL); return -ENOMEM; } else { sprintf(list[num_fli_devices], "%s;%s", fli_device_name, fli_model_name); FLIClose(dev); num_fli_devices++; } } libusb_free_device_list(usb_devs, 1); debug(FLIDEBUG_INFO, "Number of FLI Devices: %d", num_fli_devices); /* Terminate the list */ list[num_fli_devices++] = NULL; list = xrealloc(list, num_fli_devices * sizeof(char *)); *names = list; libusb_exit(NULL); return 0; } libusb_device_handle * libusb_fli_find_handle(struct libusb_context *usb_ctx, char *name) { INDI_UNUSED(usb_ctx); int r, i; libusb_device **usb_devs; libusb_device *usb_dev; libusb_device_handle *usb_han; struct libusb_device_descriptor usb_desc; int num_usb_devices; unsigned char serial[64]; num_usb_devices = libusb_get_device_list(NULL, &usb_devs); if(num_usb_devices < 0) { debug(FLIDEBUG_FAIL, "LibUSB Get Device Failed with %s", libusb_error_name(num_usb_devices)); return NULL; } for (i = 0; (usb_dev = usb_devs[i]) != NULL; i++) { char fli_usb_name[24]; if(libusb_get_device_descriptor(usb_dev, &usb_desc) != LIBUSB_SUCCESS) continue; if(usb_desc.idVendor == FLIUSB_VENDORID) { memset(serial, '\0', sizeof(serial)); memset(fli_usb_name, '\0', sizeof(fli_usb_name)); libusb_fli_create_name(usb_dev, fli_usb_name, sizeof(fli_usb_name) - 1); /* May be a serial number as the name, so let's quickly read it */ if (usb_desc.iSerialNumber != 0) { r = libusb_open(usb_dev, &usb_han); if(r == 0) { libusb_get_string_descriptor_ascii(usb_han, usb_desc.iSerialNumber, serial, sizeof(serial) - 1); libusb_close(usb_han); } } /* Is it the same as the one we are asking to open */ if( (strncasecmp(fli_usb_name, name, sizeof(fli_usb_name)) == 0) || (strncasecmp((char *) serial, name, sizeof(serial)) == 0 )) { r = libusb_open(usb_dev, &usb_han); if(r == 0) { // Found device handle, cleanup and return debug(FLIDEBUG_INFO, "Found Device Handle"); libusb_free_device_list(usb_devs, 1); return usb_han; } else { debug(FLIDEBUG_WARN, "Get USB Device Handle Failed"); } } } } libusb_free_device_list(usb_devs, 1); return NULL; } libfli-2.0+20221221182632/unix/linux/0000755000175100017510000000000014174600256015550 5ustar debiandebianlibfli-2.0+20221221182632/unix/linux/libfli-parport.c0000644000175100017510000000647614174600256020657 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-camera.h" #include "fli_ioctl.h" long unix_parportio_linux(flidev_t dev, void *buf, long *wlen, long *rlen) { fli_unixio_t *io; flicamdata_t *cam; int err = 0, locked = 0; long org_wlen = *wlen, org_rlen = *rlen; int wto, rto, dto; io = DEVICE->io_data; cam = DEVICE->device_data; if ((err = unix_fli_lock(dev))) { debug(FLIDEBUG_WARN, "Lock failed"); goto done; } locked = 1; /* Convert timeout to jiffies */ wto = cam->writeto / 1000 * HZ; rto = cam->readto / 1000 * HZ; dto = cam->dirto / 1000 * HZ; if (ioctl(io->fd, FLI_SET_WTO, &wto)) { err = -errno; goto done; } if (ioctl(io->fd, FLI_SET_DTO, &dto)) { err = -errno; goto done; } if (ioctl(io->fd, FLI_SET_RTO, &rto)) { err = -errno; goto done; } if (*wlen > 0) { if ((*wlen = write(io->fd, buf, *wlen)) != org_wlen) { debug(FLIDEBUG_WARN, "write failed, only %d of %d bytes written", *wlen, org_wlen); err = -errno; goto done; } } if (*rlen > 0) { if ((*rlen = read(io->fd, buf, *rlen)) != org_rlen) { debug(FLIDEBUG_WARN, "read failed, only %d of %d bytes read", *rlen, org_rlen); err = -errno; goto done; } } done: if (locked) { int r; if ((r = unix_fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/unix/linux/libfli-usb-sys.c0000644000175100017510000001455114174600256020566 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)) #include #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) #include #include #else #include #endif #endif #include #include #include #include #include "libfli-libfli.h" #include "libfli-sys.h" #include "libfli-mem.h" #include "libfli-usb.h" #include "fliusb_ioctl.h" long linux_usb_connect(flidev_t dev, fli_unixio_t *io, char *name) { struct usb_device_descriptor usbdesc; fliusb_string_descriptor_t strdesc; int confg, r; if ((io->fd = open(name, O_RDWR)) == -1) { xfree(io); return -errno; } if (ioctl(io->fd, FLIUSB_GET_DEVICE_DESCRIPTOR, &usbdesc) == -1) { debug(FLIDEBUG_FAIL, "%s: Could not read descriptor: %s", __PRETTY_FUNCTION__, strerror(errno)); return -EIO; } if (usbdesc.idVendor != FLIUSB_VENDORID) { debug(FLIDEBUG_INFO, "%s: Not a FLI device!", __PRETTY_FUNCTION__); return -ENODEV; } switch (usbdesc.idProduct) { /* These are valid product IDs */ case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: case FLIUSB_PROLINE_ID: break; default: /* Anything else is unknown */ return -ENODEV; } DEVICE->devinfo.devid = usbdesc.idProduct; DEVICE->devinfo.fwrev = usbdesc.bcdDevice; strdesc.index = 3; if (ioctl(io->fd, FLIUSB_GET_STRING_DESCRIPTOR, &strdesc) != 0) { debug(FLIDEBUG_FAIL, "%s: Could not read descriptor: %s", __PRETTY_FUNCTION__, strerror(errno)); } else { DEVICE->devinfo.serial = xstrndup((char *) strdesc.buf, sizeof(strdesc.buf)); } confg = 0; r = ioctl (io->fd, USBDEVFS_SETCONFIGURATION, &confg); debug(FLIDEBUG_INFO, "USBDEVFS_SETCONFIGURATION return %i", r); confg = 1; r = ioctl (io->fd, USBDEVFS_SETCONFIGURATION, &confg); debug(FLIDEBUG_INFO, "USBDEVFS_SETCONFIGURATION return %i", r); return 0; } long linux_bulktransfer(flidev_t dev, int ep, void *buf, long *len) { fli_unixio_t *io; fliusb_bulktransfer_t bulkxfer; size_t remaining; int err = 0; #define _DEBUG #ifdef _DEBUG debug(FLIDEBUG_INFO, "%s: attempting %ld bytes %s", __PRETTY_FUNCTION__, *len, (ep & USB_DIR_IN) ? "in" : "out"); #endif io = DEVICE->io_data; #ifdef _DEBUG if ((ep & 0xf0) == 0) { char buffer[1024]; int i; sprintf(buffer, "OUT %6ld: ", *len); for (i = 0; i < ((*len > 16)?16:*len); i++) { sprintf(buffer + strlen(buffer), "%02x ", ((unsigned char *) buf)[i]); } debug(FLIDEBUG_INFO, buffer); } #endif /* _DEBUG */ remaining = *len; while (remaining) /* read up to USB_READ_SIZ_MAX bytes at a time */ { int bytes; bulkxfer.ep = ep; bulkxfer.count = MIN(remaining, USB_READ_SIZ_MAX); bulkxfer.timeout = DEVICE->io_timeout; bulkxfer.buf = buf + *len - remaining; /* This ioctl returns the number of bytes transferred */ bytes = ioctl(io->fd, (ep & USB_DIR_IN) ? FLIUSB_BULKREAD : FLIUSB_BULKWRITE, &bulkxfer); if (bytes < 0) break; remaining -= bytes; if (bytes < bulkxfer.count) break; } /* Set *len to the number of bytes actually transfered */ if (remaining) err = -errno; *len -= remaining; #ifdef _DEBUG if ((ep & 0xf0) != 0) { char buffer[1024]; int i; sprintf(buffer, " IN %6ld: ", *len); for (i = 0; i < ((*len > 16)?16:*len); i++) { sprintf(buffer + strlen(buffer), "%02x ", ((unsigned char *) buf)[i]); } debug(FLIDEBUG_INFO, buffer); } #endif /* _DEBUG */ return err; } long linux_bulkwrite(flidev_t dev, void *buf, long *wlen) { int ep; switch (DEVICE->devinfo.devid) { case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: ep = 0x02; break; case FLIUSB_PROLINE_ID: ep = 0x01; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); return -EINVAL; } return linux_bulktransfer(dev, ep | USB_DIR_OUT, buf, wlen); } long linux_bulkread(flidev_t dev, void *buf, long *rlen) { int ep; switch (DEVICE->devinfo.devid) { case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: ep = 0x02; break; case FLIUSB_PROLINE_ID: ep = 0x01; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); return -EINVAL; } return linux_bulktransfer(dev, ep | USB_DIR_IN, buf, rlen); } long linux_usb_disconnect(flidev_t dev) { fli_unixio_t *io; io = DEVICE->io_data; long err = 0; if (io->fd != (-1)) err = close(io->fd); return err; } libfli-2.0+20221221182632/unix/linux/fliusb_ioctl.h0000644000175100017510000000625014174600256020402 0ustar debiandebian/* Copyright (c) 2005 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), L.L.C. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _FLIUSB_IOCTL_H_ #define _FLIUSB_IOCTL_H_ #include /* Structure to describe string descriptor transfers */ typedef struct { unsigned int index; unsigned char buf[64]; } fliusb_string_descriptor_t; /* Structure to describe bulk transfers */ typedef struct { u_int8_t ep; void *buf; size_t count; unsigned int timeout; /* in msec */ } fliusb_bulktransfer_t; /* 8-bit special value to identify ioctl 'type' */ #define FLIUSB_IOC_TYPE 0xf1 /* Recognized ioctl commands */ #define FLIUSB_GETRDEPADDR _IOR(FLIUSB_IOC_TYPE, 1, u_int8_t) #define FLIUSB_SETRDEPADDR _IOW(FLIUSB_IOC_TYPE, 2, u_int8_t) #define FLIUSB_GETWREPADDR _IOR(FLIUSB_IOC_TYPE, 3, u_int8_t) #define FLIUSB_SETWREPADDR _IOW(FLIUSB_IOC_TYPE, 4, u_int8_t) #define FLIUSB_GETBUFFERSIZE _IOR(FLIUSB_IOC_TYPE, 5, size_t) #define FLIUSB_SETBUFFERSIZE _IOW(FLIUSB_IOC_TYPE, 6, size_t) #define FLIUSB_GETTIMEOUT _IOR(FLIUSB_IOC_TYPE, 7, unsigned int) #define FLIUSB_SETTIMEOUT _IOW(FLIUSB_IOC_TYPE, 8, unsigned int) #define FLIUSB_BULKREAD _IOW(FLIUSB_IOC_TYPE, 9, fliusb_bulktransfer_t) #define FLIUSB_BULKWRITE _IOW(FLIUSB_IOC_TYPE, 10, fliusb_bulktransfer_t) #define FLIUSB_GET_DEVICE_DESCRIPTOR _IOR(FLIUSB_IOC_TYPE, 11, struct usb_device_descriptor) #define FLIUSB_GET_STRING_DESCRIPTOR _IOR(FLIUSB_IOC_TYPE, 12, struct usb_device_descriptor) #define FLIUSB_IOC_MAX 12 #endif /* _FLIUSB_IOCTL_H_ */ libfli-2.0+20221221182632/unix/linux/fli_ioctl.h0000644000175100017510000001047714174600256017676 0ustar debiandebian/* Copyright (c) 2000 Finger Lakes Instrumentation (FLI), LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation (FLI) web: http://www.fli-cam.com email: fli@rpa.net */ #ifndef _FLI_IOCTL_H #define _FLI_IOCTL_H #include /* 8-bit special value to identify ioctl 'type' */ #define FLI_IOCTL_TYPE 'F' /* Macros declaring ioctl commands and the variables they operate on */ #define FLI_IOCTL_MISC_CMDS \ FLI_IOCTL_CMD(FLI_RESET_PORT_VALUES, **NONE**) \ FLI_IOCTL_CMD(FLI_LOCK_PORT, **NONE**) \ FLI_IOCTL_CMD(FLI_UNLOCK_PORT, **NONE**) #define FLI_IOCTL_SPECIAL_SET_CMDS \ FLI_IOCTL_CMD(FLI_SET_DMABUFFSIZE, dmabuffsize) #define FLI_IOCTL_SET_CMDS \ FLI_IOCTL_CMD(FLI_SET_DMATHRESH, dmathresh) \ FLI_IOCTL_CMD(FLI_SET_DTO, dto) \ FLI_IOCTL_CMD(FLI_SET_RTO, rto) \ FLI_IOCTL_CMD(FLI_SET_WTO, wto) \ FLI_IOCTL_CMD(FLI_SET_LTL, ltl) \ FLI_IOCTL_CMD(FLI_SET_DIR, dir) \ FLI_IOCTL_CMD(FLI_SET_NUMREAD, numread) \ FLI_IOCTL_CMD(FLI_SET_NUMWRITE, numwrite) \ FLI_IOCTL_CMD(FLI_SET_NUMDTO, numdto) \ FLI_IOCTL_CMD(FLI_SET_NUMRTO, numrto) \ FLI_IOCTL_CMD(FLI_SET_NUMWTO, numwto) #define FLI_IOCTL_GET_CMDS \ FLI_IOCTL_CMD(FLI_GET_DMABUFFSIZE, dmabuffsize) \ FLI_IOCTL_CMD(FLI_GET_DMATHRESH, dmathresh) \ FLI_IOCTL_CMD(FLI_GET_DTO, dto) \ FLI_IOCTL_CMD(FLI_GET_RTO, rto) \ FLI_IOCTL_CMD(FLI_GET_WTO, wto) \ FLI_IOCTL_CMD(FLI_GET_DIR, dir) \ FLI_IOCTL_CMD(FLI_GET_LTL, ltl) \ FLI_IOCTL_CMD(FLI_GET_NUMREAD, numread) \ FLI_IOCTL_CMD(FLI_GET_NUMWRITE, numwrite) \ FLI_IOCTL_CMD(FLI_GET_NUMDTO, numdto) \ FLI_IOCTL_CMD(FLI_GET_NUMRTO, numrto) \ FLI_IOCTL_CMD(FLI_GET_NUMWTO, numwto) /* Enumerate ioctl numbers */ #undef FLI_SET_CMD #define FLI_IOCTL_CMD(cmd, var) cmd##_NUM, enum { FLI_IOCTL_MISC_CMDS FLI_IOCTL_SPECIAL_SET_CMDS FLI_IOCTL_SET_CMDS FLI_IOCTL_GET_CMDS }; /* Enumerate the actual ioctl commands */ #undef FLI_IOCTL_CMD #define FLI_IOCTL_CMD(cmd, var) \ enum {cmd = _IO(FLI_IOCTL_TYPE, cmd##_NUM)}; FLI_IOCTL_MISC_CMDS; #undef FLI_IOCTL_CMD #define FLI_IOCTL_CMD(cmd, var) \ enum {cmd = _IOW(FLI_IOCTL_TYPE, cmd##_NUM, int)}; FLI_IOCTL_SPECIAL_SET_CMDS; FLI_IOCTL_SET_CMDS; #undef FLI_IOCTL_CMD #define FLI_IOCTL_CMD(cmd, var ) \ enum {cmd = _IOR(FLI_IOCTL_TYPE, cmd##_NUM, int)}; FLI_IOCTL_GET_CMDS; #endif /* _FLI_IOCTL_H */ libfli-2.0+20221221182632/unix/libfli-serial.c0000644000175100017510000001156014174600256017276 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-sys.h" #include "libfli-serial.h" long unix_serialio(flidev_t dev, void *buf, long *wlen, long *rlen) { int err = 0, locked = 0, gotattr = 0; long org_wlen = *wlen, org_rlen = *rlen; struct termios old_termios, new_termios; fli_unixio_t *io; io = DEVICE->io_data; if ((err = unix_fli_lock(dev))) { debug(FLIDEBUG_WARN, "Lock failed"); goto done; } locked = 1; if (tcgetattr(io->fd, &old_termios)) { err = -errno; debug(FLIDEBUG_WARN, "tcgetattr() failed: %s", strerror(errno)); goto done; } gotattr = 1; bzero(&new_termios, sizeof(struct termios)); new_termios.c_cflag = CS8 | CREAD | CLOCAL; new_termios.c_cc[VMIN] = 1; new_termios.c_cc[VTIME] = 0; /* Set the input baud rate */ if (cfsetispeed(&new_termios, BAUDRATE)) { err = -errno; debug(FLIDEBUG_WARN, "cfsetispeed() failed: %s", strerror(errno)); goto done; } /* Set the output baud rate */ if (cfsetospeed(&new_termios, BAUDRATE)) { err = -errno; debug(FLIDEBUG_WARN, "cfsetospeed() failed: %s", strerror(errno)); goto done; } if (tcsetattr(io->fd, TCSANOW, &new_termios)) { err = -errno; // FIX: Should this be FLIDEBUG_FAIL debug(FLIDEBUG_WARN, "tcsetattr() failed: %s", strerror(errno)); goto done; } if ((*wlen = write(io->fd, buf, org_wlen)) != org_wlen) { err = -errno; debug(FLIDEBUG_WARN, "write() failed, only %d of %d bytes written", *wlen, org_wlen); goto done; } if (tcdrain(io->fd)) { err = -errno; debug(FLIDEBUG_WARN, "tcdrain() failed: %s", strerror(errno)); goto done; } for (*rlen = 0; *rlen < org_rlen; ) { ssize_t r; fd_set readfds; struct timeval timeout; timeout.tv_sec = DEVICE->io_timeout / 1000; timeout.tv_usec = (DEVICE->io_timeout % 1000) * 1000; FD_ZERO(&readfds); FD_SET(io->fd, &readfds); switch (select(io->fd + 1, &readfds, NULL, NULL, &timeout)) { case -1: /* An error occurred */ err = -errno; debug(FLIDEBUG_WARN, "select() failed: %s", strerror(errno)); break; case 0: /* A timeout occurred */ err = -ETIMEDOUT; debug(FLIDEBUG_WARN, "A serial communication timeout occurred"); break; default: /* There's some data to read */ if ((r = read(io->fd, buf + *rlen, org_rlen - *rlen)) <= 0) { err = -errno; debug(FLIDEBUG_WARN, "read() failed, only %d of %d bytes read", r, org_rlen - *rlen); } else *rlen += r; break; } if (err) break; } done: if (gotattr) { if (tcsetattr(io->fd, TCSANOW, &old_termios)) { if (err == 0) err = -errno; debug(FLIDEBUG_WARN, "tcsetattr() failed, could not restore terminal settings: %s", strerror(errno)); } } if (locked) { int r; if ((r = unix_fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/unix/libfli-serial.h0000644000175100017510000000371314174600256017304 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_SERIAL_H_ #define _LIBFLI_SERIAL_H_ #define BAUDRATE B1200 long unix_serialio(flidev_t dev, void *buf, long *wlen, long *rlen); #endif /* _LIBFLI_SERIAL_H_ */ libfli-2.0+20221221182632/unix/libfli-sys.h0000644000175100017510000000777714174600256016661 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_SYS_H #define _LIBFLI_SYS_H #include #include #define LIBFLIAPI long #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #if defined(__linux__) #define __SYSNAME__ "Linux" #define __LIBFLI_MINOR__ 999.1 #define USB_READ_SIZ_MAX (1024 * 64) #define _USE_PTHREAD_LOCK_ //#define _USE_FLOCK_ #define PARPORT_GLOB "/dev/ccd*" #define USB_GLOB "/dev/fliusb*" #define SERIAL_GLOB "/dev/ttyS[0-9]*" #define fli_connect unix_fli_connect #define fli_disconnect unix_fli_disconnect #define fli_list unix_fli_list #elif defined(__FreeBSD__) #define __SYSNAME__ "FreeBSD" #define __LIBFLI_MINOR__ 999 #define USB_READ_SIZ_MAX 65536 #define USB_GLOB "/dev/ugen[0-9]" #define SERIAL_GLOB "/dev/cuaa*" #define fli_connect unix_fli_connect #define fli_disconnect unix_fli_disconnect #define fli_list unix_fli_list #elif defined (__NetBSD__) #define __SYSNAME__ "NetBSD" #define __LIBFLI_MINOR__ 999 #define USB_READ_SIZ_MAX 65536 #define USB_GLOB "/dev/ugen*.0" __STRINGIFY(FLI_USB_CMDENDPOINT) #define SERIAL_GLOB "/dev/dty0*" #define fli_connect unix_fli_connect #define fli_disconnect unix_fli_disconnect #define fli_list unix_fli_list #elif defined (__APPLE__) #define __SYSNAME__ "MacOSX" #define __LIBFLI_MINOR__ 999 #define USB_READ_SIZ_MAX 65536 #define USB_GLOB "/dev/ugen*.0" __STRINGIFY(FLI_USB_CMDENDPOINT) #define SERIAL_GLOB "/dev/dty0*" #if defined(__LIBUSB__) #define fli_connect unix_fli_connect #define fli_disconnect unix_fli_disconnect #define fli_list unix_fli_list #else #define fli_connect mac_fli_connect #define fli_disconnect mac_fli_disconnect #define fli_list mac_fli_list #endif #define unix_fli_lock mac_fli_lock #define unix_fli_unlock mac_fli_unlock #define unix_fli_trylock mac_fli_trylock #else #error "Unknown system" #endif typedef struct { int fd; void *han; } fli_unixio_t; typedef struct { pthread_mutex_t mutex; pthread_mutexattr_t attr; long locked; long OS; } fli_unixsysinfo_t; long unix_fli_connect(flidev_t dev, char *name, long domain); long unix_fli_disconnect(flidev_t dev); long unix_fli_lock(flidev_t dev); long unix_fli_unlock(flidev_t dev); long unix_fli_trylock(flidev_t dev); long unix_fli_list(flidomain_t domain, char ***names); #endif /* _LIBFLI_SYS_H */ libfli-2.0+20221221182632/unix/libfli-usb.h0000644000175100017510000000767114174600256016625 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_USB_H_ #define _LIBFLI_USB_H_ #if defined(__linux__) && !defined(__LIBUSB__) #define unix_bulkwrite linux_bulkwrite #define unix_bulkread linux_bulkread #define unix_usb_connect linux_usb_connect #define unix_usb_disconnect linux_usb_disconnect #define unix_bulktransfer linux_bulktransfer #define unix_usb_list unix_fli_list_glob #elif defined(__linux__) && defined(__LIBUSB__) #define unix_bulkwrite libusb_bulkwrite #define unix_bulkread libusb_bulkread #define unix_usb_connect libusb_usb_connect #define unix_usb_disconnect libusb_usb_disconnect #define unix_bulktransfer libusb_bulktransfer #define unix_usb_list libusb_list #elif defined(__FreeBSD__) || defined(__NetBSD__) #define unix_bulkwrite bsd_bulkwrite #define unix_bulkread bsd_bulkread #define unix_usb_connect bsd_usb_connect #define unix_usb_disconnect bsd_usb_disconnect #define unix_bulktransfer bsd_bulktransfer #define unix_usb_list unix_fli_list_glob #elif defined(__APPLE__) && !defined(__LIBUSB__) #define unix_bulkwrite mac_bulkwrite #define unix_bulkread mac_bulkread #define unix_usb_connect mac_usb_connect #define unix_usb_disconnect mac_usb_disconnect #define unix_bulktransfer mac_bulktransfer #define unix_usb_list unix_fli_list_glob #elif defined(__APPLE__) && defined(__LIBUSB__) #define unix_bulkwrite libusb_bulkwrite #define unix_bulkread libusb_bulkread #define unix_usb_connect libusb_usb_connect #define unix_usb_disconnect libusb_usb_disconnect #define unix_bulktransfer libusb_bulktransfer #define unix_usb_list libusb_list #else #error "Unknown system" #endif long unix_bulkwrite(flidev_t dev, void *buf, long *wlen); long unix_bulkread(flidev_t dev, void *buf, long *rlen); long unix_usbio(flidev_t dev, void *buf, long *wlen, long *rlen); long unix_usb_connect(flidev_t dev, fli_unixio_t *io, char *name); long unix_usb_disconnect(flidev_t dev, fli_unixio_t *io); long unix_bulktransfer(flidev_t dev, int ep, void *buf, long *len); long unix_usb_list(char *pattern, flidomain_t domain,char ***names); #if defined(__APPLE__) && !defined(__LIBUSB__) #define usb_bulktransfer mac_bulktransfer #else #define usb_bulktransfer unix_bulktransfer #endif #endif /* _LIBFLI_USB_H_ */ libfli-2.0+20221221182632/unix/libfli-parport.h0000644000175100017510000000421614174600256017513 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_PARPORT_H_ #define _LIBFLI_PARPORT_H_ #if defined(__linux__) #define unix_parportio unix_parportio_linux #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) #define unix_parportio NULL #else #error "Unknown system" #endif long unix_parportio_linux(flidev_t dev, void *buf, long *wlen, long *rlen); #endif /* _LIBFLI_PARPORT_H_ */ libfli-2.0+20221221182632/unix/libfli-sys.c0000644000175100017510000003306614174600256016642 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include #include #include #include #include #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-mem.h" #include "libfli-camera.h" #include "libfli-filter-focuser.h" #include "libfli-sys.h" #include "libfli-parport.h" #include "libfli-usb.h" #include "libfli-serial.h" #include "indimacros.h" static long unix_fli_list_parport(flidomain_t domain, char ***names); static long unix_fli_list_usb(flidomain_t domain, char ***names); static long unix_fli_list_serial(flidomain_t domain, char ***names); long unix_fli_connect(flidev_t dev, char *name, long domain) { fli_unixio_t *io = NULL; pthread_mutex_t mutex; pthread_mutexattr_t fliattr; fli_unixsysinfo_t *sys; int err; CHKDEVICE(dev); if (name == NULL) return -EINVAL; /* Lock functions should be set before any other functions used */ DEVICE->fli_lock = unix_fli_lock; DEVICE->fli_unlock = unix_fli_unlock; DEVICE->fli_trylock = unix_fli_trylock; DEVICE->domain = domain & 0x00ff; DEVICE->devinfo.type = domain & 0xff00; debug(FLIDEBUG_INFO, "Domain: 0x%04x", DEVICE->domain); debug(FLIDEBUG_INFO, " Type: 0x%04x", DEVICE->devinfo.type); /* Check for valid device type */ switch (DEVICE->devinfo.type) { case FLIDEVICE_CAMERA: DEVICE->fli_open = fli_camera_open; DEVICE->fli_close = fli_camera_close; DEVICE->fli_command = fli_camera_command; break; case FLIDEVICE_FOCUSER: DEVICE->fli_open = fli_focuser_open; DEVICE->fli_close = fli_focuser_close; DEVICE->fli_command = fli_focuser_command; break; case FLIDEVICE_FILTERWHEEL: DEVICE->fli_open = fli_filter_open; DEVICE->fli_close = fli_filter_close; DEVICE->fli_command = fli_filter_command; break; default: return -EINVAL; } if ((io = xcalloc(1, sizeof(fli_unixio_t))) == NULL) return -ENOMEM; io->fd = (-1); /* No device open at this time */ io->han = NULL; switch (DEVICE->domain) { /* case FLIDOMAIN_PARALLEL_PORT: if ((io->fd = open(name, O_RDWR)) == -1) { xfree(io); return -errno; } DEVICE->fli_io = unix_parportio; break; */ case FLIDOMAIN_USB: { int r; if ((r = unix_usb_connect(dev, io, name))) { unix_usb_disconnect(dev,io); xfree(io); return r; } switch(DEVICE->devinfo.type) { case FLIDEVICE_CAMERA: if (!((DEVICE->devinfo.devid == FLIUSB_CAM_ID) || (DEVICE->devinfo.devid == FLIUSB_PROLINE_ID))) { unix_usb_disconnect(dev,io); xfree(io); return -ENODEV; } break; case FLIDEVICE_FOCUSER: if (DEVICE->devinfo.devid != FLIUSB_FOCUSER_ID) { unix_usb_disconnect(dev,io); xfree(io); return -ENODEV; } break; case FLIDEVICE_FILTERWHEEL: if (!((DEVICE->devinfo.devid == FLIUSB_FILTER_ID) || (DEVICE->devinfo.devid == FLIUSB_CFW4_ID))) { debug(FLIDEBUG_INFO, "FW Not Recognized"); unix_usb_disconnect(dev,io); xfree(io); return -ENODEV; } break; default: debug(FLIDEBUG_INFO, "Device Not Recognized"); unix_usb_disconnect(dev,io); xfree(io); return -ENODEV; } DEVICE->fli_io = unix_usbio; } break; case FLIDOMAIN_SERIAL: if ((io->fd = open(name, O_RDWR)) == -1) { xfree(io); return -errno; } DEVICE->fli_io = unix_serialio; break; default: xfree(io); return -EINVAL; } if((sys = xcalloc(1, sizeof(fli_unixsysinfo_t))) == NULL) { unix_fli_disconnect(dev); return -ENOMEM; } DEVICE->sys_data = sys; /* Create synchronization object */ if((err = pthread_mutexattr_init(&fliattr)) != 0) return err; if((err = pthread_mutexattr_settype(&fliattr, PTHREAD_MUTEX_NORMAL)) != 0) return err; if((err = pthread_mutexattr_setpshared(&fliattr, PTHREAD_PROCESS_SHARED)) != 0) return err; if((err = pthread_mutex_init(&mutex,&fliattr)) != 0) return err; ((fli_unixsysinfo_t *) (DEVICE->sys_data))->mutex = mutex; ((fli_unixsysinfo_t *) (DEVICE->sys_data))->attr = fliattr; DEVICE->io_data = io; DEVICE->name = xstrdup(name); DEVICE->io_timeout = 60 * 1000; /* 1 min. */ debug(FLIDEBUG_INFO, "Connected"); return 0; } long unix_fli_disconnect(flidev_t dev) { int err = 0; fli_unixio_t *io; fli_unixsysinfo_t *sys; CHKDEVICE(dev); if ((io = DEVICE->io_data) == NULL) return -EINVAL; if ((sys = DEVICE->sys_data) == NULL) return -EINVAL; err = pthread_mutex_destroy(&(sys->mutex)); err = pthread_mutexattr_destroy(&(sys->attr)); switch (DEVICE->domain) { case FLIDOMAIN_USB: err = unix_usb_disconnect(dev,io); break; default: err = close(io->fd); break; } if (err) err = -errno; xfree(DEVICE->io_data); DEVICE->io_data = NULL; if(DEVICE->sys_data != NULL) { xfree(DEVICE->sys_data); DEVICE->sys_data = NULL; } DEVICE->fli_lock = NULL; DEVICE->fli_unlock = NULL; DEVICE->fli_io = NULL; DEVICE->fli_open = NULL; DEVICE->fli_close = NULL; DEVICE->fli_command = NULL; return err; } #if defined(_USE_PTHREAD_LOCK_) long unix_fli_lock(flidev_t dev) { long r = -ENODEV; fli_unixsysinfo_t *sys; pthread_mutex_t mutex; CHKDEVICE(dev); if ((sys = DEVICE->sys_data) == NULL) { debug(FLIDEBUG_WARN, "lock(): Mutex is NULL!"); return r; } mutex = sys->mutex; r = pthread_mutex_lock(&mutex); if(r != 0) { debug(FLIDEBUG_WARN, "Could not acquire mutex: %d", r); r = -ENODEV; } // debug(FLIDEBUG_INFO, "Pthread Lock obtained"); return r; } long unix_fli_unlock(flidev_t dev) { int r = -ENODEV; fli_unixsysinfo_t *sys; pthread_mutex_t mutex; CHKDEVICE(dev); sys = DEVICE->sys_data; if (sys == NULL) { debug(FLIDEBUG_WARN, "unlock(): Mutex is NULL!"); return r; } mutex = sys->mutex; r = pthread_mutex_unlock(&mutex); if( r != 0) { debug(FLIDEBUG_WARN, "Could not release mutex: %d", r); return -ENODEV; } return r; } long unix_fli_trylock(flidev_t dev) { long r = -ENODEV; fli_unixsysinfo_t *sys; pthread_mutex_t mutex; CHKDEVICE(dev); if ((sys = DEVICE->sys_data) == NULL) { debug(FLIDEBUG_WARN, "trylock(): Mutex is NULL!"); return r; } mutex = sys->mutex; r = pthread_mutex_trylock(&mutex); if(r != 0) { debug(FLIDEBUG_WARN, "Could not acquire mutex with trylock: %d", r); r = -ENODEV; } return r; } #elif defined(_USE_FLOCK_) long unix_fli_lock(flidev_t dev) { fli_unixio_t *io = DEVICE->io_data; if (io == NULL) return -ENODEV; if (flock(io->fd, LOCK_EX) == -1) return -errno; else return 0; } long unix_fli_unlock(flidev_t dev) { fli_unixio_t *io = DEVICE->io_data; if (io == NULL) return -ENODEV; if (flock(io->fd, LOCK_UN) == -1) return -errno; else return 0; } long unix_fli_trylock(flidev_t dev) { (void)dev; return -ENODEV; } #else /* !defined(_USE_FLOCK_) */ //#define PUBLIC_DIR "/var/spool/lock" #define PUBLIC_DIR "/tmp" long unix_fli_lock(flidev_t dev) { int fd, err = 0, locked = 0, i; char tmpf[] = PUBLIC_DIR "/temp.XXXXXX", lockf[PATH_MAX], name[PATH_MAX]; FILE *f; unsigned int backoff = 10000; pid_t pid; if ((fd = mkstemp(tmpf)) == -1) return -errno; if ((f = fdopen(fd, "w")) == NULL) { err = -errno; goto done; } fprintf(f, "%d\n", getpid()); fclose(f); if (chmod(tmpf, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) == -1) { err = -errno; goto done; } for (i = 0; DEVICE->name[i] != '\0' && i < PATH_MAX; i++) name[i] = (DEVICE->name[i] == '/') ? '-' : DEVICE->name[i]; name[MIN(i, PATH_MAX - 1)] = '\0'; if (snprintf(lockf, PATH_MAX, PUBLIC_DIR "/libfli%s.lock", name) >= PATH_MAX) { err = -EOVERFLOW; goto done; } do { if (link(tmpf, lockf) == -1) { int r; if (errno != EEXIST) { err = -errno; goto done; } if ((f = fopen(lockf, "r")) == NULL) continue; r = fscanf(f, "%d\n", &pid); fclose(f); if (r != 1) continue; if (kill(pid, 0)) { if (errno == ESRCH) { debug(FLIDEBUG_WARN, "Removing stale lock file"); unlink(lockf); } continue; } else { usleep(backoff); if ((backoff <<= 2) == 0) { err = -ETIMEDOUT; goto done; } } } else locked = 1; } while (!locked); done: unlink(tmpf); return err; } long unix_fli_unlock(flidev_t dev) { char lockf[PATH_MAX], name[PATH_MAX]; FILE *f; pid_t pid = -1; int i; for (i = 0; DEVICE->name[i] != '\0' && i < PATH_MAX; i++) name[i] = (DEVICE->name[i] == '/') ? '-' : DEVICE->name[i]; name[MIN(i, PATH_MAX - 1)] = '\0'; if (snprintf(lockf, PATH_MAX, PUBLIC_DIR "/libfli%s.lock", name) >= PATH_MAX) return -EOVERFLOW; if ((f = fopen(lockf, "r")) == NULL) { debug(FLIDEBUG_WARN, "Trying to unlock `%s' when not locked", DEVICE->name); return -errno; } if (fscanf(f, "%d\n", &pid) != 1) debug(FLIDEBUG_WARN, "Invalid lock file for `%s'", DEVICE->name); fclose(f); if (pid != -1 && pid != getpid()) debug(FLIDEBUG_WARN, "Forcing unlock of `%s' from process %d", DEVICE->name, pid); unlink(lockf); return 0; } long unix_fli_trylock(flidev_t dev) { (void)dev; return -ENODEV; } #undef PUBLIC_DIR #endif /* defined(_USE_FLOCK_) */ long unix_fli_list(flidomain_t domain, char ***names) { *names = NULL; switch (domain & 0x00ff) { case FLIDOMAIN_PARALLEL_PORT: return unix_fli_list_parport(domain, names); break; case FLIDOMAIN_USB: return unix_fli_list_usb(domain, names); break; case FLIDOMAIN_SERIAL: return unix_fli_list_serial(domain, names); break; default: return -EINVAL; } /* Not reached */ return -EINVAL; } long unix_fli_list_glob(char *pattern, flidomain_t domain, char ***names) { int retval, found = 0; size_t i; char **list; glob_t g; if ((retval = glob(pattern, 0, NULL, &g))) { #ifdef GLOB_NOMATCH if (retval != GLOB_NOMATCH) { globfree(&g); return -errno; } /* retval == GLOB_NOMATCH */ g.gl_pathc = 0; #else globfree(&g); return -errno; #endif } if ((list = xmalloc((g.gl_pathc + 1) * sizeof(char *))) == NULL) { globfree(&g); return -ENOMEM; } for (i = 0; i < g.gl_pathc; i++) { flidev_t dev; if (FLIOpen(&dev, g.gl_pathv[i], domain)) continue; if ((list[found] = xmalloc(strlen(g.gl_pathv[i]) + strlen(DEVICE->devinfo.model) + 2)) == NULL) { int j; FLIClose(dev); for (j = 0; j < found; j++) xfree(list[j]); xfree(list); globfree(&g); return -ENOMEM; } sprintf(list[found], "%s;%s", g.gl_pathv[i], DEVICE->devinfo.model); FLIClose(dev); found++; } globfree(&g); /* Terminate the list */ list[found++] = NULL; list = xrealloc(list, found * sizeof(char *)); *names = list; return 0; } static long unix_fli_list_parport(flidomain_t domain, char ***names) { INDI_UNUSED(domain); INDI_UNUSED(names); return -EINVAL; // return unix_fli_list_glob(PARPORT_GLOB, domain, names); /* If you still have a parallel port FLI camera, buy a new one or use the older SDK. Functionality didn't * magically appear in the older hardware requiring this update. */ } static long unix_fli_list_usb(flidomain_t domain, char ***names) { return unix_usb_list(USB_GLOB, domain, names); } static long unix_fli_list_serial(flidomain_t domain, char ***names) { return unix_fli_list_glob(SERIAL_GLOB, domain, names); }libfli-2.0+20221221182632/unix/bsd/0000755000175100017510000000000014174600256015161 5ustar debiandebianlibfli-2.0+20221221182632/unix/bsd/libfli-usb-sys.c0000644000175100017510000001157214174600256020177 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include #include #include #include #include "libfli-libfli.h" #include "libfli-sys.h" #include "libfli-usb.h" long bsd_usb_connect(flidev_t dev, fli_unixio_t *io, char *name) { usb_device_descriptor_t usbdesc; int tmp, ep; char tmpname[PATH_MAX]; if (ioctl(io->fd, USB_GET_DEVICE_DESC, &usbdesc) == -1) { debug(FLIDEBUG_FAIL, "%s: Could not read descriptor: %s", __PRETTY_FUNCTION__, strerror(errno)); return -EIO; } if (UGETW(usbdesc.idVendor) != FLIUSB_VENDORID) { debug(FLIDEBUG_INFO, "%s: Not a FLI device!", __PRETTY_FUNCTION__); return -ENODEV; } switch (UGETW(usbdesc.idProduct)) { /* These are valid product IDs */ case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: case FLIUSB_PROLINE_ID: break; default: /* Anything else is unknown */ return -ENODEV; } DEVICE->devinfo.devid = UGETW(usbdesc.idProduct); DEVICE->devinfo.fwrev = UGETW(usbdesc.bcdDevice); switch (DEVICE->devinfo.devid) { case FLIUSB_CAM_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_FILTER_ID: ep = 0x02; break; case FLIUSB_PROLINE_ID: ep = 0x01; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); /* This shouldn't happen */ return -ENODEV; } if (snprintf(tmpname, sizeof(tmpname), "%s.%d", name, ep) >= sizeof(tmpname)) return -EOVERFLOW; if ((tmp = open(tmpname, O_RDWR)) == -1) { debug(FLIDEBUG_FAIL, "%s: open(%s) failed: %s", __PRETTY_FUNCTION__, tmpname, strerror(errno)); return -errno; } close(io->fd); io->fd = tmp; return 0; } long bsd_usb_disconnect(flidev_t dev) { return 0; } long bsd_bulkwrite(flidev_t dev, void *buf, long *wlen) { fli_unixio_t *io; long org_wlen = *wlen; int to; io = DEVICE->io_data; to = DEVICE->io_timeout; if (ioctl(io->fd, USB_SET_TIMEOUT, &to) == -1) return -errno; *wlen = write(io->fd, buf, *wlen); if (*wlen != org_wlen) return -errno; else return 0; } long bsd_bulkread(flidev_t dev, void *buf, long *rlen) { fli_unixio_t *io; long org_rlen = *rlen; int to; io = DEVICE->io_data; to = DEVICE->io_timeout; if (ioctl(io->fd, USB_SET_TIMEOUT, &to) == -1) return -errno; *rlen = read(io->fd, buf, *rlen); if (*rlen != org_rlen) return -errno; else return 0; } long bsd_bulktransfer(flidev_t dev, int ep, void *buf, long *len) { char name[PATH_MAX]; long orglen = *len; int fd, to, err; if (snprintf(name, sizeof(name), "%s.%d", DEVICE->name, ep) >= sizeof(name)) return -EOVERFLOW; if ((fd = open(name, O_RDWR)) == -1) { debug(FLIDEBUG_FAIL, "%s: open(%s) failed: %s", __PRETTY_FUNCTION__, name, strerror(errno)); return -errno; } to = DEVICE->io_timeout; if (ioctl(fd, USB_SET_TIMEOUT, &to) == -1) { err = -errno; goto done; } if (ep & UE_DIR_IN) *len = read(fd, buf, *len); else *len = write(fd, buf, *len); if (*len != orglen) err = -errno; else err = 0; done: close(fd); return err; } libfli-2.0+20221221182632/unix/libfli-debug.c0000644000175100017510000000631114174600256017103 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include "libfli-libfli.h" #define LOGPREFIX "libfli" static char *_loghost = NULL; static flidebug_t _loglevel = FLIDEBUG_NONE; static int _logopen = 0; int sysloglevel(int level) { switch (level) { case FLIDEBUG_INFO: return LOG_INFO; break; case FLIDEBUG_WARN: return LOG_WARNING; break; case FLIDEBUG_FAIL: return LOG_ERR; break; case FLIDEBUG_ALL: return LOG_EMERG | LOG_ALERT | LOG_CRIT | LOG_ERR | LOG_WARNING | LOG_NOTICE | LOG_INFO | LOG_DEBUG; break; } return 0; } int debugopen(char *host) { if (host != NULL) openlog(LOGPREFIX, LOG_PID | LOG_PERROR, LOG_USER); return 0; } int debugclose(void) { if (_loghost != NULL) closelog(); return 0; } void debug(int level, char *format, ...) { va_list ap; va_start(ap, format); if (_loghost != NULL) vsyslog(sysloglevel(level), format, ap); else if (level > FLIDEBUG_NONE && level <= _loglevel) { fprintf(stderr, LOGPREFIX ": "); vfprintf(stderr, format, ap); fprintf(stderr, "\n"); } va_end(ap); return; } void setdebuglevel(char *host, long level) { _loghost = host; _loglevel = level; if (level == FLIDEBUG_NONE) { debugclose(); _logopen = 0; return; } if (!_logopen) { debugopen(host); _logopen = 1; } if (host != NULL) setlogmask(LOG_UPTO(sysloglevel(level))); return; } libfli-2.0+20221221182632/cmake_modules/0000755000175100017510000000000014347562502016241 5ustar debiandebianlibfli-2.0+20221221182632/cmake_modules/FindGPSD.cmake0000644000175100017510000000103614174600255020575 0ustar debiandebian# - Find GPSD # Find the native GPSD includes and library FIND_PATH(GPSD_INCLUDE_DIR libgpsmm.h gps.h) SET(GPSD_NAMES ${GPSD_NAMES} gps) FIND_LIBRARY(GPSD_LIBRARY NAMES ${GPSD_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GPSD DEFAULT_MSG GPSD_LIBRARY GPSD_INCLUDE_DIR) IF(GPSD_FOUND) SET(GPSD_LIBRARIES ${GPSD_LIBRARY}) message(STATUS "Found libgps: ${GPSD_LIBRARIES}") ENDIF(GPSD_FOUND) libfli-2.0+20221221182632/cmake_modules/FindFTDI1.cmake0000644000175100017510000000267214174600255020656 0ustar debiandebian# - Try to find FTDI1 # Once done this will define # # FTDI1_FOUND - system has FTDI # FTDI1_INCLUDE_DIR - the FTDI include directory # FTDI1_LIBRARIES - Link these to use FTDI # # N.B. You must include the file as following: # #include # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) # in cache already set(FTDI1_FOUND TRUE) message(STATUS "Found libftdi1: ${FTDI1_LIBRARIES}") else (FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) find_path(FTDI1_INCLUDE_DIR ftdi.h PATH_SUFFIXES libftdi1 ${_obIncDir} ${GNUWIN32_DIR}/include /usr/local/include ) find_library(FTDI1_LIBRARIES NAMES ftdi1 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib ) if(FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) set(FTDI1_FOUND TRUE) else (FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) set(FTDI1_FOUND FALSE) endif(FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) if (FTDI1_FOUND) if (NOT FTDI1_FIND_QUIETLY) message(STATUS "Found FTDI1: ${FTDI1_LIBRARIES}") endif (NOT FTDI1_FIND_QUIETLY) else (FTDI1_FOUND) if (FTDI1_FIND_REQUIRED) message(FATAL_ERROR "FTDI not found. Please install libftdi1-dev") endif (FTDI1_FIND_REQUIRED) endif (FTDI1_FOUND) mark_as_advanced(FTDI1_INCLUDE_DIR FTDI1_LIBRARIES) endif (FTDI1_INCLUDE_DIR AND FTDI1_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindOpenAL.cmake0000644000175100017510000000660414174600255021164 0ustar debiandebian# Locate OpenAL # This module defines # OPENAL_LIBRARY # OPENAL_FOUND, if false, do not try to link to OpenAL # OPENAL_INCLUDE_DIR, where to find the headers # # $OPENALDIR is an environment variable that would # correspond to the ./configure --prefix=$OPENALDIR # used in building OpenAL. # # Created by Eric Wing. This was influenced by the FindSDL.cmake module. # This makes the presumption that you are include al.h like # #include "al.h" # and not # #include # The reason for this is that the latter is not entirely portable. # Windows/Creative Labs does not by default put their headers in AL/ and # OS X uses the convention . # # For Windows, Creative Labs seems to have added a registry key for their # OpenAL 1.1 installer. I have added that key to the list of search paths, # however, the key looks like it could be a little fragile depending on # if they decide to change the 1.00.0000 number for bug fix releases. # Also, they seem to have laid down groundwork for multiple library platforms # which puts the library in an extra subdirectory. Currently there is only # Win32 and I have hardcoded that here. This may need to be adjusted as # platforms are introduced. # The OpenAL 1.0 installer doesn't seem to have a useful key I can use. # I do not know if the Nvidia OpenAL SDK has a registry key. # # For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger). # To support the framework, I originally wrote special framework detection # code in this module which I have now removed with CMake's introduction # of native support for frameworks. # In addition, OpenAL is open source, and it is possible to compile on Panther. # Furthermore, due to bugs in the initial OpenAL release, and the # transition to OpenAL 1.1, it is common to need to override the built-in # framework. # Per my request, CMake should search for frameworks first in # the following order: # ~/Library/Frameworks/OpenAL.framework/Headers # /Library/Frameworks/OpenAL.framework/Headers # /System/Library/Frameworks/OpenAL.framework/Headers # # On OS X, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of # OPENAL_LIBRARY to override this selection or set the CMake environment # CMAKE_INCLUDE_PATH to modify the search paths. FIND_PATH(OPENAL_INCLUDE_DIR al.h PATHS $ENV{OPENALDIR} NO_DEFAULT_PATH PATH_SUFFIXES include/AL include/OpenAL include ) FIND_PATH(OPENAL_INCLUDE_DIR al.h PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw # Fink /opt/local # DarwinPorts /opt/csw # Blastwave /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] PATH_SUFFIXES include/AL include/OpenAL include ) FIND_LIBRARY(OPENAL_LIBRARY NAMES OpenAL al openal OpenAL32 PATHS $ENV{OPENALDIR} NO_DEFAULT_PATH PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 ) FIND_LIBRARY(OPENAL_LIBRARY NAMES OpenAL al openal OpenAL32 PATHS ~/Library/Frameworks /Library/Frameworks /usr/local /usr /sw /opt/local /opt/csw /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 ) SET(OPENAL_FOUND "NO") IF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR) SET(OPENAL_FOUND "YES") ENDIF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR) libfli-2.0+20221221182632/cmake_modules/FindFFTW3.cmake0000644000175100017510000000257314174600255020700 0ustar debiandebian# - Try to find FFTW3 # Once done this will define # # FFTW3_FOUND - system has FFTW3 # FFTW3_INCLUDE_DIR - the FFTW3 include directory # FFTW3_LIBRARIES - Link these to use FFTW3 # FFTW3_VERSION_STRING - Human readable version number of fftw3 # FFTW3_VERSION_MAJOR - Major version number of fftw3 # FFTW3_VERSION_MINOR - Minor version number of fftw3 # Copyright (c) 2017, Ilia Platone, # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FFTW3_LIBRARIES) # in cache already set(FFTW3_FOUND TRUE) message(STATUS "Found FFTW3: ${FFTW3_LIBRARIES}") else (FFTW3_LIBRARIES) find_library(FFTW3_LIBRARIES NAMES fftw3 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib ) if(FFTW3_LIBRARIES) set(FFTW3_FOUND TRUE) else (FFTW3_LIBRARIES) set(FFTW3_FOUND FALSE) endif(FFTW3_LIBRARIES) if (FFTW3_FOUND) if (NOT FFTW3_FIND_QUIETLY) message(STATUS "Found FFTW3: ${FFTW3_LIBRARIES}") endif (NOT FFTW3_FIND_QUIETLY) else (FFTW3_FOUND) if (FFTW3_FIND_REQUIRED) message(FATAL_ERROR "FFTW3 not found. Please install libfftw3-dev") endif (FFTW3_FIND_REQUIRED) endif (FFTW3_FOUND) mark_as_advanced(FFTW3_LIBRARIES) endif (FFTW3_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindSVBONY.cmake0000644000175100017510000000274014347562502021067 0ustar debiandebian# - Try to find SVBONY Library # Once done this will define # # SVBONY_FOUND - system has SVBONY CCD # SVBONY_INCLUDE_DIR - the SVBONY CCD include directory # SVBONY_LIBRARIES - Link these to use SVBONY CCD # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) # in cache already set(SVBONY_FOUND TRUE) message(STATUS "Found libsvbony: ${SVBONY_LIBRARIES}") else (SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) # find headers find_path(SVBONY_INCLUDE_DIR NAMES SVBCameraSDK.h PATH_SUFFIXES libsvbony ${_obIncDir} ${GNUWIN32_DIR}/include ) # find libraries find_library(SVBONY_LIBRARIES NAMES SVBCameraSDK PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) set(SVBONY_FOUND TRUE) else (SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) set(SVBONY_FOUND FALSE) endif(SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) if (SVBONY_FOUND) if (NOT SVBONY_FIND_QUIETLY) message(STATUS "Found SVBONY libraries : ${SVBONY_LIBRARIES}") endif (NOT SVBONY_FIND_QUIETLY) else (SVBONY_FOUND) if (SVBONY_FIND_REQUIRED) message(FATAL_ERROR "SVBONY libraries not found. Please install libsvbony http://www.indilib.org") endif (SVBONY_FIND_REQUIRED) endif (SVBONY_FOUND) mark_as_advanced(SVBONY_INCLUDE_DIR SVBONY_LIBRARIES) endif (SVBONY_INCLUDE_DIR AND SVBONY_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindMALLINCAM.cmake0000644000175100017510000000301314174600255021332 0ustar debiandebian# - Try to find MALLINCAM Camera Library # Once done this will define # # MALLINCAM_FOUND - system has Levenhuk # MALLINCAM_INCLUDE_DIR - the Levenhuk include directory # MALLINCAM_LIBRARIES - Link these to use Levenhuk # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) # in cache already set(MALLINCAM_FOUND TRUE) message(STATUS "Found libnncam: ${MALLINCAM_LIBRARIES}") else (MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) find_path(MALLINCAM_INCLUDE_DIR mallincam.h PATH_SUFFIXES libmallincam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(MALLINCAM_LIBRARIES NAMES mallincam PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) set(MALLINCAM_FOUND TRUE) else (MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) set(MALLINCAM_FOUND FALSE) endif(MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) if (MALLINCAM_FOUND) if (NOT MALLINCAM_FIND_QUIETLY) message(STATUS "Found MALLINCAM: ${MALLINCAM_LIBRARIES}") endif (NOT MALLINCAM_FIND_QUIETLY) else (MALLINCAM_FOUND) if (MALLINCAM_FIND_REQUIRED) message(FATAL_ERROR "MALLINCAM not found. Please install MALLINCAM Library http://www.indilib.org") endif (MALLINCAM_FIND_REQUIRED) endif (MALLINCAM_FOUND) mark_as_advanced(MALLINCAM_INCLUDE_DIR MALLINCAM_LIBRARIES) endif (MALLINCAM_INCLUDE_DIR AND MALLINCAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindNova.cmake0000644000175100017510000000304614174600255020746 0ustar debiandebian# - Try to find NOVA # Once done this will define # # NOVA_FOUND - system has NOVA # NOVA_INCLUDE_DIR - the NOVA include directory # NOVA_LIBRARIES - Link these to use NOVA # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) # in cache already set(NOVA_FOUND TRUE) message(STATUS "Found libnova: ${NOVA_LIBRARIES}") else (NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) find_path(NOVA_INCLUDE_DIR libnova.h PATH_SUFFIXES libnova ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(NOVA_LIBRARIES NAMES nova libnova libnovad PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) set(CMAKE_REQUIRED_INCLUDES ${NOVA_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${NOVA_LIBRARIES}) if(NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) set(NOVA_FOUND TRUE) else (NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) set(NOVA_FOUND FALSE) endif(NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) if (NOVA_FOUND) if (NOT Nova_FIND_QUIETLY) message(STATUS "Found NOVA: ${NOVA_LIBRARIES}") endif (NOT Nova_FIND_QUIETLY) else (NOVA_FOUND) if (Nova_FIND_REQUIRED) message(FATAL_ERROR "libnova not found. Please install libnova development package.") endif (Nova_FIND_REQUIRED) endif (NOVA_FOUND) mark_as_advanced(NOVA_INCLUDE_DIR NOVA_LIBRARIES) endif (NOVA_INCLUDE_DIR AND NOVA_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindVorbis.cmake0000644000175100017510000000204414174600255021304 0ustar debiandebian# - Find vorbis # Find the native vorbis includes and libraries # # VORBIS_INCLUDE_DIR - where to find vorbis.h, etc. # VORBIS_LIBRARIES - List of libraries when using vorbis(file). # VORBIS_FOUND - True if vorbis found. if(VORBIS_INCLUDE_DIR) # Already in cache, be silent set(VORBIS_FIND_QUIETLY TRUE) endif(VORBIS_INCLUDE_DIR) find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) find_library(OGG_LIBRARY NAMES ogg) find_library(VORBIS_LIBRARY NAMES vorbis) find_library(VORBISFILE_LIBRARY NAMES vorbisfile) # Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND to TRUE if # all listed variables are TRUE. include(FindPackageHandleStandardArgs) find_package_handle_standard_args(VORBIS DEFAULT_MSG VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBIS_LIBRARY) if(VORBIS_FOUND) set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) else(VORBIS_FOUND) set(VORBIS_LIBRARIES) endif(VORBIS_FOUND) mark_as_advanced(VORBIS_INCLUDE_DIR) mark_as_advanced(OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) libfli-2.0+20221221182632/cmake_modules/FindJPEG.cmake0000644000175100017510000000166314174600255020573 0ustar debiandebian# - Find JPEG # Find the native JPEG includes and library # This module defines # JPEG_INCLUDE_DIR, where to find jpeglib.h, etc. # JPEG_LIBRARIES, the libraries needed to use JPEG. # JPEG_FOUND, If false, do not try to use JPEG. # also defined, but not for general use are # JPEG_LIBRARY, where to find the JPEG library. FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h) SET(JPEG_NAMES ${JPEG_NAMES} jpeg) FIND_LIBRARY(JPEG_LIBRARY NAMES ${JPEG_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR) IF(JPEG_FOUND) SET(JPEG_LIBRARIES ${JPEG_LIBRARY}) ENDIF(JPEG_FOUND) # Deprecated declarations. SET (NATIVE_JPEG_INCLUDE_PATH ${JPEG_INCLUDE_DIR} ) GET_FILENAME_COMPONENT (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH) MARK_AS_ADVANCED(JPEG_LIBRARY JPEG_INCLUDE_DIR ) libfli-2.0+20221221182632/cmake_modules/FindCFITSIO.cmake0000644000175100017510000000434614174600255021147 0ustar debiandebian# - Try to find CFITSIO # Once done this will define # # CFITSIO_FOUND - system has CFITSIO # CFITSIO_INCLUDE_DIR - the CFITSIO include directory # CFITSIO_LIBRARIES - Link these to use CFITSIO # CFITSIO_VERSION_STRING - Human readable version number of cfitsio # CFITSIO_VERSION_MAJOR - Major version number of cfitsio # CFITSIO_VERSION_MINOR - Minor version number of cfitsio # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) # in cache already set(CFITSIO_FOUND TRUE) message(STATUS "Found CFITSIO: ${CFITSIO_LIBRARIES}") else (CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) # JM: Packages from different distributions have different suffixes find_path(CFITSIO_INCLUDE_DIR fitsio.h PATH_SUFFIXES libcfitsio3 libcfitsio0 cfitsio ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(CFITSIO_LIBRARIES NAMES cfitsio PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) set(CFITSIO_FOUND TRUE) else (CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) set(CFITSIO_FOUND FALSE) endif(CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) if (CFITSIO_FOUND) # Find the version of the cfitsio header file(STRINGS ${CFITSIO_INCLUDE_DIR}/fitsio.h CFITSIO_VERSION_STRING LIMIT_COUNT 1 REGEX "CFITSIO_VERSION") STRING(REGEX REPLACE "[^0-9.]" "" CFITSIO_VERSION_STRING ${CFITSIO_VERSION_STRING}) STRING(REGEX REPLACE "^([0-9]+)[.]([0-9]+)" "\\1" CFITSIO_VERSION_MAJOR ${CFITSIO_VERSION_STRING}) STRING(REGEX REPLACE "^([0-9]+)[.]([0-9]+)" "\\2" CFITSIO_VERSION_MINOR ${CFITSIO_VERSION_STRING}) if (NOT CFITSIO_FIND_QUIETLY) message(STATUS "Found CFITSIO ${CFITSIO_VERSION_STRING}: ${CFITSIO_LIBRARIES}") endif (NOT CFITSIO_FIND_QUIETLY) else (CFITSIO_FOUND) if (CFITSIO_FIND_REQUIRED) message(STATUS "CFITSIO not found.") endif (CFITSIO_FIND_REQUIRED) endif (CFITSIO_FOUND) mark_as_advanced(CFITSIO_INCLUDE_DIR CFITSIO_LIBRARIES) endif (CFITSIO_INCLUDE_DIR AND CFITSIO_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindUSB1.cmake0000644000175100017510000000562314174600255020560 0ustar debiandebian# - Try to find libusb-1.0 # Once done this will define # # USB1_FOUND - system has libusb-1.0 # USB1_INCLUDE_DIRS - the libusb-1.0 include directories # USB1_LIBRARIES - Link these to use libusb-1.0 # USB1_DEFINITIONS - Compiler switches required for using libusb-1.0 # # USB1_HAS_LIBUSB_ERROR_NAME - defined when libusb-1.0 has libusb_error_name() #============================================================================= # Copyright (c) 2017 Pino Toscano # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= find_package(PkgConfig) pkg_check_modules(PC_LIBUSB1 QUIET libusb-1.0) find_path(USB1_INCLUDE_DIR NAMES libusb.h HINTS ${PC_LIBUSB1_INCLUDE_DIRS} PATH_SUFFIXES libusb-1.0 ) find_library(USB1_LIBRARY NAMES ${PC_LIBUSB1_LIBRARIES} usb-1.0 HINTS ${PC_LIBUSB1_LIBRARY_DIRS} ) set(USB1_INCLUDE_DIRS ${USB1_INCLUDE_DIR}) set(USB1_LIBRARIES ${USB1_LIBRARY}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(USB1 FOUND_VAR USB1_FOUND REQUIRED_VARS USB1_LIBRARY USB1_INCLUDE_DIR VERSION_VAR PC_LIBUSB1_VERSION ) mark_as_advanced(USB1_INCLUDE_DIRS USB1_LIBRARIES) if(USB1_FOUND) include(CheckCXXSourceCompiles) include(CMakePushCheckState) cmake_push_check_state(RESET) set(CMAKE_REQUIRED_INCLUDES ${USB1_INCLUDE_DIRS}) set(CMAKE_REQUIRED_LIBRARIES ${USB1_LIBRARIES}) check_cxx_source_compiles("#include int main() { libusb_error_name(0); return 0; }" USB1_HAS_LIBUSB_ERROR_NAME) cmake_pop_check_state() endif() libfli-2.0+20221221182632/cmake_modules/FindGMock.cmake0000644000175100017510000001162314174600255021043 0ustar debiandebian#.rst: # FindGMock # --------- # # Locate the Google C++ Mocking Framework. # # Defines the following variables: # # :: # # GMOCK_FOUND - Found the Google Mocking framework # GMOCK_INCLUDE_DIRS - Include directories # # # # Also defines the library variables below as normal variables. These # contain debug/optimized keywords when a debugging library is found. # # :: # # GMOCK_LIBRARIES - libgmock # # # # Accepts the following variables as input: # # :: # # GMOCK_ROOT - (as a CMake or environment variable) # The root directory of the gmock install prefix # # # # :: # # GMOCK_MSVC_SEARCH - If compiling with MSVC, this variable can be set to # "MD" or "MT" to enable searching a GMock build tree # (defaults: "MD") # # # # Example Usage: # # :: # # find_package(GMock REQUIRED) # include_directories(${GMOCK_INCLUDE_DIRS}) # # # # :: # # add_executable(foo foo.cc) # target_link_libraries(foo ${GMOCK_LIBRARIES}) # # # # :: # # add_test(AllMocksInFoo foo) # # # # # # If you would like each Google test to show up in CMock as a test you # may use the following macro. NOTE: It will slow down your tests by # running an executable for each test and test fixture. You will also # have to rerun CMake after adding or removing tests or test fixtures. # # GMOCK_ADD_MOCKS(executable extra_args ARGN) # # :: # # executable = The path to the test executable # extra_args = Pass a list of extra arguments to be passed to # executable enclosed in quotes (or "" for none) # ARGN = A list of source files to search for tests & test # fixtures. # # # # :: # # Example: # set(FooMockArgs --foo 1 --bar 2) # add_executable(FooMock FooUnitMock.cc) # GMOCK_ADD_MOCKS(FooMock "${FooMockArgs}" FooUnitMock.cc) #============================================================================= # Copyright 2009 Kitware, Inc. # Copyright 2009 Philip Lowman # Copyright 2009 Daniel Blezek # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # # Thanks to Daniel Blezek for the GMOCK_ADD_MOCKS code function(GMOCK_ADD_MOCKS executable extra_args) if(NOT ARGN) message(FATAL_ERROR "Missing ARGN: Read the documentation for GMOCK_ADD_MOCKS") endif() foreach(source ${ARGN}) file(READ "${source}" contents) string(REGEX MATCHALL "MOCK_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) foreach(hit ${found_tests}) string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit}) add_test(${test_name} ${executable} --gmock_filter=${test_name} ${extra_args}) endforeach() endforeach() endfunction() function(_gmock_append_debugs _endvar _library) if(${_library} AND ${_library}_DEBUG) set(_output optimized ${${_library}} debug ${${_library}_DEBUG}) else() set(_output ${${_library}}) endif() set(${_endvar} ${_output} PARENT_SCOPE) endfunction() function(_gmock_find_library _name) find_library(${_name} NAMES ${ARGN} HINTS ENV GMOCK_ROOT ${GMOCK_ROOT} PATH_SUFFIXES ${_gmock_libpath_suffixes} ) mark_as_advanced(${_name}) endfunction() # if(NOT DEFINED GMOCK_MSVC_SEARCH) set(GMOCK_MSVC_SEARCH MD) endif() set(_gmock_libpath_suffixes lib) if(MSVC) if(GMOCK_MSVC_SEARCH STREQUAL "MD") list(APPEND _gmock_libpath_suffixes msvc/gmock-md/Debug msvc/gmock-md/Release) elseif(GMOCK_MSVC_SEARCH STREQUAL "MT") list(APPEND _gmock_libpath_suffixes msvc/gmock/Debug msvc/gmock/Release) endif() endif() find_path(GMOCK_INCLUDE_DIR gmock/gmock.h HINTS $ENV{GMOCK_ROOT}/include ${GMOCK_ROOT}/include ) mark_as_advanced(GMOCK_INCLUDE_DIR) if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD") # The provided /MD project files for Google Mock add -md suffixes to the # library names. _gmock_find_library(GMOCK_LIBRARY gmock-md gmock) _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd) else() _gmock_find_library(GMOCK_LIBRARY gmock) _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd) endif() FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMock DEFAULT_MSG GMOCK_LIBRARY GMOCK_INCLUDE_DIR) if(GMOCK_FOUND) set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIR}) _gmock_append_debugs(GMOCK_LIBRARIES GMOCK_LIBRARY) endif() libfli-2.0+20221221182632/cmake_modules/FindPackageMessage.cmake0000644000175100017510000000375514174600255022712 0ustar debiandebian#.rst: # FindPackageMessage # ------------------ # # # # FIND_PACKAGE_MESSAGE( "message for user" "find result details") # # This macro is intended to be used in FindXXX.cmake modules files. It # will print a message once for each unique find result. This is useful # for telling the user where a package was found. The first argument # specifies the name (XXX) of the package. The second argument # specifies the message to display. The third argument lists details # about the find result so that if they change the message will be # displayed again. The macro also obeys the QUIET argument to the # find_package command. # # Example: # # :: # # if(X11_FOUND) # FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" # "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") # else() # ... # endif() #============================================================================= # Copyright 2008-2009 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) function(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. if(NOT ${pkg}_FIND_QUIETLY) string(REPLACE "\n" "" details "${details}") set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. message(STATUS "${msg}") # Save the find details in the cache to avoid printing the same # message again. set("${DETAILS_VAR}" "${details}" CACHE INTERNAL "Details about finding ${pkg}") endif() endif() endfunction() libfli-2.0+20221221182632/cmake_modules/FindFTDI.cmake0000644000175100017510000000267114174600255020574 0ustar debiandebian# - Try to find FTDI # This finds libFTDI that is compatible with old libusb v 0.1 # For newer libusb > 1.0, use FindFTDI1.cmake # Once done this will define # # FTDI_FOUND - system has FTDI # FTDI_INCLUDE_DIR - the FTDI include directory # FTDI_LIBRARIES - Link these to use FTDI # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) # in cache already set(FTDI_FOUND TRUE) message(STATUS "Found libftdi: ${FTDI_LIBRARIES}") else (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) find_path(FTDI_INCLUDE_DIR ftdi.h PATH_SUFFIXES libftdi1 ${_obIncDir} ${GNUWIN32_DIR}/include /usr/local/include ) find_library(FTDI_LIBRARIES NAMES ftdi ftdi1 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib ) if(FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) set(FTDI_FOUND TRUE) else (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) set(FTDI_FOUND FALSE) endif(FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) if (FTDI_FOUND) if (NOT FTDI_FIND_QUIETLY) message(STATUS "Found FTDI: ${FTDI_LIBRARIES}") endif (NOT FTDI_FIND_QUIETLY) else (FTDI_FOUND) if (FTDI_FIND_REQUIRED) message(FATAL_ERROR "FTDI not found. Please install libftdi-dev") endif (FTDI_FIND_REQUIRED) endif (FTDI_FOUND) mark_as_advanced(FTDI_INCLUDE_DIR FTDI_LIBRARIES) endif (FTDI_INCLUDE_DIR AND FTDI_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindMODBUS.cmake0000644000175100017510000000320114174600255021025 0ustar debiandebian# - Try to find libmodbus # Once done this will define # # MODBUS_FOUND - system has MODBUS # MODBUS_INCLUDE_DIR - the MODBUS include directory # MODBUS_LIBRARIES - Link these to use MODBUS # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) # in cache already set(MODBUS_FOUND TRUE) message(STATUS "Found libmodbus: ${MODBUS_LIBRARIES}") else (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) find_path(MODBUS_INCLUDE_DIR modbus.h PATH_SUFFIXES modbus ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(MODBUS_LIBRARIES NAMES modbus PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) set(CMAKE_REQUIRED_INCLUDES ${MODBUS_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${MODBUS_LIBRARIES}) if(MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) set(MODBUS_FOUND TRUE) else (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) set(MODBUS_FOUND FALSE) endif(MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) if (MODBUS_FOUND) if (NOT MODBUS_FIND_QUIETLY) message(STATUS "Found libmodbus: ${MODBUS_LIBRARIES}") endif (NOT MODBUS_FIND_QUIETLY) else (MODBUS_FOUND) if (MODBUS_FIND_REQUIRED) message(FATAL_ERROR "libmodbus not found. Please install libmodbus-devel. https://launchpad.net/libmodbus/") endif (MODBUS_FIND_REQUIRED) endif (MODBUS_FOUND) mark_as_advanced(MODBUS_INCLUDE_DIR MODBUS_LIBRARIES) endif (MODBUS_INCLUDE_DIR AND MODBUS_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindSTARSHOOTG.cmake0000644000175100017510000000307014174600255021535 0ustar debiandebian# - Try to find Starshoot Camera Library # Once done this will define # # STARSHOOTG_FOUND - system has Starshoot # STARSHOOTG_INCLUDE_DIR - the Starshoot include directory # STARSHOOTG_LIBRARIES - Link these to use Starshoot # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) # in cache already set(STARSHOOTG_FOUND TRUE) message(STATUS "Found libstarshootg: ${STARSHOOTG_LIBRARIES}") else (STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) find_path(STARSHOOTG_INCLUDE_DIR starshootg.h PATH_SUFFIXES libstarshootg ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(STARSHOOTG_LIBRARIES NAMES starshootg PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) set(STARSHOOTG_FOUND TRUE) else (STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) set(STARSHOOTG_FOUND FALSE) endif(STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) if (STARSHOOTG_FOUND) if (NOT STARSHOOTG_FIND_QUIETLY) message(STATUS "Found StarshootG: ${STARSHOOTG_LIBRARIES}") endif (NOT STARSHOOTG_FIND_QUIETLY) else (STARSHOOTG_FOUND) if (STARSHOOTG_FIND_REQUIRED) message(FATAL_ERROR "StarshootG not found. Please install StarshootG Library http://www.indilib.org") endif (STARSHOOTG_FIND_REQUIRED) endif (STARSHOOTG_FOUND) mark_as_advanced(STARSHOOTG_INCLUDE_DIR STARSHOOTG_LIBRARIES) endif (STARSHOOTG_INCLUDE_DIR AND STARSHOOTG_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/InstallImported.cmake0000644000175100017510000000661114174600255022355 0ustar debiandebian function (install_imported) cmake_parse_arguments (ARG "" "DESTINATION" "TARGETS" ${ARGN}) if (NOT DEFINED ARG_DESTINATION) message (FATAL_ERROR "DESTINATION not defined") endif () foreach (target ${ARG_TARGETS}) get_target_property (location ${target} LOCATION) get_target_property (version ${target} VERSION) get_target_property (soversion ${target} SOVERSION) get_target_property (output_name ${target} OUTPUT_NAME) get_target_property (suffix ${target} SUFFIX) get_target_property (type ${target} TYPE) if (NOT ${type} STREQUAL "SHARED_LIBRARY") message (FATAL_ERROR "install_imported: ${type} not supported") endif () if (${location} STREQUAL "${target}-NOTFOUND") return () endif () if (NOT ${version} STREQUAL "version-NOTFOUND") set (version ".${version}") else () set (version "") endif () if (NOT ${soversion} STREQUAL "soversion-NOTFOUND") set (soversion ".${soversion}") else () set (soversion "") endif () if (${output_name} STREQUAL "output_name-NOTFOUND") set (output_name ${target}) endif () set (name_noversion "${CMAKE_SHARED_LIBRARY_PREFIX}${output_name}${CMAKE_SHARED_LIBRARY_SUFFIX}") if (APPLE) set (name_version "${CMAKE_SHARED_LIBRARY_PREFIX}${output_name}${version}${CMAKE_SHARED_LIBRARY_SUFFIX}") set (name_soversion "${CMAKE_SHARED_LIBRARY_PREFIX}${output_name}${soversion}${CMAKE_SHARED_LIBRARY_SUFFIX}") else () set (name_version "${CMAKE_SHARED_LIBRARY_PREFIX}${output_name}${CMAKE_SHARED_LIBRARY_SUFFIX}${version}") set (name_soversion "${CMAKE_SHARED_LIBRARY_PREFIX}${output_name}${CMAKE_SHARED_LIBRARY_SUFFIX}${soversion}") endif () if (NOT IS_ABSOLUTE ${location}) set (location ${CMAKE_CURRENT_SOURCE_DIR}/${location}) endif () if (NOT ${name_noversion} STREQUAL ${name_soversion}) add_custom_command ( OUTPUT ${name_noversion} COMMAND ${CMAKE_COMMAND} -E create_symlink ${name_soversion} ${name_noversion} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} MAIN_DEPENDENCY ${name_soversion} ) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${name_noversion} DESTINATION ${ARG_DESTINATION}) endif () if (NOT ${name_soversion} STREQUAL ${name_version}) add_custom_command ( OUTPUT ${name_soversion} COMMAND ${CMAKE_COMMAND} -E create_symlink ${name_version} ${name_soversion} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} MAIN_DEPENDENCY ${name_version} ) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${name_soversion} DESTINATION ${ARG_DESTINATION}) endif () add_custom_command ( OUTPUT ${name_version} COMMAND ${CMAKE_COMMAND} -E copy "${location}" "${CMAKE_CURRENT_BINARY_DIR}/${name_version}" MAIN_DEPENDENCY ${location} ) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${name_version} DESTINATION ${ARG_DESTINATION}) add_custom_target( imported_${output_name} ALL DEPENDS ${name_version} ${name_noversion} ${name_soversion} ) endforeach () endfunction () libfli-2.0+20221221182632/cmake_modules/FindAHPXC.cmake0000644000175100017510000000273214174600255020707 0ustar debiandebian# - Try to find AHPXC Universal Library # Once done this will define # # AHPXC_FOUND - system has AHPXC # AHPXC_INCLUDE_DIR - the AHPXC include directory # AHPXC_LIBRARIES - Link these to use AHPXC # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) # in cache already set(AHPXC_FOUND TRUE) message(STATUS "Found libahp_xc: ${AHPXC_LIBRARIES}") else (AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) find_path(AHPXC_INCLUDE_DIR ahp_xc.h PATH_SUFFIXES ahp ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(AHPXC_LIBRARIES NAMES ahp_xc PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) set(AHPXC_FOUND TRUE) else (AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) set(AHPXC_FOUND FALSE) endif(AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) if (AHPXC_FOUND) if (NOT AHPXC_FIND_QUIETLY) message(STATUS "Found AHP XC: ${AHPXC_LIBRARIES}") endif (NOT AHPXC_FIND_QUIETLY) else (AHPXC_FOUND) if (AHPXC_FIND_REQUIRED) message(FATAL_ERROR "AHP XC not found. Please install libahp_xc http://www.indilib.org") endif (AHPXC_FIND_REQUIRED) endif (AHPXC_FOUND) mark_as_advanced(AHPXC_INCLUDE_DIR AHPXC_LIBRARIES) endif (AHPXC_INCLUDE_DIR AND AHPXC_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindFLI.cmake0000644000175100017510000000264514174600255020461 0ustar debiandebian# - Try to find Finger Lakes Instruments Library # Once done this will define # # FLI_FOUND - system has FLI # FLI_INCLUDE_DIR - the FLI include directory # FLI_LIBRARIES - Link these to use FLI # Copyright (c) 2008, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FLI_INCLUDE_DIR AND FLI_LIBRARIES) # in cache already set(FLI_FOUND TRUE) message(STATUS "Found libfli: ${FLI_LIBRARIES}") else (FLI_INCLUDE_DIR AND FLI_LIBRARIES) find_path(FLI_INCLUDE_DIR libfli.h PATH_SUFFIXES fli ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(FLI_LIBRARIES NAMES fli PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(FLI_INCLUDE_DIR AND FLI_LIBRARIES) set(FLI_FOUND TRUE) else (FLI_INCLUDE_DIR AND FLI_LIBRARIES) set(FLI_FOUND FALSE) endif(FLI_INCLUDE_DIR AND FLI_LIBRARIES) if (FLI_FOUND) if (NOT FLI_FIND_QUIETLY) message(STATUS "Found FLI: ${FLI_LIBRARIES}") endif (NOT FLI_FIND_QUIETLY) else (FLI_FOUND) if (FLI_FIND_REQUIRED) message(FATAL_ERROR "FLI not found. Please install libfli-dev. http://www.indilib.org") endif (FLI_FIND_REQUIRED) endif (FLI_FOUND) mark_as_advanced(FLI_INCLUDE_DIR FLI_LIBRARIES) endif (FLI_INCLUDE_DIR AND FLI_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindASI.cmake0000644000175100017510000000356514174600255020465 0ustar debiandebian# - Try to find ASI Library # Once done this will define # # ASI_FOUND - system has ASI # ASI_INCLUDE_DIR - the ASI include directory # ASI_LIBRARIES - Link these to use ASI # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (ASI_INCLUDE_DIR AND ASI_LIBRARIES) # in cache already set(ASI_FOUND TRUE) message(STATUS "Found libasi: ${ASI_LIBRARIES}") else (ASI_INCLUDE_DIR AND ASI_LIBRARIES) find_path(ASI_INCLUDE_DIR ASICamera2.h PATH_SUFFIXES libasi ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(ASICAM_LIBRARIES NAMES ASICamera2 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(ASIEFW_LIBRARIES NAMES EFWFilter PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(ASIST4_LIBRARIES NAMES USB2ST4Conv PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(ASIEAF_LIBRARIES NAMES EAFFocuser PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if (ASICAM_LIBRARIES AND ASIEFW_LIBRARIES AND ASIST4_LIBRARIES AND ASIEAF_LIBRARIES) set(ASI_LIBRARIES ${ASICAM_LIBRARIES} ${ASIEFW_LIBRARIES} ${ASIST4_LIBRARIES} ${ASIEAF_LIBRARIES}) endif (ASICAM_LIBRARIES AND ASIEFW_LIBRARIES AND ASIST4_LIBRARIES AND ASIEAF_LIBRARIES) if(ASI_INCLUDE_DIR AND ASI_LIBRARIES) set(ASI_FOUND TRUE) else (ASI_INCLUDE_DIR AND ASI_LIBRARIES) set(ASI_FOUND FALSE) endif(ASI_INCLUDE_DIR AND ASI_LIBRARIES) if (ASI_FOUND) if (NOT ASI_FIND_QUIETLY) message(STATUS "Found ASI: ${ASI_LIBRARIES}") endif (NOT ASI_FIND_QUIETLY) else (ASI_FOUND) if (ASI_FIND_REQUIRED) message(FATAL_ERROR "ASI not found. Please install libasi http://www.indilib.org") endif (ASI_FIND_REQUIRED) endif (ASI_FOUND) mark_as_advanced(ASI_INCLUDE_DIR ASI_LIBRARIES) endif (ASI_INCLUDE_DIR AND ASI_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindINDI.cmake0000644000175100017510000003457414174600255020600 0ustar debiandebian# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # This module can find INDI Library # # Requirements: # - CMake >= 2.8.3 (for new version of find_package_handle_standard_args) # # The following variables will be defined for your use: # - INDI_FOUND : were all of your specified components found (include dependencies)? # - INDI_WEBSOCKET : was INDI compiled with websocket support? # - INDI_INCLUDE_DIR : INDI include directory # - INDI_DATA_DIR : INDI include directory # - INDI_LIBRARIES : INDI libraries # - INDI_DRIVER_LIBRARIES : Same as above maintained for backward compatibility # - INDI_VERSION : complete version of INDI (x.y.z) # - INDI_MAJOR_VERSION : major version of INDI # - INDI_MINOR_VERSION : minor version of INDI # - INDI_RELEASE_VERSION : release version of INDI # - INDI__FOUND : were found? (FALSE for non specified component if it is not a dependency) # # For windows or non standard installation, define INDI_ROOT variable to point to the root installation of INDI. Two ways: # - run cmake with -DINDI_ROOT= # - define an environment variable with the same name before running cmake # With cmake-gui, before pressing "Configure": # 1) Press "Add Entry" button # 2) Add a new entry defined as: # - Name: INDI_ROOT # - Type: choose PATH in the selection list # - Press "..." button and select the root installation of INDI # # Example Usage: # # 1. Copy this file in the root of your project source directory # 2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt: # set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) # 3. Finally call find_package() once, here are some examples to pick from # # Require INDI 1.4 or later # find_package(INDI 1.4 REQUIRED) # # if(INDI_FOUND) # include_directories(${INDI_INCLUDE_DIR}) # add_executable(myapp myapp.cpp) # target_link_libraries(myapp ${INDI_LIBRARIES}) # endif(INDI_FOUND) # # # Using Components: # # You can search for specific components. Currently, the following components are available # * driver: to build INDI hardware drivers. # * align: to build drivers that use INDI Alignment Subsystem. # * client: to build pure C++ INDI clients. # * clientqt5: to build Qt5-based INDI clients. # * lx200: To build LX200-based 3rd party drivers (you must link with driver above as well). # # By default, if you do not specify any components, driver and align components are searched. # # Example: # # To use INDI Qt5 Client library only in your application: # # find_package(INDI COMPONENTS clientqt5 REQUIRED) # # if(INDI_FOUND) # include_directories(${INDI_INCLUDE_DIR}) # add_executable(myapp myapp.cpp) # target_link_libraries(myapp ${INDI_LIBRARIES}) # endif(INDI_FOUND) # # To use INDI driver + lx200 component in your application: # # find_package(INDI COMPONENTS driver lx200 REQUIRED) # # if(INDI_FOUND) # include_directories(${INDI_INCLUDE_DIR}) # add_executable(myapp myapp.cpp) # target_link_libraries(myapp ${INDI_LIBRARIES}) # endif(INDI_FOUND) # # Notice we still use ${INDI_LIBRARIES} which now should contain both driver & lx200 libraries. #============================================================================================== # Copyright (c) 2011-2013, julp # Copyright (c) 2017-2019 Jasem Mutlaq # # Distributed under the OSI-approved BSD License # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTINDILAR PURPOSE. #============================================================================= find_package(PkgConfig QUIET) ########## Private ########## if(NOT DEFINED INDI_PUBLIC_VAR_NS) set(INDI_PUBLIC_VAR_NS "INDI") # Prefix for all INDI relative public variables endif(NOT DEFINED INDI_PUBLIC_VAR_NS) if(NOT DEFINED INDI_PRIVATE_VAR_NS) set(INDI_PRIVATE_VAR_NS "_${INDI_PUBLIC_VAR_NS}") # Prefix for all INDI relative internal variables endif(NOT DEFINED INDI_PRIVATE_VAR_NS) if(NOT DEFINED PC_INDI_PRIVATE_VAR_NS) set(PC_INDI_PRIVATE_VAR_NS "_PC${INDI_PRIVATE_VAR_NS}") # Prefix for all pkg-config relative internal variables endif(NOT DEFINED PC_INDI_PRIVATE_VAR_NS) function(indidebug _VARNAME) if(${INDI_PUBLIC_VAR_NS}_DEBUG) if(DEFINED ${INDI_PUBLIC_VAR_NS}_${_VARNAME}) message("${INDI_PUBLIC_VAR_NS}_${_VARNAME} = ${${INDI_PUBLIC_VAR_NS}_${_VARNAME}}") else(DEFINED ${INDI_PUBLIC_VAR_NS}_${_VARNAME}) message("${INDI_PUBLIC_VAR_NS}_${_VARNAME} = ") endif(DEFINED ${INDI_PUBLIC_VAR_NS}_${_VARNAME}) endif(${INDI_PUBLIC_VAR_NS}_DEBUG) endfunction(indidebug) set(${INDI_PRIVATE_VAR_NS}_ROOT "") if(DEFINED ENV{INDI_ROOT}) set(${INDI_PRIVATE_VAR_NS}_ROOT "$ENV{INDI_ROOT}") endif(DEFINED ENV{INDI_ROOT}) if (DEFINED INDI_ROOT) set(${INDI_PRIVATE_VAR_NS}_ROOT "${INDI_ROOT}") endif(DEFINED INDI_ROOT) set(${INDI_PRIVATE_VAR_NS}_BIN_SUFFIXES ) set(${INDI_PRIVATE_VAR_NS}_LIB_SUFFIXES ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND ${INDI_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin64") list(APPEND ${INDI_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib64") endif(CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND ${INDI_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin") list(APPEND ${INDI_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib") set(${INDI_PRIVATE_VAR_NS}_COMPONENTS ) # ... macro(INDI_declare_component _NAME) list(APPEND ${INDI_PRIVATE_VAR_NS}_COMPONENTS ${_NAME}) set("${INDI_PRIVATE_VAR_NS}_COMPONENTS_${_NAME}" ${ARGN}) endmacro(INDI_declare_component) INDI_declare_component(driver indidriver) INDI_declare_component(align indiAlignmentDriver) INDI_declare_component(client indiclient) INDI_declare_component(clientqt5 indiclientqt5) INDI_declare_component(lx200 indilx200) ########## Public ########## set(${INDI_PUBLIC_VAR_NS}_FOUND TRUE) set(${INDI_PUBLIC_VAR_NS}_LIBRARIES ) set(${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR ) foreach(${INDI_PRIVATE_VAR_NS}_COMPONENT ${${INDI_PRIVATE_VAR_NS}_COMPONENTS}) string(TOUPPER "${${INDI_PRIVATE_VAR_NS}_COMPONENT}" ${INDI_PRIVATE_VAR_NS}_UPPER_COMPONENT) set("${INDI_PUBLIC_VAR_NS}_${${INDI_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) # may be done in the INDI_declare_component macro endforeach(${INDI_PRIVATE_VAR_NS}_COMPONENT) # Check components if(NOT ${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS) # driver and posix client by default set(${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS driver align) else(NOT ${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS) #list(APPEND ${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS uc) list(REMOVE_DUPLICATES ${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS) foreach(${INDI_PRIVATE_VAR_NS}_COMPONENT ${${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS}) if(NOT DEFINED ${INDI_PRIVATE_VAR_NS}_COMPONENTS_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) message(FATAL_ERROR "Unknown INDI component: ${${INDI_PRIVATE_VAR_NS}_COMPONENT}") endif(NOT DEFINED ${INDI_PRIVATE_VAR_NS}_COMPONENTS_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) endforeach(${INDI_PRIVATE_VAR_NS}_COMPONENT) endif(NOT ${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS) # Includes find_path( ${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR indidevapi.h PATH_SUFFIXES libindi include/libindi ${PC_INDI_INCLUDE_DIR} ${_obIncDir} ${GNUWIN32_DIR}/include HINTS ${${INDI_PRIVATE_VAR_NS}_ROOT} DOC "Include directory for INDI" ) find_path( WEBSOCKET_HEADER indiwsserver.h PATH_SUFFIXES libindi ${PC_INDI_INCLUDE_DIR} ${_obIncDir} ${GNUWIN32_DIR}/include ) if (WEBSOCKET_HEADER) SET(INDI_WEBSOCKET TRUE) else() SET(INDI_WEBSOCKET FALSE) endif() find_path(${INDI_PUBLIC_VAR_NS}_DATA_DIR drivers.xml PATH_SUFFIXES share/indi DOC "Data directory for INDI" ) if(${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR) if(EXISTS "${${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR}/indiversion.h") # INDI >= 1.4 file(READ "${${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR}/indiversion.h" ${INDI_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS) else() message(FATAL_ERROR "INDI version header not found") endif() if(${INDI_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*INDI_VERSION ([0-9]+).([0-9]+).([0-9]+)") set(${INDI_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}") set(${INDI_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}") set(${INDI_PUBLIC_VAR_NS}_RELEASE_VERSION "${CMAKE_MATCH_3}") else() message(FATAL_ERROR "failed to detect INDI version") endif() set(${INDI_PUBLIC_VAR_NS}_VERSION "${${INDI_PUBLIC_VAR_NS}_MAJOR_VERSION}.${${INDI_PUBLIC_VAR_NS}_MINOR_VERSION}.${${INDI_PUBLIC_VAR_NS}_RELEASE_VERSION}") # Check libraries foreach(${INDI_PRIVATE_VAR_NS}_COMPONENT ${${INDI_PUBLIC_VAR_NS}_FIND_COMPONENTS}) set(${INDI_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES ) set(${INDI_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES ) foreach(${INDI_PRIVATE_VAR_NS}_BASE_NAME ${${INDI_PRIVATE_VAR_NS}_COMPONENTS_${${INDI_PRIVATE_VAR_NS}_COMPONENT}}) list(APPEND ${INDI_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${INDI_PRIVATE_VAR_NS}_BASE_NAME}") list(APPEND ${INDI_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${INDI_PRIVATE_VAR_NS}_BASE_NAME}d") list(APPEND ${INDI_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${INDI_PRIVATE_VAR_NS}_BASE_NAME}${INDI_MAJOR_VERSION}${INDI_MINOR_VERSION}") list(APPEND ${INDI_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${INDI_PRIVATE_VAR_NS}_BASE_NAME}${INDI_MAJOR_VERSION}${INDI_MINOR_VERSION}d") endforeach(${INDI_PRIVATE_VAR_NS}_BASE_NAME) find_library( ${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT} NAMES ${${INDI_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES} HINTS ${${INDI_PRIVATE_VAR_NS}_ROOT} PATH_SUFFIXES ${_INDI_LIB_SUFFIXES} DOC "Release libraries for INDI" ) find_library( ${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT} NAMES ${${INDI_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES} HINTS ${${INDI_PRIVATE_VAR_NS}_ROOT} PATH_SUFFIXES ${_INDI_LIB_SUFFIXES} DOC "Debug libraries for INDI" ) string(TOUPPER "${${INDI_PRIVATE_VAR_NS}_COMPONENT}" ${INDI_PRIVATE_VAR_NS}_UPPER_COMPONENT) if(NOT ${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) # both not found set("${INDI_PUBLIC_VAR_NS}_${${INDI_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) set("${INDI_PUBLIC_VAR_NS}_FOUND" FALSE) else(NOT ${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) # one or both found set("${INDI_PUBLIC_VAR_NS}_${${INDI_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" TRUE) if(NOT ${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) # release not found => we are in debug set(${INDI_PRIVATE_VAR_NS}_LIB_${${INDI_PRIVATE_VAR_NS}_COMPONENT} "${${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}}") elseif(NOT ${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) # debug not found => we are in release set(${INDI_PRIVATE_VAR_NS}_LIB_${${INDI_PRIVATE_VAR_NS}_COMPONENT} "${${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT}}") else() # both found set( ${INDI_PRIVATE_VAR_NS}_LIB_${${INDI_PRIVATE_VAR_NS}_COMPONENT} optimized ${${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT}} debug ${${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}} ) endif() list(APPEND ${INDI_PUBLIC_VAR_NS}_LIBRARIES ${${INDI_PRIVATE_VAR_NS}_LIB_${${INDI_PRIVATE_VAR_NS}_COMPONENT}}) endif(NOT ${INDI_PRIVATE_VAR_NS}_LIB_RELEASE_${${INDI_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${INDI_PRIVATE_VAR_NS}_LIB_DEBUG_${${INDI_PRIVATE_VAR_NS}_COMPONENT}) endforeach(${INDI_PRIVATE_VAR_NS}_COMPONENT) # Check find_package arguments include(FindPackageHandleStandardArgs) if(${INDI_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${INDI_PUBLIC_VAR_NS}_FIND_QUIETLY) find_package_handle_standard_args( ${INDI_PUBLIC_VAR_NS} REQUIRED_VARS ${INDI_PUBLIC_VAR_NS}_LIBRARIES ${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR VERSION_VAR ${INDI_PUBLIC_VAR_NS}_VERSION ) else(${INDI_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${INDI_PUBLIC_VAR_NS}_FIND_QUIETLY) find_package_handle_standard_args(${INDI_PUBLIC_VAR_NS} "INDI not found" ${INDI_PUBLIC_VAR_NS}_LIBRARIES ${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR) endif(${INDI_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${INDI_PUBLIC_VAR_NS}_FIND_QUIETLY) else(${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR) set("${INDI_PUBLIC_VAR_NS}_FOUND" FALSE) if(${INDI_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${INDI_PUBLIC_VAR_NS}_FIND_QUIETLY) message(FATAL_ERROR "Could not find INDI include directory") endif(${INDI_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${INDI_PUBLIC_VAR_NS}_FIND_QUIETLY) endif(${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR) mark_as_advanced( ${INDI_PUBLIC_VAR_NS}_INCLUDE_DIR ${INDI_PUBLIC_VAR_NS}_LIBRARIES INDI_WEBSOCKET ) # IN (args) indidebug("FIND_COMPONENTS") indidebug("FIND_REQUIRED") indidebug("FIND_QUIETLY") indidebug("FIND_VERSION") # OUT # Found indidebug("FOUND") indidebug("SERVER_FOUND") indidebug("DRIVERS_FOUND") indidebug("CLIENT_FOUND") indidebug("QT5CLIENT_FOUND") indidebug("LX200_FOUND") # Linking indidebug("INCLUDE_DIR") indidebug("DATA_DIR") indidebug("LIBRARIES") # Backward compatibility set(${INDI_PUBLIC_VAR_NS}_DRIVER_LIBRARIES ${${INDI_PUBLIC_VAR_NS}_LIBRARIES}) indidebug("DRIVER_LIBRARIES") # Version indidebug("MAJOR_VERSION") indidebug("MINOR_VERSION") indidebug("RELEASE_VERSION") indidebug("VERSION") libfli-2.0+20221221182632/cmake_modules/CMakeCommon.cmake0000644000175100017510000001366714174600255021405 0ustar debiandebian include(CheckCCompilerFlag) #IF (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #ENDIF () # C++14 Support if (NOT ANDROID) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif(NOT ANDROID) # Position Independent Code set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Ccache support IF (ANDROID OR UNIX OR APPLE) FIND_PROGRAM(CCACHE_FOUND ccache) SET(CCACHE_SUPPORT OFF CACHE BOOL "Enable ccache support") IF ((CCACHE_FOUND OR ANDROID) AND CCACHE_SUPPORT MATCHES ON) SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) ENDIF () ENDIF () # Add security (hardening flags) IF (UNIX OR APPLE OR ANDROID) # Older compilers are predefining _FORTIFY_SOURCE, so defining it causes a # warning, which is then considered an error. Second issue is that for # these compilers, _FORTIFY_SOURCE must be used while optimizing, else # causes a warning, which also results in an error. And finally, CMake is # not using optimization when testing for libraries, hence breaking the build. CHECK_C_COMPILER_FLAG("-Werror -D_FORTIFY_SOURCE=2" COMPATIBLE_FORTIFY_SOURCE) IF (${COMPATIBLE_FORTIFY_SOURCE}) SET(SEC_COMP_FLAGS "-D_FORTIFY_SOURCE=2") ENDIF () SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -fstack-protector-all -fPIE") # Make sure to add optimization flag. Some systems require this for _FORTIFY_SOURCE. IF (NOT CMAKE_BUILD_TYPE MATCHES "MinSizeRel" AND NOT CMAKE_BUILD_TYPE MATCHES "Release" AND NOT CMAKE_BUILD_TYPE MATCHES "Debug") SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -O1") ENDIF () IF (NOT ANDROID AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND NOT APPLE AND NOT CYGWIN) SET(SEC_COMP_FLAGS "${SEC_COMP_FLAGS} -Wa,--noexecstack") ENDIF () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SEC_COMP_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SEC_COMP_FLAGS}") SET(SEC_LINK_FLAGS "") IF (NOT APPLE AND NOT CYGWIN) SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} -Wl,-z,nodump -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") ENDIF () IF (NOT ANDROID AND NOT APPLE) SET(SEC_LINK_FLAGS "${SEC_LINK_FLAGS} -pie") ENDIF () SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SEC_LINK_FLAGS}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SEC_LINK_FLAGS}") ENDIF () # Warning, debug and linker flags SET(FIX_WARNINGS OFF CACHE BOOL "Enable strict compilation mode to turn compiler warnings to errors") IF (UNIX OR APPLE) SET(COMP_FLAGS "") SET(LINKER_FLAGS "") # Verbose warnings and turns all to errors SET(COMP_FLAGS "${COMP_FLAGS} -Wall -Wextra") IF (FIX_WARNINGS) SET(COMP_FLAGS "${COMP_FLAGS} -Werror") ENDIF () # Omit problematic warnings IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") SET(COMP_FLAGS "${COMP_FLAGS} -Wno-unused-but-set-variable") ENDIF () IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.9.9) SET(COMP_FLAGS "${COMP_FLAGS} -Wno-format-truncation") ENDIF () IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") SET(COMP_FLAGS "${COMP_FLAGS} -Wno-nonnull -Wno-deprecated-declarations") ENDIF () # Minimal debug info with Clang IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") SET(COMP_FLAGS "${COMP_FLAGS} -gline-tables-only") ELSE () SET(COMP_FLAGS "${COMP_FLAGS} -g") ENDIF () # Note: The following flags are problematic on older systems with gcc 4.8 IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.9)) IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") SET(COMP_FLAGS "${COMP_FLAGS} -Wno-unused-command-line-argument") ENDIF () FIND_PROGRAM(LDGOLD_FOUND ld.gold) SET(LDGOLD_SUPPORT OFF CACHE BOOL "Enable ld.gold support") # Optional ld.gold is 2x faster than normal ld IF (LDGOLD_FOUND AND LDGOLD_SUPPORT MATCHES ON AND NOT APPLE AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm) SET(LINKER_FLAGS "${LINKER_FLAGS} -fuse-ld=gold") # Use Identical Code Folding SET(COMP_FLAGS "${COMP_FLAGS} -ffunction-sections") SET(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--icf=safe") # Compress the debug sections # Note: Before valgrind 3.12.0, patch should be applied for valgrind (https://bugs.kde.org/show_bug.cgi?id=303877) IF (NOT APPLE AND NOT ANDROID AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm AND NOT CMAKE_CXX_CLANG_TIDY) SET(COMP_FLAGS "${COMP_FLAGS} -Wa,--compress-debug-sections") SET(LINKER_FLAGS "${LINKER_FLAGS} -Wl,--compress-debug-sections=zlib") ENDIF () ENDIF () ENDIF () # Apply the flags SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMP_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMP_FLAGS}") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}") ENDIF () # Sanitizer support SET(CLANG_SANITIZERS OFF CACHE BOOL "Clang's sanitizer support") IF (CLANG_SANITIZERS AND ((UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR (APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer") ENDIF () # Unity Build support include(UnityBuild) libfli-2.0+20221221182632/cmake_modules/FindFLIPRO.cmake0000644000175100017510000000314014347562502021035 0ustar debiandebian# - Try to find Finger Lakes Instruments Library # Once done this will define # # FLIPRO_FOUND - system has FLI # FLIPRO_INCLUDE_DIR - the FLI include directory # FLIPRO_LIBRARIES - Link these to use FLI # Copyright (c) 2008, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) # in cache already set(FLIPRO_FOUND TRUE) message(STATUS "Found libflipro: ${FLIPRO_LIBRARIES}") else (FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) # Might need to remove lib prefix once FLI fixes their library name find_path(FLIPRO_INCLUDE_DIR libflipro.h PATH_SUFFIXES fli ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(FLIPRO_LIBRARIES NAMES libflipro PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) set(FLIPRO_FOUND TRUE) else (FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) set(FLIPRO_FOUND FALSE) endif(FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) if (FLIPRO_FOUND) if (NOT FLIPRO_FIND_QUIETLY) message(STATUS "Found FLIPRO: ${FLIPRO_LIBRARIES}") endif (NOT FLIPRO_FIND_QUIETLY) else (FLIPRO_FOUND) if (FLIPRO_FIND_REQUIRED) message(FATAL_ERROR "FLIPRO not found. Please install it and try again. http://www.indilib.org") endif (FLIPRO_FIND_REQUIRED) endif (FLIPRO_FOUND) mark_as_advanced(FLIPRO_INCLUDE_DIR FLIPRO_LIBRARIES) endif (FLIPRO_INCLUDE_DIR AND FLIPRO_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindINOVASDK.cmake0000644000175100017510000000275314174600255021265 0ustar debiandebian# - Try to find INOVASDK Universal Library # Once done this will define # # INOVASDK_FOUND - system has INOVASDK # INOVASDK_INCLUDE_DIR - the INOVASDK include directory # INOVASDK_LIBRARIES - Link these to use INOVASDK # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) # in cache already set(INOVASDK_FOUND TRUE) message(STATUS "Found libinovasdk: ${INOVASDK_LIBRARIES}") else (INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) find_path(INOVASDK_INCLUDE_DIR inovasdk.h PATH_SUFFIXES inovasdk ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(INOVASDK_LIBRARIES NAMES inovasdk PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) set(INOVASDK_FOUND TRUE) else (INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) set(INOVASDK_FOUND FALSE) endif(INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) if (INOVASDK_FOUND) if (NOT INOVASDK_FIND_QUIETLY) message(STATUS "Found INOVASDK: ${INOVASDK_LIBRARIES}") endif (NOT INOVASDK_FIND_QUIETLY) else (INOVASDK_FOUND) if (INOVASDK_FIND_REQUIRED) message(FATAL_ERROR "INOVASDK not found. Please install INOVASDK Library http://www.indilib.org") endif (INOVASDK_FIND_REQUIRED) endif (INOVASDK_FOUND) mark_as_advanced(INOVASDK_INCLUDE_DIR INOVASDK_LIBRARIES) endif (INOVASDK_INCLUDE_DIR AND INOVASDK_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindQHY.cmake0000644000175100017510000000242614174600255020505 0ustar debiandebian# - Try to find QHY Library # Once done this will define # # QHY_FOUND - system has QHY # QHY_INCLUDE_DIR - the QHY include directory # QHY_LIBRARIES - Link these to use QHY # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (QHY_INCLUDE_DIR AND QHY_LIBRARIES) # in cache already set(QHY_FOUND TRUE) message(STATUS "Found libqhyccd: ${QHY_LIBRARIES}") else (QHY_INCLUDE_DIR AND QHY_LIBRARIES) find_path(QHY_INCLUDE_DIR qhyccd.h PATH_SUFFIXES libqhy ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(QHY_LIBRARIES NAMES qhyccd PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(QHY_INCLUDE_DIR AND QHY_LIBRARIES) set(QHY_FOUND TRUE) else (QHY_INCLUDE_DIR AND QHY_LIBRARIES) set(QHY_FOUND FALSE) endif(QHY_INCLUDE_DIR AND QHY_LIBRARIES) if (QHY_FOUND) if (NOT QHY_FIND_QUIETLY) message(STATUS "Found QHY: ${QHY_LIBRARIES}") endif (NOT QHY_FIND_QUIETLY) else (QHY_FOUND) if (QHY_FIND_REQUIRED) message(FATAL_ERROR "QHY not found. Please install libqhy http://www.indilib.org") endif (QHY_FIND_REQUIRED) endif (QHY_FOUND) mark_as_advanced(QHY_INCLUDE_DIR QHY_LIBRARIES) endif (QHY_INCLUDE_DIR AND QHY_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindPENTAX.cmake0000644000175100017510000000553014174600255021042 0ustar debiandebian# - Try to find PENTAX Universal Libraries # Once done this will define # # PENTAX_FOUND - system has PENTAX # PENTAX_INCLUDE_DIR - the PENTAX include directory # PENTAX_LIBRARIES - Link these to use PENTAX # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) # in cache already set(PENTAX_FOUND TRUE) message(STATUS "Found PENTAX libraries: ${PENTAX_LIBRARIES}") else (PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) find_path(PKTRIGGERCORD_INCLUDE_DIR libpktriggercord.h PATH_SUFFIXES libpktriggercord ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(PKTRIGGERCORD_LIBRARIES NAMES pktriggercord PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib PATH_SUFFIXES indipentax ) #if not armv8, then look for ricoh library; otherwise only use pktriggercord library if(NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")) find_path(RICOH_INCLUDE_DIR ricoh_camera_sdk.hpp PATH_SUFFIXES libpentax libricohcamerasdk ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(RICOH_LIBRARIES NAMES RicohCameraSDKCpp PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(RICOHMTP_LIBRARIES NAMES libmtpricoh.so.9.3.0 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if (RICOH_INCLUDE_DIR AND PKTRIGGERCORD_INCLUDE_DIR) set(PENTAX_INCLUDE_DIR ${RICOH_INCLUDE_DIR} ${PKTRIGGERCORD_INCLUDE_DIR}) endif (RICOH_INCLUDE_DIR AND PKTRIGGERCORD_INCLUDE_DIR) if (RICOH_LIBRARIES AND RICOHMTP_LIBRARIES AND PKTRIGGERCORD_LIBRARIES) set(PENTAX_LIBRARIES ${RICOH_LIBRARIES} ${RICOHMTP_LIBRARIES} ${PKTRIGGERCORD_LIBRARIES}) endif (RICOH_LIBRARIES AND RICOHMTP_LIBRARIES AND PKTRIGGERCORD_LIBRARIES) else() if (PKTRIGGERCORD_INCLUDE_DIR) set(PENTAX_INCLUDE_DIR ${PKTRIGGERCORD_INCLUDE_DIR}) endif (PKTRIGGERCORD_INCLUDE_DIR) if (PKTRIGGERCORD_LIBRARIES) set(PENTAX_LIBRARIES ${PKTRIGGERCORD_LIBRARIES}) endif (PKTRIGGERCORD_LIBRARIES) endif() if(PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) set(PENTAX_FOUND TRUE) else (PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) set(PENTAX_FOUND FALSE) endif(PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) if (PENTAX_FOUND) if (NOT PENTAX_FIND_QUIETLY) message(STATUS "Found PENTAX libraries: ${PENTAX_LIBRARIES}") endif (NOT PENTAX_FIND_QUIETLY) else (PENTAX_FOUND) if (PENTAX_FIND_REQUIRED) message(FATAL_ERROR "One or both of libricohcamersdk and libpktriggercord are not found. Please install them. See http://www.indilib.org.") endif (PENTAX_FIND_REQUIRED) endif (PENTAX_FOUND) mark_as_advanced(PENTAX_INCLUDE_DIR PENTAX_LIBRARIES) endif (PENTAX_INCLUDE_DIR AND PENTAX_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindGLIB2.cmake0000644000175100017510000001327114174600255020643 0ustar debiandebian# - Try to find GLib2 # Once done this will define # # GLIB2_FOUND - system has GLib2 # GLIB2_INCLUDE_DIRS - the GLib2 include directory # GLIB2_LIBRARIES - Link these to use GLib2 # # HAVE_GLIB_GREGEX_H glib has gregex.h header and # supports g_regex_match_simple # # Copyright (c) 2006 Andreas Schneider # Copyright (c) 2006 Philippe Bernery # Copyright (c) 2007 Daniel Gollub # Copyright (c) 2007 Alban Browaeys # Copyright (c) 2008 Michael Bell # Copyright (c) 2008 Bjoern Ricks # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) # in cache already SET(GLIB2_FOUND TRUE) ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS ) INCLUDE(FindPkgConfig) ## Glib IF ( GLIB2_FIND_REQUIRED ) SET( _pkgconfig_REQUIRED "REQUIRED" ) ELSE ( GLIB2_FIND_REQUIRED ) SET( _pkgconfig_REQUIRED "" ) ENDIF ( GLIB2_FIND_REQUIRED ) IF ( GLIB2_MIN_VERSION ) PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} ) ELSE ( GLIB2_MIN_VERSION ) PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 ) ENDIF ( GLIB2_MIN_VERSION ) IF ( PKG_CONFIG_FOUND ) IF ( GLIB2_FOUND ) SET ( GLIB2_CORE_FOUND TRUE ) ELSE ( GLIB2_FOUND ) SET ( GLIB2_CORE_FOUND FALSE ) ENDIF ( GLIB2_FOUND ) ENDIF ( PKG_CONFIG_FOUND ) # Look for glib2 include dir and libraries w/o pkgconfig IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) FIND_PATH( _glibconfig_include_DIR NAMES glibconfig.h PATHS /opt/gnome/lib64 /opt/gnome/lib /opt/lib/ /opt/local/lib /sw/lib/ /usr/lib64 /usr/lib /usr/local/include ${CMAKE_LIBRARY_PATH} PATH_SUFFIXES glib-2.0/include ) FIND_PATH( _glib2_include_DIR NAMES glib.h PATHS /opt/gnome/include /opt/local/include /sw/include /usr/include /usr/local/include PATH_SUFFIXES glib-2.0 ) #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}") FIND_LIBRARY( _glib2_link_DIR NAMES glib-2.0 glib PATHS /opt/gnome/lib /opt/local/lib /sw/lib /usr/lib /usr/local/lib ) IF ( _glib2_include_DIR AND _glib2_link_DIR ) SET ( _glib2_FOUND TRUE ) ENDIF ( _glib2_include_DIR AND _glib2_link_DIR ) IF ( _glib2_FOUND ) SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} ) SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} ) SET ( GLIB2_CORE_FOUND TRUE ) ELSE ( _glib2_FOUND ) SET ( GLIB2_CORE_FOUND FALSE ) ENDIF ( _glib2_FOUND ) # Handle dependencies # libintl IF ( NOT LIBINTL_FOUND ) FIND_PATH(LIBINTL_INCLUDE_DIR NAMES libintl.h PATHS /opt/gnome/include /opt/local/include /sw/include /usr/include /usr/local/include ) FIND_LIBRARY(LIBINTL_LIBRARY NAMES intl PATHS /opt/gnome/lib /opt/local/lib /sw/lib /usr/local/lib /usr/lib ) IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) SET (LIBINTL_FOUND TRUE) ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR) ENDIF ( NOT LIBINTL_FOUND ) # libiconv IF ( NOT LIBICONV_FOUND ) FIND_PATH(LIBICONV_INCLUDE_DIR NAMES iconv.h PATHS /opt/gnome/include /opt/local/include /opt/local/include /sw/include /sw/include /usr/local/include /usr/include PATH_SUFFIXES glib-2.0 ) FIND_LIBRARY(LIBICONV_LIBRARY NAMES iconv PATHS /opt/gnome/lib /opt/local/lib /sw/lib /usr/lib /usr/local/lib ) IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) SET (LIBICONV_FOUND TRUE) ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR) ENDIF ( NOT LIBICONV_FOUND ) IF (LIBINTL_FOUND) SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY}) SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR}) ENDIF (LIBINTL_FOUND) IF (LIBICONV_FOUND) SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY}) SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR}) ENDIF (LIBICONV_FOUND) ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND ) ## IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) SET (GLIB2_FOUND TRUE) ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES) IF (GLIB2_FOUND) IF (NOT GLIB2_FIND_QUIETLY) MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}") ENDIF (NOT GLIB2_FIND_QUIETLY) ELSE (GLIB2_FOUND) IF (GLIB2_FIND_REQUIRED) MESSAGE (SEND_ERROR "Could not find GLib2") ENDIF (GLIB2_FIND_REQUIRED) ENDIF (GLIB2_FOUND) # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES) MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY) MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY) ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS) IF ( GLIB2_FOUND ) # Check if system has a newer version of glib # which supports g_regex_match_simple INCLUDE( CheckIncludeFiles ) SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} ) CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H ) # Reset CMAKE_REQUIRED_INCLUDES SET( CMAKE_REQUIRED_INCLUDES "" ) ENDIF( GLIB2_FOUND ) libfli-2.0+20221221182632/cmake_modules/FindATIK.cmake0000644000175100017510000000254014174600255020571 0ustar debiandebian# - Try to find Atik Camera Library # Once done this will define # # ATIK_FOUND - system has ATIK # ATIK_INCLUDE_DIR - the ATIK include directory # ATIK_LIBRARIES - Link these to use ATIK # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) # in cache already set(ATIK_FOUND TRUE) message(STATUS "Found libatik: ${ATIK_LIBRARIES}") else (ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) find_path(ATIK_INCLUDE_DIR AtikCameras.h PATH_SUFFIXES libatik ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(ATIK_LIBRARIES NAMES atikcameras PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) set(ATIK_FOUND TRUE) else (ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) set(ATIK_FOUND FALSE) endif(ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) if (ATIK_FOUND) if (NOT ATIK_FIND_QUIETLY) message(STATUS "Found Atik Library: ${ATIK_LIBRARIES}") endif (NOT ATIK_FIND_QUIETLY) else (ATIK_FOUND) if (ATIK_FIND_REQUIRED) message(FATAL_ERROR "Atik Library not found. Please install Atik Library http://www.indilib.org") endif (ATIK_FIND_REQUIRED) endif (ATIK_FOUND) mark_as_advanced(ATIK_INCLUDE_DIR ATIK_LIBRARIES) endif (ATIK_INCLUDE_DIR AND ATIK_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindALUT.cmake0000644000175100017510000000504214174600255020606 0ustar debiandebian# - Locate ALUT # This module defines # ALUT_LIBRARY # ALUT_FOUND, if false, do not try to link to OpenAL # ALUT_INCLUDE_DIR, where to find the headers # # $OPENALDIR is an environment variable that would # correspond to the ./configure --prefix=$OPENALDIR # used in building OpenAL. # # Created by Bryan Donlan, based on the FindOpenAL.cmake module by Eric Wang. FIND_PATH(ALUT_INCLUDE_DIR alut.h $ENV{OPENALDIR}/include ~/Library/Frameworks/OpenAL.framework/Headers /Library/Frameworks/OpenAL.framework/Headers /System/Library/Frameworks/OpenAL.framework/Headers # Tiger /usr/local/include/AL /usr/local/include/OpenAL /usr/local/include /usr/include/AL /usr/include/OpenAL /usr/include /sw/include/AL # Fink /sw/include/OpenAL /sw/include /opt/local/include/AL # DarwinPorts /opt/local/include/OpenAL /opt/local/include /opt/csw/include/AL # Blastwave /opt/csw/include/OpenAL /opt/csw/include /opt/include/AL /opt/include/OpenAL /opt/include ) # I'm not sure if I should do a special casing for Apple. It is # unlikely that other Unix systems will find the framework path. # But if they do ([Next|Open|GNU]Step?), # do they want the -framework option also? IF(${ALUT_INCLUDE_DIR} MATCHES ".framework") STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ALUT_FRAMEWORK_PATH_TMP ${ALUT_INCLUDE_DIR}) IF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # String is in default search path, don't need to use -F SET (ALUT_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX") ELSE("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # String is not /Library/Frameworks, need to use -F SET(ALUT_LIBRARY "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX") ENDIF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks" OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks" ) # Clear the temp variable so nobody can see it SET(ALUT_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "") ELSE(${ALUT_INCLUDE_DIR} MATCHES ".framework") FIND_LIBRARY(ALUT_LIBRARY NAMES alut PATHS $ENV{OPENALDIR}/lib $ENV{OPENALDIR}/libs /usr/local/lib /usr/lib /sw/lib /opt/local/lib /opt/csw/lib /opt/lib ) ENDIF(${ALUT_INCLUDE_DIR} MATCHES ".framework") SET(ALUT_FOUND "NO") IF(ALUT_LIBRARY) SET(ALUT_FOUND "YES") ENDIF(ALUT_LIBRARY) libfli-2.0+20221221182632/cmake_modules/FindAHPGT.cmake0000644000175100017510000000333314347562502020711 0ustar debiandebian# - Try to find AHPGT # Once done this will define # # AHPGT_FOUND - system has AHPGT # AHPGT_INCLUDE_DIR - the AHPGT include directory # AHPGT_LIBRARIES - Link these to use AHPGT # AHPGT_VERSION_STRING - Human readable version number of ahp_gt # AHPGT_VERSION_MAJOR - Major version number of ahp_gt # AHPGT_VERSION_MINOR - Minor version number of ahp_gt # Copyright (c) 2017, Ilia Platone, # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) # in cache already set(AHPGT_FOUND TRUE) message(STATUS "Found AHPGT: ${AHPGT_LIBRARIES}") else (AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) find_path(AHPGT_INCLUDE_DIR ahp_gt.h PATH_SUFFIXES ahp ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(AHPGT_LIBRARIES NAMES ahp_gt PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES} ) if(AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) set(AHPGT_FOUND TRUE) else (AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) set(AHPGT_FOUND FALSE) endif(AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) if (AHPGT_FOUND) if (NOT AHPGT_FIND_QUIETLY) message(STATUS "Found AHPGT: ${AHPGT_LIBRARIES}") endif (NOT AHPGT_FIND_QUIETLY) else (AHPGT_FOUND) if (AHPGT_FIND_REQUIRED) message(FATAL_ERROR "AHPGT not found. Please install libahp_gt-dev") endif (AHPGT_FIND_REQUIRED) endif (AHPGT_FOUND) mark_as_advanced(AHPGT_LIBRARIES) endif (AHPGT_INCLUDE_DIR AND AHPGT_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindD2XX.cmake0000644000175100017510000000262014174600255020565 0ustar debiandebian# - Try to find D2XX # Once done this will define # # D2XX_FOUND - system has FTDI # D2XX_INCLUDE_DIR - the FTDI include directory # D2XX_LIBRARIES - Link these to use FTDI # # N.B. You must include the file as following: # #include # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) # in cache already set(D2XX_FOUND TRUE) message(STATUS "Found libfd2xx: ${D2XX_LIBRARIES}") else (D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) find_path(D2XX_INCLUDE_DIR ftd2xx.h #PATH_SUFFIXES libD2XX ${_obIncDir} ${GNUWIN32_DIR}/include /usr/local/include ) find_library(D2XX_LIBRARIES NAMES ftd2xx PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib ) if(D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) set(D2XX_FOUND TRUE) else (D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) set(D2XX_FOUND FALSE) endif(D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) if (D2XX_FOUND) if (NOT D2XX_FIND_QUIETLY) message(STATUS "Found D2XX: ${D2XX_LIBRARIES}") endif (NOT D2XX_FIND_QUIETLY) else (D2XX_FOUND) if (D2XX_FIND_REQUIRED) message(FATAL_ERROR "D2XX not found. Please install libd2xx") endif (D2XX_FIND_REQUIRED) endif (D2XX_FOUND) mark_as_advanced(D2XX_INCLUDE_DIR D2XX_LIBRARIES) endif (D2XX_INCLUDE_DIR AND D2XX_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindARAVIS.cmake0000644000175100017510000000272314174600255021031 0ustar debiandebian# - Find the native sqlite3 includes and library # # This module defines # ARV_INCLUDE_DIR, where to find libgphoto2 header files # ARV_LIBRARIES, the libraries to link against to use libgphoto2 # ARV_FOUND, If false, do not try to use libgphoto2. # ARV_VERSION_STRING, e.g. 2.4.14 # ARV_VERSION_MAJOR, e.g. 2 # ARV_VERSION_MINOR, e.g. 4 # ARV_VERSION_PATCH, e.g. 14 # # also defined, but not for general use are # ARV_LIBRARY, where to find the sqlite3 library. #============================================================================= # Copyright 2010 henrik andersson #============================================================================= SET(ARV_FIND_REQUIRED ${Arv_FIND_REQUIRED}) find_path(ARV_INCLUDE_DIR aravis-0.8/arv.h) mark_as_advanced(ARV_INCLUDE_DIR) set(ARV_NAMES ${ARV_NAMES} aravis-0.8) find_library(ARV_LIBRARY NAMES ${ARV_NAMES} ) mark_as_advanced(ARV_LIBRARY) set(ARV_VERSION_MAJOR "0") set(ARV_VERSION_MINOR "8") set(ARV_VERSION_STRING "${ARV_VERSION_MAJOR}.${ARV_VERSION_MINOR}") # handle the QUIETLY and REQUIRED arguments and set ARV_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ARV DEFAULT_MSG ARV_LIBRARY ARV_INCLUDE_DIR) IF(ARV_FOUND) #SET(Arv_LIBRARIES ${ARV_LIBRARY}) SET(Arv_LIBRARIES "aravis-0.8") SET(Arv_INCLUDE_DIRS "${ARV_INCLUDE_DIR}/aravis-0.8") MESSAGE (STATUS "Found aravis: ${Arv_LIBRARIES} ${Arv_INCLUDE_DIRS}") ENDIF(ARV_FOUND) libfli-2.0+20221221182632/cmake_modules/FindFISHCAMP.cmake0000644000175100017510000000322514174600255021234 0ustar debiandebian# - Try to find FISHCAMP CCD # Once done this will define # # FISHCAMP_FOUND - system has FISHCAMP # FISHCAMP_LIBRARIES - Link these to use FISHCAMP # FISHCAMP_INCLUDE_DIR - Fishcamp include directory # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) # in cache already set(FISHCAMP_FOUND TRUE) message(STATUS "Found FISHCAMP: ${FISHCAMP_LIBRARIES}") else (FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) find_library(FISHCAMP_LIBRARIES NAMES fishcamp PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_path(FISHCAMP_INCLUDE_DIR fishcamp.h PATH_SUFFIXES libfishcamp ${_obIncDir} ${GNUWIN32_DIR}/include ) set(CMAKE_REQUIRED_LIBRARIES ${FISHCAMP_LIBRARIES}) if(FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) set(FISHCAMP_FOUND TRUE) else (FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) set(FISHCAMP_FOUND FALSE) endif(FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) if (FISHCAMP_FOUND) if (NOT FISHCAMP_FIND_QUIETLY) message(STATUS "Found FISHCAMP: ${FISHCAMP_LIBRARIES}") endif (NOT FISHCAMP_FIND_QUIETLY) else (FISHCAMP_FOUND) if (FISHCAMP_FIND_REQUIRED) message(FATAL_ERROR "FISHCAMP not found. Please install FISHCAMP library. http://www.indilib.org") endif (FISHCAMP_FIND_REQUIRED) endif (FISHCAMP_FOUND) mark_as_advanced(FISHCAMP_LIBRARIES FISHCAMP_INCLUDE_DIR) endif (FISHCAMP_LIBRARIES AND FISHCAMP_INCLUDE_DIR) libfli-2.0+20221221182632/cmake_modules/FindDC1394.cmake0000644000175100017510000000264314174600255020654 0ustar debiandebian# - Try to find dc1394 library (version 2) and include files # Once done this will define # # DC1394_FOUND - system has DC1394 # DC1394_INCLUDE_DIR - the DC1394 include directory # DC1394_LIBRARIES - Link these to use DC1394 # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) # in cache already set(DC1394_FOUND TRUE) message(STATUS "Found libdc1394: ${DC1394_LIBRARIES}") else (DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) find_path(DC1394_INCLUDE_DIR control.h PATH_SUFFIXES dc1394 ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(DC1394_LIBRARIES NAMES dc1394 PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) set(DC1394_FOUND TRUE) else (DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) set(DC1394_FOUND FALSE) endif(DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) if (DC1394_FOUND) if (NOT DC1394_FIND_QUIETLY) message(STATUS "Found DC1394: ${DC1394_LIBRARIES}") endif (NOT DC1394_FIND_QUIETLY) else (DC1394_FOUND) if (DC1394_FIND_REQUIRED) message(FATAL_ERROR "DC1394 not found. Please install libdc1394 development package.") endif (DC1394_FIND_REQUIRED) endif (DC1394_FOUND) mark_as_advanced(DC1394_INCLUDE_DIR DC1394_LIBRARIES) endif (DC1394_INCLUDE_DIR AND DC1394_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindTIFFXX.cmake0000644000175100017510000000176314174600255021057 0ustar debiandebian# - Try to find TIFFXX Library # Once done this will define # # TIFXX_LIBRARY - Link these to use TIFFXX # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (TIFFXX_LIBRARY) # in cache already set(TIFFXX_FOUND TRUE) message(STATUS "Found libtiffxx: ${TIFFXX_LIBRARY}") else (TIFFXX_LIBRARY) find_library(TIFFXX_LIBRARY NAMES tiffxx PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(TIFFXX_LIBRARY) set(TIFFXX_FOUND TRUE) else (TIFFXX_LIBRARY) set(TIFFXX_FOUND FALSE) endif(TIFFXX_LIBRARY) if (TIFFXX_FOUND) if (NOT TIFFXX_FIND_QUIETLY) message(STATUS "Found tiffxx: ${TIFFXX_LIBRARY}") endif (NOT TIFFXX_FIND_QUIETLY) else (TIFFXX_FOUND) if (TIFFXX_FIND_REQUIRED) message(FATAL_ERROR "tiffxx is not found. Please install it first.") endif (TIFFXX_FIND_REQUIRED) endif (TIFFXX_FOUND) mark_as_advanced(TIFFXX_LIBRARY) endif (TIFFXX_LIBRARY) libfli-2.0+20221221182632/cmake_modules/FindGSL.cmake0000644000175100017510000002224114174600255020466 0ustar debiandebian#.rst: # FindGSL # -------- # # Find the native GSL includes and libraries. # # The GNU Scientific Library (GSL) is a numerical library for C and C++ # programmers. It is free software under the GNU General Public # License. # # Imported Targets # ^^^^^^^^^^^^^^^^ # # If GSL is found, this module defines the following :prop_tgt:`IMPORTED` # targets:: # # GSL::gsl - The main GSL library. # GSL::gslcblas - The CBLAS support library used by GSL. # # Result Variables # ^^^^^^^^^^^^^^^^ # # This module will set the following variables in your project:: # # GSL_FOUND - True if GSL found on the local system # GSL_INCLUDE_DIRS - Location of GSL header files. # GSL_LIBRARIES - The GSL libraries. # GSL_VERSION - The version of the discovered GSL install. # # Hints # ^^^^^ # # Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation. # # This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL # headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may # optionally provide Release and Debug folders. For Unix-like systems, this # script will use ``$GSL_ROOT_DIR/bin/gsl-config`` (if found) to aid in the # discovery GSL. # # Cache Variables # ^^^^^^^^^^^^^^^ # # This module may set the following variables depending on platform and type # of GSL installation discovered. These variables may optionally be set to # help this module find the correct files:: # # GSL_CLBAS_LIBRARY - Location of the GSL CBLAS library. # GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any). # GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any). # GSL_LIBRARY - Location of the GSL library. # GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any). # #============================================================================= # Copyright 2014 Kelly Thompson # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Include these modules to handle the QUIETLY and REQUIRED arguments. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) #============================================================================= # If the user has provided ``GSL_ROOT_DIR``, use it! Choose items found # at this location over system locations. if( EXISTS "$ENV{GSL_ROOT_DIR}" ) file( TO_CMAKE_PATH "$ENV{GSL_ROOT_DIR}" GSL_ROOT_DIR ) set( GSL_ROOT_DIR "${GSL_ROOT_DIR}" CACHE PATH "Prefix for GSL installation." ) endif() if( NOT EXISTS "${GSL_ROOT_DIR}" ) set( GSL_USE_PKGCONFIG ON ) endif() #============================================================================= # As a first try, use the PkgConfig module. This will work on many # *NIX systems. See :module:`findpkgconfig` # This will return ``GSL_INCLUDEDIR`` and ``GSL_LIBDIR`` used below. if( GSL_USE_PKGCONFIG ) find_package(PkgConfig) pkg_check_modules( GSL QUIET gsl ) if( EXISTS "${GSL_INCLUDEDIR}" ) get_filename_component( GSL_ROOT_DIR "${GSL_INCLUDEDIR}" DIRECTORY CACHE) endif() endif() #============================================================================= # Set GSL_INCLUDE_DIRS and GSL_LIBRARIES. If we skipped the PkgConfig step, try # to find the libraries at $GSL_ROOT_DIR (if provided) or in standard system # locations. These find_library and find_path calls will prefer custom # locations over standard locations (HINTS). If the requested file is not found # at the HINTS location, standard system locations will be still be searched # (/usr/lib64 (Redhat), lib/i386-linux-gnu (Debian)). find_path( GSL_INCLUDE_DIR NAMES gsl/gsl_sf.h HINTS ${GSL_ROOT_DIR}/include ${GSL_INCLUDEDIR} ) find_library( GSL_LIBRARY NAMES gsl HINTS ${GSL_ROOT_DIR}/lib ${GSL_LIBDIR} PATH_SUFFIXES Release Debug ) find_library( GSL_CBLAS_LIBRARY NAMES gslcblas cblas HINTS ${GSL_ROOT_DIR}/lib ${GSL_LIBDIR} PATH_SUFFIXES Release Debug ) # Do we also have debug versions? find_library( GSL_LIBRARY_DEBUG NAMES gsl HINTS ${GSL_ROOT_DIR}/lib ${GSL_LIBDIR} PATH_SUFFIXES Debug ) find_library( GSL_CBLAS_LIBRARY_DEBUG NAMES gslcblas cblas HINTS ${GSL_ROOT_DIR}/lib ${GSL_LIBDIR} PATH_SUFFIXES Debug ) set( GSL_INCLUDE_DIRS ${GSL_INCLUDE_DIR} ) set( GSL_LIBRARIES ${GSL_LIBRARY} ${GSL_CBLAS_LIBRARY} ) # If we didn't use PkgConfig, try to find the version via gsl-config or by # reading gsl_version.h. if( NOT GSL_VERSION ) # 1. If gsl-config exists, query for the version. find_program( GSL_CONFIG_EXECUTABLE NAMES gsl-config HINTS "${GSL_ROOT_DIR}/bin" ) if( EXISTS "${GSL_CONFIG_EXECUTABLE}" ) execute_process( COMMAND "${GSL_CONFIG_EXECUTABLE}" --version OUTPUT_VARIABLE GSL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) endif() # 2. If gsl-config is not available, try looking in gsl/gsl_version.h if( NOT GSL_VERSION AND EXISTS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" ) file( STRINGS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" gsl_version_h_contents REGEX "define GSL_VERSION" ) string( REGEX REPLACE ".*([0-9].[0-9][0-9]).*" "\\1" GSL_VERSION ${gsl_version_h_contents} ) endif() # might also try scraping the directory name for a regex match "gsl-X.X" endif() #============================================================================= # handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE if all # listed variables are TRUE find_package_handle_standard_args( GSL FOUND_VAR GSL_FOUND REQUIRED_VARS GSL_INCLUDE_DIR GSL_LIBRARY GSL_CBLAS_LIBRARY VERSION_VAR GSL_VERSION ) mark_as_advanced( GSL_ROOT_DIR GSL_VERSION GSL_LIBRARY GSL_INCLUDE_DIR GSL_CBLAS_LIBRARY GSL_LIBRARY_DEBUG GSL_CBLAS_LIBRARY_DEBUG GSL_USE_PKGCONFIG GSL_CONFIG ) #============================================================================= # Register imported libraries: # 1. If we can find a Windows .dll file (or if we can find both Debug and # Release libraries), we will set appropriate target properties for these. # 2. However, for most systems, we will only register the import location and # include directory. # Look for dlls, or Release and Debug libraries. if(WIN32) string( REPLACE ".lib" ".dll" GSL_LIBRARY_DLL "${GSL_LIBRARY}" ) string( REPLACE ".lib" ".dll" GSL_CBLAS_LIBRARY_DLL "${GSL_CBLAS_LIBRARY}" ) string( REPLACE ".lib" ".dll" GSL_LIBRARY_DEBUG_DLL "${GSL_LIBRARY_DEBUG}" ) string( REPLACE ".lib" ".dll" GSL_CBLAS_LIBRARY_DEBUG_DLL "${GSL_CBLAS_LIBRARY_DEBUG}" ) endif() if( GSL_FOUND AND NOT TARGET GSL::gsl ) if( EXISTS "${GSL_LIBRARY_DLL}" AND EXISTS "${GSL_CBLAS_LIBRARY_DLL}") # Windows systems with dll libraries. add_library( GSL::gsl SHARED IMPORTED ) add_library( GSL::gslcblas SHARED IMPORTED ) # Windows with dlls, but only Release libraries. set_target_properties( GSL::gslcblas PROPERTIES IMPORTED_LOCATION_RELEASE "${GSL_CBLAS_LIBRARY_DLL}" IMPORTED_IMPLIB "${GSL_CBLAS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${GSL_INCLUDE_DIRS}" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) set_target_properties( GSL::gsl PROPERTIES IMPORTED_LOCATION_RELEASE "${GSL_LIBRARY_DLL}" IMPORTED_IMPLIB "${GSL_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${GSL_INCLUDE_DIRS}" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "C" INTERFACE_LINK_LIBRARIES GSL::gslcblas ) # If we have both Debug and Release libraries if( EXISTS "${GSL_LIBRARY_DEBUG_DLL}" AND EXISTS "${GSL_CBLAS_LIBRARY_DEBUG_DLL}") set_property( TARGET GSL::gslcblas APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) set_target_properties( GSL::gslcblas PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_CBLAS_LIBRARY_DEBUG_DLL}" IMPORTED_IMPLIB_DEBUG "${GSL_CBLAS_LIBRARY_DEBUG}" ) set_property( TARGET GSL::gsl APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) set_target_properties( GSL::gsl PROPERTIES IMPORTED_LOCATION_DEBUG "${GSL_LIBRARY_DEBUG_DLL}" IMPORTED_IMPLIB_DEBUG "${GSL_LIBRARY_DEBUG}" ) endif() else() # For all other environments (ones without dll libraries), create # the imported library targets. add_library( GSL::gsl UNKNOWN IMPORTED ) add_library( GSL::gslcblas UNKNOWN IMPORTED ) set_target_properties( GSL::gslcblas PROPERTIES IMPORTED_LOCATION "${GSL_CBLAS_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${GSL_INCLUDE_DIRS}" IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) set_target_properties( GSL::gsl PROPERTIES IMPORTED_LOCATION "${GSL_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${GSL_INCLUDE_DIRS}" IMPORTED_LINK_INTERFACE_LANGUAGES "C" INTERFACE_LINK_LIBRARIES GSL::gslcblas ) endif() endif() libfli-2.0+20221221182632/cmake_modules/FindMICAM.cmake0000644000175100017510000000256714174600255020700 0ustar debiandebian# - Try to find Moravian Instruments Camera Library # Once done this will define # # MICAM_FOUND - system has MI # MICAM_INCLUDE_DIR - the MI include directory # MICAM_LIBRARIES - Link these to use MI # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) # in cache already set(MICAM_FOUND TRUE) message(STATUS "Found libmicam: ${MICAM_LIBRARIES}") else (MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) find_path(MICAM_INCLUDE_DIR gxccd.h PATH_SUFFIXES libmicam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(MICAM_LIBRARIES NAMES gxccd PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) set(MICAM_FOUND TRUE) else (MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) set(MICAM_FOUND FALSE) endif(MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) if (MICAM_FOUND) if (NOT MICAM_FIND_QUIETLY) message(STATUS "Found MI Library: ${MICAM_LIBRARIES}") endif (NOT MICAM_FIND_QUIETLY) else (MICAM_FOUND) if (MICAM_FIND_REQUIRED) message(FATAL_ERROR "MI Library not found. Please install MI Library http://www.indilib.org") endif (MICAM_FIND_REQUIRED) endif (MICAM_FOUND) mark_as_advanced(MICAM_INCLUDE_DIR MICAM_LIBRARIES) endif (MICAM_INCLUDE_DIR AND MICAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindPackageHandleStandardArgs.cmake0000644000175100017510000003565714174600255025025 0ustar debiandebian#[=======================================================================[.rst: FindPackageHandleStandardArgs ----------------------------- This module provides a function intended to be used in :ref:`Find Modules` implementing :command:`find_package()` calls. It handles the ``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. It also sets the ``_FOUND`` variable. The package is considered found if all variables listed contain valid results, e.g. valid filepaths. .. command:: find_package_handle_standard_args There are two signatures:: find_package_handle_standard_args( (DEFAULT_MSG|) ... ) find_package_handle_standard_args( [FOUND_VAR ] [REQUIRED_VARS ...] [VERSION_VAR ] [HANDLE_COMPONENTS] [CONFIG_MODE] [FAIL_MESSAGE ] ) The ``_FOUND`` variable will be set to ``TRUE`` if all the variables ``...`` are valid and any optional constraints are satisfied, and ``FALSE`` otherwise. A success or failure message may be displayed based on the results and on whether the ``REQUIRED`` and/or ``QUIET`` option was given to the :command:`find_package` call. The options are: ``(DEFAULT_MSG|)`` In the simple signature this specifies the failure message. Use ``DEFAULT_MSG`` to ask for a default message to be computed (recommended). Not valid in the full signature. ``FOUND_VAR `` Obsolete. Specifies either ``_FOUND`` or ``_FOUND`` as the result variable. This exists only for compatibility with older versions of CMake and is now ignored. Result variables of both names are always set for compatibility. ``REQUIRED_VARS ...`` Specify the variables which are required for this package. These may be named in the generated failure message asking the user to set the missing variable values. Therefore these should typically be cache entries such as ``FOO_LIBRARY`` and not output variables like ``FOO_LIBRARIES``. ``VERSION_VAR `` Specify the name of a variable that holds the version of the package that has been found. This version will be checked against the (potentially) specified required version given to the :command:`find_package` call, including its ``EXACT`` option. The default messages include information about the required version and the version which has been actually found, both if the version is ok or not. ``HANDLE_COMPONENTS`` Enable handling of package components. In this case, the command will report which components have been found and which are missing, and the ``_FOUND`` variable will be set to ``FALSE`` if any of the required components (i.e. not the ones listed after the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are missing. ``CONFIG_MODE`` Specify that the calling find module is a wrapper around a call to ``find_package( NO_MODULE)``. This implies a ``VERSION_VAR`` value of ``_VERSION``. The command will automatically check whether the package configuration file was found. ``FAIL_MESSAGE `` Specify a custom failure message instead of using the default generated message. Not recommended. Example for the simple signature: .. code-block:: cmake find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) The ``LibXml2`` package is considered to be found if both ``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found and ``REQUIRED`` was used, it fails with a :command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was used or not. If it is found, success will be reported, including the content of the first ````. On repeated CMake runs, the same message will not be printed again. Example for the full signature: .. code-block:: cmake find_package_handle_standard_args(LibArchive REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR VERSION_VAR LibArchive_VERSION) In this case, the ``LibArchive`` package is considered to be found if both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. Also the version of ``LibArchive`` will be checked by using the version contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, the default messages will be printed. Another example for the full signature: .. code-block:: cmake find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) find_package_handle_standard_args(Automoc4 CONFIG_MODE) In this case, a ``FindAutmoc4.cmake`` module wraps a call to ``find_package(Automoc4 NO_MODULE)`` and adds an additional search directory for ``automoc4``. Then the call to ``find_package_handle_standard_args`` produces a proper success/failure message. #]=======================================================================] #============================================================================= # Copyright 2007-2009 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) if (${_NAME}_FIND_REQUIRED) message(FATAL_ERROR "${_msg}") else () if (NOT ${_NAME}_FIND_QUIETLY) message(STATUS "${_msg}") endif () endif () endmacro() # internal helper macro to generate the failure message when used in CONFIG_MODE: macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: if(${_NAME}_CONFIG) _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") else() # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. # List them all in the error message: if(${_NAME}_CONSIDERED_CONFIGS) set(configsText "") list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) math(EXPR configsCount "${configsCount} - 1") foreach(currentConfigIndex RANGE ${configsCount}) list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) set(configsText "${configsText} ${filename} (version ${version})\n") endforeach() if (${_NAME}_NOT_FOUND_MESSAGE) set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") endif() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") else() # Simple case: No Config-file was found at all: _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") endif() endif() endmacro() function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in # new extended or in the "old" mode: set(options CONFIG_MODE HANDLE_COMPONENTS) set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) set(multiValueArgs REQUIRED_VARS) set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) if(${INDEX} EQUAL -1) set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) set(FPHSA_REQUIRED_VARS ${ARGN}) set(FPHSA_VERSION_VAR) else() CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) if(FPHSA_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") endif() if(NOT FPHSA_FAIL_MESSAGE) set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") endif() endif() # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") endif() # In config-mode, we rely on the variable _CONFIG, which is set by find_package() # when it successfully found the config-file, including version checking: if(FPHSA_CONFIG_MODE) list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) set(FPHSA_VERSION_VAR ${_NAME}_VERSION) endif() if(NOT FPHSA_REQUIRED_VARS) message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") endif() list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) string(TOUPPER ${_NAME} _NAME_UPPER) string(TOLOWER ${_NAME} _NAME_LOWER) if(FPHSA_FOUND_VAR) if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") set(_FOUND_VAR ${FPHSA_FOUND_VAR}) else() message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") endif() else() set(_FOUND_VAR ${_NAME_UPPER}_FOUND) endif() # collect all variables which were not found, so they can be printed, so the # user knows better what went wrong (#6375) set(MISSING_VARS "") set(DETAILS "") # check if all passed variables are valid set(FPHSA_FOUND_${_NAME} TRUE) foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) if(NOT ${_CURRENT_VAR}) set(FPHSA_FOUND_${_NAME} FALSE) set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") else() set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") endif() endforeach() if(FPHSA_FOUND_${_NAME}) set(${_NAME}_FOUND TRUE) set(${_NAME_UPPER}_FOUND TRUE) else() set(${_NAME}_FOUND FALSE) set(${_NAME_UPPER}_FOUND FALSE) endif() # component handling unset(FOUND_COMPONENTS_MSG) unset(MISSING_COMPONENTS_MSG) if(FPHSA_HANDLE_COMPONENTS) foreach(comp ${${_NAME}_FIND_COMPONENTS}) if(${_NAME}_${comp}_FOUND) if(NOT DEFINED FOUND_COMPONENTS_MSG) set(FOUND_COMPONENTS_MSG "found components: ") endif() set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") else() if(NOT DEFINED MISSING_COMPONENTS_MSG) set(MISSING_COMPONENTS_MSG "missing components: ") endif() set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") if(${_NAME}_FIND_REQUIRED_${comp}) set(${_NAME}_FOUND FALSE) set(MISSING_VARS "${MISSING_VARS} ${comp}") endif() endif() endforeach() set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") endif() # version handling: set(VERSION_MSG "") set(VERSION_OK TRUE) set(VERSION ${${FPHSA_VERSION_VAR}}) # check with DEFINED here as the requested or found version may be "0" if (DEFINED ${_NAME}_FIND_VERSION) if(DEFINED ${FPHSA_VERSION_VAR}) if(${_NAME}_FIND_VERSION_EXACT) # exact version required # count the dots in the version string string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}") # add one dot because there is one dot more than there are components string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT # is at most 4 here. Therefore a simple lookup table is used. if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) set(_VERSION_REGEX "[^.]*") elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) set(_VERSION_REGEX "[^.]*\\.[^.]*") elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") else () set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") endif () string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}") unset(_VERSION_REGEX) if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") set(VERSION_OK FALSE) else () set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") endif () unset(_VERSION_HEAD) else () if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION) set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") set(VERSION_OK FALSE) else () set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") endif () endif () unset(_VERSION_DOTS) else() # minimum version specified: if (${_NAME}_FIND_VERSION VERSION_GREATER VERSION) set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") set(VERSION_OK FALSE) else () set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") endif () endif() else() # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") else() set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") endif() endif() else () if(VERSION) set(VERSION_MSG "(found version \"${VERSION}\")") endif() endif () if(VERSION_OK) set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") else() set(${_NAME}_FOUND FALSE) endif() # print the result: if (${_NAME}_FOUND) FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") else () if(FPHSA_CONFIG_MODE) _FPHSA_HANDLE_FAILURE_CONFIG_MODE() else() if(NOT VERSION_OK) _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") else() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") endif() endif() endif () set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) endfunction() libfli-2.0+20221221182632/cmake_modules/FindOggTheora.cmake0000644000175100017510000000247214174600255021724 0ustar debiandebian# # Find the native Ogg/Theora includes and libraries # # This module defines # OGGTHEORA_INCLUDE_DIR, where to find ogg/ogg.h and theora/theora.h # OGGTHEORA_LIBRARIES, the libraries to link against to use Ogg/Theora. # OGGTHEORA_FOUND, If false, do not try to use Ogg/Theora. FIND_PATH(OGGTHEORA_ogg_INCLUDE_DIR ogg/ogg.h) FIND_PATH(OGGTHEORA_theora_INCLUDE_DIR theora/theora.h) FIND_LIBRARY(OGGTHEORA_ogg_LIBRARY ogg) FIND_LIBRARY(OGGTHEORA_theoraenc_LIBRARY theoraenc) FIND_LIBRARY(OGGTHEORA_theoradec_LIBRARY theoradec) SET(OGGTHEORA_INCLUDE_DIRS ${OGGTHEORA_ogg_INCLUDE_DIR} ${OGGTHEORA_theora_INCLUDE_DIR} ) #HACK multiple directories SET(OGGTHEORA_INCLUDE_DIR ${OGGTHEORA_INCLUDE_DIRS}) SET(OGGTHEORA_LIBRARIES ${OGGTHEORA_theoraenc_LIBRARY} ${OGGTHEORA_theoradec_LIBRARY} ${OGGTHEORA_ogg_LIBRARY} ) #HACK multiple libraries SET(OGGTHEORA_LIBRARY ${OGGTHEORA_LIBRARIES}) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGGTHEORA "Could NOT find the ogg and theora libraries" OGGTHEORA_ogg_LIBRARY OGGTHEORA_theoraenc_LIBRARY OGGTHEORA_theoradec_LIBRARY OGGTHEORA_ogg_INCLUDE_DIR OGGTHEORA_theora_INCLUDE_DIR ) MARK_AS_ADVANCED(OGGTHEORA_ogg_INCLUDE_DIR OGGTHEORA_theora_INCLUDE_DIR OGGTHEORA_ogg_LIBRARY OGGTHEORA_theoraenc_LIBRARY OGGTHEORA_theoradec_LIBRARY ) libfli-2.0+20221221182632/cmake_modules/FindMEADE.cmake0000644000175100017510000000247714174600255020665 0ustar debiandebian# - Try to find Meade DSI Library. # Once done this will define # # MEADEDSI_FOUND - system has Meade DSI # MEADEDSI_LIBRARIES - Link these to use Meade DSI # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (MEADEDSI_LIBRARIES) # in cache already set(MEADEDSI_FOUND TRUE) message(STATUS "Found MEADEDSI: ${MEADEDSI_LIBRARIES}") else (MEADEDSI_LIBRARIES) find_library(MEADEDSI_LIBRARIES NAMES dsi PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) set(CMAKE_REQUIRED_LIBRARIES ${MEADEDSI_LIBRARIES}) if(MEADEDSI_LIBRARIES) set(MEADEDSI_FOUND TRUE) else (MEADEDSI_LIBRARIES) set(MEADEDSI_FOUND FALSE) endif(MEADEDSI_LIBRARIES) if (MEADEDSI_FOUND) if (NOT MEADEDSI_FIND_QUIETLY) message(STATUS "Found Meade DSI: ${MEADEDSI_LIBRARIES}") endif (NOT MEADEDSI_FIND_QUIETLY) else (MEADEDSI_FOUND) if (MEADEDSI_FIND_REQUIRED) message(FATAL_ERROR "Meade DSI not found. Please install Meade DSI library. http://linuxdsi.sourceforge.net") endif (MEADEDSI_FIND_REQUIRED) endif (MEADEDSI_FOUND) mark_as_advanced(MEADEDSI_LIBRARIES) endif (MEADEDSI_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindTOUPCAM.cmake0000644000175100017510000000267614174600255021163 0ustar debiandebian# - Try to find Toupcam Camera Library # Once done this will define # # TOUPCAM_FOUND - system has Toupcam # TOUPCAM_INCLUDE_DIR - the Toupcam include directory # TOUPCAM_LIBRARIES - Link these to use Toupcam # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) # in cache already set(TOUPCAM_FOUND TRUE) message(STATUS "Found libsbig: ${TOUPCAM_LIBRARIES}") else (TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) find_path(TOUPCAM_INCLUDE_DIR toupcam.h PATH_SUFFIXES libtoupcam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(TOUPCAM_LIBRARIES NAMES toupcam PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) set(TOUPCAM_FOUND TRUE) else (TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) set(TOUPCAM_FOUND FALSE) endif(TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) if (TOUPCAM_FOUND) if (NOT TOUPCAM_FIND_QUIETLY) message(STATUS "Found Toupcam: ${TOUPCAM_LIBRARIES}") endif (NOT TOUPCAM_FIND_QUIETLY) else (TOUPCAM_FOUND) if (TOUPCAM_FIND_REQUIRED) message(FATAL_ERROR "Toupcam not found. Please install Toupcam Library http://www.indilib.org") endif (TOUPCAM_FIND_REQUIRED) endif (TOUPCAM_FOUND) mark_as_advanced(TOUPCAM_INCLUDE_DIR TOUPCAM_LIBRARIES) endif (TOUPCAM_INCLUDE_DIR AND TOUPCAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindQSI.cmake0000644000175100017510000000245514174600255020502 0ustar debiandebian# - Try to find Quantum Scientific Imaging Library # Once done this will define # # QSI_FOUND - system has QSI # QSI_INCLUDE_DIR - the QSI include directory # QSI_LIBRARIES - Link these to use QSI # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (QSI_INCLUDE_DIR AND QSI_LIBRARIES) # in cache already set(QSI_FOUND TRUE) message(STATUS "Found libqsiapi: ${QSI_LIBRARIES}") else (QSI_INCLUDE_DIR AND QSI_LIBRARIES) find_path(QSI_INCLUDE_DIR qsiapi.h PATH_SUFFIXES qsiapi ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(QSI_LIBRARIES NAMES qsiapi PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(QSI_INCLUDE_DIR AND QSI_LIBRARIES) set(QSI_FOUND TRUE) else (QSI_INCLUDE_DIR AND QSI_LIBRARIES) set(QSI_FOUND FALSE) endif(QSI_INCLUDE_DIR AND QSI_LIBRARIES) if (QSI_FOUND) if (NOT QSI_FIND_QUIETLY) message(STATUS "Found QSI: ${QSI_LIBRARIES}") endif (NOT QSI_FIND_QUIETLY) else (QSI_FOUND) if (QSI_FIND_REQUIRED) message(FATAL_ERROR "QSI not found. Please install libqsi http://www.indilib.org") endif (QSI_FIND_REQUIRED) endif (QSI_FOUND) mark_as_advanced(QSI_INCLUDE_DIR QSI_LIBRARIES) endif (QSI_INCLUDE_DIR AND QSI_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/UnityBuild.cmake0000644000175100017510000001627714174600255021344 0ustar debiandebian# # Copyright (c) 2009-2012 Christoph Heindl # Copyright (c) 2015 Csaba Kertész (csaba.kertesz@gmail.com) # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # MACRO (COMMIT_UNITY_FILE UNITY_FILE FILE_CONTENT) SET(DIRTY FALSE) # Check if the build file exists SET(OLD_FILE_CONTENT "") IF (NOT EXISTS ${${UNITY_FILE}} AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${${UNITY_FILE}}) SET(DIRTY TRUE) ELSE () # Check the file content FILE(STRINGS ${${UNITY_FILE}} OLD_FILE_CONTENT) STRING(REPLACE ";" "" OLD_FILE_CONTENT "${OLD_FILE_CONTENT}") STRING(REPLACE "\n" "" NEW_CONTENT "${${FILE_CONTENT}}") STRING(COMPARE EQUAL "${OLD_FILE_CONTENT}" "${NEW_CONTENT}" EQUAL_CHECK) IF (NOT EQUAL_CHECK EQUAL 1) SET(DIRTY TRUE) ENDIF () ENDIF () IF (DIRTY MATCHES TRUE) MESSAGE(STATUS "Write Unity Build file: " ${${UNITY_FILE}}) FILE(WRITE ${${UNITY_FILE}} "${${FILE_CONTENT}}") ENDIF () # Create a dummy copy of the unity file to trigger CMake reconfigure if it is deleted. SET(UNITY_FILE_PATH "") SET(UNITY_FILE_NAME "") GET_FILENAME_COMPONENT(UNITY_FILE_PATH ${${UNITY_FILE}} PATH) GET_FILENAME_COMPONENT(UNITY_FILE_NAME ${${UNITY_FILE}} NAME) CONFIGURE_FILE(${${UNITY_FILE}} ${UNITY_FILE_PATH}/CMakeFiles/${UNITY_FILE_NAME}.dummy) ENDMACRO () MACRO (ENABLE_UNITY_BUILD TARGET_NAME SOURCE_VARIABLE_NAME UNIT_SIZE EXTENSION) # Limit is zero based conversion of unit_size MATH(EXPR LIMIT ${UNIT_SIZE}-1) SET(FILES ${SOURCE_VARIABLE_NAME}) # Effectivly ignore the source files from the build, but keep track them for changes. SET_SOURCE_FILES_PROPERTIES(${${FILES}} PROPERTIES HEADER_FILE_ONLY true) # Counts the number of source files up to the threshold SET(COUNTER ${LIMIT}) # Have one or more unity build files SET(FILE_NUMBER 0) SET(BUILD_FILE "") SET(BUILD_FILE_CONTENT "") SET(UNITY_BUILD_FILES "") SET(_DEPS "") FOREACH (SOURCE_FILE ${${FILES}}) IF (COUNTER EQUAL LIMIT) SET(_DEPS "") # Write the actual Unity Build file IF (NOT ${BUILD_FILE} STREQUAL "" AND NOT ${BUILD_FILE_CONTENT} STREQUAL "") COMMIT_UNITY_FILE(BUILD_FILE BUILD_FILE_CONTENT) ENDIF () SET(UNITY_BUILD_FILES ${UNITY_BUILD_FILES} ${BUILD_FILE}) # Set the variables for the current Unity Build file SET(BUILD_FILE ${CMAKE_CURRENT_BINARY_DIR}/unitybuild_${FILE_NUMBER}_${TARGET_NAME}.${EXTENSION}) SET(BUILD_FILE_CONTENT "// Unity Build file generated by CMake\n") MATH(EXPR FILE_NUMBER ${FILE_NUMBER}+1) SET(COUNTER 0) ENDIF () # Add source path to the file name if it is not there yet. SET(FINAL_SOURCE_FILE "") SET(SOURCE_PATH "") GET_FILENAME_COMPONENT(SOURCE_PATH ${SOURCE_FILE} PATH) IF (SOURCE_PATH STREQUAL "" OR NOT EXISTS ${SOURCE_FILE}) SET(FINAL_SOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}) ELSE () SET(FINAL_SOURCE_FILE ${SOURCE_FILE}) ENDIF () # Treat only the existing files or moc_*.cpp files STRING(FIND ${SOURCE_FILE} "moc_" MOC_POS) IF (EXISTS ${FINAL_SOURCE_FILE} OR MOC_POS GREATER -1) # Add md5 hash of the source file (except moc files) to the build file content IF (MOC_POS LESS 0) SET(MD5_HASH "") FILE(MD5 ${FINAL_SOURCE_FILE} MD5_HASH) SET(BUILD_FILE_CONTENT "${BUILD_FILE_CONTENT}// md5: ${MD5_HASH}\n") ENDIF () # Add the source file to the build file content IF (MOC_POS GREATER -1) SET(BUILD_FILE_CONTENT "${BUILD_FILE_CONTENT}#include <${SOURCE_FILE}>\n") ELSE () SET(BUILD_FILE_CONTENT "${BUILD_FILE_CONTENT}#include <${FINAL_SOURCE_FILE}>\n") ENDIF () # Add the source dependencies to the Unity Build file GET_SOURCE_FILE_PROPERTY(_FILE_DEPS ${SOURCE_FILE} OBJECT_DEPENDS) IF (_FILE_DEPS) SET(_DEPS ${_DEPS} ${_FILE_DEPS}) SET_SOURCE_FILES_PROPERTIES(${BUILD_FILE} PROPERTIES OBJECT_DEPENDS "${_DEPS}") ENDIF() # Keep counting up to the threshold. Increment counter. MATH(EXPR COUNTER ${COUNTER}+1) ENDIF () ENDFOREACH () # Write out the last Unity Build file IF (NOT ${BUILD_FILE} STREQUAL "" AND NOT ${BUILD_FILE_CONTENT} STREQUAL "") COMMIT_UNITY_FILE(BUILD_FILE BUILD_FILE_CONTENT) ENDIF () SET(UNITY_BUILD_FILES ${UNITY_BUILD_FILES} ${BUILD_FILE}) SET(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${UNITY_BUILD_FILES}) ENDMACRO () MACRO (UNITY_GENERATE_MOC TARGET_NAME SOURCES HEADERS) SET(NEW_SOURCES "") FOREACH (HEADER_FILE ${${HEADERS}}) IF (NOT EXISTS ${HEADER_FILE}) MESSAGE(FATAL_ERROR "Header file does not exist (mocing): ${HEADER_FILE}") ENDIF () FILE(READ ${HEADER_FILE} FILE_CONTENT) STRING(FIND "${FILE_CONTENT}" "Q_OBJECT" QOBJECT_POS) STRING(FIND "${FILE_CONTENT}" "Q_SLOTS" QSLOTS_POS) STRING(FIND "${FILE_CONTENT}" "Q_SIGNALS" QSIGNALS_POS) STRING(FIND "${FILE_CONTENT}" "QObject" OBJECT_POS) STRING(FIND "${FILE_CONTENT}" "slots" SLOTS_POS) STRING(FIND "${FILE_CONTENT}" "signals" SIGNALS_POS) IF (QOBJECT_POS GREATER 0 OR OBJECT_POS GREATER 0 OR QSLOTS_POS GREATER 0 OR Q_SIGNALS GREATER 0 OR SLOTS_POS GREATER 0 OR SIGNALS GREATER 0) # Generate the moc filename GET_FILENAME_COMPONENT(HEADER_BASENAME ${HEADER_FILE} NAME_WE) SET(MOC_FILENAME "moc_${HEADER_BASENAME}.cpp") SET(NEW_SOURCES ${NEW_SOURCES} ; "${CMAKE_CURRENT_BINARY_DIR}/${MOC_FILENAME}") ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${MOC_FILENAME}" DEPENDS ${HEADER_FILE} COMMAND ${QT_MOC_EXECUTABLE} ${HEADER_FILE} -o "${CMAKE_CURRENT_BINARY_DIR}/${MOC_FILENAME}") ENDIF () ENDFOREACH () IF (NEW_SOURCES) SET_SOURCE_FILES_PROPERTIES(${NEW_SOURCES} PROPERTIES GENERATED TRUE) SET(${SOURCES} ${${SOURCES}} ; ${NEW_SOURCES}) ENDIF () ENDMACRO () libfli-2.0+20221221182632/cmake_modules/FindLibRaw.cmake0000644000175100017510000000562514174600255021230 0ustar debiandebian# - Find LibRaw # Find the LibRaw library # This module defines # LibRaw_VERSION_STRING, the version string of LibRaw # LibRaw_INCLUDE_DIR, where to find libraw.h # LibRaw_LIBRARIES, the libraries needed to use LibRaw (non-thread-safe) # LibRaw_r_LIBRARIES, the libraries needed to use LibRaw (thread-safe) # LibRaw_DEFINITIONS, the definitions needed to use LibRaw (non-thread-safe) # LibRaw_r_DEFINITIONS, the definitions needed to use LibRaw (thread-safe) # # Copyright (c) 2013, Pino Toscano # Copyright (c) 2013, Gilles Caulier # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. FIND_PACKAGE(PkgConfig) IF(PKG_CONFIG_FOUND) PKG_CHECK_MODULES(PC_LIBRAW libraw) SET(LibRaw_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER}) PKG_CHECK_MODULES(PC_LIBRAW_R libraw_r) SET(LibRaw_r_DEFINITIONS ${PC_LIBRAW_R_CFLAGS_OTHER}) ENDIF() FIND_PATH(LibRaw_INCLUDE_DIR libraw.h HINTS ${PC_LIBRAW_INCLUDEDIR} ${PC_LibRaw_INCLUDE_DIRS} PATH_SUFFIXES libraw ) FIND_LIBRARY(LibRaw_LIBRARIES NAMES raw HINTS ${PC_LIBRAW_LIBDIR} ${PC_LIBRAW_LIBRARY_DIRS} ) FIND_LIBRARY(LibRaw_r_LIBRARIES NAMES raw_r HINTS ${PC_LIBRAW_R_LIBDIR} ${PC_LIBRAW_R_LIBRARY_DIRS} ) IF(LibRaw_INCLUDE_DIR) FILE(READ ${LibRaw_INCLUDE_DIR}/libraw_version.h _libraw_version_content) STRING(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content}) SET(_libraw_version_major "${CMAKE_MATCH_1}") STRING(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content}) SET(_libraw_version_minor "${CMAKE_MATCH_1}") STRING(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content}) SET(_libraw_version_patch "${CMAKE_MATCH_1}") IF(_version_major_match AND _version_minor_match AND _version_patch_match) SET(LibRaw_VERSION_STRING "${_libraw_version_major}.${_libraw_version_minor}.${_libraw_version_patch}") ELSE() IF(NOT LibRaw_FIND_QUIETLY) MESSAGE(STATUS "Failed to get version information from ${LibRaw_INCLUDE_DIR}/libraw_version.h") ENDIF() ENDIF() ENDIF() INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibRaw REQUIRED_VARS LibRaw_LIBRARIES LibRaw_INCLUDE_DIR VERSION_VAR LibRaw_VERSION_STRING ) MARK_AS_ADVANCED(LibRaw_VERSION_STRING LibRaw_INCLUDE_DIR LibRaw_LIBRARIES LibRaw_r_LIBRARIES LibRaw_DEFINITIONS LibRaw_r_DEFINITIONS ) libfli-2.0+20221221182632/cmake_modules/FindALTAIRCAM.cmake0000644000175100017510000000301014174600255021327 0ustar debiandebian# - Try to find Altair Camera Library # Once done this will define # # ALTAIRCAM_FOUND - system has Altair # ALTAIRCAM_INCLUDE_DIR - the Altair include directory # ALTAIRCAM_LIBRARIES - Link these to use Altair # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) # in cache already set(ALTAIRCAM_FOUND TRUE) message(STATUS "Found libaltaircam: ${ALTAIRCAM_LIBRARIES}") else (ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) find_path(ALTAIRCAM_INCLUDE_DIR altaircam.h PATH_SUFFIXES libaltaircam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(ALTAIRCAM_LIBRARIES NAMES altaircam PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) set(ALTAIRCAM_FOUND TRUE) else (ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) set(ALTAIRCAM_FOUND FALSE) endif(ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) if (ALTAIRCAM_FOUND) if (NOT ALTAIRCAM_FIND_QUIETLY) message(STATUS "Found Altaircam: ${ALTAIRCAM_LIBRARIES}") endif (NOT ALTAIRCAM_FIND_QUIETLY) else (ALTAIRCAM_FOUND) if (ALTAIRCAM_FIND_REQUIRED) message(FATAL_ERROR "Altaircam not found. Please install Altaircam Library http://www.indilib.org") endif (ALTAIRCAM_FIND_REQUIRED) endif (ALTAIRCAM_FOUND) mark_as_advanced(ALTAIRCAM_INCLUDE_DIR ALTAIRCAM_LIBRARIES) endif (ALTAIRCAM_INCLUDE_DIR AND ALTAIRCAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindSBIG.cmake0000644000175100017510000000251214174600255020564 0ustar debiandebian# - Try to find SBIG Universal Library # Once done this will define # # SBIG_FOUND - system has SBIG # SBIG_INCLUDE_DIR - the SBIG include directory # SBIG_LIBRARIES - Link these to use SBIG # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) # in cache already set(SBIG_FOUND TRUE) message(STATUS "Found libsbig: ${SBIG_LIBRARIES}") else (SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) find_path(SBIG_INCLUDE_DIR sbigudrv.h PATH_SUFFIXES libsbig ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(SBIG_LIBRARIES NAMES sbig PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) set(SBIG_FOUND TRUE) else (SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) set(SBIG_FOUND FALSE) endif(SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) if (SBIG_FOUND) if (NOT SBIG_FIND_QUIETLY) message(STATUS "Found SBIG: ${SBIG_LIBRARIES}") endif (NOT SBIG_FIND_QUIETLY) else (SBIG_FOUND) if (SBIG_FIND_REQUIRED) message(FATAL_ERROR "SBIG not found. Please install SBIG Library http://www.indilib.org") endif (SBIG_FIND_REQUIRED) endif (SBIG_FOUND) mark_as_advanced(SBIG_INCLUDE_DIR SBIG_LIBRARIES) endif (SBIG_INCLUDE_DIR AND SBIG_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/CMakeParseArguments.cmake0000644000175100017510000000164214174600255023103 0ustar debiandebian#.rst: # CMakeParseArguments # ------------------- # # This module once implemented the :command:`cmake_parse_arguments` command # that is now implemented natively by CMake. It is now an empty placeholder # for compatibility with projects that include it to get the command from # CMake 3.4 and lower. #============================================================================= # Copyright 2010 Alexander Neundorf # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) libfli-2.0+20221221182632/cmake_modules/FindGPHOTO2.cmake0000644000175100017510000000562614174600255021133 0ustar debiandebian# - Find the native sqlite3 includes and library # # This module defines # GPHOTO2_INCLUDE_DIR, where to find libgphoto2 header files # GPHOTO2_LIBRARIES, the libraries to link against to use libgphoto2 # GPHOTO2_FOUND, If false, do not try to use libgphoto2. # GPHOTO2_VERSION_STRING, e.g. 2.4.14 # GPHOTO2_VERSION_MAJOR, e.g. 2 # GPHOTO2_VERSION_MINOR, e.g. 4 # GPHOTO2_VERSION_PATCH, e.g. 14 # # also defined, but not for general use are # GPHOTO2_LIBRARY, where to find the sqlite3 library. #============================================================================= # Copyright 2010 henrik andersson #============================================================================= SET(GPHOTO2_FIND_REQUIRED ${Gphoto2_FIND_REQUIRED}) find_path(GPHOTO2_INCLUDE_DIR gphoto2/gphoto2.h) mark_as_advanced(GPHOTO2_INCLUDE_DIR) set(GPHOTO2_NAMES ${GPHOTO2_NAMES} gphoto2 libgphoto2) set(GPHOTO2_PORT_NAMES ${GPHOTO2_PORT_NAMES} gphoto2_port libgphoto2_port) find_library(GPHOTO2_LIBRARY NAMES ${GPHOTO2_NAMES} ) find_library(GPHOTO2_PORT_LIBRARY NAMES ${GPHOTO2_PORT_NAMES} ) mark_as_advanced(GPHOTO2_LIBRARY) mark_as_advanced(GPHOTO2_PORT_LIBRARY) # Detect libgphoto2 version FIND_PROGRAM(GPHOTO2CONFIG_EXECUTABLE NAMES gphoto2-config) IF(GPHOTO2CONFIG_EXECUTABLE) EXEC_PROGRAM(${GPHOTO2CONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GPHOTO2_VERSION) string(REGEX REPLACE "^.*libgphoto2 ([0-9]+).*$" "\\1" GPHOTO2_VERSION_MAJOR "${GPHOTO2_VERSION}") string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_MINOR "${GPHOTO2_VERSION}") string(REGEX REPLACE "^.*libgphoto2 [0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GPHOTO2_VERSION_PATCH "${GPHOTO2_VERSION}") set(GPHOTO2_VERSION_STRING "${GPHOTO2_VERSION_MAJOR}.${GPHOTO2_VERSION_MINOR}.${GPHOTO2_VERSION_PATCH}") ENDIF(GPHOTO2CONFIG_EXECUTABLE) # handle the QUIETLY and REQUIRED arguments and set GPHOTO2_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GPHOTO2 DEFAULT_MSG GPHOTO2_LIBRARY GPHOTO2_INCLUDE_DIR) IF(GPHOTO2_FOUND) SET(Gphoto2_LIBRARIES ${GPHOTO2_LIBRARY} ${GPHOTO2_PORT_LIBRARY}) SET(Gphoto2_INCLUDE_DIRS ${GPHOTO2_INCLUDE_DIR}) # libgphoto2 dynamically loads and unloads usb library # without calling any cleanup functions (since they are absent from libusb-0.1). # This leaves usb event handling threads running with invalid callback and return addresses, # which causes a crash after any usb event is generated, at least in Mac OS X. # libusb1 backend does correctly call exit function, but ATM it crashes anyway. # Workaround is to link against libusb so that it wouldn't get unloaded. IF(APPLE) find_library(USB_LIBRARY NAMES usb-1.0 libusb-1.0) mark_as_advanced(USB_LIBRARY) IF(USB_LIBRARY) SET(Gphoto2_LIBRARIES ${Gphoto2_LIBRARIES} ${USB_LIBRARY}) ENDIF(USB_LIBRARY) ENDIF(APPLE) ENDIF(GPHOTO2_FOUND) libfli-2.0+20221221182632/cmake_modules/FindMMAL.cmake0000644000175100017510000000303214174600255020564 0ustar debiandebian# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # This module can find the MMAL camera libraries. # cmake_minimum_required(VERSION 3.0.0) set (MMAL_LIBS mmal_core mmal_util mmal_vc_client) set (EGL_LIBS brcmGLESv2 brcmEGL) foreach(lib ${MMAL_LIBS} ${EGL_LIBS} vcos bcm_host m dl) find_library(${lib}_LIBRARY NAMES ${lib} HINTS ${MMAL_DIR}/lib /opt/vc/lib ) if (DEFINED ${lib}_LIBRARY) set(MMAL_LIBRARIES ${MMAL_LIBRARIES} ${${lib}_LIBRARY}) else() message(FATAL_ERROR "Failed to find ${${lib}_LIBRARY} library") endif() endforeach(lib) find_path(BCM_INCLUDE_DIR NAMES bcm_host.h HINTS "/opt/vc/include" ) find_path(MMAL_BASE_INCLUDE_DIR NAMES mmal.h HINTS "/opt/vc/include/interface/mmal" ) find_path(MMAL_UTIL_INCLUDE_DIR NAMES mmal_util.h HINTS "/opt/vc/include/interface/mmal/util" ) if (MMAL_BASE_INCLUDE_DIR AND BCM_INCLUDE_DIR AND MMAL_UTIL_INCLUDE_DIR) set(MMAL_INCLUDE_DIR ${MMAL_BASE_INCLUDE_DIR} ${BCM_INCLUDE_DIR} ${MMAL_UTIL_INCLUDE_DIR}) set(MMAL_FOUND TRUE) endif() libfli-2.0+20221221182632/cmake_modules/FindAIOUSB.cmake0000644000175100017510000000371314174600255021026 0ustar debiandebian# - Try to find libaiousb # Once done this will define # # AIOUSB_FOUND - system has AIOUSB # AIOUSB_INCLUDE_DIR - the AIOUSB include directory # AIOUSB_LIBRARIES - Link these to use AIOUSB (C) # AIOUSB_CPP_LIBRARIES - Link these to use AIOUSB (C++) # Copyright (c) 2006, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) # in cache already set(AIOUSB_FOUND TRUE) message(STATUS "Found libaiusb: ${AIOUSB_LIBRARIES}") message(STATUS "Found libaiusbcpp: ${AIOUSB_CPP_LIBRARIES}") else (AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) find_path(AIOUSB_INCLUDE_DIR aiousb.h ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(AIOUSB_LIBRARIES NAMES aiousb PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(AIOUSB_CPP_LIBRARIES NAMES aiousbcpp PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) set(AIOUSB_FOUND TRUE) else (AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) set(AIOUSB_FOUND FALSE) endif(AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) if (AIOUSB_FOUND) if (NOT AIOUSB_FIND_QUIETLY) message(STATUS "Found libaiousb: ${AIOUSB_LIBRARIES}") message(STATUS "Found libaiusbcpp: ${AIOUSB_CPP_LIBRARIES}") endif (NOT AIOUSB_FIND_QUIETLY) else (AIOUSB_FOUND) if (AIOUSB_FIND_REQUIRED) message(FATAL_ERROR "libaiousb not found. Please install libaiousb. https://www.accesio.com") endif (AIOUSB_FIND_REQUIRED) endif (AIOUSB_FOUND) mark_as_advanced(AIOUSB_INCLUDE_DIR AIOUSB_LIBRARIES AIOUSB_CPP_LIBRARIES) endif (AIOUSB_INCLUDE_DIR AND AIOUSB_LIBRARIES AND AIOUSB_CPP_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindAPOGEE.cmake0000644000175100017510000000311514174600255021000 0ustar debiandebian# - Try to find Apogee Instruments Library # Once done this will define # # APOGEE_FOUND - system has APOGEE # APOGEE_INCLUDE_DIR - the APOGEE include directory # APOGEE_LIBRARY - Link these to use APOGEE # Copyright (c) 2008, Jasem Mutlaq # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) # in cache already set(APOGEE_FOUND TRUE) message(STATUS "Found libapogee: ${APOGEE_LIBRARY}") else (APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) find_path(APOGEE_INCLUDE_DIR ApogeeCam.h PATH_SUFFIXES libapogee ${_obIncDir} ${GNUWIN32_DIR}/include ) # Find Apogee Library find_library(APOGEE_LIBRARY NAMES apogee PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) set(APOGEE_FOUND TRUE) else (APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) set(APOGEE_FOUND FALSE) endif(APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) if (APOGEE_FOUND) if (NOT APOGEE_FIND_QUIETLY) message(STATUS "Found APOGEE: ${APOGEE_LIBRARY}") endif (NOT APOGEE_FIND_QUIETLY) else (APOGEE_FOUND) if (APOGEE_FIND_REQUIRED) message(FATAL_ERROR "libapogee not found. Cannot compile Apogee CCD Driver. Please install libapogee and try again. http://www.indilib.org") endif (APOGEE_FIND_REQUIRED) endif (APOGEE_FOUND) mark_as_advanced(APOGEE_INCLUDE_DIR APOGEE_LIBRARY) endif (APOGEE_INCLUDE_DIR AND APOGEE_LIBRARY) libfli-2.0+20221221182632/cmake_modules/FindFFmpeg.cmake0000644000175100017510000001615414243553447021222 0ustar debiandebian# - Try to find ffmpeg libraries (libavcodec, libavdevice, libavformat, libavutil, and libswscale) # Once done this will define # # FFMPEG_FOUND - system has ffmpeg or libav # FFMPEG_INCLUDE_DIR - the ffmpeg include directory # FFMPEG_LIBRARIES - Link these to use ffmpeg # FFMPEG_LIBAVCODEC # FFMPEG_LIBAVDEVICE # FFMPEG_LIBAVFORMAT # FFMPEG_LIBAVUTIL # FFMPEG_LIBSWSCALE # # Copyright (c) 2008 Andreas Schneider # Modified for other libraries by Lasse Kärkkäinen # Modified for Hedgewars by Stepik777 # Modified for INDILIB by rlancaste # # Redistribution and use is allowed according to the terms of the New # BSD license. # macro(_FFMPEG_PACKAGE_check_version) if(EXISTS "${PACKAGE_INCLUDE_DIR}/version.h") file(READ "${PACKAGE_INCLUDE_DIR}/version.h" _FFMPEG_PACKAGE_version_header) string(REGEX MATCH "#define ${PACKAGE_NAME}_VERSION_MAJOR[ \t]+([0-9]+)" _VERSION_MAJOR_match "${_FFMPEG_PACKAGE_version_header}") set(FFMPEG_PACKAGE_VERSION_MAJOR "${CMAKE_MATCH_1}") string(REGEX MATCH "#define ${PACKAGE_NAME}_VERSION_MINOR[ \t]+([0-9]+)" _VERSION_MINOR_match "${_FFMPEG_PACKAGE_version_header}") set(FFMPEG_PACKAGE_VERSION_MINOR "${CMAKE_MATCH_1}") string(REGEX MATCH "#define ${PACKAGE_NAME}_VERSION_MICRO[ \t]+([0-9]+)" _VERSION_MICRO_match "${_FFMPEG_PACKAGE_version_header}") set(FFMPEG_PACKAGE_VERSION_MICRO "${CMAKE_MATCH_1}") set(FFMPEG_PACKAGE_VERSION ${FFMPEG_PACKAGE_VERSION_MAJOR}.${FFMPEG_PACKAGE_VERSION_MINOR}.${FFMPEG_PACKAGE_VERSION_MICRO}) if(${FFMPEG_PACKAGE_VERSION} VERSION_LESS ${FFMPEG_PACKAGE_FIND_VERSION}) set(FFMPEG_PACKAGE_VERSION_OK FALSE) else(${FFMPEG_PACKAGE_VERSION} VERSION_LESS ${FFMPEG_PACKAGE_FIND_VERSION}) set(FFMPEG_PACKAGE_VERSION_OK TRUE) endif(${FFMPEG_PACKAGE_VERSION} VERSION_LESS ${FFMPEG_PACKAGE_FIND_VERSION}) if(NOT FFMPEG_PACKAGE_VERSION_OK) message(STATUS "${PACKAGE_NAME} version ${FFMPEG_PACKAGE_VERSION} found in ${PACKAGE_INCLUDE_DIR}, " "but at least version ${FFMPEG_PACKAGE_FIND_VERSION} is required") else(NOT FFMPEG_PACKAGE_VERSION_OK) mark_as_advanced(FFMPEG_PACKAGE_VERSION_MAJOR FFMPEG_PACKAGE_VERSION_MINOR FFMPEG_PACKAGE_VERSION_MICRO) endif(NOT FFMPEG_PACKAGE_VERSION_OK) else(EXISTS "${PACKAGE_INCLUDE_DIR}/version.h") set(FFMPEG_PACKAGE_VERSION_OK FALSE) message(STATUS "${PACKAGE_NAME}'s version.h file was not found in the include directory: ${PACKAGE_INCLUDE_DIR}, please install this program.") endif(EXISTS "${PACKAGE_INCLUDE_DIR}/version.h") endmacro(_FFMPEG_PACKAGE_check_version) # required ffmpeg library versions, Requiring at least FFMPEG 3.2.11, Hypatia set(_avcodec_ver ">=57.64.101") set(_avdevice_ver ">=57.1.100") set(_avformat_ver ">=57.56.100") set(_avutil_ver ">=55.34.100") set(_swscale_ver ">=4.2.100") if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) # in cache already set(FFMPEG_FOUND TRUE) else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_path(FFMPEG_INCLUDE_DIR NAMES libavcodec/avcodec.h PATHS ${FFMPEG_INCLUDE_DIRS} ${CMAKE_INSTALL_PREFIX}/include /usr/include /usr/local/include /opt/local/include /sw/include PATH_SUFFIXES ffmpeg libav ) find_package(PkgConfig) if (PKG_CONFIG_FOUND) pkg_check_modules(AVCODEC libavcodec${_avcodec_ver}) pkg_check_modules(AVDEVICE libavdevice${_avdevice_ver}) pkg_check_modules(AVFORMAT libavformat${_avformat_ver}) pkg_check_modules(AVUTIL libavutil${_avutil_ver}) pkg_check_modules(SWSCALE libswscale${_swscale_ver}) endif (PKG_CONFIG_FOUND) if (NOT PKG_CONFIG_FOUND OR NOT FFMPEG_LIBAVCODEC OR NOT FFMPEG_LIBAVDEVICE OR NOT FFMPEG_LIBAVFORMAT OR NOT FFMPEG_LIBAVUTIL OR NOT FFMPEG_LIBSWSCALE) # LIBAVCODEC set(PACKAGE_NAME "LIBAVCODEC") set(PACKAGE_INCLUDE_DIR "${FFMPEG_INCLUDE_DIR}/libavcodec") set(FFMPEG_PACKAGE_FIND_VERSION _avcodec_ver) _FFMPEG_PACKAGE_check_version() if(FFMPEG_PACKAGE_VERSION_OK) set(AVCODEC_VERSION FFMPEG_PACKAGE_VERSION) endif(FFMPEG_PACKAGE_VERSION_OK) # LIBAVDEVICE set(PACKAGE_NAME "LIBAVDEVICE") set(PACKAGE_INCLUDE_DIR "${FFMPEG_INCLUDE_DIR}/libavdevice") set(FFMPEG_PACKAGE_FIND_VERSION _avdevice_ver) _FFMPEG_PACKAGE_check_version() if(FFMPEG_PACKAGE_VERSION_OK) set(AVDEVICE_VERSION FFMPEG_PACKAGE_VERSION) endif(FFMPEG_PACKAGE_VERSION_OK) # LIBAVFORMAT set(PACKAGE_NAME "LIBAVFORMAT") set(PACKAGE_INCLUDE_DIR "${FFMPEG_INCLUDE_DIR}/libavformat") set(FFMPEG_PACKAGE_FIND_VERSION _avformat_ver) _FFMPEG_PACKAGE_check_version() if(FFMPEG_PACKAGE_VERSION_OK) set(AVFORMAT_VERSION FFMPEG_PACKAGE_VERSION) endif(FFMPEG_PACKAGE_VERSION_OK) # LIBAVUTIL set(PACKAGE_NAME "LIBAVUTIL") set(PACKAGE_INCLUDE_DIR "${FFMPEG_INCLUDE_DIR}/libavutil") set(FFMPEG_PACKAGE_FIND_VERSION _avutil_ver) _FFMPEG_PACKAGE_check_version() if(FFMPEG_PACKAGE_VERSION_OK) set(AVUTIL_VERSION FFMPEG_PACKAGE_VERSION) endif(FFMPEG_PACKAGE_VERSION_OK) # LIBSWSCALE set(PACKAGE_NAME "LIBSWSCALE") set(PACKAGE_INCLUDE_DIR "${FFMPEG_INCLUDE_DIR}/libswscale") set(FFMPEG_PACKAGE_FIND_VERSION _swscale_ver) _FFMPEG_PACKAGE_check_version() if(FFMPEG_PACKAGE_VERSION_OK) set(SWSCALE_VERSION FFMPEG_PACKAGE_VERSION) endif(FFMPEG_PACKAGE_VERSION_OK) endif () find_library(FFMPEG_LIBAVCODEC NAMES avcodec libavcodec PATHS ${AVCODEC_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) find_library(FFMPEG_LIBAVDEVICE NAMES avdevice libavdevice PATHS ${AVDEVICE_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) find_library(FFMPEG_LIBAVFORMAT NAMES avformat libavformat PATHS ${AVFORMAT_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) find_library(FFMPEG_LIBAVUTIL NAMES avutil libavutil PATHS ${AVUTIL_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) find_library(FFMPEG_LIBSWSCALE NAMES swscale libswscale PATHS ${SWSCALE_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX}/lib /usr/lib /usr/local/lib /opt/local/lib /sw/lib ) #Only set FFMPEG to found if all the libraries are found in the right versions. if(AVCODEC_VERSION AND AVDEVICE_VERSION AND AVFORMAT_VERSION AND AVUTIL_VERSION AND SWSCALE_VERSION AND FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVDEVICE AND FFMPEG_LIBAVFORMAT AND FFMPEG_LIBAVUTIL AND FFMPEG_LIBSWSCALE) set(FFMPEG_FOUND TRUE) endif() if (FFMPEG_FOUND) set(FFMPEG_LIBRARIES ${FFMPEG_LIBAVCODEC} ${FFMPEG_LIBAVDEVICE} ${FFMPEG_LIBAVFORMAT} ${FFMPEG_LIBAVUTIL} ${FFMPEG_LIBSWSCALE} ) endif (FFMPEG_FOUND) if (FFMPEG_FOUND) if (NOT FFMPEG_FIND_QUIETLY) message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}") endif (NOT FFMPEG_FIND_QUIETLY) else (FFMPEG_FOUND) message(STATUS "Could not find up to date FFMPEG for INDI Webcam. Up to date versions of these packages are required: libavcodec, libavdevice, libavformat, libavutil, and libswscale") if (FFMPEG_FIND_REQUIRED) message(FATAL_ERROR "Error: FFMPEG is required by this package!") endif (FFMPEG_FIND_REQUIRED) endif (FFMPEG_FOUND) endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) libfli-2.0+20221221182632/cmake_modules/FindNUTClient.cmake0000644000175100017510000000304014347562502021646 0ustar debiandebian# - Try to find nutclient library (version 2) and include files # Once done this will define # # NUTCLIENT_FOUND - system has NUTCLIENT # NUTCLIENT_INCLUDE_DIR - the NUTCLIENT include directory # NUTCLIENT_LIBRARIES - Link these to use NUTCLIENT # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) # in cache already set(NUTCLIENT_FOUND TRUE) message(STATUS "Found libnutclient: ${NUTCLIENT_LIBRARIES}") else (NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) find_path(NUTCLIENT_INCLUDE_DIR nutclient.h PATH_SUFFIXES nutclient ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(NUTCLIENT_LIBRARIES NAMES nutclient PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) set(NUTCLIENT_FOUND TRUE) else (NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) set(NUTCLIENT_FOUND FALSE) endif(NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) if (NUTCLIENT_FOUND) if (NOT NUTCLIENT_FIND_QUIETLY) message(STATUS "Found NUTCLIENT: ${NUTCLIENT_LIBRARIES}") endif (NOT NUTCLIENT_FIND_QUIETLY) else (NUTCLIENT_FOUND) if (NUTCLIENT_FIND_REQUIRED) message(FATAL_ERROR "NUTCLIENT not found. Please install libnutclient development package.") endif (NUTCLIENT_FIND_REQUIRED) endif (NUTCLIENT_FOUND) mark_as_advanced(NUTCLIENT_INCLUDE_DIR NUTCLIENT_LIBRARIES) endif (NUTCLIENT_INCLUDE_DIR AND NUTCLIENT_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindIconv.cmake0000644000175100017510000000426114174600255021121 0ustar debiandebian# # Copyright (C) 2010 Michael Bell # 2015-2016 MariaDB Corporation AB # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the COPYING-CMAKE-SCRIPTS file. # # ICONV_EXTERNAL - Iconv is an external library (not libc) # ICONV_FOUND - system has Iconv # ICONV_INCLUDE_DIR - the Iconv include directory # ICONV_LIBRARIES - Link these to use Iconv # ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const # ICONV_VERSION - Iconv version string if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) # Already in cache, be silent set(ICONV_FIND_QUIETLY TRUE) endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) find_path(ICONV_INCLUDE_DIR iconv.h) IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") # There is some libiconv.so in /usr/local that must # be avoided, iconv routines are in libc ELSEIF(APPLE) find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS /usr/lib/ NO_CMAKE_SYSTEM_PATH) SET(ICONV_EXTERNAL TRUE) ELSE() find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2) IF(ICONV_LIBRARIES) SET(ICONV_EXTERNAL TRUE) ENDIF() ENDIF() if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) set (ICONV_FOUND TRUE) endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) IF(ICONV_EXTERNAL) set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) ENDIF() if (ICONV_FOUND) include(CheckCSourceCompiles) CHECK_C_SOURCE_COMPILES(" #include int main(){ iconv_t conv = 0; const char* in = 0; size_t ilen = 0; char* out = 0; size_t olen = 0; iconv(conv, &in, &ilen, &out, &olen); return 0; } " ICONV_SECOND_ARGUMENT_IS_CONST ) endif (ICONV_FOUND) set (CMAKE_REQUIRED_INCLUDES) set (CMAKE_REQUIRED_LIBRARIES) if (ICONV_FOUND) if (NOT ICONV_FIND_QUIETLY) message (STATUS "Found Iconv: ${ICONV_LIBRARIES}") endif (NOT ICONV_FIND_QUIETLY) else (ICONV_FOUND) if (Iconv_FIND_REQUIRED) message (FATAL_ERROR "Could not find Iconv") endif (Iconv_FIND_REQUIRED) endif (ICONV_FOUND) MARK_AS_ADVANCED( ICONV_INCLUDE_DIR ICONV_LIBRARIES ICONV_EXTERNAL ICONV_SECOND_ARGUMENT_IS_CONST ) libfli-2.0+20221221182632/cmake_modules/FindLIMESUITE.cmake0000644000175100017510000000301214174600255021374 0ustar debiandebian# - Try to find LIMESUITE # Once done this will define # # LIMESUITE_FOUND - system has LIMESUITE # LIMESUITE_INCLUDE_DIR - the LIMESUITE include directory # LIMESUITE_LIBRARIES - Link these to use LIMESUITE # LIMESUITE_VERSION_STRING - Human readable version number of rtlsdr # LIMESUITE_VERSION_MAJOR - Major version number of rtlsdr # LIMESUITE_VERSION_MINOR - Minor version number of rtlsdr # Copyright (c) 2017, Ilia Platone, # Based on FindLibfacile by Carsten Niehaus, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (LIMESUITE_LIBRARIES) # in cache already set(LIMESUITE_FOUND TRUE) message(STATUS "Found LIMESUITE: ${LIMESUITE_LIBRARIES}") else (LIMESUITE_LIBRARIES) find_library(LIMESUITE_LIBRARIES NAMES LimeSuite PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib /usr/local/lib ) if(LIMESUITE_LIBRARIES) set(LIMESUITE_FOUND TRUE) else (LIMESUITE_LIBRARIES) set(LIMESUITE_FOUND FALSE) endif(LIMESUITE_LIBRARIES) if (LIMESUITE_FOUND) if (NOT LIMESUITE_FIND_QUIETLY) message(STATUS "Found LIMESUITE: ${LIMESUITE_LIBRARIES}") endif (NOT LIMESUITE_FIND_QUIETLY) else (LIMESUITE_FOUND) if (LIMESUITE_FIND_REQUIRED) message(FATAL_ERROR "LIMESUITE not found. Please install libLimeSuite-dev") endif (LIMESUITE_FIND_REQUIRED) endif (LIMESUITE_FOUND) mark_as_advanced(LIMESUITE_LIBRARIES) endif (LIMESUITE_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindOMEGONPROCAM.cmake0000644000175100017510000000323314247236061021730 0ustar debiandebian# - Try to find Omegon Pro Cam Camera Library # Once done this will define # # OMEGONPROCAM_FOUND - system has Omegon Pro Cam # OMEGONPROCAM_INCLUDE_DIR - the Omegon Pro Cam include directory # OMEGONPROCAM_LIBRARIES - Link these to use Omegon Pro Cam # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) # in cache already set(OMEGONPROCAM_FOUND TRUE) message(STATUS "Found libomegonprocam: ${OMEGONPROCAM_LIBRARIES}") else (OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) find_path(OMEGONPROCAM_INCLUDE_DIR omegonprocam.h PATH_SUFFIXES libomegonprocam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(OMEGONPROCAM_LIBRARIES NAMES omegonprocam PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) set(OMEGONPROCAM_FOUND TRUE) else (OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) set(OMEGONPROCAM_FOUND FALSE) endif(OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) if (OMEGONPROCAM_FOUND) if (NOT OMEGONPROCAM_FIND_QUIETLY) message(STATUS "Found OmegonProCam: ${OMEGONPROCAM_LIBRARIES}") endif (NOT OMEGONPROCAM_FIND_QUIETLY) else (OMEGONPROCAM_FOUND) if (OMEGONPROCAM_FIND_REQUIRED) message(FATAL_ERROR "OmegonProCam not found. Please install OmegonProCam Library http://www.indilib.org") endif (OMEGONPROCAM_FIND_REQUIRED) endif (OMEGONPROCAM_FOUND) mark_as_advanced(OMEGONPROCAM_INCLUDE_DIR OMEGONPROCAM_LIBRARIES) endif (OMEGONPROCAM_INCLUDE_DIR AND OMEGONPROCAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindPLAYERONE.cmake0000644000175100017510000000322114347562502021400 0ustar debiandebian# - Try to find PlayerOne Library # Once done this will define # # PLAYERONE_FOUND - system has PLAYERONE # PLAYERONE_INCLUDE_DIR - the PLAYERONE include directory # PLAYERONE_LIBRARIES - Link these to use ASI # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) # in cache already set(PLAYERONE_FOUND TRUE) message(STATUS "Found libplayerone: ${PLAYERONE_LIBRARIES}") else (PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) find_path(PLAYERONE_INCLUDE_DIR PlayerOneCamera.h PATH_SUFFIXES libplayerone ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(PLAYERONECAM_LIBRARIES NAMES PlayerOneCamera PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if (PLAYERONECAM_LIBRARIES) set(PLAYERONE_LIBRARIES ${PLAYERONECAM_LIBRARIES}) endif (PLAYERONECAM_LIBRARIES) if(PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) set(PLAYERONE_FOUND TRUE) else (PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) set(PLAYERONE_FOUND FALSE) endif(PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) if (PLAYERONE_FOUND) if (NOT PLAYERONE_FIND_QUIETLY) message(STATUS "Found PLAYERONE: ${PLAYERONE_LIBRARIES}") endif (NOT PLAYERONE_FIND_QUIETLY) else (PLAYERONE_FOUND) if (PLAYERONE_FIND_REQUIRED) message(FATAL_ERROR "PLAYERONE not found. Please install libPlayerOneCamera.3 http://www.indilib.org") endif (PLAYERONE_FIND_REQUIRED) endif (PLAYERONE_FOUND) mark_as_advanced(PLAYERONE_INCLUDE_DIR PLAYERONE_LIBRARIES) endif (PLAYERONE_INCLUDE_DIR AND PLAYERONE_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindLibCameraApps.cmake0000644000175100017510000000425114347562502022511 0ustar debiandebian# - Try to find LIBCAMERAAPPS Library # Once done this will define # # LIBCAMERAAPPS_FOUND - system has LIBCAMERAAPPS # LIBCAMERAAPPS_APPS - Link these to use Apps # LIBCAMERAAPPS_ENCODERS - Link these to use Encoders # LIBCAMERAAPPS_IMAGES - Link these to use Images # LIBCAMERAAPPS_OUTPUTS - Link these to use Outputs # LIBCAMERAAPPS_PREVIEW - Link these to use Preview # LIBCAMERAAPPS_POST - Link these to use Post Processing Stages # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (LIBCAMERAAPPS_APPS) # in cache already set(LIBCAMERAAPPS_FOUND TRUE) message(STATUS "Found LIBCAMERAAPPS: ${LIBCAMERAAPPS_APPS}") else (LIBCAMERAAPPS_APPS) find_library(LIBCAMERAAPPS_APPS NAMES camera_app PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(LIBCAMERAAPPS_ENCODERS NAMES encoders PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(LIBCAMERAAPPS_IMAGES NAMES images PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(LIBCAMERAAPPS_OUTPUTS NAMES outputs PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(LIBCAMERAAPPS_POST NAMES post_processing_stages PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) find_library(LIBCAMERAAPPS_PREVIEW NAMES preview PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(LIBCAMERAAPPS_APPS) set(LIBCAMERAAPPS_FOUND TRUE) else (LIBCAMERAAPPS_APPS) set(LIBCAMERAAPPS_FOUND FALSE) endif(LIBCAMERAAPPS_APPS) if (LIBCAMERAAPPS_FOUND) if (NOT LIBCAMERAAPPS_FIND_QUIETLY) message(STATUS "Found LIBCAMERAAPPS Library: ${LIBCAMERAAPPS_APPS}") endif (NOT LIBCAMERAAPPS_FIND_QUIETLY) else (LIBCAMERAAPPS_FOUND) if (LIBCAMERAAPPS_FIND_REQUIRED) message(FATAL_ERROR "LIBCAMERAAPPS Library not found. Please install libcamera-apps") endif (LIBCAMERAAPPS_FIND_REQUIRED) endif (LIBCAMERAAPPS_FOUND) mark_as_advanced(LIBCAMERAAPPS_APPS LIBCAMERAAPPS_ENCODERS LIBCAMERAAPPS_IMAGES LIBCAMERAAPPS_OUTPUTS LIBCAMERAAPPS_POST LIBCAMERAAPPS_PREVIEW) endif (LIBCAMERAAPPS_APPS) libfli-2.0+20221221182632/cmake_modules/FindNNCAM.cmake0000644000175100017510000000256314174600255020702 0ustar debiandebian# - Try to find NNCAM Camera Library # Once done this will define # # NNCAM_FOUND - system has Levenhuk # NNCAM_INCLUDE_DIR - the Levenhuk include directory # NNCAM_LIBRARIES - Link these to use Levenhuk # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. if (NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) # in cache already set(NNCAM_FOUND TRUE) message(STATUS "Found libnncam: ${NNCAM_LIBRARIES}") else (NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) find_path(NNCAM_INCLUDE_DIR nncam.h PATH_SUFFIXES libnncam ${_obIncDir} ${GNUWIN32_DIR}/include ) find_library(NNCAM_LIBRARIES NAMES nncam PATHS ${_obLinkDir} ${GNUWIN32_DIR}/lib ) if(NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) set(NNCAM_FOUND TRUE) else (NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) set(NNCAM_FOUND FALSE) endif(NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) if (NNCAM_FOUND) if (NOT NNCAM_FIND_QUIETLY) message(STATUS "Found NNCAM: ${NNCAM_LIBRARIES}") endif (NOT NNCAM_FIND_QUIETLY) else (NNCAM_FOUND) if (NNCAM_FIND_REQUIRED) message(FATAL_ERROR "NNCAM not found. Please install NNCAM Library http://www.indilib.org") endif (NNCAM_FIND_REQUIRED) endif (NNCAM_FOUND) mark_as_advanced(NNCAM_INCLUDE_DIR NNCAM_LIBRARIES) endif (NNCAM_INCLUDE_DIR AND NNCAM_LIBRARIES) libfli-2.0+20221221182632/cmake_modules/FindRT.cmake0000644000175100017510000000152514174600255020370 0ustar debiandebian# FindRT.cmake - Try to find the RT library # Once done this will define # # RT_FOUND - System has rt # RT_INCLUDE_DIR - The rt include directory # RT_LIBRARIES - The libraries needed to use rt # RT_DEFINITIONS - Compiler switches required for using rt # # Also creates an import target called RT::RT find_path (RT_INCLUDE_DIR NAMES time.h PATHS /usr /usr/local /opt PATH_SUFFIXES ) find_library(RT_LIBRARIES NAMES rt PATHS /usr /usr/local /opt ) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(rt DEFAULT_MSG RT_LIBRARIES RT_INCLUDE_DIR) mark_as_advanced(RT_INCLUDE_DIR RT_LIBRARIES) if (NOT TARGET RT::RT) add_library(RT::RT INTERFACE IMPORTED) set_target_properties(RT::RT PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${RT_INCLUDE_DIR} INTERFACE_LINK_LIBRARIES ${RT_LIBRARIES} ) endif()libfli-2.0+20221221182632/libfli-filter-focuser.h0000644000175100017510000000545414174600256017777 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _FLI_FILTER_FOCUSER_H_ #define _FLI_FILTER_FOCUSER_H_ #define FLI_FILTERPOSITION_HOME (-1) #define FLI_FILTERMAXWHEELS (4) /* Filter wheel and focuser parameters */ typedef struct _flifilterfocuserdata_t { long tableindex; long stepspersec; long currentslot; long numslots; long numtempsensors; long extent; long hwtype; long uselong; long activewheel; long numwheels; long numslotswheel[2]; char *nameinfobuf; } flifilterfocuserdata_t; typedef struct { int n_pos; int n_offset; int n_steps[32]; } wheeldata_t; long fli_filter_focuser_open(flidev_t dev); #define fli_filter_open fli_filter_focuser_open #define fli_focuser_open fli_filter_focuser_open long fli_filter_focuser_close(flidev_t dev); #define fli_filter_close fli_filter_focuser_close #define fli_focuser_close fli_filter_focuser_close long fli_filter_command(flidev_t dev, int cmd, int argc, ...); long fli_focuser_command(flidev_t dev, int cmd, int argc, ...); long fli_filter_focuser_probe(flidev_t dev); #endif /* _FLI_FILTER_FOCUSER_H_ */ libfli-2.0+20221221182632/libfli-raw.h0000644000175100017510000000371614174600256015636 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_RAW_H_ #define _LIBFLI_RAW_H_ long fli_raw_open(flidev_t dev); long fli_raw_close(flidev_t dev); long fli_raw_command(flidev_t dev, int cmd, int argc, ...); #endiflibfli-2.0+20221221182632/99-fli.rules0000644000175100017510000000013414174600256015511 0ustar debiandebian# All FLI Cameras and filter wheels SUBSYSTEMS=="usb", ATTRS{idVendor}=="0f18", MODE="0666" libfli-2.0+20221221182632/libfli-mem.h0000644000175100017510000000432414174600256015617 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_MEM_H_ #define _LIBFLI_MEM_H_ void *xmalloc(size_t size); void *xcalloc(size_t nmemb, size_t size); #ifdef __linux__ void *xmemalign(size_t alignment, size_t size); #endif /* __linux__ */ void xfree(void *ptr); void *xrealloc(void *ptr, size_t size); int xfree_all(void); char *xstrdup(const char *s); int xasprintf(char **strp, const char *fmt, ...); char *xstrndup(const char *s, size_t siz); #endif /* _LIBFLI_MEM_H_ */ libfli-2.0+20221221182632/CMakeLists.txt0000644000175100017510000000466314174600256016177 0ustar debiandebiancmake_minimum_required(VERSION 3.0) PROJECT(libfli CXX C) LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/") include(GNUInstallDirs) set(UDEVRULES_INSTALL_DIR "/lib/udev/rules.d" CACHE STRING "Base directory for udev rules") ADD_DEFINITIONS(-Wall -O2 -D__LIBUSB__) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") find_package(USB1 REQUIRED) find_package(INDI REQUIRED) #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") include_directories( ${INDI_INCLUDE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(unix) ## Some files like libnova.h and libusb.h are in in subdirectories of the include directory ## For the CMAKE Modules, they find the subdirectory, so then something like ln_types.h should be #include ln_types.h ## But some packages and drivers write their header files like this: #include libnova/ln_types.h ## On Linux, this is fine since the top include directory such as /usr/include is already included and therefore ## is resolved. But on Mac it its not already in the path and has to be explicitly added. if (APPLE) ##This one is needed for homebrew include_directories( "/usr/local/include") ## This one is needed for Craft include_directories("${CMAKE_INSTALL_PREFIX}/include") endif(APPLE) set(fli_LIB_SRCS libfli.c libfli-camera.c libfli-camera-parport.c libfli-camera-usb.c libfli-filter-focuser.c libfli-mem.c libfli-raw.c unix/libfli-usb.c unix/libfli-debug.c unix/libfli-serial.c unix/libfli-sys.c #unix/linux/libfli-usb-sys.c # LIBUSB support unix/libusb/libfli-usb-sys.c ) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") list(APPEND fli_LIB_SRCS unix/linux/libfli-parport.c) endif() #build a shared library ADD_LIBRARY(fli SHARED ${fli_LIB_SRCS}) set_target_properties(fli PROPERTIES VERSION 2.0 SOVERSION 2) #need to link to some other libraries ? just add them here TARGET_LINK_LIBRARIES(fli ${USB1_LIBRARIES} -lm -lpthread) #add an install target here INSTALL(FILES libfli.h DESTINATION include) INSTALL(TARGETS fli LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/99-fli.rules DESTINATION ${UDEVRULES_INSTALL_DIR}) endif() libfli-2.0+20221221182632/libfli-raw.c0000644000175100017510000000520014174600256015617 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-mem.h" #include "libfli-raw.h" #include "indimacros.h" long fli_raw_open(flidev_t dev) { INDI_UNUSED(dev); return 0; } long fli_raw_close(flidev_t dev) { if (DEVICE->devinfo.model != NULL) { xfree(DEVICE->devinfo.model); DEVICE->devinfo.model = NULL; } if (DEVICE->devinfo.devnam != NULL) { xfree(DEVICE->devinfo.devnam); DEVICE->devinfo.devnam = NULL; } if (DEVICE->device_data != NULL) { xfree(DEVICE->device_data); DEVICE->device_data = NULL; } return 0; } long fli_raw_command(flidev_t dev, int cmd, int argc, ...) { INDI_UNUSED(dev); INDI_UNUSED(cmd); INDI_UNUSED(argc); return -EINVAL; }libfli-2.0+20221221182632/libfli-camera.c0000644000175100017510000006455714174600256016302 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include "libfli-libfli.h" #include "libfli-debug.h" #include "libfli-mem.h" #include "libfli-camera.h" #include "libfli-camera-parport.h" #include "libfli-camera-usb.h" const fliccdinfo_t knowndev[] = { /* id model array_area visible_area */ {1, "KAF-0260C0-2", {{0, 0}, {534, 520}}, {{12, 4}, {524, 516}}, 1.0, 20.0, 20.0}, {2, "KAF-0400C0-2", {{0, 0}, {796, 520}}, {{14, 4}, {782, 516}}, 1.0, 20.0, 20.0}, {3, "KAF-1000C0-2", {{0, 0}, {1042, 1032}}, {{8, 4}, {1032, 1028}}, 1.0, 24.0, 24.0}, {4, "KAF-1300C0-2", {{0, 0}, {1304, 1028}}, {{4, 2}, {1284, 1026}}, 1.0, 20.0, 20.0}, {5, "KAF-1400C0-2", {{0, 0}, {1348, 1037}}, {{14,14}, {782, 526}}, 1.0, 20.0, 20.0}, {6, "KAF-1600C0-2", {{0, 0}, {1564, 1032}}, {{14, 4}, {1550, 1028}}, 1.0, 20.0, 20.0}, {7, "KAF-4200C0-2", {{0, 0}, {2060, 2048}}, {{25, 2}, {2057, 2046}}, 1.0, 20.0, 20.0}, {8, "SITe-502S", {{0, 0}, {527, 512}}, {{15, 0}, {527, 512}}, 1.0, 20.0, 20.0}, {9, "TK-1024", {{0, 0}, {1124, 1024}}, {{50, 0}, {1074, 1024}}, 1.0, 24.0, 24.0}, {10, "TK-512", {{0, 0}, {563, 512}}, {{51, 0}, {563, 512}}, 1.0, 24.0, 24.0}, {11, "SI-003A", {{0, 0}, {1056, 1024}}, {{16, 0}, {1040, 1024}}, 1.0, 24.0, 24.0}, {12, "KAF-6300", {{0, 0}, {3100, 2056}}, {{16, 4}, {3088, 2052}}, 1.0, 9.0, 9.0}, {13, "KAF-3200", {{0, 0}, {2267, 1510}}, {{46,34}, {2230, 1506}}, 1.0, 6.8, 6.8}, {14, "SI424A", {{0, 0}, {2088, 2049}}, {{20, 0}, {2068, 2049}}, 1.0, 6.8, 6.8}, {15, "CCD47-10", {{0, 0}, {1072, 1027}}, {{8, 0}, {1064, 1027}}, 0.0, 0.0, 0.0}, {16, "CCD77", {{0, 0}, {527, 512}}, {{15, 0}, {527, 512}}, 0.0, 0.0, 0.0}, {17, "CCD42-40", {{0, 0}, {2148, 2048}}, {{50, 0}, {2098, 2048}}, 1.0, 13.5, 13.5}, {18, "KAF-4300", {{0, 0}, {2102, 2092}}, {{8, 4}, {2092, 2088}}, 1.0, 24.0, 24.0}, {19, "KAF-16801", {{0, 0}, {4145, 4128}}, {{44,29}, {4124, 4109}}, 1.0, 9.0, 9.0}, {0, "Unknown Model", {{0, 0}, {0, 0}}, {{0, 0}, {0, 0}}, 0.0, 0.0, 0.0} }; /* Common camera routines */ static long fli_camera_get_pixel_size(flidev_t dev, double *pixel_x, double *pixel_y); #define fli_camera_parport_get_pixel_size fli_camera_get_pixel_size #define fli_camera_usb_get_pixel_size fli_camera_get_pixel_size static long fli_camera_set_frame_type(flidev_t dev, fliframe_t frametype); #define fli_camera_parport_set_frame_type fli_camera_set_frame_type #define fli_camera_usb_set_frame_type fli_camera_set_frame_type static long fli_camera_set_flushes(flidev_t dev, long nflushes); #define fli_camera_parport_set_flushes fli_camera_set_flushes #define fli_camera_usb_set_flushes fli_camera_set_flushes long fli_camera_open(flidev_t dev) { int r; CHKDEVICE(dev); if ((DEVICE->device_data = xcalloc(1, sizeof(flicamdata_t))) == NULL) return -ENOMEM; // load_camera_defaults(); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_open(dev); break; case FLIDOMAIN_USB: r = fli_camera_usb_open(dev); break; default: r = -EINVAL; } if (r) { xfree(DEVICE->device_data); DEVICE->device_data = NULL; } return r; } long fli_camera_close(flidev_t dev) { flicamdata_t *cam; CHKDEVICE(dev); cam = DEVICE->device_data; if (cam->gbuf != NULL) { xfree(cam->gbuf); cam->gbuf = NULL; } if (cam->ibuf != NULL) { xfree(cam->ibuf); cam->ibuf = NULL; } if (DEVICE->devinfo.model != NULL) { xfree(DEVICE->devinfo.model); DEVICE->devinfo.model = NULL; } if (DEVICE->devinfo.devnam != NULL) { xfree(DEVICE->devinfo.devnam); DEVICE->devinfo.devnam = NULL; } if (DEVICE->device_data != NULL) { xfree(DEVICE->device_data); DEVICE->device_data = NULL; } return 0; } long fli_camera_command(flidev_t dev, int cmd, int argc, ...) { long r = 0; va_list ap; va_start(ap, argc); CHKDEVICE(dev); switch (cmd) { case FLI_GET_PIXEL_SIZE: if (argc != 2) r = -EINVAL; else { double *pixel_x, *pixel_y; pixel_x = va_arg(ap, double *); pixel_y = va_arg(ap, double *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_pixel_size(dev, pixel_x, pixel_y); break; case FLIDOMAIN_USB: r = fli_camera_usb_get_pixel_size(dev, pixel_x, pixel_y); break; default: r = -EINVAL; } } break; case FLI_GET_ARRAY_AREA: if (argc != 4) r = -EINVAL; else { long *ul_x, *ul_y, *lr_x, *lr_y; ul_x = va_arg(ap, long *); ul_y = va_arg(ap, long *); lr_x = va_arg(ap, long *); lr_y = va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_array_area(dev, ul_x, ul_y, lr_x, lr_y); break; case FLIDOMAIN_USB: r = fli_camera_usb_get_array_area(dev, ul_x, ul_y, lr_x, lr_y); break; default: r = -EINVAL; } } break; case FLI_GET_VISIBLE_AREA: if (argc != 4) r = -EINVAL; else { long *ul_x, *ul_y, *lr_x, *lr_y; ul_x = va_arg(ap, long *); ul_y = va_arg(ap, long *); lr_x = va_arg(ap, long *); lr_y = va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_visible_area(dev, ul_x, ul_y, lr_x, lr_y); break; case FLIDOMAIN_USB: r = fli_camera_usb_get_visible_area(dev, ul_x, ul_y, lr_x, lr_y); break; default: r = -EINVAL; } } break; case FLI_SET_EXPOSURE_TIME: if (argc != 1) r = -EINVAL; else { unsigned long exptime; exptime = *va_arg(ap, unsigned long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_exposure_time(dev, exptime); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_exposure_time(dev, exptime); break; default: r = -EINVAL; } } break; case FLI_SET_IMAGE_AREA: if (argc != 4) r = -EINVAL; else { long ul_x, ul_y, lr_x, lr_y; ul_x = *va_arg(ap, long *); ul_y = *va_arg(ap, long *); lr_x = *va_arg(ap, long *); lr_y = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_image_area(dev, ul_x, ul_y, lr_x, lr_y); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_image_area(dev, ul_x, ul_y, lr_x, lr_y); break; default: r = -EINVAL; } } break; case FLI_SET_HBIN: if (argc != 1) r = -EINVAL; else { long hbin; hbin = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_hbin(dev, hbin); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_hbin(dev, hbin); break; default: r = -EINVAL; } } break; case FLI_SET_VBIN: if (argc != 1) r = -EINVAL; else { long vbin; vbin = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_vbin(dev, vbin); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_vbin(dev, vbin); break; default: r = -EINVAL; } } break; case FLI_SET_FRAME_TYPE: if (argc != 1) r = -EINVAL; else { long frametype; frametype = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_frame_type(dev, frametype); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_frame_type(dev, frametype); break; default: r = -EINVAL; } } break; case FLI_CANCEL_EXPOSURE: if (argc != 0) r = -EINVAL; else { flicamdata_t *cam; cam = DEVICE->device_data; cam->grabrowcount = 1; cam->grabrowcounttot = cam->grabrowcount; cam->grabrowindex = 0; cam->grabrowbatchsize = 1; cam->grabrowbufferindex = cam->grabrowcount; cam->flushcountbeforefirstrow = 0; cam->flushcountafterlastrow = 0; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = DEVICE->fli_command(dev, FLI_CONTROL_SHUTTER, (long) FLI_SHUTTER_CLOSE); break; case FLIDOMAIN_USB: r = fli_camera_usb_cancel_exposure(dev); break; default: r = -EINVAL; } } break; case FLI_GET_EXPOSURE_STATUS: if (argc != 1) r = -EINVAL; else { long *timeleft; timeleft = va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_exposure_status(dev, timeleft); break; case FLIDOMAIN_USB: r = fli_camera_usb_get_exposure_status(dev, timeleft); break; default: r = -EINVAL; } } break; case FLI_SET_FAN_SPEED: if (argc != 1) r = -EINVAL; else { long fan_speed; fan_speed = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_set_fan_speed(dev, fan_speed); break; default: r = -EINVAL; } } break; case FLI_SET_VERTICAL_TABLE_ENTRY: if (argc != 4) r = -EINVAL; else { long index; long height; long bin; long mode; index = *va_arg(ap, long *); height = *va_arg(ap, long *); bin = *va_arg(ap, long *); mode = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_set_vertical_table_entry(dev, index, height, bin, mode); break; default: r = -EINVAL; } } break; case FLI_ENABLE_VERTICAL_TABLE: if (argc != 3) r = -EINVAL; else { long width; long offset; long flags; width = *va_arg(ap, long *); offset = *va_arg(ap, long *); flags = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_enable_vertical_table(dev, width, offset, flags); break; default: r = -EINVAL; } } break; case FLI_GET_VERTICAL_TABLE_ENTRY: if (argc != 4) r = -EINVAL; else { long index; long *height; long *bin; long *mode; index = *va_arg(ap, long *); height = va_arg(ap, long *); bin = va_arg(ap, long *); mode = va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_get_vertical_table_entry(dev, index, height, bin, mode); break; default: r = -EINVAL; } } break; case FLI_SET_TEMPERATURE: if (argc != 1) r = -EINVAL; else { double temperature; temperature = *va_arg(ap, double *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_temperature(dev, temperature); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_temperature(dev, temperature); break; default: r = -EINVAL; } } break; case FLI_READ_TEMPERATURE: if (argc != 2) r = -EINVAL; else { double *temperature; flichannel_t channel; channel = va_arg(ap, flichannel_t); temperature = va_arg(ap, double *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_temperature(dev, temperature); break; case FLIDOMAIN_USB: r = fli_camera_usb_read_temperature(dev, channel, temperature); break; default: r = -EINVAL; } } break; case FLI_GET_TEMPERATURE: if (argc != 1) r = -EINVAL; else { double *temperature; temperature = va_arg(ap, double *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_get_temperature(dev, temperature); break; case FLIDOMAIN_USB: r = fli_camera_usb_get_temperature(dev, temperature); break; default: r = -EINVAL; } } break; case FLI_SET_TDI: if (argc != 2) r = -EINVAL; else { flitdirate_t rate; flitdiflags_t flags; rate = *va_arg(ap, flitdirate_t *); flags = *va_arg(ap, flitdiflags_t *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_set_tdi(dev, rate, flags); break; default: r = -EINVAL; } } break; case FLI_GRAB_ROW: if (argc != 2) r = -EINVAL; else { void *buf; size_t width; buf = va_arg(ap, void *); width = *va_arg(ap, size_t *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_grab_row(dev, buf, width); break; case FLIDOMAIN_USB: r = fli_camera_usb_grab_row(dev, buf, width); break; default: r = -EINVAL; } } break; case FLI_EXPOSE_FRAME: if (argc != 0) r = -EINVAL; else { switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_expose_frame(dev); break; case FLIDOMAIN_USB: r = fli_camera_usb_expose_frame(dev); break; default: r = -EINVAL; } } break; case FLI_START_VIDEO_MODE: if (argc != 0) r = -EINVAL; else { switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_start_video_mode(dev); break; default: r = -EINVAL; } } break; case FLI_STOP_VIDEO_MODE: if (argc != 0) r = -EINVAL; else { switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_stop_video_mode(dev); break; default: r = -EINVAL; } } break; case FLI_GRAB_VIDEO_FRAME: if (argc != 2) r = -EINVAL; else { void *buf; size_t size; buf = va_arg(ap, void *); size = *va_arg(ap, size_t *); switch (DEVICE->domain) { case FLIDOMAIN_USB: r = fli_camera_usb_grab_video_frame(dev, buf, size); break; default: r = -EINVAL; } } break; case FLI_FLUSH_ROWS: if (argc != 2) r = -EINVAL; else { long rows, repeat; rows = *va_arg(ap, long *); repeat = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_flush_rows(dev, rows, repeat); break; case FLIDOMAIN_USB: r = fli_camera_usb_flush_rows(dev, rows, repeat); break; default: r = -EINVAL; } } break; case FLI_SET_FLUSHES: if (argc != 1) r = -EINVAL; else { long nflushes; nflushes = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_flushes(dev, nflushes); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_flushes(dev, nflushes); break; default: r = -EINVAL; } } break; case FLI_SET_BIT_DEPTH: if (argc != 1) r = -EINVAL; else { flibitdepth_t bitdepth; bitdepth = *va_arg(ap, flibitdepth_t *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_set_bit_depth(dev, bitdepth); break; case FLIDOMAIN_USB: r = fli_camera_usb_set_bit_depth(dev, bitdepth); break; default: r = -EINVAL; } } break; case FLI_READ_IOPORT: if (argc != 1) r = -EINVAL; else { long *ioportset; ioportset = va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_read_ioport(dev, ioportset); break; case FLIDOMAIN_USB: r = fli_camera_usb_read_ioport(dev, ioportset); break; default: r = -EINVAL; } } break; case FLI_WRITE_IOPORT: if (argc != 1) r = -EINVAL; else { long ioportset; ioportset = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_write_ioport(dev, ioportset); break; case FLIDOMAIN_USB: r = fli_camera_usb_write_ioport(dev, ioportset); break; default: r = -EINVAL; } } break; case FLI_CONFIGURE_IOPORT: if (argc != 1) r = -EINVAL; else { long ioportset; ioportset = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_configure_ioport(dev, ioportset); break; case FLIDOMAIN_USB: r = fli_camera_usb_configure_ioport(dev, ioportset); break; default: r = -EINVAL; } } break; case FLI_GET_READOUT_DIMENSIONS: if (argc != 6) r = -EINVAL; else { long *width, *hoffset, *hbin, *height, *voffset, *vbin; flicamdata_t *cam = DEVICE->device_data; width = va_arg(ap, long *); hoffset = va_arg(ap, long *); hbin = va_arg(ap, long *); height = va_arg(ap, long *); voffset = va_arg(ap, long *); vbin = va_arg(ap, long *); if (width != NULL) *width = cam->image_area.lr.x - cam->image_area.ul.x; if (hoffset != NULL) *hoffset = cam->image_area.ul.x; if (hbin != NULL) *hbin = cam->hbin; if (height != NULL) *height = cam->image_area.lr.y - cam->image_area.ul.y; if (voffset != NULL) *voffset = cam->image_area.ul.y; if (vbin != NULL) *vbin = cam->vbin; r = 0; } break; case FLI_CONTROL_SHUTTER: if (argc != 1) r = -EINVAL; else { long shutter; flicamdata_t *cam; cam = DEVICE->device_data; shutter = *va_arg(ap, long *); if( (shutter & FLI_SHUTTER_EXTERNAL_TRIGGER_LOW) || (shutter & FLI_SHUTTER_EXTERNAL_TRIGGER_HIGH) || ((shutter & FLI_SHUTTER_EXTERNAL_EXPOSURE_CONTROL)) ) { debug(FLIDEBUG_INFO, "External trigger: %02x", shutter); cam->exttrigger = 1; cam->exttriggerpol = (shutter & FLI_SHUTTER_EXTERNAL_TRIGGER_LOW)?0:1; cam->extexposurectrl = (shutter & FLI_SHUTTER_EXTERNAL_EXPOSURE_CONTROL)?1:0; r = 0; } else { debug(FLIDEBUG_INFO, "No External trigger.\n"); cam->exttrigger = 0; cam->extexposurectrl = 0; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = fli_camera_parport_control_shutter(dev, shutter); break; case FLIDOMAIN_USB: r = fli_camera_usb_control_shutter(dev, shutter); break; default: r = -EINVAL; } } } break; case FLI_CONTROL_BGFLUSH: if (argc != 1) r = -EINVAL; else { long bgflush; flicamdata_t *cam; cam = DEVICE->device_data; bgflush = *va_arg(ap, long *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EFAULT; break; case FLIDOMAIN_USB: r = fli_camera_usb_control_bgflush(dev, bgflush); break; default: r = -EINVAL; } } break; case FLI_GET_COOLER_POWER: if (argc != 1) r = -EINVAL; else { double *cooler_power; cooler_power = va_arg(ap, double *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EINVAL; break; case FLIDOMAIN_USB: r = fli_camera_usb_get_cooler_power(dev, cooler_power); break; default: r = -EINVAL; } } break; case FLI_GET_STATUS: if (argc != 1) r = -EINVAL; else { long *camera_status; camera_status = va_arg(ap, long *); *camera_status = 0xffffffff; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = 0; break; case FLIDOMAIN_USB: r = fli_camera_usb_get_camera_status(dev, camera_status); break; default: r = -EINVAL; } } break; case FLI_GET_CAMERA_MODE: if (argc != 1) r = -EINVAL; else { flimode_t *camera_mode; camera_mode = va_arg(ap, flimode_t *); *camera_mode = 0; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = 0; break; case FLIDOMAIN_USB: r = fli_camera_usb_get_camera_mode(dev, camera_mode); break; default: r = -EINVAL; } } break; case FLI_SET_CAMERA_MODE: if (argc != 1) r = -EINVAL; else { flimode_t camera_mode; camera_mode = va_arg(ap, flimode_t); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = 0; break; case FLIDOMAIN_USB: r = fli_camera_usb_set_camera_mode(dev, camera_mode); break; default: r = -EINVAL; } } break; case FLI_GET_CAMERA_MODE_STRING: if (argc != 3) r = -EINVAL; else { flimode_t camera_mode; char *buf; size_t len; camera_mode = va_arg(ap, flimode_t); buf = va_arg(ap, char *); len = va_arg(ap, size_t); memset(buf, '\0', len); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: if (camera_mode == 0) { r = 0; strncpy(buf, "Default Mode", len - 1); } else { r = -EINVAL; } break; case FLIDOMAIN_USB: r = fli_camera_usb_get_camera_mode_string(dev, camera_mode, buf, len); break; default: r = -EINVAL; } } break; case FLI_TRIGGER_EXPOSURE: if (argc != 0) r = -EINVAL; else { switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EINVAL; break; case FLIDOMAIN_USB: r = fli_camera_usb_trigger_exposure(dev); break; default: r = -EINVAL; } } break; case FLI_END_EXPOSURE: if (argc != 0) r = -EINVAL; else { switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EINVAL; break; case FLIDOMAIN_USB: r = fli_camera_usb_end_exposure(dev); break; default: r = -EINVAL; } } break; case FLI_READ_EEPROM: if (argc != 4) r = -EINVAL; else { long loc; long address; long length; void *rbuf; loc = *va_arg(ap, long *); address = *va_arg(ap, long *); length = *va_arg(ap, long *); rbuf = va_arg(ap, void *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EINVAL; break; case FLIDOMAIN_USB: r = fli_camera_usb_read_eeprom(dev, loc, address, length, rbuf); break; default: r = -EINVAL; } } break; case FLI_WRITE_EEPROM: if (argc != 4) r = -EINVAL; else { long loc; long address; long length; void *rbuf; loc = *va_arg(ap, long *); address = *va_arg(ap, long *); length = *va_arg(ap, long *); rbuf = va_arg(ap, void *); switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: r = -EINVAL; break; case FLIDOMAIN_USB: r = fli_camera_usb_write_eeprom(dev, loc, address, length, rbuf); break; default: r = -EINVAL; } } break; default: r = -EINVAL; } va_end(ap); return r; } static long fli_camera_get_pixel_size(flidev_t dev, double *pixel_x, double *pixel_y) { flicamdata_t *cam; cam = DEVICE->device_data; *pixel_x = (double)cam->ccd.pixelwidth; *pixel_y = (double)cam->ccd.pixelheight; return 0; } static long fli_camera_set_frame_type(flidev_t dev, fliframe_t frametype) { flicamdata_t *cam; cam = DEVICE->device_data; if (frametype & 0xfff8) return -EINVAL; cam->frametype = frametype; return 0; } static long fli_camera_set_flushes(flidev_t dev, long nflushes) { flicamdata_t *cam; cam = DEVICE->device_data; if((nflushes < 0) || (nflushes > 16)) return -EINVAL; cam->flushes = nflushes; return 0; } libfli-2.0+20221221182632/windows/0000755000175100017510000000000014174600256015120 5ustar debiandebianlibfli-2.0+20221221182632/windows/libfli-usb.c0000644000175100017510000002112714174600256017317 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include "..\libfli-libfli.h" #include "..\libfli-debug.h" #include "libfli-sys.h" #include #include "libfli-usb.h" #include "stdio.h" static LARGE_INTEGER time = { -1 }; long usb_bulktransfer(flidev_t dev, int ep, void *buf, long *len) { #ifdef OLDUSBDRIVER // BULK_TRANSFER_CONTROL pipe = { (-1) }; ULONG pipe = (-1); int i; #else FLI_USB_EPIO epio; #endif unsigned long ioctl_code; int abort = 0, retries = 5; DWORD retval = 0; long tlen = 0, total = 0; #ifdef _DEBUG_IO LARGE_INTEGER btime, etime, freq; double dtime; #endif #ifdef OLDUSBDRIVER // for (i = 0; (pipe.pipeNum == (-1)) && (i < USB_MAX_PIPES); i++) for (i = 0; (pipe == (-1)) && (i < USB_MAX_PIPES); i++) { if (((fli_io_t *)DEVICE->io_data)->endpointlist[i] == ep) // pipe.pipeNum = i; pipe = i; } // if (pipe.pipeNum == (-1)) if (pipe == (-1)) { debug(FLIDEBUG_FAIL, "Requested endpoint 0x%02x not found.", ep); return -EIO; } #ifdef _DEBUG_IO // debug(FLIDEBUG_IO, "Got PIPE %d for endpoint 0x%02x.", pipe.pipeNum, ep); #endif if ((ep & 0x80) == 0) ioctl_code = IOCTL_BULK_WRITE; else ioctl_code = IOCTL_BULK_READ; #else if ((ep & 0x80) == 0) ioctl_code = IOCTL_BULK_WRITE; else ioctl_code = IOCTL_BULK_READ; epio.Endpoint = ep; epio.Timeout = 60000; #endif #ifdef _DEBUG_IO if ((ep & 0x80) == 0) { char dbuf[100], cbuf[10]; int i; snprintf(dbuf, 100, "IOW ep:%02x len:%04x : ", ep, *len); for(i = 0; i < (int) (*len < 24?*len:24); i++) { snprintf(cbuf, 10, "%02x ", ((unsigned char *) buf)[i]); strcat(dbuf, cbuf); } debug(FLIDEBUG_INFO, dbuf); } QueryPerformanceCounter(&btime); #endif /* _DEBUG_IO */ #define MOD_USB #ifdef MOD_USB while ( (total < *len) && (abort == 0) && (retries > 0)) { tlen = 0; #ifdef OLDUSBDRIVER retval = DeviceIoControl(((fli_io_t *)DEVICE->io_data)->fd, ioctl_code, &pipe, sizeof(pipe), (unsigned char *) buf + total, *len - total, &tlen, NULL); #else retval = DeviceIoControl(((fli_io_t *)DEVICE->io_data)->fd, ioctl_code, &epio, sizeof(epio), (unsigned char *) buf + total, *len - total, &tlen, NULL); #endif total += tlen; /* Update our length transferred */ /* Check for error status */ if (retval == 0) { debug(FLIDEBUG_FAIL, " Transfer failed, error: %d", GetLastError()); abort = 1; continue; } if (total < *len) /* We didn't transfer everything */ { DWORD urb_status = 0x00; DWORD iolen; DeviceIoControl(((fli_io_t *)DEVICE->io_data)->fd, IOCTL_GET_LAST_USBD_ERROR, NULL, 0, &urb_status, sizeof(urb_status), &iolen, NULL); debug(FLIDEBUG_WARN, "URB status:0x%08x ep:%02x t:%d l:%d ", urb_status, ep, total, *len); retries --; switch (urb_status) { case 0xC0000011: debug(FLIDEBUG_WARN, " USBD_STATUS_XACT_ERROR, retrying..."); OutputDebugString("\n"); Sleep(50); break; case 0xC0000012: debug(FLIDEBUG_WARN, " USBD_STATUS_BABBLE_DETECTED, retrying..."); OutputDebugString("\n"); Sleep(50); break; case 0x00000000: #ifdef BAD_CABLE_HACK if ( (total % 512) != 0) { char b[2048]; sprintf(b, "P:%d\n", 512 - (total % 512)); OutputDebugString(b); memset((unsigned char *) buf + total, 0x00, 512 - (total % 512)); total += 512 - (total % 512); } else #endif { abort = 1; } break; default: debug(FLIDEBUG_WARN, " aborting transfer..."); abort = 1; break; } } if (total != *len) { debug(FLIDEBUG_WARN, " I/O operation lengths differ, %04x (desired) != %04x (actual)", *len, tlen); } } tlen = total; #else if(*len > 0) { retval = DeviceIoControl(((fli_io_t *)DEVICE->io_data)->fd, ioctl_code, &pipe, sizeof(pipe), buf, *len, &tlen, NULL); } if (tlen != *len) { debug(FLIDEBUG_WARN, " I/O operation lengths differ, %04x (desired) != %04x (actual)", *len, tlen); } if (retval == 0) { unsigned long urb_status = 0x00; DWORD iolen, last; last = GetLastError(); retval = DeviceIoControl(((fli_io_t *)DEVICE->io_data)->fd, IOCTL_EZUSB_GET_LAST_ERROR, NULL, 0, &urb_status, sizeof(urb_status), &iolen, NULL); debug(FLIDEBUG_WARN, "Last Error: %d URB Status: %d", last, urb_status); } #endif #ifdef _DEBUG_IO QueryPerformanceCounter(&etime); QueryPerformanceFrequency(&freq); if ((ep & 0x80) != 0) { char dbuf[100], cbuf[10]; int i; snprintf(dbuf, 100, "IOR ep:%02x len:%04x : ", ep, *len); for(i = 0; i < (int) (*len < 16?*len:16); i++) { snprintf(cbuf, 10, "%02x ", ((unsigned char *) buf)[i]); strcat(dbuf, cbuf); } debug(FLIDEBUG_INFO, dbuf); } dtime = ((double) etime.QuadPart - (double) btime.QuadPart ) / (double) freq.QuadPart; debug(FLIDEBUG_INFO, " ret:%02x len:%04x dtime:%09.6f", retval, tlen, dtime); #endif /* _DEBUG_IO */ *len = tlen; return ((retval == 0) || (retries <= 0))?-EIO:0; } long usbio(flidev_t dev, void *buf, long *wlen, long *rlen) { int err = 0, locked = 0, epread = 0, epwrite = 0; long org_wlen = *wlen, org_rlen = *rlen; if ((err = fli_lock(dev))) { debug(FLIDEBUG_WARN, "Lock failed"); goto done; } locked = 1; /* Determine which endpoint we should be using */ switch (DEVICE->devinfo.devid) { case FLIUSB_FILTER_ID: case FLIUSB_FOCUSER_ID: case FLIUSB_CAM_ID: epwrite = 0x02; epread = 0x82; break; case FLIUSB_PROLINE_ID: epwrite = 0x01; epread = 0x81; break; default: debug(FLIDEBUG_FAIL, "Unknown device type."); return -EINVAL; } if (*wlen > 0) { if (err = usb_bulktransfer(dev, epwrite, buf, wlen)) { debug(FLIDEBUG_WARN, "Bulkwrite failed, only %d of %d bytes written", *wlen, org_wlen); goto done; } } if (*rlen > 0) { if (err = usb_bulktransfer(dev, epread, buf, rlen)) { debug(FLIDEBUG_WARN, "Bulkread failed, only %d of %d bytes read", *rlen, org_rlen); goto done; } } done: if (locked) { int r; if ((r = fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/windows/libfli-windows-parport.c0000644000175100017510000003043414174600256021706 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include //#include #include "../libfli-libfli.h" #include "../libfli-debug.h" #include "../libfli-camera.h" #pragma intrinsic(_inp,_inpw,_inpd,_outp,_outpw,_outpd) #define CCDPAR_TYPE ((ULONG) 43000) #define CCDPAR_IOCTL_BASE ((USHORT) 2833) #define IOCTL_SET_READ_TIMEOUT CTL_CODE(CCDPAR_TYPE, CCDPAR_IOCTL_BASE+1, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_SET_WRITE_TIMEOUT CTL_CODE(CCDPAR_TYPE, CCDPAR_IOCTL_BASE+2, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_SET_DIRECTION_TIMEOUT CTL_CODE(CCDPAR_TYPE, CCDPAR_IOCTL_BASE+3, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_GET_TIMEOUT_COUNT CTL_CODE(CCDPAR_TYPE, CCDPAR_IOCTL_BASE+4, METHOD_BUFFERED, FILE_ANY_ACCESS) #define DPORT (io->port+0x000) /* Data port */ #define SPORT (io->port+0x001) #define CPORT (io->port+0x002) #define FPORT (io->port+0x400) #define BPORT (io->port+0x401) #define EPORT (io->port+0x402) #define DIR_FORWARD 0x01 #define DIR_REVERSE 0x02 #define C2 0x04 /* Bit 2 on the control port */ #define S5 0x20 /* Bit 5 on the status port */ #define S3 0x08 /* Bit 3 on the status port */ #define C5 0x20 /* Bit 5 on the control port */ static long ECPSetReverse(flidev_t dev) { unsigned char byte; long timeout; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; if(io->dir == DIR_REVERSE) return 0; byte = _inp(EPORT); /* Switch to PS/2 mode */ byte &= ~0xe0; byte |= 0x20; _outp(EPORT, byte); /* Set reverse mode */ byte = _inp(CPORT); byte |= C5; /* Program for input */ _outp(CPORT, byte); byte &= ~C2; /* Assert nReverseReq */ if(io->notecp > 0) byte |= 0x02; _outp(CPORT, byte); timeout = 0; while((_inp(SPORT) & S5) > 0) /* Wait for nAckReverse */ { timeout++; if(timeout > cam->dirto) { debug(FLIDEBUG_FAIL, "ECP: Write timeout during reverse."); return -EIO; } } byte = _inp(EPORT); /* Switch to ECP mode */ byte &= ~0xe0; if(io->notecp > 0) byte |= 0x20; else byte |= 0x60; _outp(EPORT, byte); io->dir = DIR_REVERSE; /* We are now set in reverse transfer mode */ return 0; } long ECPReadByte(flidev_t dev, unsigned char *byte, unsigned long *timeout) { unsigned char pdata; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; if(ECPSetReverse(dev) != 0) { return -EIO; } if(io->notecp > 0) { pdata = _inp(CPORT); while((_inp(SPORT) & 0x40) > 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Timeout during read."); return -EIO; } (*timeout)--; } *byte = _inp(DPORT); pdata &= ~0x02; outp(CPORT,pdata); while((_inp(SPORT) & 0x40) == 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Timeout during read."); return -EIO; } (*timeout)--; } pdata |= 0x02; outp(CPORT,pdata); } else { while(((pdata = _inp(EPORT)) & 0x01) > 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Timeout during read."); return -EIO; } (*timeout)--; } *byte = _inp(FPORT); } return 0; } long ECPReadWord(flidev_t dev, unsigned short *word, unsigned long *timeout) { unsigned char byte; if(ECPReadByte(dev, &byte, timeout) != 0) { debug(FLIDEBUG_FAIL, "ECP: Error during read (high byte)."); return -EIO; } *word = (unsigned short) byte; if(ECPReadByte(dev, &byte, timeout) != 0) { debug(FLIDEBUG_FAIL, "ECP: Error during read (low byte)."); return -EIO; } *word += (byte << 8); return 0; } static long ECPSetForward(flidev_t dev) { unsigned char byte; long timeout; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; if(io->dir == DIR_FORWARD) return 0; byte = _inp(EPORT); /* Switch to PS/2 mode */ byte &= ~0xe0; byte |= 0x20; _outp(EPORT, byte); /* Switch to forward mode */ byte = _inp(CPORT); byte |= C2; /* Deassert nReverseReq */ if(io->notecp > 0) byte &= ~0x03; _outp(CPORT, byte); timeout=0; while((_inp(SPORT) & S5) == 0) /* Wait for nAckReverse */ { timeout++; if(timeout > cam->dirto) { debug(FLIDEBUG_FAIL, "ECP: Error setting forward direction."); return -EIO; } } byte &= ~C5; /* Set for forward transfers */ _outp(CPORT, byte); byte=_inp(EPORT); /* Switch back to ECP mode */ byte &= ~0xe0; if(io->notecp > 0) byte |= 0x20; else byte |= 0x60; _outp(EPORT, byte); io->dir = DIR_FORWARD; return 0; } long ECPWriteByte(flidev_t dev, unsigned char byte, unsigned long *timeout) { unsigned char pdata; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; if (ECPSetForward(dev) != 0) { return -EIO; } if (io->notecp == TRUE) { outp(DPORT,byte); pdata = _inp(CPORT); pdata |= 0x01; outp(CPORT,pdata); while((_inp(SPORT) & 0x80) > 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Write Timeout."); return -EIO; } (*timeout)--; } pdata &= ~0x01; outp(CPORT,pdata); while((_inp(SPORT) & 0x80) == 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Write Timeout."); return -EIO; } (*timeout)--; } } else { outp(FPORT, byte); /* Check FIFO status */ while((_inp(EPORT) & 0x01) == 0) { if((*timeout) == 0) { debug(FLIDEBUG_FAIL, "ECP: Write Timeout."); return -EIO; } (*timeout)--; } } return 0; } long ECPWrite(flidev_t dev, void *buffer, long length) { int i = 0; long retval = 0; unsigned long to; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; fli_sysinfo_t *sys= DEVICE->sys_data; if(length == 0) return 0; debug(FLIDEBUG_INFO, "Write: %02x [%02x %02x]", length, ((unsigned char *) buffer)[0], ((unsigned char *) buffer)[1]); if(sys->OS == VER_PLATFORM_WIN32_NT) { if(WriteFile(io->fd, buffer, length, &retval, NULL) == FALSE) { debug(FLIDEBUG_WARN, "Write failed: %d", GetLastError()); } } else { while(i < length) { to = cam->writeto; if((retval = ECPWriteByte(dev, ((unsigned char *) buffer)[i], &to)) != 0) { debug(FLIDEBUG_FAIL, "ECP: Error during write."); break; } i++; } retval = i; } return retval; } long ECPWriteWord(flidev_t dev, unsigned short word, unsigned long *timeout) { if(ECPWriteByte(dev, (unsigned char) (word & 0x00ff), timeout)==FALSE) { debug(FLIDEBUG_FAIL, "ECP: Write timeout on low byte."); return -EIO; } if(ECPWriteByte(dev, (unsigned char) (word >> 8), timeout)==FALSE) { debug(FLIDEBUG_FAIL, "ECP: Write timeout on high byte."); return -EIO; } return 0; } long ECPRead(flidev_t dev, void *buffer, long length) { int i = 0; DWORD retval = 0; unsigned long to; fli_io_t *io = DEVICE->io_data; flicamdata_t *cam = DEVICE->device_data; fli_sysinfo_t *sys= DEVICE->sys_data; if (length == 0) return 0; debug(FLIDEBUG_INFO, " Read: %02x", length); if(sys->OS == VER_PLATFORM_WIN32_NT) { if(ReadFile(io->fd, buffer, length, &retval, NULL) == FALSE) { debug(FLIDEBUG_WARN, "Read failed: %d", GetLastError()); } debug(FLIDEBUG_INFO, " Read: %02x [%02x %02x]", retval, ((unsigned char *) buffer)[0], ((unsigned char *) buffer)[1]); } else { while(i < length) { to = cam->readto; if((retval = ECPReadByte(dev, &((unsigned char *) buffer)[i], &to)) != 0) { debug(FLIDEBUG_FAIL, "ECP: Error during read."); break; } i++; } retval = i; } return retval; } long ECPInit(flidev_t dev) { fli_io_t *io = DEVICE->io_data; fli_sysinfo_t *sys= DEVICE->sys_data; long retval = 0; if(sys->OS == VER_PLATFORM_WIN32_NT) { } else { if (io->port == 0) { retval = -EINVAL; } else { io->dir = 0; io->notecp = 0; /* Let's Preserve the context */ io->portval[0]=_inp(DPORT); io->portval[1]=_inp(SPORT); io->portval[2]=_inp(CPORT); io->portval[3]=_inp(FPORT); io->portval[4]=_inp(BPORT); io->portval[5]=_inp(EPORT); /* Enable the ECP port */ _outp(CPORT, 0x00); _outp(EPORT, 0x24); /* Select ECP mode */ retval = ECPSetForward(dev); } } return retval; } long ECPClose(flidev_t dev) { fli_io_t *io = DEVICE->io_data; fli_sysinfo_t *sys = DEVICE->sys_data; long retval = 0; if(sys->OS == VER_PLATFORM_WIN32_NT) { } else { _outp(EPORT, io->portval[5]); _outp(BPORT, io->portval[4]); _outp(FPORT, io->portval[3]); _outp(CPORT, io->portval[2]); _outp(SPORT, io->portval[1]); _outp(DPORT, io->portval[0]); } return retval; } long parportio(flidev_t dev, void *buf, long *wlen, long *rlen) { fli_io_t *io; flicamdata_t *cam; fli_sysinfo_t *sys; int err = 0, locked = 0; long org_wlen = *wlen, org_rlen = *rlen; unsigned long rto, dto, wto; DWORD bytes; io = DEVICE->io_data; cam = DEVICE->device_data; sys = DEVICE->sys_data; rto = cam->readto; wto = cam->writeto; dto = cam->dirto; if ((err = fli_lock(dev))) { debug(FLIDEBUG_WARN, "Lock failed"); goto done; } locked = 1; if (sys->OS == VER_PLATFORM_WIN32_NT) { if (DeviceIoControl(io->fd, IOCTL_SET_WRITE_TIMEOUT, &wto, sizeof(unsigned long), NULL, 0, &bytes, NULL) == FALSE) { err = -EIO; goto done; } if (DeviceIoControl(io->fd, IOCTL_SET_DIRECTION_TIMEOUT, &dto, sizeof(unsigned long), NULL, 0, &bytes, NULL) == FALSE) { err = -EIO; goto done; } // rto = 1000000; if (DeviceIoControl(io->fd, IOCTL_SET_READ_TIMEOUT, &rto, sizeof(unsigned long), NULL, 0, &bytes, NULL) == FALSE) { err = -EIO; goto done; } } if (*wlen > 0) { if ((*wlen = ECPWrite(dev, buf, *wlen)) != org_wlen) { debug(FLIDEBUG_WARN, "write failed, only %d of %d bytes written", *wlen, org_wlen); err = -EIO; goto done; } } if (*rlen > 0) { if ((*rlen = ECPRead(dev, buf, *rlen)) != org_rlen) { debug(FLIDEBUG_WARN, "read failed, only %d of %d bytes read", *rlen, org_rlen); err = -EIO; goto done; } } done: if (locked) { int r; if ((r = fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/windows/libfli-serial.c0000644000175100017510000000735314174600256020012 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include "..\libfli-libfli.h" #include "..\libfli-debug.h" #include "libfli-sys.h" #include "libfli-serial.h" long serportio(flidev_t dev, void *buf, long *wlen, long *rlen) { fli_io_t *io; fli_sysinfo_t *sys; int err = 0, locked = 0; long org_wlen = *wlen, org_rlen = *rlen; COMMTIMEOUTS CommTimeout; io = DEVICE->io_data; // cam = DEVICE->device_data; sys = DEVICE->sys_data; locked = 1; if (fli_lock(dev)) { debug(FLIDEBUG_WARN, "Could not lock device"); locked = 0; } CommTimeout.ReadIntervalTimeout = 100; CommTimeout.ReadTotalTimeoutConstant = DEVICE->io_timeout; CommTimeout.ReadTotalTimeoutMultiplier = 1; // 1 unit per character CommTimeout.WriteTotalTimeoutConstant = 0; CommTimeout.WriteTotalTimeoutMultiplier = 0; if(SetCommTimeouts(io->fd, &CommTimeout) == FALSE) { debug(FLIDEBUG_WARN, "Error setting communications timeouts, %d", GetLastError()); } if (*wlen > 0) { debug(FLIDEBUG_INFO, "SER IOW: %02x [%02x %02x]", *wlen, ((unsigned char *) buf)[0], ((unsigned char *) buf)[1]); WriteFile(io->fd, buf, *wlen, wlen, NULL); if (*wlen != org_wlen) { debug(FLIDEBUG_WARN, "write failed, only %d of %d bytes written", *wlen, org_wlen); err = -EIO; goto done; } } if (*rlen > 0) { if(ReadFile(io->fd, buf, *rlen, rlen, NULL) != TRUE) { debug(FLIDEBUG_WARN, "read failed."); err = -EIO; goto done; } debug(FLIDEBUG_INFO, "SER IOR: %02x [%02x %02x]", *wlen, ((unsigned char *) buf)[0], ((unsigned char *) buf)[1]); if (*rlen != org_rlen) { debug(FLIDEBUG_WARN, "read failed, only %d of %d bytes read", *rlen, org_rlen); err = -EIO; goto done; } } done: if (locked) { int r; if ((r = fli_unlock(dev))) debug(FLIDEBUG_WARN, "Unlock failed"); if (err == 0) err = r; } return err; } libfli-2.0+20221221182632/windows/libfli-serial.h0000644000175100017510000000366014174600256020014 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_SERIAL_H_ #define _LIBFLI_SERIAL_H_ long serportio(flidev_t dev, void *buf, long *wlen, long *rlen); #endif /* _LIBFLI_SERIAL_H_ */ libfli-2.0+20221221182632/windows/libfli-sys.h0000644000175100017510000000527214174600256017354 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_SYSDEP_H #define _LIBFLI_SYSDEP_H #include #include #ifndef LIBFLIAPI #define LIBFLIAPI __declspec(dllimport) long __stdcall #endif /* LIBFLIAPI */ #define __SYSNAME__ "Windows" #define __LIBFLI_MINOR__ 104 #define snprintf _snprintf #define USB_READ_SIZ_MAX (65535) #define USB_MAX_PIPES (10) #ifndef EOVERFLOW #define EOVERFLOW ERROR_INSUFFICIENT_BUFFER #endif typedef struct { HANDLE fd; int port; int dir; int notecp; char portval[6]; /* This is used to map and endpoint to a pipe */ int endpointlist[USB_MAX_PIPES]; } fli_io_t; /* System specific information */ typedef struct { HANDLE mutex; long locked; long OS; } fli_sysinfo_t; long fli_connect(flidev_t dev, char *name, long domain); long fli_disconnect(flidev_t dev); long fli_lock(flidev_t dev); long fli_unlock(flidev_t dev); long fli_list(flidomain_t domain, char ***names); #endif /* _LIBFLI_SYSDEP_H */ libfli-2.0+20221221182632/windows/resource.h0000644000175100017510000000062014174600256017116 0ustar debiandebian//{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by libfli.rc // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif libfli-2.0+20221221182632/windows/libfli.vcproj0000644000175100017510000003577114174600256017623 0ustar debiandebian libfli-2.0+20221221182632/windows/libfli-windows.c0000644000175100017510000010066014174600256020220 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include #include #include "../libfli-libfli.h" #include "../libfli-debug.h" #include "../libfli-mem.h" #include "../libfli-camera.h" #include "../libfli-raw.h" #include "../libfli-filter-focuser.h" #include "libfli-sys.h" #include "libfli-parport.h" #include "libfli-usb.h" #include "libfli-serial.h" #define MAX_SEARCH 16 #define MAX_SEARCH_DIGITS 3 static WSADATA WSAData; static short WSEnabled; static SOCKET sock = INVALID_SOCKET; static OSVERSIONINFO OSVersionInfo; static long OS = 0; extern LARGE_INTEGER dlltime; static long fli_resolve_serial_number(char **filename, char *serial, flidomain_t domain); #ifndef SERVICE_MATCH #define SERVICE_MATCH { \ if (stricmp(pBuffer, "fliusb") == 0) match ++; \ if (stricmp(pBuffer, "dnrusb") == 0) match ++; \ if (stricmp(pBuffer, "reltusb") == 0) match ++; \ if (stricmp(pBuffer, "pslcamusb") == 0) match ++; \ } #define FN_MATCH ( \ (_strnicmp(name, "fci", 3) == 0) || \ (_strnicmp(name, "psl", 3) == 0) || \ (_strnicmp(name, "rel", 3) == 0) || \ (_strnicmp(name, "fli", 3) == 0) || \ (_strnicmp(name, "dnr", 3) == 0) || \ (_strnicmp(name, "ccd", 3) == 0) \ ) #define LIST_USB_CAM_PREFIX_LIST "flipro,flicam,pslcam,fcicam,reltcam-" #define LIST_USB_FOCUSER_PREFIX_LIST "flifoc" #define LIST_USB_FILTER_PREFIX_LIST "flifil" #endif #ifdef _USRDLL BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { char strPath[ MAX_PATH ]; HKEY hKey; DWORD len, forcedebug = 0; switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: QueryPerformanceCounter(&dlltime); WSEnabled = 0; if (WSAStartup(MAKEWORD(1, 1), &WSAData) == 0) { WSEnabled = 1; } #define CREATEDEBUG #ifdef CREATEDEBUG // OutputDebugString("libfli: loading\n"); if (RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Finger Lakes Instrumentation\\libfli", &hKey) == ERROR_SUCCESS) { len = sizeof(DWORD); if (RegQueryValueEx(hKey, "debug", NULL, NULL, (LPBYTE) &forcedebug, &len) == ERROR_SUCCESS) { // OutputDebugString("libfli: debug registry key found!\n"); } else { // OutputDebugString("libfli: debug registry key not found!\n"); } RegCloseKey(hKey); } //{ // char _s[1024]; // sprintf(_s, "libfli: [%08x]\n", forcedebug); // OutputDebugString(_s); //} if (forcedebug) { SHGetSpecialFolderPath(0, strPath, CSIDL_DESKTOPDIRECTORY, FALSE); strcat(strPath, "\\flidbg.txt"); FLISetDebugLevel(strPath, forcedebug); } #endif OSVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); if(GetVersionEx(&OSVersionInfo)==0) return FALSE; switch (OSVersionInfo.dwPlatformId) { case VER_PLATFORM_WIN32_WINDOWS: OS = VER_PLATFORM_WIN32_WINDOWS; break; case VER_PLATFORM_WIN32_NT: OS = VER_PLATFORM_WIN32_NT; break; default: return FALSE; } return TRUE; break; case DLL_THREAD_ATTACH: return TRUE; break; case DLL_THREAD_DETACH: return TRUE; break; case DLL_PROCESS_DETACH: xfree_all(); if(WSEnabled == 1) WSACleanup(); return TRUE; break; } return TRUE; } #endif #ifdef _LIB LIBFLIAPI FLILibAttach(void) { char strPath[MAX_PATH]; HKEY hKey; DWORD len, forcedebug = 0; QueryPerformanceCounter(&dlltime); WSEnabled = 0; if (WSAStartup(MAKEWORD(1, 1), &WSAData) == 0) { WSEnabled = 1; } //#define CREATEDEBUG #ifdef CREATEDEBUG SHGetSpecialFolderPath(0, strPath, CSIDL_DESKTOPDIRECTORY, FALSE ); strcat(strPath, "\\flidbg.txt"); FLISetDebugLevel(strPath, FLIDEBUG_ALL); #endif if (RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Finger Lakes Instrumentation\\libfli", &hKey) == ERROR_SUCCESS) { len = sizeof(DWORD); if (RegQueryValueEx(hKey, "debug", NULL, NULL, (LPBYTE) &forcedebug, &len) == ERROR_SUCCESS) { // OutputDebugString("libfli: debug registry key found!\n"); } else { // OutputDebugString("libfli: debug registry key not found!\n"); } RegCloseKey(hKey); } //{ // char _s[1024]; // sprintf(_s, "libfli: [%08x]\n", forcedebug); // OutputDebugString(_s); //} if (forcedebug) { SHGetSpecialFolderPath(0, strPath, CSIDL_DESKTOPDIRECTORY, FALSE); strcat(strPath, "\\flidbg.txt"); FLISetDebugLevel(strPath, forcedebug); } OSVersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); if(GetVersionEx(&OSVersionInfo)==0) return 0; switch (OSVersionInfo.dwPlatformId) { case VER_PLATFORM_WIN32_WINDOWS: OS = VER_PLATFORM_WIN32_WINDOWS; break; case VER_PLATFORM_WIN32_NT: OS = VER_PLATFORM_WIN32_NT; break; default: ; } return 0; } LIBFLIAPI FLILibDetach(void) { xfree_all(); if(WSEnabled == 1) WSACleanup(); return 0; } #endif long fli_connect(flidev_t dev, char *name, long domain) { fli_io_t *io; char *tname, *mname; HANDLE mutex; fli_sysinfo_t *sys; Usb_Device_Descriptor usbdesc; DWORD read; int i; COMMCONFIG IO_Config; DWORD ConfigSize=sizeof(COMMCONFIG); CHKDEVICE(dev); if(name == NULL) return -EINVAL; /* Lock functions should be set before any other functions used */ DEVICE->fli_lock = fli_lock; DEVICE->fli_unlock = fli_unlock; DEVICE->domain = domain & 0x00ff; DEVICE->devinfo.type = domain & 0x7f00; debug(FLIDEBUG_INFO, "Domain: 0x%04x", DEVICE->domain); debug(FLIDEBUG_INFO, " Type: 0x%04x", DEVICE->devinfo.type); if ((io = xcalloc(1, sizeof(fli_io_t))) == NULL) { fli_disconnect(dev); return -ENOMEM; } io->fd = INVALID_HANDLE_VALUE; DEVICE->io_data = io; if ((sys = xcalloc(1, sizeof(fli_sysinfo_t))) == NULL) { fli_disconnect(dev); return -ENOMEM; } DEVICE->sys_data = sys; sys->OS = OS; /* Hack for COM port devices */ if ( ((DEVICE->domain & 0x00ff) == FLIDOMAIN_SERIAL) && (_strnicmp(name, "COM", 3) == 0) ) { if (xasprintf(&tname, "\\\\.\\%s", name) == (-1)) { tname = NULL; fli_disconnect(dev); return -ENOMEM; } } /* Determine if we are receiving a proper filename */ else if (strncmp(name, "\\\\", 2) == 0) { if (xasprintf(&tname, "%s", name) == (-1)) { tname = NULL; fli_disconnect(dev); return -ENOMEM; } } else if (FN_MATCH) { if (xasprintf(&tname, "\\\\.\\%s", name) == (-1)) { tname = NULL; fli_disconnect(dev); return -ENOMEM; } } else /* Maybe we are opening by serial number, so, lets look for it... */ { fli_resolve_serial_number(&tname, name, domain); if (tname == NULL) { fli_disconnect(dev); return -ENODEV; } } DEVICE->name = tname; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: { if (OS == VER_PLATFORM_WIN32_NT) { io->fd = CreateFile(tname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (io->fd == INVALID_HANDLE_VALUE) { fli_disconnect(dev); return -ENODEV; } } else { io->port = strtol(name, NULL, 0); if(stricmp(name, "ccdpar0") == 0) { io->port = 0x378; } if(stricmp(name, "ccdpar1") == 0) { io->port = 0x278; } } if(ECPInit(dev) != 0) { fli_disconnect(dev); return -ENODEV; } DEVICE->fli_io = parportio; } break; case FLIDOMAIN_SERIAL: case FLIDOMAIN_SERIAL_1200: case FLIDOMAIN_SERIAL_19200: { debug(FLIDEBUG_INFO, "Serial, opening port."); io->fd = CreateFile(tname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (io->fd == INVALID_HANDLE_VALUE) { fli_disconnect(dev); return -ENODEV; } DEVICE->fli_io = serportio; debug(FLIDEBUG_INFO, "Attempting at 19200 baud..."); GetCommConfig(io->fd, &IO_Config, &ConfigSize); IO_Config.dcb.BaudRate = 19200; IO_Config.dcb.Parity = NOPARITY; IO_Config.dcb.ByteSize = 8; IO_Config.dcb.StopBits = ONESTOPBIT; IO_Config.dcb.fRtsControl = RTS_CONTROL_DISABLE; IO_Config.dcb.fOutxCtsFlow = FALSE; if(SetCommConfig(io->fd, &IO_Config, ConfigSize)==FALSE) { fli_disconnect(dev); return -ENODEV; } /* We need to probe the serial port... */ if (fli_filter_focuser_probe(dev) == 0) { debug(FLIDEBUG_INFO, "Found device at 19200 baud..."); break; } Sleep(50); /* Wait for probe to timeout */ debug(FLIDEBUG_INFO, "Attempting at 1200 baud..."); GetCommConfig(io->fd, &IO_Config, &ConfigSize); IO_Config.dcb.BaudRate = 1200; IO_Config.dcb.Parity = NOPARITY; IO_Config.dcb.ByteSize = 8; IO_Config.dcb.StopBits = ONESTOPBIT; IO_Config.dcb.fRtsControl = RTS_CONTROL_DISABLE; IO_Config.dcb.fOutxCtsFlow = FALSE; if(SetCommConfig(io->fd, &IO_Config, ConfigSize)==FALSE) { fli_disconnect(dev); return -ENODEV; } /* We need to probe the serial port... */ if (fli_filter_focuser_probe(dev) == 0) { debug(FLIDEBUG_INFO, "Found device at 1200 baud..."); break; } debug(FLIDEBUG_INFO, "Did not find a serial device."); fli_disconnect(dev); return -ENODEV; } break; case FLIDOMAIN_USB: { #ifdef OLDUSBDRIVER unsigned char buf[1024]; DWORD bytes; PFLI_INTERFACE_INFORMATION pInterface; PFLI_PIPE_INFORMATION pPipe; int i; #endif io->fd = CreateFile(tname, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (io->fd == INVALID_HANDLE_VALUE) { fli_disconnect(dev); return -ENODEV; } debug(FLIDEBUG_INFO, "Getting Device configuration."); if (DeviceIoControl(io->fd, IOCTL_GET_DEVICE_DESCRIPTOR, NULL, 0, &usbdesc, sizeof(usbdesc), &read, NULL) == FALSE) { debug(FLIDEBUG_WARN, "Couldn't read device description, error: %d", GetLastError()); fli_disconnect(dev); return -ENODEV; } DEVICE->devinfo.devid = usbdesc.idProduct; DEVICE->devinfo.fwrev = usbdesc.bcdDevice; /* Hack for incorrect FW rev on early proline cameras */ if ( (usbdesc.idProduct == 0x0a) && (usbdesc.iSerialNumber == 3) && (usbdesc.bcdDevice == 0x0100) ) { DEVICE->devinfo.fwrev = 0x0101; } /* Get serial string */ if (usbdesc.iSerialNumber == 3) { GET_STRING_DESCRIPTOR_IN sd; char name[MAX_PATH]; sd.Index = 3; sd.LanguageId = 0x00; ZeroMemory(name, sizeof(name)); if (DeviceIoControl(io->fd, IOCTL_GET_STRING_DESCRIPTOR, &sd, sizeof(sd), name, sizeof(name), &read, NULL) != FALSE) { DWORD i; /* de-unicode it */ for (i = 0; i < read; i++) { name[i] = name[(i + 1) * 2]; } name[i] = '\0'; debug(FLIDEBUG_INFO, "Serial: %s [%d]", name, i); DEVICE->devinfo.serial = xstrdup(name); } } #ifdef OLDUSBDRIVER /* Get pipe information */ if (DeviceIoControl(io->fd, IOCTL_Ezusb_GET_PIPE_INFO, NULL, 0, buf, 1024, &bytes, NULL) == FALSE) { debug(FLIDEBUG_FAIL, "Error getting USB pipe information, error: %d", GetLastError()); fli_disconnect(dev); return -ENODEV; } pInterface = (PFLI_INTERFACE_INFORMATION) buf; pPipe = pInterface->Pipes; for(i = 0; (i < (int) pInterface->NumberOfPipes) && (i < USB_MAX_PIPES); i++) { debug(FLIDEBUG_INFO, "Pipe: %d Type: %02x Endpoint: %02x MaxSize: %02x MaxXfer: %04x", i, pPipe[i].PipeType, pPipe[i].EndpointAddress, pPipe[i].MaximumPacketSize, pPipe[i].MaximumTransferSize ); io->endpointlist[i] = pPipe[i].EndpointAddress; } #endif debug(FLIDEBUG_INFO, " id: 0x%04x", DEVICE->devinfo.devid); debug(FLIDEBUG_INFO, " fwrev: 0x%04x", DEVICE->devinfo.fwrev); DEVICE->fli_io = usbio; } break; default: fli_disconnect(dev); return -EINVAL; } switch (DEVICE->devinfo.type) { case FLIDEVICE_CAMERA: DEVICE->fli_open = fli_camera_open; DEVICE->fli_close = fli_camera_close; DEVICE->fli_command = fli_camera_command; break; case FLIDEVICE_FOCUSER: DEVICE->fli_open = fli_focuser_open; DEVICE->fli_close = fli_focuser_close; DEVICE->fli_command = fli_focuser_command; break; case FLIDEVICE_FILTERWHEEL: DEVICE->fli_open = fli_filter_open; DEVICE->fli_close = fli_filter_close; DEVICE->fli_command = fli_filter_command; break; case FLIDEVICE_RAW: DEVICE->fli_open = fli_raw_open; DEVICE->fli_close = fli_raw_close; DEVICE->fli_command = fli_raw_command; break; default: fli_disconnect(dev); return -EINVAL; } /* Now create the synchronization object */ mname = (char *) xcalloc(MAX_PATH, sizeof(char)); if(mname != NULL) /* We can allocate the mutex */ { int j = 0; strcpy(mname, "CEC615E9-917D-4cee-BC2F-2DE1B6D3E03B_"); strcat(mname, name); for(i = 0; mname[i] != '\0'; i++) /* Convert case and strip nasties */ { if (isalnum(mname[i])) { mname[j] = toupper(mname[i]); j++; } } mname[j] = '\0'; debug(FLIDEBUG_INFO, "Creating named mutex \"%s\"", mname); mutex = OpenMutex(MUTEX_ALL_ACCESS | SYNCHRONIZE, TRUE, mname); if(mutex == NULL) { mutex = CreateMutex(NULL, FALSE, mname); } if(mutex == NULL) { debug(FLIDEBUG_WARN, "Failed to create mutex object, error: %d", GetLastError()); } ((fli_sysinfo_t *) (DEVICE->sys_data))->mutex = mutex; xfree(mname); } else { debug(FLIDEBUG_WARN, "Failed to allocate name for mutex."); } DEVICE->io_timeout = 20 * 1000; /* 20 seconds. */ return 0; } long fli_disconnect(flidev_t dev) { int err = 0; fli_io_t *io; CHKDEVICE(dev); io = DEVICE->io_data; switch (DEVICE->domain) { case FLIDOMAIN_PARALLEL_PORT: ECPClose(dev); break; case FLIDOMAIN_USB: break; default: err = -EINVAL; } if(io != NULL) { if(io->fd != INVALID_HANDLE_VALUE) { if (CloseHandle(io->fd) == FALSE) err = -EIO; else err = 0; } } if(((fli_sysinfo_t *) (DEVICE->sys_data))->mutex != NULL) { CloseHandle(((fli_sysinfo_t *) (DEVICE->sys_data))->mutex); } if (DEVICE->devinfo.serial != NULL) { xfree(DEVICE->devinfo.serial); DEVICE->devinfo.serial = NULL; } if (DEVICE->io_data != NULL) { xfree(DEVICE->io_data); DEVICE->io_data = NULL; } if (DEVICE->sys_data != NULL) { xfree(DEVICE->sys_data); DEVICE->sys_data = NULL; } if(DEVICE->name != NULL) { xfree(DEVICE->name); DEVICE->name = NULL; } DEVICE->fli_lock = NULL; DEVICE->fli_unlock = NULL; DEVICE->fli_io = NULL; DEVICE->fli_open = NULL; DEVICE->fli_close = NULL; DEVICE->fli_command = NULL; return err; } long fli_lock(flidev_t dev) { long r = -ENODEV; HANDLE mutex; CHKDEVICE(dev); mutex = ((fli_sysinfo_t *) (DEVICE->sys_data))->mutex; // debug(FLIDEBUG_INFO, "Acquiring lock..."); if (mutex != NULL) { switch(WaitForSingleObject(mutex, INFINITE)) { case WAIT_OBJECT_0: // debug(FLIDEBUG_INFO, "Lock acquired..."); r = 0; break; default: debug(FLIDEBUG_WARN, "Could not acquire mutex: %d", GetLastError()); r = -ENODEV; break; } } else { debug(FLIDEBUG_WARN, "lock(): Mutex is NULL!"); } return r; } long fli_unlock(flidev_t dev) { HANDLE mutex; CHKDEVICE(dev); mutex = ((fli_sysinfo_t *) (DEVICE->sys_data))->mutex; // debug(FLIDEBUG_INFO, "Releasing lock..."); if (mutex != NULL) { if(ReleaseMutex(mutex) == FALSE) { debug(FLIDEBUG_WARN, "Could not release mutex: %d", GetLastError()); return -ENODEV; } return 0; } else { debug(FLIDEBUG_WARN, "unlock(): Mutex is NULL!"); } return -ENODEV; } static long fli_list_usb(flidomain_t domain, char ***names); static long fli_list_parport(flidomain_t domain, char ***names); static long fli_list_serial(flidomain_t domain, char ***names); long fli_list(flidomain_t domain, char ***names) { *names = NULL; switch (domain & 0x00ff) { case FLIDOMAIN_PARALLEL_PORT: return fli_list_parport(domain, names); break; case FLIDOMAIN_SERIAL: case FLIDOMAIN_SERIAL_1200: case FLIDOMAIN_SERIAL_19200: return fli_list_serial(domain, names); break; case FLIDOMAIN_USB: return fli_list_usb(domain, names); break; default: return -EINVAL; } /* Not reached */ return -EINVAL; } #define NAME_LEN_MAX 4096 /* This function enumerates FLI devices by port, this removes boot time * configuration problems */ #include #include static const GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } }; static long fli_resolve_serial_number(char **filename, char *serial, flidomain_t domain) { HDEVINFO hDevInfo; SP_DEVICE_INTERFACE_DATA devInterfaceData; BOOL bRet = FALSE; DWORD dwIndex = 0; *filename = NULL; hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_USB_DEVICE, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (hDevInfo == INVALID_HANDLE_VALUE) { debug(FLIDEBUG_FAIL, "Could not obtain handle from SetupDiGetClassDevs(), error %d", GetLastError()); return 0; } ZeroMemory(&devInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA)); devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); while(*filename == NULL) { bRet = SetupDiEnumDeviceInterfaces(hDevInfo, NULL, /* PSP_DEVINFO_DATA DeviceInfoData */ &GUID_DEVINTERFACE_USB_DEVICE, dwIndex, &devInterfaceData); if (bRet == TRUE) { PSP_DEVICE_INTERFACE_DETAIL_DATA detailData; DWORD DataSize, RequiredSize; SP_DEVINFO_DATA DeviceInfoData; DWORD dwRegType, dwRegSize; int match = 0; char *pBuffer; ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA)); DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); /* Get required size of detail data and the DEVINFO_DATA structure */ if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &devInterfaceData, NULL, 0, &DataSize, &DeviceInfoData) != TRUE) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { debug(FLIDEBUG_FAIL, "Could not obtain size for interface detail data, error %d", GetLastError()); break; } } detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) xmalloc(DataSize); ZeroMemory(detailData, DataSize); detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); /* Get the detail data */ if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &devInterfaceData, detailData, DataSize, &RequiredSize, NULL) != TRUE) { debug(FLIDEBUG_FAIL, "Could not obtain interface detail data, error %d", GetLastError()); xfree(detailData); break; } dwRegSize = 0; pBuffer = NULL; /* Get the service name (this should be "fliusb") */ if (SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_SERVICE, &dwRegType, NULL, 0, &dwRegSize) != TRUE) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { debug(FLIDEBUG_FAIL, "Could not obtain size for service name, error %d", GetLastError()); xfree(detailData); break; } } /* Allocate buffer for the friendly name. */ pBuffer = (TCHAR *) xmalloc (dwRegSize * sizeof(TCHAR)); /* Retreive the service name */ if (SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_SERVICE, &dwRegType, (PBYTE) pBuffer, dwRegSize, &dwRegSize) != TRUE) { debug(FLIDEBUG_FAIL, "Could not get service name, error %d", GetLastError()); xfree(detailData); xfree(pBuffer); break; } debug(FLIDEBUG_INFO, "Found [%s] [%s]", detailData->DevicePath, pBuffer); /* Is it our driver? */ SERVICE_MATCH if (match != 0) { Usb_Device_Descriptor usbdesc; HANDLE fd; int pid; DWORD read; do { fd = CreateFile(detailData->DevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fd == INVALID_HANDLE_VALUE) { break; } if (DeviceIoControl(fd, IOCTL_GET_DEVICE_DESCRIPTOR, NULL, 0, &usbdesc, sizeof(usbdesc), &read, NULL) == FALSE) { debug(FLIDEBUG_WARN, "Couldn't read device description, error: %d", GetLastError()); CloseHandle(fd); break; } pid = usbdesc.idProduct; if ( ((pid == FLIUSB_CAM_ID) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) || ((pid == FLIUSB_PROLINE_ID) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) || ((pid >= 0x0100) && (pid < 0x0110) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) || ((pid == FLIUSB_FOCUSER_ID) && ((domain & 0x7f00) == FLIDEVICE_FOCUSER)) || ((pid == FLIUSB_FILTER_ID) && ((domain & 0x7f00) == FLIDEVICE_FILTERWHEEL)) ) { GET_STRING_DESCRIPTOR_IN sd; char name[MAX_PATH]; sd.Index = 3; sd.LanguageId = 0x00; ZeroMemory(name, sizeof(name)); if ( (usbdesc.iSerialNumber == 3) && (DeviceIoControl(fd, IOCTL_GET_STRING_DESCRIPTOR, &sd, sizeof(sd), name, sizeof(name), &read, NULL) == FALSE) ) { /* No serial number, so it can't match */ } else { DWORD i; /* de-unicode it */ for (i = 0; i < read; i++) { name[i] = name[(i + 1) * 2]; } name[i] = '\0'; if (stricmp(name, serial) == 0) { debug(FLIDEBUG_INFO, "Found %s as [%s]", serial, detailData->DevicePath); xasprintf(filename, "%s", detailData->DevicePath); } } } else { // debug(FLIDEBUG_INFO, "Not the device we are looking for."); } CloseHandle(fd); } while (0 == 1); } xfree(detailData); xfree(pBuffer); } else { int err = GetLastError(); if ( (err == ERROR_NO_MORE_ITEMS) || (err == ERROR_FILE_NOT_FOUND) ) { break; } } dwIndex++; } SetupDiDestroyDeviceInfoList(hDevInfo); return 0; } static long fli_list_usb_by_port(flidomain_t domain, char ***names) { HDEVINFO hDevInfo; SP_DEVICE_INTERFACE_DATA devInterfaceData; BOOL bRet = FALSE; DWORD dwIndex = 0; char **list = NULL; int matched = 0; hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE_USB_DEVICE, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); debug(FLIDEBUG_FAIL, "Searching by port."); if (hDevInfo == INVALID_HANDLE_VALUE) { debug(FLIDEBUG_FAIL, "Could not obtain handle from SetupDiGetClassDevs(), error %d", GetLastError()); return 0; } ZeroMemory(&devInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA)); devInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); /* Allocate the list */ if ((list = xcalloc((MAX_SEARCH + 1) * sizeof(char *), 1)) == NULL) return -ENOMEM; while(TRUE) { bRet = SetupDiEnumDeviceInterfaces(hDevInfo, NULL, /* PSP_DEVINFO_DATA DeviceInfoData */ &GUID_DEVINTERFACE_USB_DEVICE, dwIndex, &devInterfaceData); if (bRet == TRUE) { PSP_DEVICE_INTERFACE_DETAIL_DATA detailData; DWORD DataSize, RequiredSize; SP_DEVINFO_DATA DeviceInfoData; DWORD dwRegType, dwRegSize; int match = 0; char *pBuffer; ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA)); DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); /* Get required size of detail data and the DEVINFO_DATA structure */ if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &devInterfaceData, NULL, 0, &DataSize, &DeviceInfoData) != TRUE) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { debug(FLIDEBUG_FAIL, "Could not obtain size for interface detail data, error %d", GetLastError()); break; } } detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA) xmalloc(DataSize); ZeroMemory(detailData, DataSize); detailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); /* Get the detail data */ if (SetupDiGetDeviceInterfaceDetail(hDevInfo, &devInterfaceData, detailData, DataSize, &RequiredSize, NULL) != TRUE) { debug(FLIDEBUG_FAIL, "Could not obtain interface detail data, error %d", GetLastError()); xfree(detailData); break; } dwRegSize = 0; pBuffer = NULL; /* Get the service name (this should be "fliusb") */ if (SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_SERVICE, &dwRegType, NULL, 0, &dwRegSize) != TRUE) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { debug(FLIDEBUG_FAIL, "Could not obtain size for service name, error %d", GetLastError()); xfree(detailData); break; } } /* Allocate buffer for the friendly name. */ pBuffer = (TCHAR *) xmalloc (dwRegSize * sizeof(TCHAR)); /* Retreive the service name */ if (SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_SERVICE, &dwRegType, (PBYTE) pBuffer, dwRegSize, &dwRegSize) != TRUE) { debug(FLIDEBUG_FAIL, "Could not get service name, error %d", GetLastError()); xfree(detailData); xfree(pBuffer); break; } debug(FLIDEBUG_INFO, "Found [%s] [%s]", detailData->DevicePath, pBuffer); /* Is it our driver? */ SERVICE_MATCH if (match != 0) { Usb_Device_Descriptor usbdesc; HANDLE fd; int pid; DWORD read; do { fd = CreateFile(detailData->DevicePath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (fd == INVALID_HANDLE_VALUE) { break; } if (DeviceIoControl(fd, IOCTL_GET_DEVICE_DESCRIPTOR, NULL, 0, &usbdesc, sizeof(usbdesc), &read, NULL) == FALSE) { debug(FLIDEBUG_WARN, "Couldn't read device description, error: %d", GetLastError()); CloseHandle(fd); break; } pid = usbdesc.idProduct; debug(FLIDEBUG_INFO, "Found USB PID: 0x%04x", pid); if ( ((pid == FLIUSB_CAM_ID) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) || ((pid == FLIUSB_PROLINE_ID) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) || ((pid == FLIUSB_FOCUSER_ID) && ((domain & 0x7f00) == FLIDEVICE_FOCUSER)) || ((pid == FLIUSB_FILTER_ID) && ((domain & 0x7f00) == FLIDEVICE_FILTERWHEEL)) || ((pid >= 0x0100) && (pid < 0x0110) && ((domain & 0x7f00) == FLIDEVICE_CAMERA)) ) { GET_STRING_DESCRIPTOR_IN sd; char name[MAX_PATH]; char model[MAX_PATH]; flidev_t dev; sd.Index = 3; sd.LanguageId = 0x00; ZeroMemory(name, sizeof(name)); ZeroMemory(model, sizeof(model)); if ( (usbdesc.iSerialNumber == 3) && (DeviceIoControl(fd, IOCTL_GET_STRING_DESCRIPTOR, &sd, sizeof(sd), name, sizeof(name), &read, NULL) != FALSE) ) { DWORD i; /* de-unicode it */ for (i = 0; i < read; i++) { name[i] = name[(i + 1) * 2]; } name[i] = '\0'; debug(FLIDEBUG_INFO, "Adding %s", name); } else { strncpy(name, detailData->DevicePath, MAX_PATH - 1); } /* Get model information */ if (FLIOpen(&dev, detailData->DevicePath, domain) == 0) { xasprintf(&list[matched], "%s;%s", name, DEVICE->devinfo.model); matched ++; FLIClose(dev); } } else { debug(FLIDEBUG_INFO, "Not the device we are looking for."); } CloseHandle(fd); } while (0 == 1); } xfree(detailData); xfree(pBuffer); } else { int err = GetLastError(); if ( (err == ERROR_NO_MORE_ITEMS) || (err == ERROR_FILE_NOT_FOUND) ) { break; } } dwIndex++; } SetupDiDestroyDeviceInfoList(hDevInfo); if(matched == 0) { *names = NULL; xfree(list); return 0; } list[matched++] = NULL; *names = list; return 0; } static long fli_list_tree(const char *root, flidomain_t domain, char ***names) { int matched = 0, device = 0, max_search = MAX_SEARCH; char fname[NAME_LEN_MAX], **list, name[NAME_LEN_MAX]; flidev_t dev; char prefix[NAME_LEN_MAX]; int cnt, index; /* Allocate the list */ if ((list = xcalloc((MAX_SEARCH + 1) * sizeof(char *), 1)) == NULL) return -ENOMEM; index = 0; while (root[index] != '\0') { cnt = 0; while ((root[index] != '\0') && (root[index] != ',') && (cnt < NAME_LEN_MAX)) { prefix[cnt] = root[index]; cnt++; index++; } prefix[cnt] = '\0'; if (root[index] != '\0') index++; device = 0; while(device < max_search) { if (snprintf(fname, NAME_LEN_MAX, "%s%d", prefix, device) >= NAME_LEN_MAX) { xfree(list); return -EOVERFLOW; } if (FLIOpen(&dev, fname, domain) == 0) { if (snprintf(name, NAME_LEN_MAX, "%s;%s", fname, DEVICE->devinfo.model) >= NAME_LEN_MAX) { xfree(list); return -EOVERFLOW; } list[matched++] = xstrdup(name); FLIClose(dev); } device++; } } if(matched == 0) { *names = NULL; xfree(list); return 0; } /* Terminate the list */ list[matched++] = NULL; // list = xrealloc(list, matched * sizeof(char *)); *names = list; return 0; } static long fli_list_usb(flidomain_t domain, char ***names) { switch (domain & 0x7f00) { case FLIDEVICE_CAMERA: if ( (domain & 0x8000) == 0 ) return fli_list_tree(LIST_USB_CAM_PREFIX_LIST, domain, names); else return fli_list_usb_by_port(domain, names); case FLIDEVICE_FOCUSER: return fli_list_tree(LIST_USB_FOCUSER_PREFIX_LIST, domain, names); case FLIDEVICE_FILTERWHEEL: return fli_list_tree(LIST_USB_FILTER_PREFIX_LIST, domain, names); default: return -EINVAL; } /* Not reached */ return -EINVAL; } static long fli_list_serial(flidomain_t domain, char ***names) { switch (domain & 0xff00) { case FLIDEVICE_FOCUSER: return fli_list_tree("\\\\?\\COM", domain, names); case FLIDEVICE_FILTERWHEEL: return fli_list_tree("\\\\?\\COM", domain, names); default: return -EINVAL; } /* Not reached */ return -EINVAL; } static long fli_list_parport(flidomain_t domain, char ***names) { switch (domain & 0xff00) { case FLIDEVICE_CAMERA: return fli_list_tree("ccdpar", domain, names); default: return -EINVAL; } /* Not reached */ return -EINVAL; } #undef NAME_LEN_MAX libfli-2.0+20221221182632/windows/libfli.sln0000644000175100017510000000456314174600256017107 0ustar debiandebian Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libfli", "libfli.vcproj", "{EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution DLL Debug|Win32 = DLL Debug|Win32 DLL Debug|x64 = DLL Debug|x64 DLL Release|Win32 = DLL Release|Win32 DLL Release|x64 = DLL Release|x64 Static Library Debug|Win32 = Static Library Debug|Win32 Static Library Debug|x64 = Static Library Debug|x64 Static Library Release|Win32 = Static Library Release|Win32 Static Library Release|x64 = Static Library Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Debug|x64.ActiveCfg = DLL Debug|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Debug|x64.Build.0 = DLL Debug|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Release|Win32.Build.0 = DLL Release|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Release|x64.ActiveCfg = DLL Release|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.DLL Release|x64.Build.0 = DLL Release|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Debug|Win32.ActiveCfg = Static Library Debug|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Debug|Win32.Build.0 = Static Library Debug|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Debug|x64.ActiveCfg = Static Library Debug|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Debug|x64.Build.0 = Static Library Debug|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Release|Win32.ActiveCfg = Static Library Release|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Release|Win32.Build.0 = Static Library Release|Win32 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Release|x64.ActiveCfg = Static Library Release|x64 {EF4B8A79-8ACA-4B90-A36C-BA3E2E727535}.Static Library Release|x64.Build.0 = Static Library Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal libfli-2.0+20221221182632/windows/libfli.rc0000644000175100017510000000452014174600256016710 0ustar debiandebian// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,104,0,0 PRODUCTVERSION 1,104,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Finger Lakes Instrumentation, L.L.C." VALUE "FileDescription", "FLI Product Interface Library" VALUE "FileVersion", "1, 104, 0, 0" VALUE "InternalName", "libfli" VALUE "LegalCopyright", "Copyright (C) 2008" VALUE "OriginalFilename", "libfli.dll" VALUE "ProductName", "FLI Product Interface Library" VALUE "ProductVersion", "1, 104, 0, 0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED libfli-2.0+20221221182632/windows/libfli-usb.h0000644000175100017510000001331614174600256017325 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_USB_H_ #define _LIBFLI_USB_H_ #define MAXCAM_EP_IN (0x82) #define MAXCAM_EP_OUT (0x02) #define USB_DIR_OUT (0x00) #define USB_DIR_IN (0x80) #define USB_READ_SIZ_MAX (65535) typedef struct fli_usb_epio_t { WORD Endpoint; /* USB Endpoint */ DWORD Timeout; /* USB I/O Timeout in mSec */ } FLI_USB_EPIO, *PFLI_USB_EPIO; long usb_bulktransfer(flidev_t dev, int ep, void *buf, long *len); long usbio(flidev_t dev, void *buf, long *wlen, long *rlen); /* Legacy stuff to work with old driver */ typedef struct _FLI_PIPE_INFORMATION { USHORT MaximumPacketSize; UCHAR EndpointAddress; UCHAR Interval; UCHAR PipeType; DWORD PipeHandle; /* This is a pointer, causes problems in 64 bit driver */ ULONG MaximumTransferSize; ULONG PipeFlags; } FLI_PIPE_INFORMATION, *PFLI_PIPE_INFORMATION; typedef struct _FLI_INTERFACE_INFORMATION { USHORT Length; UCHAR InterfaceNumber; UCHAR AlternateSetting; UCHAR Class; UCHAR SubClass; UCHAR Protocol; UCHAR Reserved; DWORD InterfaceHandle; ULONG NumberOfPipes; FLI_PIPE_INFORMATION Pipes[1]; } FLI_INTERFACE_INFORMATION, *PFLI_INTERFACE_INFORMATION; /* USB Descriptor (from DDK) */ typedef struct __usb_Dev_Descriptor__ { UCHAR bLength; UCHAR bDescriptorType; USHORT bcdUSB; UCHAR bDeviceClass; UCHAR bDeviceSubClass; UCHAR bDeviceProtocol; UCHAR bMaxPacketSize0; USHORT idVendor; USHORT idProduct; USHORT bcdDevice; UCHAR iManufacturer; UCHAR iProduct; UCHAR iSerialNumber; UCHAR bNumConfigurations; } Usb_Device_Descriptor, *pUsb_Device_Descriptor; /* Taken initially from EZUSB before driver was rewritten */ typedef struct _GET_STRING_DESCRIPTOR_IN { UCHAR Index; USHORT LanguageId; } GET_STRING_DESCRIPTOR_IN, *PGET_STRING_DESCRIPTOR_IN; #define IOCTL_GET_DEVICE_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 0x0800 + 1,\ METHOD_BUFFERED, \ FILE_ANY_ACCESS) #define IOCTL_BULK_READ CTL_CODE(FILE_DEVICE_UNKNOWN, \ 0x0800 + 19,\ METHOD_OUT_DIRECT, \ FILE_ANY_ACCESS) #define IOCTL_BULK_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, \ 0x0800 + 20,\ METHOD_IN_DIRECT, \ FILE_ANY_ACCESS) #define IOCTL_GET_LAST_USBD_ERROR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 0x0800 + 23,\ METHOD_BUFFERED, \ FILE_ANY_ACCESS) #define IOCTL_GET_STRING_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN, \ 0x0800 + 17,\ METHOD_BUFFERED, \ FILE_ANY_ACCESS) #ifdef OLDUSBDRIVER typedef PVOID USBD_PIPE_HANDLE; typedef PVOID USBD_CONFIGURATION_HANDLE; typedef PVOID USBD_INTERFACE_HANDLE; typedef enum _USBD_PIPE_TYPE { UsbdPipeTypeControl, UsbdPipeTypeIsochronous, UsbdPipeTypeBulk, UsbdPipeTypeInterrupt } USBD_PIPE_TYPE; typedef struct _USBD_PIPE_INFORMATION { USHORT MaximumPacketSize; UCHAR EndpointAddress; UCHAR Interval; USBD_PIPE_TYPE PipeType; USBD_PIPE_HANDLE PipeHandle; ULONG MaximumTransferSize; ULONG PipeFlags; } USBD_PIPE_INFORMATION, *PUSBD_PIPE_INFORMATION; typedef struct _USBD_INTERFACE_INFORMATION { USHORT Length; // Length of this structure, including // all pipe information structures that // follow. // // INPUT // // Interface number and Alternate setting this // structure is associated with // UCHAR InterfaceNumber; UCHAR AlternateSetting; // // OUTPUT // These fields are filled in by USBD // UCHAR Class; UCHAR SubClass; UCHAR Protocol; UCHAR Reserved; USBD_INTERFACE_HANDLE InterfaceHandle; ULONG NumberOfPipes; // // INPUT/OUPUT // see PIPE_INFORMATION //TPM USBD_PIPE_INFORMATION Pipes[0]; USBD_PIPE_INFORMATION Pipes[1]; } USBD_INTERFACE_INFORMATION, *PUSBD_INTERFACE_INFORMATION; #endif #endif /* _LIBFLI_UNIX_USB_H_ */ libfli-2.0+20221221182632/windows/libfli.def0000644000175100017510000000333514174600256017045 0ustar debiandebianLIBRARY libfli EXPORTS FLIOpen @1 FLIClose @2 FLISetDebugLevel @3 FLIGetLibVersion @4 FLIGetModel @5 FLIGetArrayArea @6 FLIGetVisibleArea @7 FLIExposeFrame @8 FLICancelExposure @9 FLIGetExposureStatus @10 FLISetTemperature @11 FLIGetTemperature @12 FLIGrabRow @13 FLIGrabFrame @14 FLIFlushRow @15 FLISetExposureTime @16 FLISetFrameType @17 FLISetImageArea @18 FLISetHBin @19 FLISetVBin @20 FLISetNFlushes @21 FLISetBitDepth @22 FLIReadIOPort @23 FLIWriteIOPort @24 FLIConfigureIOPort @25 FLIControlShutter @26 FLILockDevice @27 FLIUnlockDevice @28 FLIList @29 FLIFreeList @30 FLISetFilterPos @31 FLIGetFilterPos @32 FLIGetFilterCount @33 FLIStepMotor @34 FLIGetStepperPosition @35 FLIGetHWRevision @36 FLIGetPixelSize @37 FLIGetFWRevision @38 FLIHomeFocuser @39 FLICreateList @40 FLIDeleteList @41 FLIListFirst @42 FLIListNext @43 FLIControlBackgroundFlush @44 FLISetDAC @45 FLIGetStepsRemaining @46 FLIStepMotorAsync @47 FLIReadTemperature @48 FLIGetFocuserExtent @49 FLIUsbBulkIO @50 FLIGetCoolerPower @51 FLIGetDeviceStatus @52 FLIGetCameraModeString @53 FLIGetCameraMode @54 FLISetCameraMode @55 FLIHomeDevice @56 FLIGrabVideoFrame @57 FLIStopVideoMode @58 FLIStartVideoMode @59 FLIGetSerialString @60 FLIEndExposure @61 FLITriggerExposure @62 FLISetFanSpeed @63 FLISetVerticalTableEntry @64 FLIGetVerticalTableEntry @65 FLIGetReadoutDimensions @66 FLIEnableVerticalTable @67 FLIReadUserEEPROM @68 FLIWriteUserEEPROM @69 FLISetActiveWheel @70 FLIGetFilterName @71 FLIDebug @72 FLISetTDI @73libfli-2.0+20221221182632/windows/libfli-parport.h0000644000175100017510000000375514174600256020231 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_PARPORT_H_ #define _LIBFLI_PARPORT_H_ long parportio(flidev_t dev, void *buf, long *wlen, long *rlen); long ECPInit(flidev_t dev); long ECPClose(flidev_t dev); #endif /* _LIBFLI_PARPORT_H_ */ libfli-2.0+20221221182632/windows/libfli64.def0000644000175100017510000000331614174600256017216 0ustar debiandebianLIBRARY libfli64 EXPORTS FLIOpen @1 FLIClose @2 FLISetDebugLevel @3 FLIGetLibVersion @4 FLIGetModel @5 FLIGetArrayArea @6 FLIGetVisibleArea @7 FLIExposeFrame @8 FLICancelExposure @9 FLIGetExposureStatus @10 FLISetTemperature @11 FLIGetTemperature @12 FLIGrabRow @13 FLIGrabFrame @14 FLIFlushRow @15 FLISetExposureTime @16 FLISetFrameType @17 FLISetImageArea @18 FLISetHBin @19 FLISetVBin @20 FLISetNFlushes @21 FLISetBitDepth @22 FLIReadIOPort @23 FLIWriteIOPort @24 FLIConfigureIOPort @25 FLIControlShutter @26 FLILockDevice @27 FLIUnlockDevice @28 FLIList @29 FLIFreeList @30 FLISetFilterPos @31 FLIGetFilterPos @32 FLIGetFilterCount @33 FLIStepMotor @34 FLIGetStepperPosition @35 FLIGetHWRevision @36 FLIGetPixelSize @37 FLIGetFWRevision @38 FLIHomeFocuser @39 FLICreateList @40 FLIDeleteList @41 FLIListFirst @42 FLIListNext @43 FLIControlBackgroundFlush @44 FLISetDAC @45 FLIGetStepsRemaining @46 FLIStepMotorAsync @47 FLIReadTemperature @48 FLIGetFocuserExtent @49 FLIUsbBulkIO @50 FLIGetCoolerPower @51 FLIGetDeviceStatus @52 FLIGetCameraModeString @53 FLIGetCameraMode @54 FLISetCameraMode @55 FLIHomeDevice @56 FLIGrabVideoFrame @57 FLIStopVideoMode @58 FLIStartVideoMode @59 FLIGetSerialString @60 FLIEndExposure @61 FLITriggerExposure @62 FLISetFanSpeed @63 FLISetVerticalTableEntry @64 FLIGetVerticalTableEntry @65 FLIGetReadoutDimensions @66 FLIEnableVerticalTable @67 FLIReadUserEEPROM @68 FLIWriteUserEEPROM @69 FLISetActiveWheel @70 FLIGetFilterName @71 FLIDebug @72 libfli-2.0+20221221182632/windows/libfli-debug.c0000644000175100017510000001156714174600256017623 0ustar debiandebian#include #include #include #include #include "../libfli-libfli.h" #include "../libfli-debug.h" #include "../libfli-mem.h" #define MAX_DEBUG_STRING (1024) LARGE_INTEGER dlltime; static int _level = 0; static int _forced = 0; static int _debugstring = 0; static char *_debugfile = NULL; static HANDLE dfile = INVALID_HANDLE_VALUE; static HANDLE debugmutex = NULL; static void _debug(int level, const char *buffer); static char _mutexname[] = { "1CE1A58C33904535873088172EFF34A0" }; int debugclose(void) { if (dfile != INVALID_HANDLE_VALUE) { CloseHandle(dfile); dfile = INVALID_HANDLE_VALUE; } if(_debugfile != NULL) { debug(FLIDEBUG_ALL, "Closing debug file."); xfree(_debugfile); _debugfile = NULL; } if (debugmutex != NULL) { CloseHandle(debugmutex); // OutputDebugString("libfli: debug mutex destroyed"); debugmutex = NULL; } return 0; } int debugopen(char *host) { char date[12], time[12]; _strdate(date); _strtime(time); QueryPerformanceCounter(&dlltime); debugclose(); if(host != NULL) { _debugfile = xstrdup(host); } /* Open the mutex for debug information */ if (debugmutex == NULL) { debugmutex = CreateMutex(NULL, FALSE, _mutexname); if (debugmutex == NULL) { // OutputDebugString("libfli: failed to create debug mutex"); } else { // OutputDebugString("libfli: debug mutex created"); } } debug(FLIDEBUG_ALL, "*** %s %s ***", date, time); debug(FLIDEBUG_ALL, "%s - Compiled %s %s", version, __DATE__, __TIME__); return 0; } void __cdecl FLIDebug(int level, char *format, ...) { char buffer[MAX_DEBUG_STRING]; int ret; if( ((_debugstring != 0) || (_debugfile != NULL )) && (level & _level) ) { va_list ap; va_start(ap, format); ret = _vsnprintf(buffer, MAX_DEBUG_STRING - 1, format, ap); va_end(ap); if (ret >= 0) _debug(level, buffer); } } void debug(int level, char *format, ...) { char buffer[MAX_DEBUG_STRING]; int ret; if( ((_debugstring != 0) || (_debugfile != NULL )) && (level & _level) ) { va_list ap; va_start(ap, format); ret = _vsnprintf(buffer, MAX_DEBUG_STRING - 1, format, ap); va_end(ap); if (ret >= 0) _debug(level, buffer); } } void _debug(int level, const char *buffer) { char stime[16]; char output[MAX_DEBUG_STRING]; int ret; LARGE_INTEGER time, freq; double dtime; unsigned long pid, tid; //#ifndef _DEBUGSTRING // if( ((_debugstring != 0) || (_debugfile != NULL )) && (level & _level) ) //#endif { // va_list ap; // va_start(ap, format); // ret = _vsnprintf(buffer, MAX_DEBUG_STRING - 1, format, ap); // va_end(ap); QueryPerformanceCounter(&time); QueryPerformanceFrequency(&freq); dtime = ((double) time.QuadPart - (double) dlltime.QuadPart ) / (double) freq.QuadPart; _snprintf(stime, 15, "%8.3f", dtime); pid = GetCurrentProcessId(); tid = GetCurrentThreadId(); switch (level) { case FLIDEBUG_INFO: ret = _snprintf(output, MAX_DEBUG_STRING - 1, "INFO<%s:%04X:%04X>: %s\n", stime, pid, tid, buffer); break; case FLIDEBUG_WARN: ret = _snprintf(output, MAX_DEBUG_STRING - 1, "WARN<%s:%04X:%04X>: %s\n", stime, pid, tid, buffer); break; case FLIDEBUG_FAIL: ret = _snprintf(output, MAX_DEBUG_STRING - 1, "FAIL<%s:%04X:%04X>: %s\n", stime, pid, tid, buffer); break; default: ret = _snprintf(output, MAX_DEBUG_STRING - 1, " ALL<%s:%04X:%04X>: %s\n", stime, pid, tid, buffer); break; } if(ret >= 0) { long locked = 0; if (debugmutex != NULL) { switch(WaitForSingleObject(debugmutex, 1000)) { case WAIT_OBJECT_0: locked = 1; break; default: OutputDebugString("libfli: failed to obtain debug mutex!\n"); break; } } if (_debugstring) { OutputDebugString(output); } if (_debugfile != NULL) { if (dfile == INVALID_HANDLE_VALUE) { dfile = CreateFile(_debugfile, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); SetFilePointer(dfile, 0, NULL, FILE_END); } if(dfile != INVALID_HANDLE_VALUE) { DWORD bytes; WriteFile(dfile, output, (DWORD) strlen(output), &bytes, NULL); //CloseHandle(dfile); //dfile = INVALID_HANDLE_VALUE; } } if (locked != 0) { ReleaseMutex(debugmutex); } } } return; } void setdebuglevel(char *host, long level) { if (_forced == 1) return; if (stricmp(host, "C:\\FLIDBG.TXT") == 0) _forced = 1; debug(FLIDEBUG_INFO, "Changing debug level to %d.", level); _level = level; _debugstring = (level & 0x80000000)?1:0; if (level == 0) { debug(FLIDEBUG_INFO, "Disabling debugging."); debugclose(); } else { debugopen(host); } return; } libfli-2.0+20221221182632/.project0000644000175100017510000000032614174600256015076 0ustar debiandebian Project-Source@libfli libfli-2.0+20221221182632/libfli-libfli.h0000644000175100017510000002130014174600256016273 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_LIBFLI_H_ #define _LIBFLI_LIBFLI_H_ //#define OLDUSBDRIVER //#define BADCOLUMN #include #ifdef DEFINELONG #define LIBFLIAPI long __stdcall #endif #ifdef _WIN32 #ifndef LIBFLIAPI //#define LIBFLIAPI __declspec(dllexport) long __stdcall #endif #define stricmp _stricmp #endif #include "libfli.h" #include "libfli-sys.h" #include "libfli-debug.h" #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #define __STRINGIFY(x) ___STRINGIFY(x) #define ___STRINGIFY(x) #x #define __LIBFLIVER_MAJOR__ 1 #define __LIBFLIVER__ __STRINGIFY(__LIBFLIVER_MAJOR__) "." \ __STRINGIFY(__LIBFLI_MINOR__) #define CHKDEVICE(xdev) \ do { \ if((xdev < 0) || (xdev >= MAX_OPEN_DEVICES)) \ { \ debug(FLIDEBUG_WARN, \ "[%s] Attempt to use a device out of range (%d)", __FUNCTION__, xdev); \ return -EINVAL; \ } \ if(devices[xdev] == NULL) \ { \ debug(FLIDEBUG_WARN, \ "[%s] Attempt to use a NULL device (%d)", __FUNCTION__, xdev); \ return -EINVAL; \ } \ } while(0) #define CHKFUNCTION(func) \ do { \ if(func == NULL) \ { \ debug(FLIDEBUG_WARN, \ "Attempt to use a NULL function (" #func ")"); \ return -EINVAL; \ } \ } while(0) #define IO(dev, buf, wlen, rlen) \ do { \ int err; \ if((err = devices[dev]->fli_io(dev, buf, wlen, rlen))) \ { \ debug(FLIDEBUG_WARN, "Communication error: %d [%s]", \ err, strerror(-err)); \ return err; \ } \ } while(0) #define COMMAND(function) \ do { \ int err; \ if((err = function)) \ { \ debug(FLIDEBUG_WARN, \ "Function `" #function "' failed, error: %d [%s]", \ err, strerror(-err)); \ return err; \ } \ } while(0) #define MSW(x) ((unsigned short) ((x >> 16) & 0xffff)) #define LSW(x) ((unsigned short) (x & 0xffff)) #define MSB(x) ((unsigned char) ((x >> 8) & 0xff)) #define LSB(x) ((unsigned char) (x & 0xff)) #define IOBUF_MAX_SIZ (64) typedef unsigned char iobuf_t; #define CLEARIO { memset(_buf, 0, IOBUF_MAX_SIZ); } #define IOREAD_U16L(b, i, y) { y = (*(b + i + 1) << 8) | *(b + i); } #define IOREAD_U8(b, i, y) { y = *(b + i); } #define IOREAD_U16(b, i, y) { y = (*(b + i) << 8) | *(b + i + 1); } #define IOREAD_U32(b, i, y) { y = (*(b + i) << 24) | *(b + i + 1) << 16 | \ *(b + i + 2) << 8 | *(b + i + 3); } #define IOWRITE_U8(b, i, y) { *(b + i) = (unsigned char) y; } #define IOWRITE_U16(b, i, y) { *(b + i) = MSB(y); *(b + i + 1) = LSB(y); } #define IOWRITE_U32(b, i, y) { *(b + i) = MSB(MSW(y)); *(b + i + 1) = LSB(MSW(y)); \ *(b + i + 2) = MSB(LSW(y)); *(b + i + 3) = LSB(LSW(y)); } #define IOREAD_LF(b, i, y) { y = dconvert(b + i); } #define FLIUSB_VENDORID 0xf18 #define FLIUSB_CAM_ID 0x02 #define FLIUSB_PROLINE_ID 0x0a #define FLIUSB_FILTER_ID 0x07 #define FLIUSB_FOCUSER_ID 0x06 #define FLIUSB_CFW4_ID 0x0b #define FLIUSB_PDF2_ID 0x0c #define FLIUSB_GUIDER_ID 0x0d #define MAX_OPEN_DEVICES (32) #define MAX_SEARCH_LIST (16) #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /* Common device information */ typedef struct _flidevinfo_t { long type; long fwrev; long hwrev; long devid; long serno; char *model; char *devnam; char *serial; } flidevinfo_t; /* A specific device instance */ typedef struct _flidevdesc_t { char *name; /* The device name */ long domain; /* The device's domain */ flidevinfo_t devinfo; /* Device information */ long io_timeout; /* Timeout in msec for all I/O */ void *io_data; /* For holding I/O specific data */ void *device_data; /* For holding device specific data */ void *sys_data; /* For holding system specific data */ /* System-specific functions */ long (*fli_lock)(flidev_t dev); long (*fli_unlock)(flidev_t dev); long (*fli_trylock)(flidev_t dev); /* Domain-specific functions */ long (*fli_io)(flidev_t dev, void *buf, long *wlen, long *rlen); /* Device-specific functions */ long (*fli_open)(flidev_t dev); long (*fli_close)(flidev_t dev); long (*fli_command)(flidev_t dev, int cmd, int argc, ...); } flidevdesc_t; extern const char* version; extern flidevdesc_t *devices[MAX_OPEN_DEVICES]; #define DEVICE devices[dev] /* Device commands, the format is FLI_COMMAND(, ) */ #define FLI_COMMANDS \ FLI_COMMAND(FLI_NONE, 0) \ FLI_COMMAND(FLI_GET_PIXEL_SIZE, 2) \ FLI_COMMAND(FLI_GET_ARRAY_AREA, 4) \ FLI_COMMAND(FLI_GET_VISIBLE_AREA, 4) \ FLI_COMMAND(FLI_SET_EXPOSURE_TIME, 1) \ FLI_COMMAND(FLI_SET_IMAGE_AREA, 4) \ FLI_COMMAND(FLI_SET_HBIN, 1) \ FLI_COMMAND(FLI_SET_VBIN, 1) \ FLI_COMMAND(FLI_SET_FRAME_TYPE, 1) \ FLI_COMMAND(FLI_CANCEL_EXPOSURE, 0) \ FLI_COMMAND(FLI_GET_EXPOSURE_STATUS, 1) \ FLI_COMMAND(FLI_SET_TEMPERATURE, 1) \ FLI_COMMAND(FLI_GET_TEMPERATURE, 1) \ FLI_COMMAND(FLI_GRAB_ROW, 2) \ FLI_COMMAND(FLI_EXPOSE_FRAME, 0) \ FLI_COMMAND(FLI_FLUSH_ROWS, 2) \ FLI_COMMAND(FLI_SET_FLUSHES, 1) \ FLI_COMMAND(FLI_SET_BIT_DEPTH, 1) \ FLI_COMMAND(FLI_READ_IOPORT, 1) \ FLI_COMMAND(FLI_WRITE_IOPORT, 1) \ FLI_COMMAND(FLI_CONFIGURE_IOPORT, 1) \ FLI_COMMAND(FLI_CONTROL_SHUTTER, 1) \ FLI_COMMAND(FLI_CONTROL_BGFLUSH, 1) \ FLI_COMMAND(FLI_SET_DAC, 1) \ FLI_COMMAND(FLI_SET_FILTER_POS, 1) \ FLI_COMMAND(FLI_GET_FILTER_POS, 1) \ FLI_COMMAND(FLI_GET_STEPS_REMAINING, 1) \ FLI_COMMAND(FLI_GET_FILTER_COUNT, 1) \ FLI_COMMAND(FLI_STEP_MOTOR, 1) \ FLI_COMMAND(FLI_SET_ACTIVE_WHEEL, 1) \ FLI_COMMAND(FLI_GET_ACTIVE_WHEEL, 1) \ FLI_COMMAND(FLI_STEP_MOTOR_ASYNC, 1) \ FLI_COMMAND(FLI_GET_STEPPER_POS, 1) \ FLI_COMMAND(FLI_GET_FOCUSER_EXTENT, 1) \ FLI_COMMAND(FLI_READ_TEMPERATURE, 2) \ FLI_COMMAND(FLI_HOME_FOCUSER, 0) \ FLI_COMMAND(FLI_HOME_DEVICE, 0) \ FLI_COMMAND(FLI_GET_COOLER_POWER, 1) \ FLI_COMMAND(FLI_SET_CAMERA_MODE, 1) \ FLI_COMMAND(FLI_GET_CAMERA_MODE_STRING, 3) \ FLI_COMMAND(FLI_GET_CAMERA_MODE, 1) \ FLI_COMMAND(FLI_SET_CAMERA_GAIN, 1) \ FLI_COMMAND(FLI_GET_CAMERA_GAIN, 1) \ FLI_COMMAND(FLI_SET_CAMERA_OFFSET, 1) \ FLI_COMMAND(FLI_GET_CAMERA_OFFSET, 1) \ FLI_COMMAND(FLI_SET_TDI, 2) \ FLI_COMMAND(FLI_GET_STATUS, 1) \ FLI_COMMAND(FLI_START_VIDEO_MODE, 0) \ FLI_COMMAND(FLI_STOP_VIDEO_MODE, 0) \ FLI_COMMAND(FLI_GRAB_VIDEO_FRAME, 2) \ FLI_COMMAND(FLI_END_EXPOSURE, 0) \ FLI_COMMAND(FLI_TRIGGER_EXPOSURE, 0) \ FLI_COMMAND(FLI_SET_FAN_SPEED, 1) \ FLI_COMMAND(FLI_SET_VERTICAL_TABLE_ENTRY, 4) \ FLI_COMMAND(FLI_GET_VERTICAL_TABLE_ENTRY, 4) \ FLI_COMMAND(FLI_GET_READOUT_DIMENSIONS, 6) \ FLI_COMMAND(FLI_ENABLE_VERTICAL_TABLE, 3) \ FLI_COMMAND(FLI_READ_EEPROM, 4) \ FLI_COMMAND(FLI_WRITE_EEPROM, 4) \ FLI_COMMAND(FLI_GET_FILTER_NAME, 3) \ /* Enumerate the commands */ enum _commands { #define FLI_COMMAND(name, args) name, FLI_COMMANDS #undef FLI_COMMAND }; #endif /* _LIBFLI_LIBFLI_H_ */ libfli-2.0+20221221182632/libfli.dxx0000644000175100017510000000244414174600256015420 0ustar debiandebian/* -*- mode: c; -*- */ /** @name FLI Software Development Library @version 1.40 @author \URL[Finger Lakes Instrumentation]{http://www.fli-cam.com} \\ Copyright (c) 2000-2002 Finger Lakes Instrumentation (FLI), LLC. \\ All rights reserved. @memo Windows and Linux support for FLI CCD cameras, filter wheels, and focusers. */ //@{ /** @name Introduction This library provides a core set of functions for programming FLI CCD cameras, filter wheels, and focusers under Windows and Linux. The type definitions, function prototypes, and definitions/enumerations of constant values used by library functions are spcified in \texttt{libfli.h}. All library functions return zero on sucessful completion, and non-zero if an error occurred. The exact nature of an error can be found by treating the negative of a function's return value as a system error code, for example: \begin{verbatim} if ((err = FLIOpen(&dev, name, domain))) { fprintf(stderr, "Error FLIOpen: %s\n", strerror((int)-err)); exit(1); } \end{verbatim} */ /** @name Library Defined Types */ //@{ //@Include: libfli.h //@} /** @name Library Functions */ //@{ //@Include: libfli.c //@} //@} libfli-2.0+20221221182632/libfli-camera-usb.h0000644000175100017510000001647414174600256017071 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_CAMERA_USB_H_ #define _LIBFLI_CAMERA_USB_H_ #define FLI_USBCAM_DEVICENAME 0x01 #define FLI_USBCAM_DEVICEMFG 0x02 #define FLI_USBCAM_VERSION 0x03 #define FLI_USBCAM_DEVICEID 0x04 #define FLI_USBCAM_SERIALNUM 0x05 #define FLI_USBCAM_HARDWAREREV 0x06 #define FLI_USBCAM_DEVINIT 0x07 #define FLI_USBCAM_READPARAMBLOCK 0x08 #define FLI_USBCAM_ARRAYSIZE 0x100 #define FLI_USBCAM_IMAGEOFFSET 0x102 #define FLI_USBCAM_IMAGESIZE 0x103 #define FLI_USBCAM_TEMPERATURE 0x104 #define FLI_USBCAM_SETFRAMEOFFSET 0x105 #define FLI_USBCAM_SETBINFACTORS 0x106 #define FLI_USBCAM_SETFLUSHBINFACTORS 0x107 #define FLI_USBCAM_SETEXPOSURE 0x108 #define FLI_USBCAM_STARTEXPOSURE 0x109 #define FLI_USBCAM_ABORTEXPOSURE 0x10a #define FLI_USBCAM_EXPOSURESTATUS 0x10b #define FLI_USBCAM_FLUSHROWS 0x10c #define FLI_USBCAM_SENDROW 0x10d #define FLI_USBCAM_SETDAC 0x10e #define FLI_USBCAM_SHUTTER 0x10f #define FLI_USBCAM_WRITEIO 0x110 #define FLI_USBCAM_READIO 0x111 #define FLI_USBCAM_WRITEDIR 0x112 #define FLI_USBCAM_BGFLUSH 0x114 #define PROLINE_GET_HARDWAREINFO (0x0001) #define PROLINE_GET_DEVICESTRINGS (0x0002) #define PROLINE_GET_CAMERAINFO (0x0003) #define PROLINE_COMMAND_GET_ROW (0x0004) #define PROLINE_COMMAND_EXPOSE (0x0005) #define PROLINE_COMMAND_GET_EXPOSURE_STATUS (0x0006) #define PROLINE_COMMAND_CANCEL_EXPOSURE (0x0007) #define PROLINE_COMMAND_GET_TEMPERATURE (0x0008) #define PROLINE_COMMAND_SET_TEMPERATURE (0x0009) #define PROLINE_COMMAND_SET_SHUTTER (0x000a) #define PROLINE_COMMAND_SET_BGFLUSH (0x000b) #define PROLINE_COMMAND_GET_STATUS (0x000c) #define PROLINE_COMMAND_GET_CURRENT_MODE (0x000d) #define PROLINE_COMMAND_GET_MODE_STRING (0x000e) #define PROLINE_COMMAND_SET_MODE (0x000f) #define PROLINE_COMMAND_CONFIGURE_IOPORT (0x0010) #define PROLINE_COMMAND_WRITE_IOPORT (0x0011) #define PROLINE_COMMAND_READ_IOPORT (0x0012) #define PROLINE_COMMAND_SET_TDI_MODE (0x0013) #define PROLINE_COMMAND_UPDATE_EXPOSURE (0x0015) #define PROLINE_COMMAND_SET_FAN_SPEED (0x0016) #define PROLINE_COMMAND_SET_VERTICAL_TABLE_ENTRY (0x0017) #define PROLINE_COMMAND_GET_VERTICAL_TABLE_ENTRY (0x0018) #define PROLINE_COMMAND_READ_USER_EEPROM (0x0020) #define PROLINE_COMMAND_WRITE_USER_EEPROM (0x0021) long fli_camera_usb_open(flidev_t dev); long fli_camera_usb_get_array_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y); long fli_camera_usb_get_visible_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y); long fli_camera_usb_set_exposure_time(flidev_t dev, unsigned long exptime); long fli_camera_usb_set_image_area(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y); long fli_camera_usb_set_hbin(flidev_t dev, long hbin); long fli_camera_usb_set_vbin(flidev_t dev, long vbin); long fli_camera_usb_get_exposure_status(flidev_t dev, long *timeleft); long fli_camera_usb_cancel_exposure(flidev_t dev); long fli_camera_usb_set_temperature(flidev_t dev, double temperature); long fli_camera_usb_get_temperature(flidev_t dev, double *temperature); long fli_camera_usb_grab_row(flidev_t dev, void *buff, size_t width); long fli_camera_usb_expose_frame(flidev_t dev); long fli_camera_usb_flush_rows(flidev_t dev, long rows, long repeat); long fli_camera_usb_set_bit_depth(flidev_t dev, flibitdepth_t bitdepth); long fli_camera_usb_read_ioport(flidev_t dev, long *ioportset); long fli_camera_usb_write_ioport(flidev_t dev, long ioportset); long fli_camera_usb_configure_ioport(flidev_t dev, long ioportset); long fli_camera_usb_control_shutter(flidev_t dev, long shutter); long fli_camera_usb_control_bgflush(flidev_t dev, long bgflush); long fli_camera_usb_set_dac(flidev_t dev, unsigned long dacset); long fli_camera_usb_get_cooler_power(flidev_t dev, double *power); long fli_camera_usb_get_camera_status(flidev_t dev, long *camera_status); long fli_camera_usb_get_camera_mode_string(flidev_t dev, flimode_t camera_mode, char *dest, size_t siz); long fli_camera_usb_set_camera_mode(flidev_t dev, flimode_t camera_mode); long fli_camera_usb_get_camera_mode(flidev_t dev, flimode_t *camera_mode); long fli_camera_usb_read_temperature(flidev_t dev, flichannel_t channel, double *temperature); long fli_camera_usb_set_tdi(flidev_t dev, flitdirate_t rate, flitdiflags_t flags); long fli_camera_usb_start_video_mode(flidev_t dev); long fli_camera_usb_stop_video_mode(flidev_t dev); long fli_camera_usb_start_video_mode(flidev_t dev); long fli_camera_usb_grab_video_frame(flidev_t dev, void *buff, size_t size); long fli_camera_usb_end_exposure(flidev_t dev); long fli_camera_usb_trigger_exposure(flidev_t dev); long fli_camera_usb_set_fan_speed(flidev_t dev, long fan_speed); long fli_camera_usb_enable_custom_vertical_table(flidev_t dev, long width, long offset, long bin, long flags); long fli_camera_usb_get_vertical_table_entry(flidev_t dev, long index, long *height, long *bin, long *mode); long fli_camera_usb_set_vertical_table_entry(flidev_t dev, long index, long height, long bin, long mode); long fli_camera_usb_get_readout_dimensions(flidev_t dev, long *width, long *hoffset, long *hbin, long *height, long *voffset, long *vbin); long fli_camera_usb_enable_vertical_table(flidev_t dev, long width, long offset, long flags); long fli_camera_usb_read_eeprom(flidev_t dev, long loc, long address, long length, void *rbuf); long fli_camera_usb_write_eeprom(flidev_t dev, long loc, long address, long length, void *wbuf); #endif /* _LIBFLI_CAMERA_USB_H_ */ libfli-2.0+20221221182632/LICENSE.BSD0000644000175100017510000000225014174600256015041 0ustar debiandebianRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. libfli-2.0+20221221182632/libfli-camera-parport.h0000644000175100017510000001066514174600256017763 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_CAMERA_PARPORT_H_ #define _LIBFLI_CAMERA_PARPORT_H_ /* Define command and data word formats */ #define C_ADDRESS(addr,ext) (0x8000|(((addr)<<8)&0x0f00)|((ext)&0x00ff)) #define C_RESTCFG(gain,chnl,exttrig,res) (0x9000|(((gain)<<8)&0x0f00)|(((chnl)<<5)&0x00e0)|(((exttrig)<<4)&0x0010)|(((res)&0x000f))) #define C_SHUTTER(open,dmult) (0xa000|((dmult)&0x07ff)|(((open)<<11)&0x0800)) #define C_SEND(x) (0xb000|((x)&0x0fff)) #define C_FLUSH(x) (0xc000|((x)&0x0fff)) #define C_VSKIP(x) (0xd000|((x)&0x0fff)) #define C_HSKIP(x) (0xe000|((x)&0x0fff)) #define C_TEMP(x) (0xf000|((x)&0x0fff)) #define D_XROWOFF(x) (0x0000|((x)&0x0fff)) #define D_XROWWID(x) (0x1000|((x)&0x0fff)) #define D_XFLBIN(x) (0x2000|((x)&0x0fff)) #define D_YFLBIN(x) (0x3000|((x)&0x0fff)) #define D_XBIN(x) (0x4000|((x)&0x0fff)) #define D_YBIN(x) (0x5000|((x)&0x0fff)) #define D_EXPDUR(x) (0x6000|((x)&0x0fff)) #define D_RESERVE(x) (0x7000|((x)&0x0fff)) /* Define extended parameter fields for querying camera */ #define EPARAM_ECHO (0x00) #define EPARAM_CCDID (0x01) #define EPARAM_FIRM (0x02) #define EPARAM_SNHIGH (0x03) #define EPARAM_SNLOW (0x04) #define EPARAM_SIGGAIN (0x05) #define EPARAM_DEVICE (0x06) /* I/O Bit definitions */ #define FLICCD_IO_P0 (0x01) #define FLICCD_IO_P1 (0x02) #define FLICCD_IO_P2 (0x04) #define FLICCD_IO_P3 (0x08) long fli_camera_parport_open(flidev_t dev); long fli_camera_parport_get_array_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y); long fli_camera_parport_get_visible_area(flidev_t dev, long *ul_x, long *ul_y, long *lr_x, long *lr_y); long fli_camera_parport_set_exposure_time(flidev_t dev, long exptime); long fli_camera_parport_set_image_area(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y); long fli_camera_parport_set_hbin(flidev_t dev, long hbin); long fli_camera_parport_set_vbin(flidev_t dev, long vbin); long fli_camera_parport_get_exposure_status(flidev_t dev, long *timeleft); long fli_camera_parport_set_temperature(flidev_t dev, double temperature); long fli_camera_parport_get_temperature(flidev_t dev, double *temperature); long fli_camera_parport_grab_row(flidev_t dev, void *buf, size_t width); long fli_camera_parport_expose_frame(flidev_t dev); long fli_camera_parport_flush_rows(flidev_t dev, long rows, long repeat); long fli_camera_parport_set_bit_depth(flidev_t dev, flibitdepth_t bitdepth); long fli_camera_parport_read_ioport(flidev_t dev, long *ioportset); long fli_camera_parport_write_ioport(flidev_t dev, long ioportset); long fli_camera_parport_configure_ioport(flidev_t dev, long ioportset); long fli_camera_parport_control_shutter(flidev_t dev, long shutter); #endif /* _LIBFLI_CAMERA_PARPORT_H_ */ libfli-2.0+20221221182632/libfli.h0000644000175100017510000003165514174600256015052 0ustar debiandebian/* Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifndef _LIBFLI_H_ #define _LIBFLI_H_ #include /** An opaque handle used by library functions to refer to FLI hardware. */ #define FLI_INVALID_DEVICE (-1) typedef long flidev_t; /** The domain of an FLI device. This consists of a bitwise ORed combination of interface method and device type. Valid interfaces are \texttt{FLIDOMAIN_PARALLEL_PORT}, \texttt{FLIDOMAIN_USB}, \texttt{FLIDOMAIN_SERIAL}, and \texttt{FLIDOMAIN_INET}. Valid device types are \texttt{FLIDEVICE_CAMERA}, \texttt{FLIDOMAIN_FILTERWHEEL}, and \texttt{FLIDOMAIN_FOCUSER}. @see FLIOpen @see FLIList */ typedef long flidomain_t; #define FLIDOMAIN_NONE (0x00) #define FLIDOMAIN_PARALLEL_PORT (0x01) #define FLIDOMAIN_USB (0x02) #define FLIDOMAIN_SERIAL (0x03) #define FLIDOMAIN_INET (0x04) #define FLIDOMAIN_SERIAL_19200 (0x05) #define FLIDOMAIN_SERIAL_1200 (0x06) #define FLIDOMAIN_INTERFACE_MASK (0x000f) #define FLIDEVICE_NONE (0x000) #define FLIDEVICE_CAMERA (0x100) #define FLIDEVICE_FILTERWHEEL (0x200) #define FLIDEVICE_FOCUSER (0x300) #define FLIDEVICE_HS_FILTERWHEEL (0x0400) #define FLIDEVICE_RAW (0x0f00) #define FLIDOMAIN_DEVICE_MASK (0x0f00) /* The following two are really the same. ..._CONNECTION is old (deprecated) */ #define FLIDEVICE_ENUMERATE_BY_CONNECTION (0x8000) #define FLIDEVICE_ENUMERATE_BY_SERIAL (0x8000) #define FLIDOMAIN_OPTIONS_MASK (0xf000) /** The frame type for an FLI CCD camera device. Valid frame types are \texttt{FLI_FRAME_TYPE_NORMAL} and \texttt{FLI_FRAME_TYPE_DARK}. @see FLISetFrameType */ typedef long fliframe_t; #define FLI_FRAME_TYPE_NORMAL (0) #define FLI_FRAME_TYPE_DARK (1) #define FLI_FRAME_TYPE_FLOOD (2) #define FLI_FRAME_TYPE_RBI_FLUSH (FLI_FRAME_TYPE_FLOOD | FLI_FRAME_TYPE_DARK) /** The gray-scale bit depth for an FLI camera device. Valid bit depths are \texttt{FLI_MODE_8BIT} and \texttt{FLI_MODE_16BIT}. @see FLISetBitDepth */ typedef long flibitdepth_t; #define FLI_MODE_8BIT (0) #define FLI_MODE_16BIT (1) /** Type used for shutter operations for an FLI camera device. Valid shutter types are \texttt{FLI_SHUTTER_CLOSE}, \texttt{FLI_SHUTTER_OPEN}, \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER}, \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER_LOW}, and \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER_HIGH}. @see FLIControlShutter */ typedef long flishutter_t; #define FLI_SHUTTER_CLOSE (0x0000) #define FLI_SHUTTER_OPEN (0x0001) #define FLI_SHUTTER_EXTERNAL_TRIGGER (0x0002) #define FLI_SHUTTER_EXTERNAL_TRIGGER_LOW (0x0002) #define FLI_SHUTTER_EXTERNAL_TRIGGER_HIGH (0x0004) #define FLI_SHUTTER_EXTERNAL_EXPOSURE_CONTROL (0x0008) /** Type used for background flush operations for an FLI camera device. Valid bgflush types are \texttt{FLI_BGFLUSH_STOP} and \texttt{FLI_BGFLUSH_START}. @see FLIControlBackgroundFlush */ typedef long flibgflush_t; #define FLI_BGFLUSH_STOP (0x0000) #define FLI_BGFLUSH_START (0x0001) /** Type used to determine which temperature channel to read. Valid channel types are \texttt{FLI_TEMPERATURE_INTERNAL} and \texttt{FLI_TEMPERATURE_EXTERNAL}. @see FLIReadTemperature */ typedef long flichannel_t; #define FLI_TEMPERATURE_INTERNAL (0x0000) #define FLI_TEMPERATURE_EXTERNAL (0x0001) #define FLI_TEMPERATURE_CCD (0x0000) #define FLI_TEMPERATURE_BASE (0x0001) /** Type specifying library debug levels. Valid debug levels are \texttt{FLIDEBUG_NONE}, \texttt{FLIDEBUG_INFO}, \texttt{FLIDEBUG_WARN}, and \texttt{FLIDEBUG_FAIL}. @see FLISetDebugLevel */ typedef long flidebug_t; typedef long flimode_t; typedef long flistatus_t; typedef long flitdirate_t; typedef long flitdiflags_t; /* Status settings */ #define FLI_CAMERA_STATUS_UNKNOWN (0xffffffff) #define FLI_CAMERA_STATUS_MASK (0x00000003) #define FLI_CAMERA_STATUS_IDLE (0x00) #define FLI_CAMERA_STATUS_WAITING_FOR_TRIGGER (0x01) #define FLI_CAMERA_STATUS_EXPOSING (0x02) #define FLI_CAMERA_STATUS_READING_CCD (0x03) #define FLI_CAMERA_DATA_READY (0x80000000) #define FLI_FOCUSER_STATUS_UNKNOWN (0xffffffff) #define FLI_FOCUSER_STATUS_HOMING (0x00000004) #define FLI_FOCUSER_STATUS_MOVING_IN (0x00000001) #define FLI_FOCUSER_STATUS_MOVING_OUT (0x00000002) #define FLI_FOCUSER_STATUS_MOVING_MASK (0x00000007) #define FLI_FOCUSER_STATUS_HOME (0x00000080) #define FLI_FOCUSER_STATUS_LIMIT (0x00000040) #define FLI_FOCUSER_STATUS_LEGACY (0x10000000) #define FLI_FILTER_WHEEL_PHYSICAL (0x100) #define FLI_FILTER_WHEEL_VIRTUAL (0) #define FLI_FILTER_WHEEL_LEFT (FLI_FILTER_WHEEL_PHYSICAL | 0x00) #define FLI_FILTER_WHEEL_RIGHT (FLI_FILTER_WHEEL_PHYSICAL | 0x01) #define FLI_FILTER_STATUS_MOVING_CCW (0x01) #define FLI_FILTER_STATUS_MOVING_CW (0x02) #define FLI_FILTER_POSITION_UNKNOWN (0xff) #define FLI_FILTER_POSITION_CURRENT (0x200) #define FLI_FILTER_STATUS_HOMING (0x00000004) #define FLI_FILTER_STATUS_HOME (0x00000080) #define FLI_FILTER_STATUS_HOME_LEFT (0x00000080) #define FLI_FILTER_STATUS_HOME_RIGHT (0x00000040) #define FLI_FILTER_STATUS_HOME_SUCCEEDED (0x00000008) #define FLIDEBUG_NONE (0x00) #define FLIDEBUG_INFO (0x01) #define FLIDEBUG_WARN (0x02) #define FLIDEBUG_FAIL (0x04) #define FLIDEBUG_IO (0x08) #define FLIDEBUG_ALL (FLIDEBUG_INFO | FLIDEBUG_WARN | FLIDEBUG_FAIL) #define FLI_IO_P0 (0x01) #define FLI_IO_P1 (0x02) #define FLI_IO_P2 (0x04) #define FLI_IO_P3 (0x08) #define FLI_FAN_SPEED_OFF (0x00) #define FLI_FAN_SPEED_ON (0xffffffff) #define FLI_EEPROM_USER (0x00) #define FLI_EEPROM_PIXEL_MAP (0x01) #define FLI_PIXEL_DEFECT_COLUMN (0x00) #define FLI_PIXEL_DEFECT_CLUSTER (0x10) #define FLI_PIXEL_DEFECT_POINT_BRIGHT (0x20) #define FLI_PIXEL_DEFECT_POINT_DARK (0x30) #ifndef LIBFLIAPI # ifdef _WIN32 # ifdef _LIB # define LIBFLIAPI long __stdcall # else # ifdef _USRDLL /* The module definition file precludes using __declspec(dllexport) */ /*# define LIBFLIAPI __declspec(dllexport) long __stdcall */ # define LIBFLIAPI long __stdcall # else # define LIBFLIAPI __declspec(dllimport) long __stdcall # endif # endif # else # define LIBFLIAPI long # endif #endif /* Library API Function prototypes */ #ifdef __cplusplus extern "C" { // only need to export C interface if used by C++ source code #endif #ifdef WIN32 void __cdecl FLIDebug(int level, char *format, ...); #else void FLIDebug(int level, char *format, ...); #endif LIBFLIAPI FLIOpen(flidev_t *dev, char *name, flidomain_t domain); LIBFLIAPI FLISetDebugLevel(char *host, flidebug_t level); LIBFLIAPI FLIClose(flidev_t dev); LIBFLIAPI FLIGetLibVersion(char* ver, size_t len); LIBFLIAPI FLIGetModel(flidev_t dev, char* model, size_t len); LIBFLIAPI FLIGetPixelSize(flidev_t dev, double *pixel_x, double *pixel_y); LIBFLIAPI FLIGetHWRevision(flidev_t dev, long *hwrev); LIBFLIAPI FLIGetFWRevision(flidev_t dev, long *fwrev); LIBFLIAPI FLIGetArrayArea(flidev_t dev, long* ul_x, long* ul_y, long* lr_x, long* lr_y); LIBFLIAPI FLIGetVisibleArea(flidev_t dev, long* ul_x, long* ul_y, long* lr_x, long* lr_y); LIBFLIAPI FLISetExposureTime(flidev_t dev, long exptime); LIBFLIAPI FLISetImageArea(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y); LIBFLIAPI FLISetHBin(flidev_t dev, long hbin); LIBFLIAPI FLISetVBin(flidev_t dev, long vbin); LIBFLIAPI FLISetFrameType(flidev_t dev, fliframe_t frametype); LIBFLIAPI FLICancelExposure(flidev_t dev); LIBFLIAPI FLIGetExposureStatus(flidev_t dev, long *timeleft); LIBFLIAPI FLISetTemperature(flidev_t dev, double temperature); LIBFLIAPI FLIGetTemperature(flidev_t dev, double *temperature); LIBFLIAPI FLIGetCoolerPower(flidev_t dev, double *power); LIBFLIAPI FLIGrabRow(flidev_t dev, void *buff, size_t width); LIBFLIAPI FLIExposeFrame(flidev_t dev); LIBFLIAPI FLIFlushRow(flidev_t dev, long rows, long repeat); LIBFLIAPI FLISetNFlushes(flidev_t dev, long nflushes); LIBFLIAPI FLISetBitDepth(flidev_t dev, flibitdepth_t bitdepth); LIBFLIAPI FLIReadIOPort(flidev_t dev, long *ioportset); LIBFLIAPI FLIWriteIOPort(flidev_t dev, long ioportset); LIBFLIAPI FLIConfigureIOPort(flidev_t dev, long ioportset); LIBFLIAPI FLILockDevice(flidev_t dev); LIBFLIAPI FLIUnlockDevice(flidev_t dev); LIBFLIAPI FLIControlShutter(flidev_t dev, flishutter_t shutter); LIBFLIAPI FLIControlBackgroundFlush(flidev_t dev, flibgflush_t bgflush); LIBFLIAPI FLISetDAC(flidev_t dev, unsigned long dacset); LIBFLIAPI FLIList(flidomain_t domain, char ***names); LIBFLIAPI FLIFreeList(char **names); LIBFLIAPI FLIGetFilterName(flidev_t dev, long filter, char *name, size_t len); LIBFLIAPI FLISetActiveWheel(flidev_t dev, long wheel); LIBFLIAPI FLIGetActiveWheel(flidev_t dev, long *wheel); LIBFLIAPI FLISetFilterPos(flidev_t dev, long filter); LIBFLIAPI FLIGetFilterPos(flidev_t dev, long *filter); LIBFLIAPI FLIGetFilterCount(flidev_t dev, long *filter); LIBFLIAPI FLIStepMotor(flidev_t dev, long steps); LIBFLIAPI FLIStepMotorAsync(flidev_t dev, long steps); LIBFLIAPI FLIGetStepperPosition(flidev_t dev, long *position); LIBFLIAPI FLIGetStepsRemaining(flidev_t dev, long *steps); LIBFLIAPI FLIHomeFocuser(flidev_t dev); LIBFLIAPI FLICreateList(flidomain_t domain); LIBFLIAPI FLIDeleteList(void); LIBFLIAPI FLIListFirst(flidomain_t *domain, char *filename, size_t fnlen, char *name, size_t namelen); LIBFLIAPI FLIListNext(flidomain_t *domain, char *filename, size_t fnlen, char *name, size_t namelen); LIBFLIAPI FLIReadTemperature(flidev_t dev, flichannel_t channel, double *temperature); LIBFLIAPI FLIGetFocuserExtent(flidev_t dev, long *extent); LIBFLIAPI FLIUsbBulkIO(flidev_t dev, int ep, void *buf, long *len); LIBFLIAPI FLIGetDeviceStatus(flidev_t dev, long *status); LIBFLIAPI FLIGetCameraModeString(flidev_t dev, flimode_t mode_index, char *mode_string, size_t siz); LIBFLIAPI FLIGetCameraMode(flidev_t dev, flimode_t *mode_index); LIBFLIAPI FLISetCameraMode(flidev_t dev, flimode_t mode_index); LIBFLIAPI FLIHomeDevice(flidev_t dev); LIBFLIAPI FLIGrabFrame(flidev_t dev, void* buff, size_t buffsize, size_t* bytesgrabbed); LIBFLIAPI FLISetTDI(flidev_t dev, flitdirate_t tdi_rate, flitdiflags_t flags); LIBFLIAPI FLIGrabVideoFrame(flidev_t dev, void *buff, size_t size); LIBFLIAPI FLIStopVideoMode(flidev_t dev); LIBFLIAPI FLIStartVideoMode(flidev_t dev); LIBFLIAPI FLIGetSerialString(flidev_t dev, char* serial, size_t len); LIBFLIAPI FLIEndExposure(flidev_t dev); LIBFLIAPI FLITriggerExposure(flidev_t dev); LIBFLIAPI FLISetFanSpeed(flidev_t dev, long fan_speed); LIBFLIAPI FLISetVerticalTableEntry(flidev_t dev, long index, long height, long bin, long mode); LIBFLIAPI FLIGetVerticalTableEntry(flidev_t dev, long index, long *height, long *bin, long *mode); LIBFLIAPI FLIGetReadoutDimensions(flidev_t dev, long *width, long *hoffset, long *hbin, long *height, long *voffset, long *vbin); LIBFLIAPI FLIEnableVerticalTable(flidev_t dev, long width, long offset, long flags); LIBFLIAPI FLIReadUserEEPROM(flidev_t dev, long loc, long address, long length, void *rbuf); LIBFLIAPI FLIWriteUserEEPROM(flidev_t dev, long loc, long address, long length, void *wbuf); #ifdef __cplusplus } #endif #endif /* _LIBFLI_H_ */ libfli-2.0+20221221182632/libfli.c0000644000175100017510000014214014174600256015035 0ustar debiandebian/* Copyright (c) 2000, 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #include #include #include #include "libfli-libfli.h" #include "libfli-mem.h" #include "libfli-debug.h" #include "indimacros.h" static long devalloc(flidev_t *dev); static long devfree(flidev_t dev); static long fli_open(flidev_t *dev, char *name, long domain); static long fli_close(flidev_t dev); static long fli_freelist(char **names); flidevdesc_t *devices[MAX_OPEN_DEVICES] = {NULL,}; //#define SHOWFUNCTIONS const char* version = \ "Software Development Library for " __SYSNAME__ " " __LIBFLIVER__; static long devalloc(flidev_t *dev) { int i; if (dev == NULL) return -EINVAL; for (i = 0; i < MAX_OPEN_DEVICES; i++) if (devices[i] == NULL) break; if (i == MAX_OPEN_DEVICES) return -ENODEV; if ((devices[i] = (flidevdesc_t *)xcalloc(1, sizeof(flidevdesc_t))) == NULL) return -ENOMEM; *dev = i; return 0; } static long devfree(flidev_t dev) { CHKDEVICE(dev); if (DEVICE->io_data != NULL) { debug(FLIDEBUG_WARN, "close didn't free io_data (not NULL)"); xfree(DEVICE->io_data); DEVICE->io_data = NULL; } if (DEVICE->device_data != NULL) { debug(FLIDEBUG_WARN, "close didn't free device_data (not NULL)"); xfree(DEVICE->device_data); DEVICE->device_data = NULL; } if (DEVICE->sys_data != NULL) { debug(FLIDEBUG_WARN, "close didn't free sys_data (not NULL)"); xfree(DEVICE->sys_data); DEVICE->sys_data = NULL; } if (DEVICE->name != NULL) { xfree(DEVICE->name); DEVICE->name = NULL; } xfree(DEVICE); DEVICE = NULL; return 0; } static long fli_open(flidev_t *dev, char *name, long domain) { int retval; debug(FLIDEBUG_INFO, "Trying to open file <%s> in domain %d.", name, domain); if ((retval = devalloc(dev)) != 0) { debug(FLIDEBUG_WARN, "error devalloc() %d [%s]", retval, strerror(-retval)); return retval; } debug(FLIDEBUG_INFO, "Got device index %d", *dev); if ((retval = fli_connect(*dev, name, domain)) != 0) { debug(FLIDEBUG_WARN, "connect() error %d [%s]", retval, strerror(-retval)); devfree(*dev); return retval; } if ((retval = devices[*dev]->fli_open(*dev)) != 0) { debug(FLIDEBUG_WARN, "open() error %d [%s]", retval, strerror(-retval)); fli_disconnect(*dev); devfree(*dev); return retval; } return retval; } static long fli_close(flidev_t dev) { CHKDEVICE(dev); CHKFUNCTION(DEVICE->fli_close); debug(FLIDEBUG_INFO, "Closing device index: %d ", dev); DEVICE->fli_close(dev); fli_disconnect(dev); devfree(dev); return 0; } static long fli_freelist(char **names) { int i; if (names == NULL) return 0; for (i = 0; names[i] != NULL; i++) xfree(names[i]); xfree(names); return 0; } /* This is for FLI INTERNAL USE ONLY */ #ifdef _WIN32 long usb_bulktransfer(flidev_t dev, int ep, void *buf, long *len); #elif defined(__APPLE__) && !defined(__LIBUSB__) long mac_bulktransfer(flidev_t dev, int ep, void *buf, long *len); #define usb_bulktransfer mac_bulktransfer #elif defined(__LINUX__) long linux_bulktransfer(flidev_t dev, int ep, void *buf, long *len); #define usb_bulktransfer linux_bulktransfer #else long libusb_bulktransfer(flidev_t dev, int ep, void *buf, long *len); #define usb_bulktransfer libusb_bulktransfer #endif LIBFLIAPI FLIStartVideoMode(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_START_VIDEO_MODE, 0); } LIBFLIAPI FLIStopVideoMode(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_STOP_VIDEO_MODE, 0); } LIBFLIAPI FLIGrabVideoFrame(flidev_t dev, void *buff, size_t size) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GRAB_VIDEO_FRAME, 2, buff, &size); } LIBFLIAPI FLIUsbBulkIO(flidev_t dev, int ep, void *buf, long *len) { return usb_bulktransfer(dev, ep, buf, len); } LIBFLIAPI FLIGrabFrame(flidev_t dev, void* buff, size_t buffsize, size_t* bytesgrabbed) { INDI_UNUSED(dev); INDI_UNUSED(buff); INDI_UNUSED(buffsize); INDI_UNUSED(bytesgrabbed); return -EINVAL; } /** Cancel an exposure for a given camera. This function cancels an exposure in progress by closing the shutter. @param dev Camera to cancel the exposure of. @return Zero on success. @return Non-zero on failure. @see FLIExposeFrame @see FLIEndExposure @see FLIGetExposureStatus @see FLISetExposureTime */ LIBFLIAPI FLICancelExposure(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_CANCEL_EXPOSURE, 0); } /** End an exposure for a given camera. This function causes the exposure to end and image download begins immediately. @param dev Camera to end the exposure of. @return Zero on success. @return Non-zero on failure. @see FLIExposeFrame @see FLICancelExposure @see FLIGetExposureStatus @see FLISetExposureTime */ LIBFLIAPI FLIEndExposure(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_END_EXPOSURE, 0); } /** Trigger an exposure that is awaiting an external trigger. This is a software override for the external trigger option. @param dev Camera to trigger the exposure of. @return Zero on success. @return Non-zero on failure. @see FLIExposeFrame @see FLICancelExposure @see FLIEndExposure @see FLIGetExposureStatus @see FLISetExposureTime */ LIBFLIAPI FLITriggerExposure(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_TRIGGER_EXPOSURE, 0); } /** Close a handle to a FLI device. @param dev The device handle to be closed. @return Zero on success. @return Non-zero on failure. @see FLIOpen */ LIBFLIAPI FLIClose(flidev_t dev) { long r; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = fli_close(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Get the array area of the given camera. This function finds the \emph{total} area of the CCD array for camera \texttt{dev}. This area is specified in terms of a upper-left point and a lower-right point. The upper-left x-coordinate is placed in \texttt{ul_x}, the upper-left y-coordinate is placed in \texttt{ul_y}, the lower-right x-coordinate is placed in \texttt{lr_x}, and the lower-right y-coordinate is placed in \texttt{lr_y}. @param dev Camera to get the array area of. @param ul_x Pointer to where the upper-left x-coordinate is to be placed. @param ul_y Pointer to where the upper-left y-coordinate is to be placed. @param lr_x Pointer to where the lower-right x-coordinate is to be placed. @param lr_y Pointer to where the lower-right y-coordinate is to be placed. @return Zero on success. @return Non-zero on failure. @see FLIGetVisibleArea @see FLISetImageArea */ LIBFLIAPI FLIGetArrayArea(flidev_t dev, long* ul_x, long* ul_y, long* lr_x, long* lr_y) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_ARRAY_AREA, 4, ul_x, ul_y, lr_x, lr_y); } /** Flush rows of a given camera. This function flushes \texttt{rows} rows of camera \texttt{dev} \texttt{repeat} times. @param dev Camera to flush rows of. @param rows Number of rows to flush. @param repeat Number of times to flush each row. @return Zero on success. @return Non-zero on failure. @see FLISetNFlushes */ LIBFLIAPI FLIFlushRow(flidev_t dev, long rows, long repeat) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_FLUSH_ROWS, 2, &rows, &repeat); } /** Get firmware revision of a given device. @param dev Device to find the firmware revision of. @param fwrev Pointer to a long which will receive the firmware revision. @return Zero on success. @return Non-zero on failure. @see FLIGetModel @see FLIGetHWRevision @see FLIGetSerialNum */ LIBFLIAPI FLIGetFWRevision(flidev_t dev, long *fwrev) { CHKDEVICE(dev); *fwrev = DEVICE->devinfo.fwrev; return 0; } /** Get the hardware revision of a given device. @param dev Device to find the hardware revision of. @param hwrev Pointer to a long which will receive the hardware revision. @return Zero on success. @return Non-zero on failure. @see FLIGetModel @see FLIGetFWRevision @see FLIGetSerialNum */ LIBFLIAPI FLIGetHWRevision(flidev_t dev, long *hwrev) { CHKDEVICE(dev); *hwrev = DEVICE->devinfo.hwrev; return 0; } /** Get the current library version. This function copies up to \texttt{len - 1} characters of the current library version string followed by a terminating \texttt{NULL} character into the buffer pointed to by \texttt{ver}. @param ver Pointer to a character buffer where the library version string is to be placed. @param len The size in bytes of the buffer pointed to by \texttt{ver}. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLIGetLibVersion(char* ver, size_t len) { if (len > 0 && ver == NULL) return -EINVAL; if ((size_t) snprintf(ver, len, "%s", version) >= len) return -EOVERFLOW; else return 0; } /** Get the serial string of a given device. This function copies up to \texttt{len - 1} characters of the serial string for device \texttt{dev}, followed by a terminating \texttt{NULL} character into the buffer pointed to by \texttt{serial}. @param dev Device to find serial of. @param serial Pointer to a character buffer where the serial string is to be placed. @param len The size in bytes of buffer pointed to by \texttt{serial}. @return Zero on success. @return Non-zero on failure. @see FLIGetHWRevision @see FLIGetFWRevision @see FLIGetModel */ LIBFLIAPI FLIGetSerialString(flidev_t dev, char* serial, size_t len) { if (serial == NULL) return -EINVAL; CHKDEVICE(dev); if (DEVICE->devinfo.serial == NULL) { serial[0] = '\0'; return 0; } if ((size_t) snprintf(serial, len, "%s", DEVICE->devinfo.serial) >= len) return -EOVERFLOW; else return 0; } /** Get the model of a given device. This function copies up to \texttt{len - 1} characters of the model string for device \texttt{dev}, followed by a terminating \texttt{NULL} character into the buffer pointed to by \texttt{model}. @param dev Device to find model of. @param model Pointer to a character buffer where the model string is to be placed. @param len The size in bytes of buffer pointed to by \texttt{model}. @return Zero on success. @return Non-zero on failure. @see FLIGetHWRevision @see FLIGetFWRevision @see FLIGetSerialNum */ LIBFLIAPI FLIGetModel(flidev_t dev, char* model, size_t len) { if (model == NULL) return -EINVAL; CHKDEVICE(dev); if (DEVICE->devinfo.model == NULL) { model[0] = '\0'; return 0; } if ((size_t) snprintf(model, len, "%s", DEVICE->devinfo.model) >= len) return -EOVERFLOW; else return 0; } /** Find the dimensions of a pixel in the array of the given device. @param dev Device to find the pixel size of. @param pixel_x Pointer to a double which will receive the size (in microns) of a pixel in the x direction. @param pixel_y Pointer to a double which will receive the size (in microns) of a pixel in the y direction. @return Zero on success. @return Non-zero on failure. @see FLIGetArrayArea @see FLIGetVisibleArea */ LIBFLIAPI FLIGetPixelSize(flidev_t dev, double *pixel_x, double *pixel_y) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_PIXEL_SIZE, 2, pixel_x, pixel_y); } /** Get the visible area of the given camera. This function finds the \emph{visible} area of the CCD array for the camera \texttt{dev}. This area is specified in terms of a upper-left point and a lower-right point. The upper-left x-coordinate is placed in \texttt{ul_x}, the upper-left y-coordinate is placed in \texttt{ul_y}, the lower-right x-coordinate is placed in \texttt{lr_x}, the lower-right y-coordinate is placed in \texttt{lr_y}. @param dev Camera to get the visible area of. @param ul_x Pointer to where the upper-left x-coordinate is to be placed. @param ul_y Pointer to where the upper-left y-coordinate is to be placed. @param lr_x Pointer to where the lower-right x-coordinate is to be placed. @param lr_y Pointer to where the lower-right y-coordinate is to be placed. @return Zero on success. @return Non-zero on failure. @see FLIGetArrayArea @see FLISetImageArea */ LIBFLIAPI FLIGetVisibleArea(flidev_t dev, long* ul_x, long* ul_y, long* lr_x, long* lr_y) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_VISIBLE_AREA, 4, ul_x, ul_y, lr_x, lr_y); } /** Get a handle to an FLI device. This function requires the filename and domain of the requested device. Valid device filenames can be obtained using the \texttt{FLIList()} function. An application may use any number of handles associated with the same physical device. When doing so, it is important to lock the appropriate device to ensure that multiple accesses to the same device do not occur during critical operations. @param dev Pointer to where a device handle will be placed. @param name Pointer to a string where the device filename to be opened is stored. For parallel port devices that are not probed by \texttt{FLIList()} (Windows 95/98/Me), place the address of the parallel port in a string in ascii form ie: "0x378". @param domain Domain to apply to \texttt{name} for device opening. This is a bitwise ORed combination of interface method and device type. Valid interfaces include \texttt{FLIDOMAIN_PARALLEL_PORT}, \texttt{FLIDOMAIN_USB}, \texttt{FLIDOMAIN_SERIAL}, and \texttt{FLIDOMAIN_INET}. Valid device types include \texttt{FLIDEVICE_CAMERA}, \texttt{FLIDOMAIN_FILTERWHEEL}, and \texttt{FLIDOMAIN_FOCUSER}. @return Zero on success. @return Non-zero on failure. @see FLIList @see FLIClose @see flidomain_t */ LIBFLIAPI FLIOpen(flidev_t *dev, char *name, flidomain_t domain) { long r; #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = fli_open(dev, name, domain); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Enable debugging of API operations and communications. Use this function in combination with FLIDebug to assist in diagnosing problems that may be encountered during programming. When usings Microsoft Windows operating systems, creating an empty file C:\\FLIDBG.TXT will override this option. All debug output will then be directed to this file. @param host Name of the file to send debugging information to. This parameter is ignored under Linux where \texttt{syslog(3)} is used to send debug messages (see \texttt{syslog.conf(5)} for how to configure syslogd). @param level Debug level. A value of \texttt{FLIDEBUG_NONE} disables debugging. Values of \texttt{FLIDEBUG_FAIL}, \texttt{FLIDEBUG_WARN}, and \texttt{FLIDEBUG_INFO} enable progressively more verbose debug messages. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLISetDebugLevel(char *host, flidebug_t level) { setdebuglevel(host, level); return 0; } /** Set the exposure time for a camera. This function sets the exposure time for the camera \texttt{dev} to \texttt{exptime} msec. @param dev Camera to set the exposure time of. @param exptime Exposure time in msec. @return Zero on success. @return Non-zero on failure. @see FLIExposeFrame @see FLICancelExposure @see FLIGetExposureStatus */ LIBFLIAPI FLISetExposureTime(flidev_t dev, long exptime) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_EXPOSURE_TIME, 1, &exptime); } /** Set the horizontal bin factor for a given camera. This function sets the horizontal bin factor for the camera \texttt{dev} to \texttt{hbin}. The valid range of the \texttt{hbin} parameter is from 1 to 16. @param dev Camera to set horizontal bin factor of. @param hbin Horizontal bin factor. @return Zero on success. @return Non-zero on failure. @see FLISetVBin @see FLISetImageArea */ LIBFLIAPI FLISetHBin(flidev_t dev, long hbin) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_HBIN, 1, &hbin); } /** Set the frame type for a given camera. This function sets the frame type for camera \texttt{dev} to \texttt{frametype}. The \texttt{frametype} parameter is either \texttt{FLI_FRAME_TYPE_NORMAL} for a normal frame where the shutter opens or \texttt{FLI_FRAME_TYPE_DARK} for a dark frame where the shutter remains closed. @param cam Camera to set the frame type of. @param frametype Frame type: \texttt{FLI_FRAME_TYPE_NORMAL} or \texttt{FLI_FRAME_TYPE_DARK}. @return Zero on success. @return Non-zero on failure. @see fliframe_t @see FLIExposeFrame */ LIBFLIAPI FLISetFrameType(flidev_t dev, fliframe_t frametype) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_FRAME_TYPE, 1, &frametype); } LIBFLIAPI FLISetTDI(flidev_t dev, flitdirate_t tdi_rate, flitdiflags_t flags) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_TDI, 2, &tdi_rate, &flags); } /** Get the cooler power level. The function places the current cooler power in percent in the location pointed to by \texttt{power}. @param dev Camera to find the cooler power of. @param timeleft Pointer to where the cooler power (in percent) will be placed. @return Zero on success. @return Non-zero on failure. @see FLISetTemperature @see FLIGetTemperature */ LIBFLIAPI FLIGetCoolerPower(flidev_t dev, double *power) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_COOLER_POWER, 1, power); } LIBFLIAPI FLIGetCameraModeString(flidev_t dev, flimode_t mode_index, char *mode_string, size_t siz) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_CAMERA_MODE_STRING, 3, mode_index, mode_string, siz); } LIBFLIAPI FLIGetCameraMode(flidev_t dev, flimode_t *mode_index) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_CAMERA_MODE, 1, mode_index); } LIBFLIAPI FLIGetFilterName(flidev_t dev, long filter, char *name, size_t len) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_FILTER_NAME, 3, filter, name, len); } LIBFLIAPI FLISetCameraMode(flidev_t dev, flimode_t mode_index) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_CAMERA_MODE, 1, mode_index); } LIBFLIAPI FLIGetDeviceStatus(flidev_t dev, long *status) { CHKDEVICE(dev); *status = 0xffffffff; return DEVICE->fli_command(dev, FLI_GET_STATUS, 1, status); } /** Set the image area for a given camera. This function sets the image area for camera \texttt{dev} to an area specified in terms of a upper-left point and a lower-right point. The upper-left x-coordinate is \texttt{ul_x}, the upper-left y-coordinate is \texttt{ul_y}, the lower-right x-coordinate is \texttt{lr_x}, and the lower-right y-coordinate is \texttt{lr_y}. Note that the given lower-right coordinate must take into account the horizontal and vertical bin factor settings, but the upper-left coordinate is absolute. In other words, the lower-right coordinate used to set the image area is a virtual point $(lr_x', lr_y')$ determined by: \[ lr_x' = ul_x + (lr_x - ul_x) / hbin \] \[ lr_y' = ul_y + (lr_y - ul_y) / vbin \] Where $(lr_x', lr_y')$ is the coordinate to pass to the \texttt{FLISetImageArea} function, $(ul_x, ul_y)$ and $(lr_x, lr_y)$ are the absolute coordinates of the desired image area, $hbin$ is the horizontal bin factor, and $vbin$ is the vertical bin factor. @param dev Camera to set image area of. @param ul_x Upper-left x-coordinate of image area. @param ul_y Upper-left y-coordinate of image area. @param lr_x Lower-right x-coordinate of image area ($lr_x'$ from above). @param lr_y Lower-right y-coordinate of image area ($lr_y'$ from above). @return Zero on success. @return Non-zero on failure. @see FLIGetVisibleArea @see FLIGetArrayArea */ LIBFLIAPI FLISetImageArea(flidev_t dev, long ul_x, long ul_y, long lr_x, long lr_y) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_IMAGE_AREA, 4, &ul_x, &ul_y, &lr_x, &lr_y); } /** Set the vertical bin factor for a given camera. This function sets the vertical bin factor for the camera \texttt{dev} to \texttt{vbin}. The valid range of the \texttt{vbin} parameter is from 1 to 16. @param dev Camera to set vertical bin factor of. @param vbin Vertical bin factor. @return Zero on success. @return Non-zero on failure. @see FLISetHBin @see FLISetImageArea */ LIBFLIAPI FLISetVBin(flidev_t dev, long vbin) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_VBIN, 1, &vbin); } /** Find the remaining exposure time of a given camera. This functions places the remaining exposure time (in milliseconds) in the location pointed to by \texttt{timeleft}. @param dev Camera to find the remaining exposure time of. @param timeleft Pointer to where the remaining exposure time (in milliseonds) will be placed. @return Zero on success. @return Non-zero on failure. @see FLIExposeFrame @see FLICancelExposure @see FLISetExposureTime */ LIBFLIAPI FLIGetExposureStatus(flidev_t dev, long *timeleft) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_EXPOSURE_STATUS, 1, timeleft); } /** Set the temperature of a given camera. This function sets the temperature of the CCD camera \texttt{dev} to \texttt{temperature} degrees Celsius. The valid range of the \texttt{temperature} parameter is from -55 C to 45 C. @param dev Camera device to set the temperature of. @param temperature Temperature in Celsius to set CCD camera cold finger to. @return Zero on success. @return Non-zero on failure. @see FLIGetTemperature */ LIBFLIAPI FLISetTemperature(flidev_t dev, double temperature) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_TEMPERATURE, 1, &temperature); } /** Get the temperature of a given camera. This function places the temperature of the CCD camera cold finger of device \texttt{dev} in the location pointed to by \texttt{temperature}. @param dev Camera device to get the temperature of. @param temperature Pointer to where the temperature will be placed. @return Zero on success. @return Non-zero on failure. @see FLISetTemperature */ LIBFLIAPI FLIGetTemperature(flidev_t dev, double *temperature) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_TEMPERATURE, 1, temperature); } /** Grab a row of an image. This function grabs the next available row of the image from camera device \texttt{dev}. The row of width \texttt{width} is placed in the buffer pointed to by \texttt{buff}. The size of the buffer pointed to by \texttt{buff} must take into account the bit depth of the image, meaning the buffer size must be at least \texttt{width} bytes for an 8-bit image, and at least 2*\texttt{width} for a 16-bit image. @param dev Camera whose image to grab the next available row from. @param buff Pointer to where the next available row will be placed. @param width Row width in pixels. @return Zero on success. @return Non-zero on failure. @see FLIGrabFrame */ LIBFLIAPI FLIGrabRow(flidev_t dev, void *buff, size_t width) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GRAB_ROW, 2, buff, &width); } /** Expose a frame for a given camera. This function exposes a frame according to the settings (image area, exposure time, bit depth, etc.) of camera \texttt{dev}. The settings of \texttt{dev} must be valid for the camera device. They are set by calling the appropriate set library functions. This function returns after the exposure has started. @param dev Camera to expose the frame of. @return Zero on success. @return Non-zero on failure. @see FLISetExposureTime @see FLISetFrameType @see FLISetImageArea @see FLISetHBin @see FLISetVBin @see FLISetNFlushes @see FLISetBitDepth @see FLIGrabFrame @see FLICancelExposure @see FLIGetExposureStatus */ LIBFLIAPI FLIExposeFrame(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_EXPOSE_FRAME, 0); } /** Set the gray-scale bit depth for a given camera. This function sets the gray-scale bit depth of camera \texttt{dev} to \texttt{bitdepth}. The \texttt{bitdepth} parameter is either \texttt{FLI_MODE_8BIT} for 8-bit mode or \texttt{FLI_MODE_16BIT} for 16-bit mode. Many cameras do not support this mode. @param dev Camera to set the bit depth of. @param bitdepth Gray-scale bit depth: \texttt{FLI_MODE_8BIT} or \texttt{FLI_MODE_16BIT}. @return Zero on success. @return Non-zero on failure. @see flibitdepth_t @see FLIExposeFrame */ LIBFLIAPI FLISetBitDepth(flidev_t dev, flibitdepth_t bitdepth) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_BIT_DEPTH, 1, &bitdepth); } /** Set the number of flushes for a given camera. This function sets the number of times the CCD array of camera \texttt{dev} is flushed by the FLIExposeFrame \emph{before} exposing a frame to \texttt{nflushes}. The valid range of the \texttt{nflushes} parameter is from 0 to 16. Some FLI cameras support background flushing. Background flushing continuously flushes the CCD eliminating the need for pre-exposure flushing. @param dev Camera to set the number of flushes of. @param nflushes Number of times to flush CCD array before an exposure. @return Zero on success. @return Non-zero on failure. @see FLIFlushRow @see FLIExposeFrame @see FLIControlBackgroundFlush */ LIBFLIAPI FLISetNFlushes(flidev_t dev, long nflushes) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_FLUSHES, 1, &nflushes); } /** Read the I/O port of a given camera. This function reads the I/O port on camera \texttt{dev} and places the value in the location pointed to by \texttt{ioportset}. @param dev Camera to read the I/O port of. @param ioportset Pointer to where the I/O port data will be stored. @return Zero on success. @return Non-zero on failure. @see FLIWriteIOPort @see FLIConfigureIOPort */ LIBFLIAPI FLIReadIOPort(flidev_t dev, long *ioportset) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_READ_IOPORT, 1, ioportset); } /** Write to the I/O port of a given camera. This function writes the value \texttt{ioportset} to the I/O port on camera \texttt{dev}. @param dev Camera to write I/O port of. @param ioportset Data to be written to the I/O port. @return Zero on success. @return Non-zero on failure. @see FLIReadIOPort @see FLIConfigureIOPort */ LIBFLIAPI FLIWriteIOPort(flidev_t dev, long ioportset) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_WRITE_IOPORT, 1, &ioportset); } /** Configure the I/O port of a given camera. This function configures the I/O port on camera \texttt{dev} with the value \texttt{ioportset}. The I/O configuration of each pin on a given camera is determined by the value of \texttt{ioportset}. Setting a respective I/O bit enables the port bit for output while clearing an I/O bit enables to port bit for input. By default, all I/O ports are configured as inputs. @param dev Camera to configure the I/O port of. @param ioportset Data to configure the I/O port with. @return Zero on success. @return Non-zero on failure. @see FLIReadIOPort @see FLIWriteIOPort */ LIBFLIAPI FLIConfigureIOPort(flidev_t dev, long ioportset) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_CONFIGURE_IOPORT, 1, &ioportset); } /** Lock a specified device. This function establishes an exclusive lock (mutex) on the given device to prevent access to the device by any other function or process. @param dev Device to lock. @return Zero on success. @return Non-zero on failure. @see FLIUnlockDevice */ LIBFLIAPI FLILockDevice(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_lock(dev); } /** Unlock a specified device. This function releases a previously established exclusive lock (mutex) on the given device to allow access to the device by any other function or process. @param dev Device to unlock. @return Zero on success. @return Non-zero on failure. @see FLILockDevice */ LIBFLIAPI FLIUnlockDevice(flidev_t dev) { CHKDEVICE(dev); return DEVICE->fli_unlock(dev); } /** Control the shutter on a given camera. This function controls the shutter function on camera \texttt{dev} according to the \texttt{shutter} parameter. @param dev Device to control the shutter of. @param shutter How to control the shutter. A value of \texttt{FLI_SHUTTER_CLOSE} closes the shutter and \texttt{FLI_SHUTTER_OPEN} opens the shutter. \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER_LOW}, \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER} causes the exposure to begin only when a logic LOW is detected on I/O port bit 0. \texttt{FLI_SHUTTER_EXTERNAL_TRIGGER_HIGH} causes the exposure to begin only when a logic HIGH is detected on I/O port bit 0. This setting may not be available on all cameras. @return Zero on success. @return Non-zero on failure. @see flishutter_t */ LIBFLIAPI FLIControlShutter(flidev_t dev, flishutter_t shutter) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_CONTROL_SHUTTER, 1, &shutter); } /* The following function is for internal use only, improper use of this function can lead to permanent damage of the attached device. */ LIBFLIAPI FLISetDAC(flidev_t dev, unsigned long dacset) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_DAC, 1, &dacset); } /** Enables background flushing of CCD array. This function enables the background flushing of the CCD array camera \texttt{dev} according to the \texttt{bgflush} parameter. Note that this function may not succeed on all FLI products as this feature may not be available. @param dev Device to control the background flushing of. @param bgflush Enables or disables background flushing. A value of \texttt{FLI_BGFLUSH_START} begins background flushing. It is important to note that background flushing is stopped whenever \texttt{FLIExposeFrame()} or \texttt{FLIControlShutter()} are called. \texttt{FLI_BGFLUSH_STOP} stops all background flush activity. @return Zero on success. @return Non-zero on failure. @see flibgflush_t */ LIBFLIAPI FLIControlBackgroundFlush(flidev_t dev, flibgflush_t bgflush) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_CONTROL_BGFLUSH, 1, &bgflush); } /** List available devices. This function returns a pointer to a NULL terminated list of device names. The pointer should be freed later with \texttt{FLIFreeList()}. Each device name in the returned list includes the filename needed by \texttt{FLIOpen()}, a separating semicolon, followed by the model name or user assigned device name. @param domain Domain to list the devices of. This is a bitwise ORed combination of interface method and device type. Valid interfaces include \texttt{FLIDOMAIN_PARALLEL_PORT}, \texttt{FLIDOMAIN_USB}, \texttt{FLIDOMAIN_SERIAL}, and \texttt{FLIDOMAIN_INET}. Valid device types include \texttt{FLIDEVICE_CAMERA}, \texttt{FLIDOMAIN_FILTERWHEEL}, and \texttt{FLIDOMAIN_FOCUSER}. @param names Pointer to where the device name list will be placed. @return Zero on success. @return Non-zero on failure. @see flidomain_t @see FLIFreeList @see FLIOpen */ LIBFLIAPI FLIList(flidomain_t domain, char ***names) { debug(FLIDEBUG_INFO, "List() domain %04x", domain); return fli_list(domain, names); } /** Free a previously generated device list. Use this function after \texttt{FLIList()} to free the list of device names. @param names Pointer to the list. @return Zero on success. @return Non-zero on failure. @see FLIList */ LIBFLIAPI FLIFreeList(char **names) { return fli_freelist(names); } /** Set the filter wheel position of a given device. Use this function to set the filter wheel position of \texttt{dev} to \texttt{filter}. @param dev Filter wheel device handle. @param filter Desired filter wheel position. @return Zero on success. @return Non-zero on failure. @see FLIGetFilterPos */ LIBFLIAPI FLISetFilterPos(flidev_t dev, long filter) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_FILTER_POS, 1, &filter); } LIBFLIAPI FLISetActiveWheel(flidev_t dev, long wheel) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_SET_ACTIVE_WHEEL, 1, &wheel); } LIBFLIAPI FLIGetActiveWheel(flidev_t dev, long *wheel) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_ACTIVE_WHEEL, 1, wheel); } /** Get the filter wheel position of a given device. Use this function to get the filter wheel position of \texttt{dev}. @param dev Filter wheel device handle. @param filter Pointer to where the filter wheel position will be placed. @return Zero on success. @return Non-zero on failure. @see FLISetFilterPos */ LIBFLIAPI FLIGetFilterPos(flidev_t dev, long *filter) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_FILTER_POS, 1, filter); } /** Get the number of motor steps remaining. Use this function to determine if the stepper motor of \texttt{dev} is still moving. @param dev Filter wheel device handle. @param filter Pointer to where the number of remaning steps will be placed. @return Zero on success. @return Non-zero on failure. @see FLISetFilterPos */ LIBFLIAPI FLIGetStepsRemaining(flidev_t dev, long *steps) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_GET_STEPS_REMAINING, 1, steps); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Get the filter wheel filter count of a given device. Use this function to get the filter count of filter wheel \texttt{dev}. @param dev Filter wheel device handle. @param filter Pointer to where the filter wheel filter count will be placed. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLIGetFilterCount(flidev_t dev, long *filter) { CHKDEVICE(dev); return DEVICE->fli_command(dev, FLI_GET_FILTER_COUNT, 1, filter); } /** Step the filter wheel or focuser motor of a given device. Use this function to move the focuser or filter wheel \texttt{dev} by an amount \texttt{steps}. This function is non-blocking. @param dev Filter wheel or focuser device handle. @param steps Number of steps to move the focuser or filter wheel. @return Zero on success. @return Non-zero on failure. @see FLIGetStepperPosition */ LIBFLIAPI FLIStepMotorAsync(flidev_t dev, long steps) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_STEP_MOTOR_ASYNC, 1, &steps); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Step the filter wheel or focuser motor of a given device. Use this function to move the focuser or filter wheel \texttt{dev} by an amount \texttt{steps}. @param dev Filter wheel or focuser device handle. @param steps Number of steps to move the focuser or filter wheel. @return Zero on success. @return Non-zero on failure. @see FLIGetStepperPosition */ LIBFLIAPI FLIStepMotor(flidev_t dev, long steps) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_STEP_MOTOR, 1, &steps); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Get the stepper motor position of a given device. Use this function to read the stepper motor position of filter wheel or focuser \texttt{dev}. @param dev Filter wheel or focuser device handle. @param position Pointer to where the postion of the stepper motor will be placed. @return Zero on success. @return Non-zero on failure. @see FLIStepMotor */ LIBFLIAPI FLIGetStepperPosition(flidev_t dev, long *position) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_GET_STEPPER_POS, 1, position); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Home focuser or filter wheel specified by \texttt{dev}. The home position of a device is defined as where the electromechanical home sensor detects home. Note that on color filter wheels this may not be located at filter slot zero and may in fact be between filter slots. It should be noted that this function replaces the deprecated function FLIHomeFocuser(). This function may not return immediately as older FLI devices blocked during a HOME operation. Use the function FLIGetDeviceStatus() to determine if the filter wheel or focuser is still moving (or is capable of reporting device status). @param dev Device handle. @return Zero on success. @return Non-zero on failure. @see FLIGetDeviceStatus */ LIBFLIAPI FLIHomeDevice(flidev_t dev) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_HOME_DEVICE, 0); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Home focuser \texttt{dev}. The home position is closed as far as mechanically possiable. @param dev Focuser device handle. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLIHomeFocuser(flidev_t dev) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_HOME_FOCUSER, 0); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Retreive the maximum extent for FLI focuser \texttt{dev}. @param dev Focuser device handle. @param extent Pointer to where the maximum extent of the focuser will be placed. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLIGetFocuserExtent(flidev_t dev, long *extent) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_GET_FOCUSER_EXTENT, 1, extent); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /** Retreive temperature from the FLI focuser \texttt{dev}. Valid channels are \texttt{FLI_TEMPERATURE_INTERNAL} and \texttt{FLI_TEMPERATURE_EXTERNAL}. @param dev Focuser device handle. @param channel Channel to be read. @param extent Pointer to where the channel temperature will be placed. @return Zero on success. @return Non-zero on failure. */ LIBFLIAPI FLIReadTemperature(flidev_t dev, flichannel_t channel, double *temperature) { long r; CHKDEVICE(dev); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Entering " __FUNCTION__); #endif r = DEVICE->fli_command(dev, FLI_READ_TEMPERATURE, 2, channel, temperature); #ifdef SHOWFUNCTIONS debug(FLIDEBUG_INFO, "Exiting " __FUNCTION__); #endif return r; } /* This stuff is used by the next four functions */ typedef struct list { char *filename; char *name; long domain; struct list *next; } list_t; static list_t *firstdevice = NULL; static list_t *currentdevice = NULL; /** Creates a list of all devices within a specified \texttt{domain}. Use \texttt{FLIDeleteList()} to delete the list created with this function. This function is the first called begin the iteration through the list of current FLI devices attached. @param domain Domain to search for devices, set to zero to search all domains. This parameter must contain the device type. @return Zero on success. @return Non-zero on failure. @see FLIDeleteList @see FLIListFirst @see FLIListNext */ LIBFLIAPI FLICreateList(flidomain_t domain) { char **list; flidomain_t domord[5]; int i, j, k; for (i = 0; i < 5; i++) { domord[i] = 0; } if (firstdevice != NULL) { FLIDeleteList(); } currentdevice = NULL; if ((domain & 0x00ff) != 0) { domord[0] = domain; } else { domord[0] = domain | FLIDOMAIN_PARALLEL_PORT; domord[1] = domain | FLIDOMAIN_USB; domord[2] = domain | FLIDOMAIN_SERIAL; } i = 0; while (domord[i] != 0) { debug(FLIDEBUG_INFO, "Searching for domain 0x%04x.", domord[i]); FLIList(domord[i], &list); if (list != NULL) { j = 0; while (list[j] != NULL) { if (firstdevice == NULL) { firstdevice = (list_t *)xmalloc(sizeof(list_t)); if (firstdevice == NULL) return -ENOMEM; currentdevice = firstdevice; } else { currentdevice->next = (list_t *) xmalloc(sizeof(list_t)); if (currentdevice->next == NULL) return -ENOMEM; currentdevice = currentdevice->next; } currentdevice->next = NULL; currentdevice->domain = domord[i]; currentdevice->filename = NULL; currentdevice->name = NULL; k = 0; while (k < (int) strlen(list[j])) { if (list[j][k] == ';') { currentdevice->filename = (char *) xmalloc(k+1); if (currentdevice->filename != NULL) { strncpy(currentdevice->filename, list[j], k); currentdevice->filename[k] = '\0'; } currentdevice->name = (char *) xmalloc(strlen(&list[j][k+1]) + 1); if (currentdevice->name != NULL) { strcpy(currentdevice->name, &list[j][k+1]); } break; } k++; } j++; } FLIFreeList(list); } i++; } return 0; } /** Deletes a list of devices created by \texttt{FLICreateList()}. @return Zero on success. @return Non-zero on failure. @see FLICreateList @see FLIListFirst @see FLIListNext */ LIBFLIAPI FLIDeleteList(void) { list_t *dev = firstdevice; list_t *last; while (dev != NULL) { if (dev->filename != NULL) xfree(dev->filename); if (dev->name != NULL) xfree(dev->name); last = dev; dev = dev->next; xfree(last); } firstdevice = NULL; currentdevice = NULL; return 0; } /** Obtains the first device in the list. Use this function to get the first \texttt{domain}, \texttt{filename} and \texttt{name} from the list of attached FLI devices created using the function \texttt{FLICreateList()}. Use \texttt{FLIListNext()} to obtain more found devices. @param domain Pointer to where to domain of the device will be placed. @param filename Pointer to where the filename of the device will be placed. @param fnlen Length of the supplied buffer to hold the filename. @param name Pointer to where the name of the device will be placed. @param namelen Length of the supplied buffer to hold the name. @return Zero on success. @return Non-zero on failure. @see FLICreateList @see FLIDeleteList @see FLIListNext */ LIBFLIAPI FLIListFirst(flidomain_t *domain, char *filename, size_t fnlen, char *name, size_t namelen) { currentdevice = firstdevice; return FLIListNext(domain, filename, fnlen, name, namelen); } /** Obtains the next device in the list. Use this function to get the next \texttt{domain}, \texttt{filename} and \texttt{name} from the list of attached FLI devices created using the function \texttt{FLICreateList()}. @param domain Pointer to where to domain of the device will be placed. @param filename Pointer to where the filename of the device will be placed. @param fnlen Length of the supplied buffer to hold the filename. @param name Pointer to where the name of the device will be placed. @param namelen Length of the supplied buffer to hold the name. @return Zero on success. @return Non-zero on failure. @see FLICreateList @see FLIDeleteList @see FLIListFirst */ LIBFLIAPI FLIListNext(flidomain_t *domain, char *filename, size_t fnlen, char *name, size_t namelen) { if (currentdevice == NULL) { *domain = 0; filename[0] = '\0'; name[0] = '\0'; return -EBADF; } *domain = currentdevice->domain; strncpy(filename, currentdevice->filename, fnlen); filename[fnlen-1] = '\0'; strncpy(name, currentdevice->name, namelen); name[namelen-1] = '\0'; currentdevice = currentdevice->next; return 0; } LIBFLIAPI FLISetFanSpeed(flidev_t dev, long fan_speed) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_SET_FAN_SPEED, 1, &fan_speed); return r; } LIBFLIAPI FLISetVerticalTableEntry(flidev_t dev, long index, long height, long bin, long mode) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_SET_VERTICAL_TABLE_ENTRY, 4, &index, &height, &bin, &mode); return r; } LIBFLIAPI FLIGetVerticalTableEntry(flidev_t dev, long index, long *height, long *bin, long *mode) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_GET_VERTICAL_TABLE_ENTRY, 4, &index, height, bin, mode); return r; } LIBFLIAPI FLIGetReadoutDimensions(flidev_t dev, long *width, long *hoffset, long *hbin, long *height, long *voffset, long *vbin) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_GET_READOUT_DIMENSIONS, 6, width, hoffset, hbin, height, voffset, vbin); return r; } LIBFLIAPI FLIEnableVerticalTable(flidev_t dev, long width, long offset, long flags) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_ENABLE_VERTICAL_TABLE, 3, &width, &offset, &flags); return r; } LIBFLIAPI FLIReadUserEEPROM(flidev_t dev, long loc, long address, long length, void *rbuf) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_READ_EEPROM, 4, &loc, &address, &length, rbuf); return r; } LIBFLIAPI FLIWriteUserEEPROM(flidev_t dev, long loc, long address, long length, void *wbuf) { long r; CHKDEVICE(dev); r = DEVICE->fli_command(dev, FLI_WRITE_EEPROM, 4, &loc, &address, &length, wbuf); return r; }libfli-2.0+20221221182632/libfli-mem.c0000644000175100017510000001453014174600256015612 0ustar debiandebian/* Copyright (c) 2000, 2002 Finger Lakes Instrumentation (FLI), L.L.C. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Finger Lakes Instrumentation (FLI), LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ====================================================================== Finger Lakes Instrumentation, L.L.C. (FLI) web: http://www.fli-cam.com email: support@fli-cam.com */ #ifdef __linux__ #define _XOPEN_SOURCE 600 #define _GNU_SOURCE #endif /* __linux__ */ #include #include #include #include #include "libfli-libfli.h" #include "libfli-mem.h" #include "indimacros.h" #define DEFAULT_NUM_POINTERS (1024) static struct _mem_ptrs { void **pointers; int total; int used; } allocated = {NULL, 0, 0}; static void *saveptr(void *ptr) { int i, err = 0; if (allocated.used + 1 > allocated.total) { void **tmp; int newtotal; if (allocated.total == 0) newtotal = DEFAULT_NUM_POINTERS; else newtotal = 2 * allocated.total; if ((tmp = realloc(allocated.pointers, newtotal * sizeof(void **))) == NULL) { err = 1; goto done; } allocated.pointers = tmp; memset(allocated.pointers + allocated.total, 0, (newtotal - allocated.total) * sizeof(void **)); allocated.total = newtotal; } for (i = 0; i < allocated.total; i++) if (allocated.pointers[i] == NULL) break; if (i == allocated.total) { /* This shouldn't happen */ debug(FLIDEBUG_WARN, "Internal memory allocation error"); err = 1; goto done; } allocated.pointers[i] = ptr; allocated.used++; done: if (err) { free(ptr); return NULL; } return ptr; } static void **findptr(void *ptr) { int i; for (i = 0; i < allocated.total; i++) if (allocated.pointers[i] == ptr) return &allocated.pointers[i]; debug(FLIDEBUG_WARN, "Invalid pointer not found: %p", ptr); return NULL; } static int deleteptr(void *ptr) { void **allocatedptr; if ((allocatedptr = findptr(ptr)) == NULL) return -1; *allocatedptr = NULL; allocated.used--; return 0; } void *xmalloc(size_t size) { void *ptr; if ((ptr = malloc(size)) == NULL) return NULL; return saveptr(ptr); } void *xcalloc(size_t nmemb, size_t size) { void *ptr; if ((ptr = calloc(nmemb, size)) == NULL) return NULL; return saveptr(ptr); } #ifdef __linux__ void *xmemalign(size_t alignment, size_t size) { int err; void *ptr; if ((err = posix_memalign(&ptr, alignment, size))) { debug(FLIDEBUG_WARN, "posix_memalign() failed: %d", err); return NULL; } return saveptr(ptr); } #endif /* __linux__ */ void xfree(void *ptr) { if (deleteptr(ptr)) return; free(ptr); return; } void *xrealloc(void *ptr, size_t size) { void **allocatedptr, *tmp; if ((allocatedptr = findptr(ptr)) == NULL) return NULL; if ((tmp = realloc(ptr, size)) == NULL) return NULL; *allocatedptr = tmp; return tmp; } int xfree_all(void) { int i; int freed = 0; for (i = 0; i < allocated.total; i++) { if (allocated.pointers[i] != NULL) { free(allocated.pointers[i]); allocated.pointers[i] = NULL; allocated.used--; freed++; } } if (allocated.used != 0) debug(FLIDEBUG_WARN, "Internal memory handling error"); if (allocated.pointers != NULL) free(allocated.pointers); allocated.pointers = NULL; allocated.used = 0; allocated.total = 0; return freed; } char *xstrdup(const char *s) { char *tmp; #ifdef _WIN32 #define strdup _strdup #endif if ((tmp = strdup(s)) == NULL) return NULL; return saveptr(tmp); } char *xstrndup(const char *s, size_t siz) { char *tmp; size_t len; if (strlen(s) > siz) len = siz; else len = strlen(s); tmp = (char *) xmalloc(len + 1); if (tmp == NULL) return NULL; strncpy(tmp, s, len); tmp[len] = '\0'; return tmp; } #ifdef __linux__ int xasprintf(char **strp, const char *fmt, ...) { INDI_UNUSED(strp); va_list ap; char *tmp; int err; va_start(ap, fmt); if ((err = vasprintf(&tmp, fmt, ap)) < 0) goto done; if (saveptr(tmp) == NULL) err = -1; done: va_end(ap); return err; } #else int xasprintf(char **strp, const char *fmt, ...) { va_list ap; char *p; int n, size = 100; /* Guess we need no more than 100 bytes. */ if ((p = (char *) xmalloc (size)) == NULL) return (-1); while (1) { /* Try to print in the allocated space. */ va_start(ap, fmt); #ifdef _WIN32 n = _vsnprintf (p, size, fmt, ap); #else n = vsnprintf (p, size, fmt, ap); #endif va_end(ap); /* If that worked, send the string. */ if (n > -1 && n < size) { *strp = p; return n; } /* Else try again with more space. */ if (n > -1) /* glibc 2.1 */ size = n + 1; /* precisely what is needed */ else /* glibc 2.0 */ size *= 2; /* twice the old size */ if ((p = (char *) xrealloc (p, size)) == NULL) return (-1); } } #endif