Instrument Neutral Distributed Interface INDI  2.0.2
Lx.cpp
Go to the documentation of this file.
1 
2 #include "Lx.h"
3 
4 #include "indicom.h"
5 
6 #include <fcntl.h>
7 #include <cstring>
8 #include <unistd.h>
9 #include <sys/ioctl.h>
10 
11 // from indicom.cpp for tty_connect
12 #define PARITY_NONE 0
13 #define PARITY_EVEN 1
14 #define PARITY_ODD 2
15 
17 {
18  camerafd = fd;
19 }
20 
22 {
23  return (LxEnableS[1].s == ISS_ON);
24 }
25 
27 {
28  //IDLog("Initializing Long Exposure Properties\n");
29  dev = device;
30  device_name = dev->getDeviceName();
31  IUFillSwitch(&LxEnableS[0], "Disable", "", ISS_ON);
32  IUFillSwitch(&LxEnableS[1], "Enable", "", ISS_OFF);
33  IUFillSwitchVector(&LxEnableSP, LxEnableS, NARRAY(LxEnableS), device_name, "Activate", "", LX_TAB, IP_RW,
34  ISR_1OFMANY, 0, IPS_IDLE);
35  IUFillSwitch(&LxModeS[LXSERIAL], "Serial", "", ISS_ON);
36  //IUFillSwitch(&LxModeS[LXPARALLEL], "Parallel", "", ISS_OFF);
37  IUFillSwitch(&LxModeS[LXLED], "SPC900 LED", "", ISS_OFF);
38  //IUFillSwitch(&LxModeS[LXGPIO], "GPIO (Arm/RPI)", "", ISS_OFF);
39  // IUFillSwitch(&LxModeS[4], "IndiDuino Switcher", "", ISS_OFF); // Snooping is not enough
40  IUFillSwitchVector(&LxModeSP, LxModeS, NARRAY(LxModeS), device_name, "LX Mode", "", LX_TAB, IP_RW, ISR_1OFMANY, 0,
41  IPS_IDLE);
42  IUFillText(&LxPortT[0], "Port", "", "/dev/ttyUSB0");
43  IUFillTextVector(&LxPortTP, LxPortT, NARRAY(LxPortT), device_name, "Lx port", "", LX_TAB, IP_RW, 0, IPS_IDLE);
44  IUFillSwitch(&LxSerialOptionS[0], "Use DTR (pin 4)", "", ISS_OFF);
45  IUFillSwitch(&LxSerialOptionS[1], "Use RTS (pin 7)", "", ISS_ON);
46  IUFillSwitch(&LxSerialOptionS[2], "Use Serial command", "", ISS_OFF);
47  IUFillSwitchVector(&LxSerialOptionSP, LxSerialOptionS, NARRAY(LxSerialOptionS), device_name, "Serial Options", "",
49  IUFillSwitch(&LxParallelOptionS[0], "Use Data 0 (pin 2)", "", ISS_OFF);
50  IUFillSwitch(&LxParallelOptionS[1], "Use Data 1 (pin 3)", "", ISS_ON); // Steve's Chambers Schematics
51  IUFillSwitch(&LxParallelOptionS[2], "Use Data 2 (pin 4)", "", ISS_OFF);
52  IUFillSwitch(&LxParallelOptionS[3], "Use Data 3 (pin 5)", "", ISS_OFF);
53  IUFillSwitch(&LxParallelOptionS[4], "Use Data 4 (pin 6)", "", ISS_OFF);
54  IUFillSwitch(&LxParallelOptionS[5], "Use Data 5 (pin 7)", "", ISS_OFF);
55  IUFillSwitch(&LxParallelOptionS[6], "Use Data 6 (pin 8)", "", ISS_OFF);
56  IUFillSwitch(&LxParallelOptionS[7], "Use Data 7 (pin 9)", "", ISS_OFF);
57  IUFillSwitch(&LxParallelOptionS[8], "Use Parallel command", "", ISS_OFF);
59  "Parallel Options", "", LX_TAB, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
60  IUFillText(&LxStartStopCmdT[0], "Start command", "", ":O1");
61  IUFillText(&LxStartStopCmdT[1], "Stop command", "", ":O0");
62  IUFillTextVector(&LxStartStopCmdTP, LxStartStopCmdT, NARRAY(LxStartStopCmdT), device_name, "Start/Stop commands",
63  "", LX_TAB, IP_RW, 0, IPS_IDLE);
64  IUFillSwitch(&LxLogicalLevelS[0], "Low to High", "", ISS_ON);
65  IUFillSwitch(&LxLogicalLevelS[1], "High to Low", "", ISS_OFF);
66  IUFillSwitchVector(&LxLogicalLevelSP, LxLogicalLevelS, NARRAY(LxLogicalLevelS), device_name, "Start Transition", "",
68  IUFillSwitch(&LxSerialSpeedS[0], "1200", "", ISS_OFF);
69  IUFillSwitch(&LxSerialSpeedS[1], "2400", "", ISS_OFF);
70  IUFillSwitch(&LxSerialSpeedS[2], "4800", "", ISS_OFF);
71  IUFillSwitch(&LxSerialSpeedS[3], "9600", "", ISS_ON);
72  IUFillSwitch(&LxSerialSpeedS[4], "19200", "", ISS_OFF);
73  IUFillSwitch(&LxSerialSpeedS[5], "38400", "", ISS_OFF);
74  IUFillSwitch(&LxSerialSpeedS[6], "57600", "", ISS_OFF);
75  IUFillSwitch(&LxSerialSpeedS[7], "115200", "", ISS_OFF);
76  IUFillSwitch(&LxSerialSpeedS[8], "230400", "", ISS_OFF);
77  IUFillSwitchVector(&LxSerialSpeedSP, LxSerialSpeedS, NARRAY(LxSerialSpeedS), device_name, "Serial speed", "",
79  IUFillSwitch(&LxSerialSizeS[0], "5", "", ISS_OFF);
80  IUFillSwitch(&LxSerialSizeS[1], "6", "", ISS_OFF);
81  IUFillSwitch(&LxSerialSizeS[2], "7", "", ISS_OFF);
82  IUFillSwitch(&LxSerialSizeS[3], "8", "", ISS_ON);
83  IUFillSwitchVector(&LxSerialSizeSP, LxSerialSizeS, NARRAY(LxSerialSizeS), device_name, "Serial size", "", LX_TAB,
85  IUFillSwitch(&LxSerialParityS[0], "None", "", ISS_ON);
86  IUFillSwitch(&LxSerialParityS[1], "Even", "", ISS_OFF);
87  IUFillSwitch(&LxSerialParityS[2], "Odd", "", ISS_OFF);
88  IUFillSwitchVector(&LxSerialParitySP, LxSerialParityS, NARRAY(LxSerialParityS), device_name, "Serial parity", "",
90  IUFillSwitch(&LxSerialStopS[0], "1", "", ISS_ON);
91  IUFillSwitch(&LxSerialStopS[1], "2", "", ISS_OFF);
92  IUFillSwitchVector(&LxSerialStopSP, LxSerialStopS, NARRAY(LxSerialStopS), device_name, "Serial stop", "", LX_TAB,
94  IUFillSwitch(&LxSerialAddeolS[0], "None", "", ISS_OFF);
95  IUFillSwitch(&LxSerialAddeolS[1], "CR (OxD, \\r)", "", ISS_ON);
96  IUFillSwitch(&LxSerialAddeolS[2], "LF (0xA, \\n)", "", ISS_OFF);
97  IUFillSwitch(&LxSerialAddeolS[3], "CR+LF", "", ISS_OFF);
100  FlashStrobeSP = INDI::Property();
101  FlashStrobeStopSP = INDI::Property();
102  ledmethod = PWCIOCTL;
103  return true;
104 }
105 
107 {
108  if (dev->isConnected())
109  {
110  dev->defineProperty(&LxEnableSP);
111  dev->defineProperty(&LxModeSP);
112  dev->defineProperty(&LxPortTP);
114  //dev->defineProperty(&LxParallelOptionSP);
122 
123  INDI::Property pfound = findByLabel(dev, "Strobe");
124  if (pfound)
125  {
126  FlashStrobeSP = dev->getSwitch(pfound.getName());
127  pfound = findByLabel(dev, "Stop Strobe");
128  FlashStrobeStopSP = dev->getSwitch(pfound.getName());
129  }
130  }
131  else
132  {
137  //dev->deleteProperty(LxParallelOptionSP.name);
145  FlashStrobeSP = INDI::Property();
146  FlashStrobeStopSP = INDI::Property();
147  }
148  return true;
149 }
150 
151 bool Lx::ISNewSwitch(const char *devname, const char *name, ISState *states, char *names[], int n)
152 {
153  /* ignore if not ours */
154  if (devname && strcmp(device_name, devname))
155  return true;
156 
157  if (!strcmp(name, LxEnableSP.name))
158  {
160  IUUpdateSwitch(&LxEnableSP, states, names, n);
161  LxEnableSP.s = IPS_OK;
162 
163  IDSetSwitch(&LxEnableSP, "%s long exposure on device %s", (LxEnableS[0].s == ISS_ON ? "Disabling" : "Enabling"),
164  device_name);
165  return true;
166  }
167 
168  if (!strcmp(name, LxModeSP.name))
169  {
170  unsigned int index, oldindex;
171  oldindex = IUFindOnSwitchIndex(&LxModeSP);
173  IUUpdateSwitch(&LxModeSP, states, names, n);
174  LxModeSP.s = IPS_OK;
175  index = IUFindOnSwitchIndex(&LxModeSP);
176  if (index == LXLED)
177  if (!checkPWC())
178  {
180  LxModeSP.s = IPS_ALERT;
181  LxModeS[oldindex].s = ISS_ON;
182  IDSetSwitch(&LxModeSP, "Can not set Lx Mode to %s", LxModeS[index].name);
183  return false;
184  }
185  IDSetSwitch(&LxModeSP, "Setting Lx Mode to %s", LxModeS[index].name);
186  return true;
187  }
188 
189  if (!strcmp(name, LxSerialOptionSP.name))
190  {
191  unsigned int index;
193  IUUpdateSwitch(&LxSerialOptionSP, states, names, n);
196  IDSetSwitch(&LxSerialOptionSP, "Setting Lx Serial option: %s", LxSerialOptionS[index].name);
197  return true;
198  }
199 
200  if (!strcmp(name, LxParallelOptionSP.name))
201  {
202  unsigned int index;
204  IUUpdateSwitch(&LxParallelOptionSP, states, names, n);
207  IDSetSwitch(&LxParallelOptionSP, "Setting Lx Parallel option: %s", LxParallelOptionS[index].name);
208  return true;
209  }
210 
211  if (!strcmp(name, LxLogicalLevelSP.name))
212  {
213  unsigned int index;
215  IUUpdateSwitch(&LxLogicalLevelSP, states, names, n);
218  IDSetSwitch(&LxLogicalLevelSP, "Setting Lx logical levels for start transition: %s",
219  LxLogicalLevelS[index].name);
220  return true;
221  }
222 
223  if (!strcmp(name, LxSerialSpeedSP.name))
224  {
225  unsigned int index;
227  IUUpdateSwitch(&LxSerialSpeedSP, states, names, n);
230  IDSetSwitch(&LxSerialSpeedSP, "Setting Lx serial speed: %s", LxSerialSpeedS[index].name);
231  return true;
232  }
233 
234  if (!strcmp(name, LxSerialSizeSP.name))
235  {
236  unsigned int index;
238  IUUpdateSwitch(&LxSerialSizeSP, states, names, n);
241  IDSetSwitch(&LxSerialSizeSP, "Setting Lx serial word size: %s", LxSerialSizeS[index].name);
242  return true;
243  }
244 
245  if (!strcmp(name, LxSerialParitySP.name))
246  {
247  unsigned int index;
249  IUUpdateSwitch(&LxSerialParitySP, states, names, n);
252  IDSetSwitch(&LxSerialParitySP, "Setting Lx serial parity: %s", LxSerialParityS[index].name);
253  return true;
254  }
255 
256  if (!strcmp(name, LxSerialStopSP.name))
257  {
258  unsigned int index;
260  IUUpdateSwitch(&LxSerialStopSP, states, names, n);
263  IDSetSwitch(&LxSerialStopSP, "Setting Lx serial stop bits: %s", LxSerialStopS[index].name);
264  return true;
265  }
266 
267  if (!strcmp(name, LxSerialAddeolSP.name))
268  {
269  unsigned int index;
271  IUUpdateSwitch(&LxSerialAddeolSP, states, names, n);
274  IDSetSwitch(&LxSerialAddeolSP, "Setting Lx End of Line: %s", LxSerialAddeolS[index].name);
275  return true;
276  }
277 
278  return true; // not ours, don't care
279 }
280 
281 bool Lx::ISNewText(const char *devname, const char *name, char *texts[], char *names[], int n)
282 {
283  IText *tp;
284  /* ignore if not ours */
285  if (devname && strcmp(device_name, devname))
286  return true;
287 
288  if (!strcmp(name, LxPortTP.name))
289  {
290  LxPortTP.s = IPS_OK;
291  tp = IUFindText(&LxPortTP, names[0]);
292  if (!tp)
293  return false;
294 
295  IUSaveText(tp, texts[0]);
296  IDSetText(&LxPortTP, "Setting Lx port to %s", tp->text);
297  return true;
298  }
299 
300  if (!strcmp(name, LxStartStopCmdTP.name))
301  {
303  for (int i = 0; i < n; i++)
304  {
305  tp = IUFindText(&LxStartStopCmdTP, names[i]);
306  if (!tp)
307  return false;
308  IUSaveText(tp, texts[i]);
309  }
310  IDSetText(&LxStartStopCmdTP, "Setting Lx Start/stop commands");
311  return true;
312  }
313 
314  return true; // not ours, don't care
315 }
316 
317 unsigned int Lx::getLxmode()
318 {
319  return IUFindOnSwitchIndex(&LxModeSP);
320 }
321 
323 {
324  unsigned int index;
325  IDMessage(device_name, "Starting Long Exposure");
326  index = IUFindOnSwitchIndex(&LxModeSP);
327  switch (index)
328  {
329  case LXSERIAL:
330  return startLxSerial();
331  case LXLED:
332  return startLxPWC();
333  default:
334  return false;
335  }
336  return false;
337 }
338 
340 {
341  unsigned int index = 0;
342 
343  IDMessage(device_name, "Stopping Long Exposure");
344  index = IUFindOnSwitchIndex(&LxModeSP);
345  switch (index)
346  {
347  case LXSERIAL:
348  return stopLxSerial();
349  case LXLED:
350  return stopLxPWC();
351  default:
352  return -1;
353  }
354 
355  return 0;
356 }
357 
358 // Serial Stuff
359 
360 void Lx::closeserial(int fd)
361 {
362  tcsetattr(fd, TCSANOW, &oldterminfo);
363  if (close(fd) < 0)
364  perror("closeserial()");
365 }
366 
367 int Lx::openserial(const char *devicename)
368 {
369  int fd;
370  struct termios attr;
371 
372  if ((fd = open(devicename, O_RDWR)) == -1)
373  {
374  IDLog("openserial(): open()");
375  return -1;
376  }
377  if (tcgetattr(fd, &oldterminfo) == -1)
378  {
379  IDLog("openserial(): tcgetattr()");
380  return -1;
381  }
382  attr = oldterminfo;
383  //attr.c_cflag |= CRTSCTS | CLOCAL;
384  attr.c_cflag |= CLOCAL;
385  attr.c_oflag = 0;
386  if (tcflush(fd, TCIOFLUSH) == -1)
387  {
388  IDLog("openserial(): tcflush()");
389  return -1;
390  }
391  if (tcsetattr(fd, TCSANOW, &attr) == -1)
392  {
393  IDLog("initserial(): tcsetattr()");
394  return -1;
395  }
396  return fd;
397 }
398 
399 int Lx::setRTS(int fd, int level)
400 {
401  // int status;
402  int mcr = 0;
403  // does not work for RTS
404  //if (ioctl(fd, TIOCMGET, &status) == -1) {
405  // IDLog("setRTS(): TIOCMGET");
406  // return 0;
407  //}
408  //if (level)
409  // status |= TIOCM_RTS;
410  //else
411  // status &= ~TIOCM_RTS;
412  //if (ioctl(fd, TIOCMSET, &status) == -1) {
413  // IDLog("setRTS(): TIOCMSET");
414  // return 0;
415  //}
416  mcr = TIOCM_RTS;
417  if (level)
418  {
419  if (ioctl(fd, TIOCMBIS, &mcr) == -1)
420  {
421  IDLog("setRTS(): TIOCMBIS");
422  return 0;
423  }
424  }
425  else
426  {
427  if (ioctl(fd, TIOCMBIC, &mcr) == -1)
428  {
429  IDLog("setRTS(): TIOCMBIC");
430  return 0;
431  }
432  }
433  return 1;
434 }
435 
436 int Lx::setDTR(int fd, int level)
437 {
438  int status;
439 
440  if (ioctl(fd, TIOCMGET, &status) == -1)
441  {
442  IDLog("setDTR(): TIOCMGET");
443  return 0;
444  }
445  if (level)
446  status |= TIOCM_DTR;
447  else
448  status &= ~TIOCM_DTR;
449  if (ioctl(fd, TIOCMSET, &status) == -1)
450  {
451  IDLog("setDTR(): TIOCMSET");
452  return 0;
453  }
454  return 1;
455 }
456 
457 void Lx::getSerialOptions(unsigned int *speed, unsigned int *wordsize, unsigned int *parity, unsigned int *stops)
458 {
459  unsigned int index;
460  unsigned int speedopts[] = { 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 };
461  unsigned int sizeopts[] = { 5, 6, 7, 8 };
462  unsigned int parityopts[] = { PARITY_NONE, PARITY_EVEN, PARITY_ODD };
463  unsigned int stopopts[] = { 1, 2 };
465  *speed = speedopts[index];
467  *wordsize = sizeopts[index];
469  *parity = parityopts[index];
471  *stops = stopopts[index];
472 }
473 
474 const char *Lx::getSerialEOL()
475 {
476  unsigned int index;
478  switch (index)
479  {
480  case 0:
481  return "";
482  case 1:
483  return "\r";
484  case 2:
485  return "\n";
486  case 3:
487  return "\r\n";
488  }
489  return nullptr;
490 }
491 
492 bool Lx::startLxSerial()
493 {
494  unsigned int speed = 0, wordsize = 0, parity = 0, stops = 0;
495  const char *eol = nullptr;
496  unsigned int index = IUFindOnSwitchIndex(&LxSerialOptionSP);
497 
498  switch (index)
499  {
500  case 0:
501  serialfd = openserial(LxPortT[0].text);
502  if (serialfd < 0)
503  return false;
504  if (LxLogicalLevelS[0].s == ISS_ON)
505  setDTR(serialfd, 1);
506  else
507  setDTR(serialfd, 0);
508  break;
509  case 1:
510  serialfd = openserial(LxPortT[0].text);
511  if (serialfd < 0)
512  return false;
513  if (LxLogicalLevelS[0].s == ISS_ON)
514  setRTS(serialfd, 1);
515  else
516  setRTS(serialfd, 0);
517  break;
518  case 2:
519  getSerialOptions(&speed, &wordsize, &parity, &stops);
520  eol = getSerialEOL();
521  tty_connect(LxPortT[0].text, speed, wordsize, parity, stops, &serialfd);
522  if (serialfd < 0)
523  return false;
524 
525  int rc = write(serialfd, LxStartStopCmdT[0].text, strlen(LxStartStopCmdT[0].text));
526  rc = write(serialfd, eol, strlen(eol));
527  INDI_UNUSED(rc);
528  break;
529  }
530  return true;
531 }
532 
533 int Lx::stopLxSerial()
534 {
535  const char *eol = nullptr;
536  unsigned int index = IUFindOnSwitchIndex(&LxSerialOptionSP);
537 
538  switch (index)
539  {
540  case 0:
541  if (LxLogicalLevelS[0].s == ISS_ON)
542  setDTR(serialfd, 0);
543  else
544  setDTR(serialfd, 1);
545  break;
546  case 1:
547  if (LxLogicalLevelS[0].s == ISS_ON)
548  setRTS(serialfd, 0);
549  else
550  setRTS(serialfd, 1);
551  break;
552  case 2:
553  int rc = write(serialfd, LxStartStopCmdT[1].text, strlen(LxStartStopCmdT[1].text));
554  eol = getSerialEOL();
555  rc = write(serialfd, eol, strlen(eol));
556  INDI_UNUSED(rc);
557  break;
558  }
559  close(serialfd);
560  return 0;
561 }
562 
563 INDI::Property Lx::findByLabel(INDI::DefaultDevice *dev, const char *label)
564 {
565  for(auto &oneProperty : dev->getProperties())
566  if (oneProperty.isLabelMatch(label))
567  return oneProperty;
568  return INDI::Property();
569 }
570 
571 // PWC Stuff
572 bool Lx::checkPWC()
573 {
574  if (FlashStrobeSP && FlashStrobeStopSP)
575  {
576  IDMessage(device_name, "Using Flash control for led Lx Mode");
577  ledmethod = FLASHLED;
578  return true;
579  }
580  if (ioctl(camerafd, VIDIOCPWCPROBE, &probe) != 0)
581  {
582  IDMessage(device_name, "ERROR: device does not support PWC ioctl");
583  return false;
584  }
585  if (probe.type < 730)
586  {
587  IDMessage(device_name, "ERROR: camera type %d does not support led control", probe.type);
588  return false;
589  }
590  IDMessage(device_name, "Using PWC ioctl for led Lx Mode");
591  return true;
592 }
593 
594 void Lx::pwcsetLed(int on, int off)
595 {
596  struct pwc_leds leds;
597  leds.led_on = on;
598  leds.led_off = off;
599  if (ioctl(camerafd, VIDIOCPWCSLED, &leds))
600  {
601  IDLog("ioctl: can't set Led.\n");
602  }
603 }
604 
605 void Lx::pwcsetflashon()
606 {
607  ISState states[2] = { ISS_ON, ISS_OFF };
608  const char *names[2] = { FlashStrobeSP[0].getName(), FlashStrobeStopSP[0].getName() };
609  dev->ISNewSwitch(device_name, FlashStrobeSP.getName(), &(states[0]), (char **)names, 1);
610  //dev->ISNewSwitch(device_name, FlashStrobeStopSP.name, &(states[1]), (char **)(names + 1), 1);
611  FlashStrobeSP.setState(IPS_OK);
612  FlashStrobeSP.apply();
613  FlashStrobeStopSP.setState(IPS_IDLE);
614  FlashStrobeStopSP.apply();
615 }
616 
617 void Lx::pwcsetflashoff()
618 {
619  ISState states[2] = { ISS_OFF, ISS_ON };
620  const char *names[2] = { FlashStrobeSP[0].getName(), FlashStrobeStopSP[0].getName()};
621  //dev->ISNewSwitch(device_name, FlashStrobeSP.name, &(states[0]), (char **)names, 1);
622  dev->ISNewSwitch(device_name, FlashStrobeStopSP.getName(), &(states[1]), (char **)(names + 1), 1);
623  FlashStrobeStopSP.setState(IPS_OK);
624  FlashStrobeStopSP.apply();
625 
626  FlashStrobeSP.setState(IPS_IDLE);
627  FlashStrobeSP.apply();
628 }
629 
630 bool Lx::startLxPWC()
631 {
632  switch (ledmethod)
633  {
634  case PWCIOCTL:
635  if (LxLogicalLevelS[0].s == ISS_ON)
636  pwcsetLed(25500, 0);
637  else
638  pwcsetLed(0, 25500);
639  return true;
640  case FLASHLED:
641  if (LxLogicalLevelS[0].s == ISS_ON)
642  pwcsetflashon();
643  else
644  pwcsetflashoff();
645  return true;
646  }
647 
648  return false;
649 }
650 
651 int Lx::stopLxPWC()
652 {
653  switch (ledmethod)
654  {
655  case PWCIOCTL:
656  if (LxLogicalLevelS[0].s == ISS_ON)
657  pwcsetLed(0, 25500);
658  else
659  pwcsetLed(25500, 0);
660  return 0;
661  case FLASHLED:
662  if (LxLogicalLevelS[0].s == ISS_ON)
663  pwcsetflashoff();
664  else
665  pwcsetflashon();
666  return 0;
667  }
668 
669  return -1;
670 }
#define PARITY_ODD
Definition: Lx.cpp:14
#define PARITY_EVEN
Definition: Lx.cpp:13
#define PARITY_NONE
Definition: Lx.cpp:12
#define LX_TAB
Definition: Lx.h:14
#define LXLED
Definition: Lx.h:17
#define LXSERIAL
Definition: Lx.h:16
hid_device * device
bool isConnected() const
Definition: basedevice.cpp:520
const char * getDeviceName() const
Definition: basedevice.cpp:821
INDI::PropertySwitch getSwitch(const char *name) const
Definition: basedevice.cpp:99
Properties getProperties()
Return a list of all properties in the device.
Definition: basedevice.cpp:158
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
const char * getName() const
Provides generic container for INDI properties.
Definition: indiproperty.h:48
const char * getName() const
bool updateProperties()
Definition: Lx.cpp:106
ISwitch LxModeS[LXMODENUM]
Definition: Lx.h:28
IText LxStartStopCmdT[2]
Definition: Lx.h:36
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Definition: Lx.cpp:151
IText LxPortT[1]
Definition: Lx.h:30
ISwitch LxSerialSizeS[4]
Definition: Lx.h:42
ISwitch LxParallelOptionS[9]
Definition: Lx.h:34
ISwitchVectorProperty LxSerialSizeSP
Definition: Lx.h:43
ISwitch LxLogicalLevelS[2]
Definition: Lx.h:38
bool startLx()
Definition: Lx.cpp:322
ITextVectorProperty LxStartStopCmdTP
Definition: Lx.h:37
ISwitch LxSerialAddeolS[4]
Definition: Lx.h:48
ITextVectorProperty LxPortTP
Definition: Lx.h:31
ISwitchVectorProperty LxSerialParitySP
Definition: Lx.h:45
ISwitch LxEnableS[2]
Definition: Lx.h:26
ISwitch LxSerialSpeedS[9]
Definition: Lx.h:40
ISwitchVectorProperty LxSerialOptionSP
Definition: Lx.h:33
int stopLx()
Definition: Lx.cpp:339
ISwitchVectorProperty LxSerialAddeolSP
Definition: Lx.h:49
ISwitchVectorProperty LxLogicalLevelSP
Definition: Lx.h:39
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Definition: Lx.cpp:281
ISwitchVectorProperty LxSerialStopSP
Definition: Lx.h:47
ISwitch LxSerialStopS[2]
Definition: Lx.h:46
ISwitchVectorProperty LxEnableSP
Definition: Lx.h:27
bool isEnabled()
Definition: Lx.cpp:21
ISwitch LxSerialParityS[3]
Definition: Lx.h:44
ISwitchVectorProperty LxModeSP
Definition: Lx.h:29
bool initProperties(INDI::DefaultDevice *device)
Definition: Lx.cpp:26
ISwitchVectorProperty LxParallelOptionSP
Definition: Lx.h:35
ISwitchVectorProperty LxSerialSpeedSP
Definition: Lx.h:41
unsigned int getLxmode()
Definition: Lx.cpp:317
void setCamerafd(int fd)
Definition: Lx.cpp:16
ISwitch LxSerialOptionS[3]
Definition: Lx.h:32
ISState
Switch state.
Definition: indiapi.h:150
@ ISS_OFF
Definition: indiapi.h:151
@ ISS_ON
Definition: indiapi.h:152
#define NARRAY(a)
Handy macro to find the number of elements in array a[]. Must be used with actual array,...
Definition: indiapi.h:500
@ IP_RW
Definition: indiapi.h:186
@ IPS_ALERT
Definition: indiapi.h:164
@ IPS_IDLE
Definition: indiapi.h:161
@ IPS_OK
Definition: indiapi.h:162
@ ISR_1OFMANY
Definition: indiapi.h:173
int tty_connect(const char *device, int bit_rate, int word_size, int parity, int stop_bits, int *fd)
Establishes a tty connection to a terminal device.
Definition: indicom.c:946
void IDLog(const char *fmt,...)
Definition: indicom.c:316
Implementations for common driver routines.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
Definition: indidevapi.c:128
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
Definition: indidevapi.c:148
void IUFillTextVector(ITextVectorProperty *tvp, IText *tp, int ntp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a text vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:291
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
Definition: indidevapi.c:36
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
Definition: indidevapi.c:158
void IUFillText(IText *tp, const char *name, const char *label, const char *initialText)
Assign attributes for a text property. The text's auxiliary elements will be set to NULL.
Definition: indidevapi.c:198
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
Definition: indidevapi.c:235
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
Definition: indidevapi.c:56
#define INDI_UNUSED(x)
Definition: indidevapi.h:131
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
Definition: indidriver.c:1308
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
Definition: indidriver.c:1231
void IDMessage(const char *dev, const char *fmt,...)
Definition: indidriver.c:960
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
Definition: indidriver.c:1191
int fd
Definition: intelliscope.c:43
#define VIDIOCPWCPROBE
Definition: pwc-ioctl.h:240
#define VIDIOCPWCSLED
Definition: pwc-ioctl.h:258
One text descriptor.
char name[MAXINDINAME]
Definition: indiapi.h:371
char name[MAXINDINAME]
Definition: indiapi.h:250
int led_on
Definition: pwc-ioctl.h:142
int type
Definition: pwc-ioctl.h:98