[490] | 1 | /* |
---|
| 2 | Meade LPI Experimental driver |
---|
| 3 | Copyright (C) 2005 by Jasem Mutlaq |
---|
| 4 | |
---|
| 5 | This library is free software; you can redistribute it and/or |
---|
| 6 | modify it under the terms of the GNU Lesser General Public |
---|
| 7 | License as published by the Free Software Foundation; either |
---|
| 8 | version 2.1 of the License, or (at your option) any later version. |
---|
| 9 | |
---|
| 10 | This library is distributed in the hope that it will be useful, |
---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 13 | Lesser General Public License for more details. |
---|
| 14 | |
---|
| 15 | You should have received a copy of the GNU Lesser General Public |
---|
| 16 | License along with this library; if not, write to the Free Software |
---|
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | #include "v4ldriver.h" |
---|
| 22 | |
---|
| 23 | class Meade_LPI : public V4L_Driver |
---|
| 24 | { |
---|
| 25 | public: |
---|
| 26 | Meade_LPI(); |
---|
| 27 | ~Meade_LPI(); |
---|
| 28 | |
---|
| 29 | #ifdef HAVE_LINUX_VIDEODEV2_H |
---|
| 30 | void connectCamera(void); |
---|
| 31 | #endif |
---|
| 32 | |
---|
| 33 | }; |
---|
| 34 | |
---|
| 35 | Meade_LPI::Meade_LPI() : V4L_Driver() |
---|
| 36 | { |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | Meade_LPI::~Meade_LPI() |
---|
| 40 | { |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | #ifdef HAVE_LINUX_VIDEODEV2_H |
---|
| 44 | void Meade_LPI::connectCamera() |
---|
| 45 | { |
---|
| 46 | char errmsg[ERRMSGSIZ]; |
---|
| 47 | |
---|
| 48 | switch (PowerS[0].s) |
---|
| 49 | { |
---|
| 50 | case ISS_ON: |
---|
| 51 | if (v4l_base->connectCam(PortT[0].text, errmsg, V4L2_PIX_FMT_SBGGR8, 352, 288) < 0) |
---|
| 52 | { |
---|
| 53 | PowerSP.s = IPS_IDLE; |
---|
| 54 | PowerS[0].s = ISS_OFF; |
---|
| 55 | PowerS[1].s = ISS_ON; |
---|
| 56 | IDSetSwitch(&PowerSP, "Error: unable to open device"); |
---|
| 57 | IDLog("Error: %s\n", errmsg); |
---|
| 58 | return; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | /* Sucess! */ |
---|
| 62 | PowerS[0].s = ISS_ON; |
---|
| 63 | PowerS[1].s = ISS_OFF; |
---|
| 64 | PowerSP.s = IPS_OK; |
---|
| 65 | IDSetSwitch(&PowerSP, "Meade LPI is online. Retrieving basic data."); |
---|
| 66 | |
---|
| 67 | v4l_base->registerCallback(newFrame, this); |
---|
| 68 | |
---|
| 69 | V4LFrame->compressedFrame = (unsigned char *) malloc (sizeof(unsigned char) * 1); |
---|
| 70 | |
---|
| 71 | IDLog("Meade LPI is online. Retrieving basic data.\n"); |
---|
| 72 | getBasicData(); |
---|
| 73 | |
---|
| 74 | break; |
---|
| 75 | |
---|
| 76 | case ISS_OFF: |
---|
| 77 | PowerS[0].s = ISS_OFF; |
---|
| 78 | PowerS[1].s = ISS_ON; |
---|
| 79 | PowerSP.s = IPS_IDLE; |
---|
| 80 | |
---|
| 81 | free(V4LFrame->compressedFrame); |
---|
| 82 | V4LFrame->compressedFrame = NULL; |
---|
| 83 | v4l_base->disconnectCam(); |
---|
| 84 | |
---|
| 85 | IDSetSwitch(&PowerSP, "Meade LPI is offline."); |
---|
| 86 | |
---|
| 87 | break; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | } |
---|
| 91 | #endif |
---|
| 92 | |
---|
| 93 | Meade_LPI *MainCam = NULL; /* Main and only camera */ |
---|
| 94 | |
---|
| 95 | /* send client definitions of all properties */ |
---|
| 96 | void ISInit() |
---|
| 97 | { |
---|
| 98 | if (MainCam == NULL) |
---|
| 99 | { |
---|
| 100 | MainCam = new Meade_LPI(); |
---|
| 101 | MainCam->initProperties("Meade LPI"); |
---|
| 102 | MainCam->initCamBase(); |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | void ISGetProperties (const char *dev) |
---|
| 107 | { |
---|
| 108 | ISInit(); |
---|
| 109 | |
---|
| 110 | MainCam->ISGetProperties(dev); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
---|
| 115 | { |
---|
| 116 | |
---|
| 117 | ISInit(); |
---|
| 118 | |
---|
| 119 | MainCam->ISNewSwitch(dev, name, states, names, n); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n) |
---|
| 123 | { |
---|
| 124 | |
---|
| 125 | ISInit(); |
---|
| 126 | |
---|
| 127 | MainCam->ISNewText(dev, name, texts, names, n); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n) |
---|
| 132 | { |
---|
| 133 | |
---|
| 134 | ISInit(); |
---|
| 135 | |
---|
| 136 | MainCam->ISNewNumber(dev, name, values, names, n); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) |
---|
| 140 | { |
---|
| 141 | INDI_UNUSED(dev); |
---|
| 142 | INDI_UNUSED(name); |
---|
| 143 | INDI_UNUSED(sizes); |
---|
| 144 | INDI_UNUSED(blobsizes); |
---|
| 145 | INDI_UNUSED(blobs); |
---|
| 146 | INDI_UNUSED(formats); |
---|
| 147 | INDI_UNUSED(names); |
---|
| 148 | INDI_UNUSED(n); |
---|
| 149 | } |
---|
| 150 | void ISSnoopDevice (XMLEle *root) |
---|
| 151 | { |
---|
| 152 | INDI_UNUSED(root); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | |
---|