37static std::unique_ptr<DeepSkyDadFP> dsdFp(
new DeepSkyDadFP());
60 IUFillText(&StatusT[0],
"Cover",
"Cover",
nullptr);
61 IUFillText(&StatusT[1],
"Light",
"Light",
nullptr);
62 IUFillText(&StatusT[2],
"Motor",
"Motor",
nullptr);
63 IUFillText(&StatusT[3],
"Heater",
"Heater",
nullptr);
67 IUFillText(&FirmwareT[0],
"Version",
"Version",
nullptr);
82 serialConnection->registerHandshake([&]()
88 serialConnection->setPortMatchPattern(
"Deep_Sky_Dad_FP[0-9]");
127 return "Deep Sky Dad FP";
130bool DeepSkyDadFP::Handshake()
174 if (strcmp(HeaterModeSP.name, name) == 0)
182 if (current_mode == target_mode)
193 bool rc = sendCommand(
cmd, response);
197 HeaterModeS[current_mode].s =
ISS_ON;
228bool DeepSkyDadFP::ping()
232 if (!sendCommand(
"[GPOS]", response))
248bool DeepSkyDadFP::getStartupData()
250 bool rc1 = getFirmwareVersion();
251 bool rc2 = getStatus();
252 bool rc3 = getBrightness();
254 return (rc1 && rc2 && rc3);
260 if (!sendCommand(
"[STRG270]", response) || !sendCommand(
"[SMOV]", response))
263 if (strcmp(response,
"(OK)") == 0)
266 prevCoverStatus = 10;
276 if (!sendCommand(
"[STRG0]", response) || !sendCommand(
"[SMOV]", response))
279 if (strcmp(response,
"(OK)") == 0)
282 prevCoverStatus = 10;
295 strncpy(command,
"[SLON1]",
FLAT_CMD);
297 strncpy(command,
"[SLON0]",
FLAT_CMD);
299 if (!sendCommand(command, response))
302 if (strcmp(response,
"(OK)") == 0)
308bool DeepSkyDadFP::getStatus()
315 int heaterTemperature;
318 if (!sendCommand(
"[GMOV]", response))
321 sscanf(response,
"(%d)", &motorStatus);
323 if (!sendCommand(
"[GLON]", response))
326 sscanf(response,
"(%d)", &lightStatus);
330 if (!sendCommand(
"[GOPS]", response))
333 sscanf(response,
"(%d)", &coverStatus);
337 if (!sendCommand(
"[GPOS]", response))
340 sscanf(response,
"(%d)", &coverStatus);
343 if (!sendCommand(
"[GHTT]", response))
346 sscanf(response,
"(%d)", &heaterTemperature);
348 if (!sendCommand(
"[GHTM]", response))
351 sscanf(response,
"(%d)", &heaterMode);
354 bool statusUpdated =
false;
358 if (coverStatus != prevCoverStatus)
366 else if(coverStatus == 1)
377 prevCoverStatus = coverStatus;
379 statusUpdated =
true;
393 else if(coverStatus == 0)
414 if (coverStatus != prevCoverStatus)
422 else if(coverStatus == 270)
433 prevCoverStatus = coverStatus;
435 statusUpdated =
true;
449 else if(coverStatus == 270)
474 if (lightStatus != prevLightStatus)
476 prevLightStatus = lightStatus;
478 statusUpdated =
true;
498 if (motorStatus != prevMotorStatus)
500 prevMotorStatus = motorStatus;
502 statusUpdated =
true;
519 int heaterConnected = heaterTemperature > -40;
520 if(heaterConnected != prevHeaterConnected)
522 prevHeaterConnected = heaterConnected;
523 if(heaterConnected == 1)
535 if(heaterMode != prevHeaterMode)
537 prevHeaterMode = heaterMode;
541 HeaterModeS[0].s =
ISS_ON;
543 else if(heaterMode == 1)
545 HeaterModeS[1].s =
ISS_ON;
547 else if(heaterMode == 2)
549 HeaterModeS[2].s =
ISS_ON;
557bool DeepSkyDadFP::getFirmwareVersion()
560 if (!sendCommand(
"[GFRM]", response))
563 char versionString[6] = { 0 };
564 snprintf(versionString, 6,
"%s", response + 31);
567 isFP2 = strstr(response,
"DeepSkyDad.FP2") !=
nullptr;
572bool DeepSkyDadFP::getBrightness()
575 if (!sendCommand(
"[GLBR]", response))
578 int32_t brightnessValue;
579 int rc = sscanf(response,
"(%d)", &brightnessValue);
583 LOGF_ERROR(
"Unable to parse brightness value (%s)", response);
587 if (brightnessValue != prevBrightness)
589 prevBrightness = brightnessValue;
601 snprintf(command,
FLAT_CMD,
"[SLBR%04d]", value);
603 if (!sendCommand(command, response))
606 if (strcmp(response,
"(OK)") != 0)
608 LOGF_ERROR(
"Unable to set brightness value", response);
615bool DeepSkyDadFP::sendCommand(
const char *
cmd,
char *res)
617 int nbytes_written = 0, nbytes_read = 0, rc = -1;
619 tcflush(PortFD, TCIOFLUSH);
627 LOGF_ERROR(
"Serial write error: %s.", errstr);
644 tcflush(PortFD, TCIOFLUSH);
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
@ OnIfFlapOpenOrLedActive
virtual bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be implemented in the child class, if supported.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be implemented in the child class.
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
const char * getDefaultName() override
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
const char * getDeviceName() const
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
void registerConnection(Connection::Interface *newConnection)
registerConnection Add new connection plugin to the existing connection pool. The connection type sha...
virtual void ISGetProperties(const char *dev)
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool ISSnoopDevice(XMLEle *root)
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
virtual bool initProperties()
Initialize properties initial state and value. The child class must implement this function.
void syncDriverInfo()
syncDriverInfo sends the current driver information to the client.
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
friend class LightBoxInterface
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
DustCapInterface(DefaultDevice *device)
INDI::PropertySwitch ParkCapSP
bool updateProperties()
updateProperties Defines or Delete properties based on default device connection status
void initProperties(const char *group, uint32_t capabilities=0)
Initialize dust cap properties. It is recommended to call this function within initProperties() of yo...
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process dust cap switch properties.
void initProperties(const char *group, uint32_t capabilities)
Initialize light box properties. It is recommended to call this function within initProperties() of y...
void ISGetProperties(const char *deviceName)
isGetLightBoxProperties Get light box properties
INDI::PropertyNumber LightIntensityNP
bool saveConfigItems(FILE *fp)
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process light box switch properties.
bool processText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process light box text properties.
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process light box number properties.
INDI::PropertySwitch LightSP
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
void IUSaveConfigSwitch(FILE *fp, const ISwitchVectorProperty *svp)
Add a switch vector property value to the configuration file.
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.
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 IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)