40 IUFillSwitchVector(&
LxModeSP,
LxModeS,
NARRAY(
LxModeS), device_name,
"LX Mode",
"",
LX_TAB,
IP_RW,
ISR_1OFMANY, 0,
102 ledmethod = PWCIOCTL;
127 pfound = findByLabel(dev,
"Stop Strobe");
154 if (devname && strcmp(device_name, devname))
170 unsigned int index, oldindex;
281 bool Lx::ISNewText(
const char *devname,
const char *name,
char *texts[],
char *names[],
int n)
285 if (devname && strcmp(device_name, devname))
303 for (
int i = 0; i < n; i++)
325 IDMessage(device_name,
"Starting Long Exposure");
330 return startLxSerial();
341 unsigned int index = 0;
343 IDMessage(device_name,
"Stopping Long Exposure");
348 return stopLxSerial();
360 void Lx::closeserial(
int fd)
362 tcsetattr(
fd, TCSANOW, &oldterminfo);
364 perror(
"closeserial()");
367 int Lx::openserial(
const char *devicename)
372 if ((
fd = open(devicename, O_RDWR)) == -1)
374 IDLog(
"openserial(): open()");
377 if (tcgetattr(
fd, &oldterminfo) == -1)
379 IDLog(
"openserial(): tcgetattr()");
384 attr.c_cflag |= CLOCAL;
386 if (tcflush(
fd, TCIOFLUSH) == -1)
388 IDLog(
"openserial(): tcflush()");
391 if (tcsetattr(
fd, TCSANOW, &attr) == -1)
393 IDLog(
"initserial(): tcsetattr()");
399 int Lx::setRTS(
int fd,
int level)
419 if (ioctl(
fd, TIOCMBIS, &mcr) == -1)
421 IDLog(
"setRTS(): TIOCMBIS");
427 if (ioctl(
fd, TIOCMBIC, &mcr) == -1)
429 IDLog(
"setRTS(): TIOCMBIC");
436 int Lx::setDTR(
int fd,
int level)
440 if (ioctl(
fd, TIOCMGET, &status) == -1)
442 IDLog(
"setDTR(): TIOCMGET");
448 status &= ~TIOCM_DTR;
449 if (ioctl(
fd, TIOCMSET, &status) == -1)
451 IDLog(
"setDTR(): TIOCMSET");
457 void Lx::getSerialOptions(
unsigned int *speed,
unsigned int *wordsize,
unsigned int *parity,
unsigned int *stops)
460 unsigned int speedopts[] = { 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 };
461 unsigned int sizeopts[] = { 5, 6, 7, 8 };
463 unsigned int stopopts[] = { 1, 2 };
465 *speed = speedopts[index];
467 *wordsize = sizeopts[index];
469 *parity = parityopts[index];
471 *stops = stopopts[index];
474 const char *Lx::getSerialEOL()
492 bool Lx::startLxSerial()
494 unsigned int speed = 0, wordsize = 0, parity = 0, stops = 0;
495 const char *eol =
nullptr;
501 serialfd = openserial(
LxPortT[0].text);
510 serialfd = openserial(
LxPortT[0].text);
519 getSerialOptions(&speed, &wordsize, &parity, &stops);
520 eol = getSerialEOL();
526 rc = write(serialfd, eol, strlen(eol));
533 int Lx::stopLxSerial()
535 const char *eol =
nullptr;
554 eol = getSerialEOL();
555 rc = write(serialfd, eol, strlen(eol));
566 if (oneProperty.isLabelMatch(label))
574 if (FlashStrobeSP && FlashStrobeStopSP)
576 IDMessage(device_name,
"Using Flash control for led Lx Mode");
577 ledmethod = FLASHLED;
582 IDMessage(device_name,
"ERROR: device does not support PWC ioctl");
585 if (probe.
type < 730)
587 IDMessage(device_name,
"ERROR: camera type %d does not support led control", probe.
type);
590 IDMessage(device_name,
"Using PWC ioctl for led Lx Mode");
594 void Lx::pwcsetLed(
int on,
int off)
601 IDLog(
"ioctl: can't set Led.\n");
605 void Lx::pwcsetflashon()
608 const char *names[2] = { FlashStrobeSP[0].
getName(), FlashStrobeStopSP[0].
getName() };
609 dev->
ISNewSwitch(device_name, FlashStrobeSP.
getName(), &(states[0]), (
char **)names, 1);
612 FlashStrobeSP.
apply();
614 FlashStrobeStopSP.
apply();
617 void Lx::pwcsetflashoff()
620 const char *names[2] = { FlashStrobeSP[0].
getName(), FlashStrobeStopSP[0].
getName()};
622 dev->
ISNewSwitch(device_name, FlashStrobeStopSP.
getName(), &(states[1]), (
char **)(names + 1), 1);
624 FlashStrobeStopSP.
apply();
627 FlashStrobeSP.
apply();
630 bool Lx::startLxPWC()
const char * getDeviceName() const
INDI::PropertySwitch getSwitch(const char *name) const
Properties getProperties()
Return a list of all properties in the device.
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.
const char * getName() const
ISwitch LxModeS[LXMODENUM]
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
ISwitch LxParallelOptionS[9]
ISwitchVectorProperty LxSerialSizeSP
ISwitch LxLogicalLevelS[2]
ITextVectorProperty LxStartStopCmdTP
ISwitch LxSerialAddeolS[4]
ITextVectorProperty LxPortTP
ISwitchVectorProperty LxSerialParitySP
ISwitch LxSerialSpeedS[9]
ISwitchVectorProperty LxSerialOptionSP
ISwitchVectorProperty LxSerialAddeolSP
ISwitchVectorProperty LxLogicalLevelSP
bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
ISwitchVectorProperty LxSerialStopSP
ISwitchVectorProperty LxEnableSP
ISwitch LxSerialParityS[3]
ISwitchVectorProperty LxModeSP
bool initProperties(INDI::DefaultDevice *device)
ISwitchVectorProperty LxParallelOptionSP
ISwitchVectorProperty LxSerialSpeedSP
ISwitch LxSerialOptionS[3]
#define NARRAY(a)
Handy macro to find the number of elements in array a[]. Must be used with actual array,...
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.
void IDLog(const char *fmt,...)
Implementations for common driver routines.
int IUFindOnSwitchIndex(const ISwitchVectorProperty *svp)
Returns the index of first ON switch it finds in the vector switch property.
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
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.
void IUSaveText(IText *tp, const char *newtext)
Function to reliably save new text in a IText.
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.
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.
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.
IText * IUFindText(const ITextVectorProperty *tvp, const char *name)
Find an IText member in a vector text property.
int IUUpdateSwitch(ISwitchVectorProperty *svp, ISState *states, char *names[], int n)
Update all switches in a switch vector property.
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
void IDMessage(const char *dev, const char *fmt,...)
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)