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);
126 return "Deep Sky Dad FP";
129bool DeepSkyDadFP::Handshake()
173 if (strcmp(HeaterModeSP.
name, name) == 0)
181 if (current_mode == target_mode)
192 bool rc = sendCommand(
cmd, response);
196 HeaterModeS[current_mode].s =
ISS_ON;
227bool DeepSkyDadFP::ping()
231 if (!sendCommand(
"[GPOS]", response))
247bool DeepSkyDadFP::getStartupData()
249 bool rc1 = getFirmwareVersion();
250 bool rc2 = getStatus();
251 bool rc3 = getBrightness();
253 return (rc1 && rc2 && rc3);
259 if (!sendCommand(
"[STRG270]", response) || !sendCommand(
"[SMOV]", response))
262 if (strcmp(response,
"(OK)") == 0)
265 prevCoverStatus = 10;
275 if (!sendCommand(
"[STRG0]", response) || !sendCommand(
"[SMOV]", response))
278 if (strcmp(response,
"(OK)") == 0)
281 prevCoverStatus = 10;
294 strncpy(command,
"[SLON1]",
FLAT_CMD);
296 strncpy(command,
"[SLON0]",
FLAT_CMD);
298 if (!sendCommand(command, response))
301 if (strcmp(response,
"(OK)") == 0)
307bool DeepSkyDadFP::getStatus()
314 int heaterTemperature;
317 if (!sendCommand(
"[GMOV]", response))
320 sscanf(response,
"(%d)", &motorStatus);
322 if (!sendCommand(
"[GLON]", response))
325 sscanf(response,
"(%d)", &lightStatus);
328 if (!sendCommand(
"[GOPS]", response))
331 sscanf(response,
"(%d)", &coverStatus);
333 if (!sendCommand(
"[GPOS]", response))
336 sscanf(response,
"(%d)", &coverStatus);
339 if (!sendCommand(
"[GHTT]", response))
342 sscanf(response,
"(%d)", &heaterTemperature);
344 if (!sendCommand(
"[GHTM]", response))
347 sscanf(response,
"(%d)", &heaterMode);
350 bool statusUpdated =
false;
353 if (coverStatus != prevCoverStatus)
361 else if(coverStatus == 1)
372 prevCoverStatus = coverStatus;
374 statusUpdated =
true;
388 else if(coverStatus == 0)
407 if (coverStatus != prevCoverStatus)
415 else if(coverStatus == 270)
426 prevCoverStatus = coverStatus;
428 statusUpdated =
true;
442 else if(coverStatus == 270)
467 if (lightStatus != prevLightStatus)
469 prevLightStatus = lightStatus;
471 statusUpdated =
true;
491 if (motorStatus != prevMotorStatus)
493 prevMotorStatus = motorStatus;
495 statusUpdated =
true;
512 int heaterConnected = heaterTemperature > -40;
513 if(heaterConnected != prevHeaterConnected)
515 prevHeaterConnected = heaterConnected;
516 if(heaterConnected == 1)
528 if(heaterMode != prevHeaterMode)
530 prevHeaterMode = heaterMode;
534 HeaterModeS[0].s =
ISS_ON;
536 else if(heaterMode == 1)
538 HeaterModeS[1].s =
ISS_ON;
540 else if(heaterMode == 2)
542 HeaterModeS[2].s =
ISS_ON;
550bool DeepSkyDadFP::getFirmwareVersion()
553 if (!sendCommand(
"[GFRM]", response))
556 char versionString[6] = { 0 };
557 snprintf(versionString, 6,
"%s", response + 31);
560 isFP2 = strstr(response,
"DeepSkyDad.FP2") !=
nullptr;
565bool DeepSkyDadFP::getBrightness()
568 if (!sendCommand(
"[GLBR]", response))
571 int32_t brightnessValue;
572 int rc = sscanf(response,
"(%d)", &brightnessValue);
576 LOGF_ERROR(
"Unable to parse brightness value (%s)", response);
580 if (brightnessValue != prevBrightness)
582 prevBrightness = brightnessValue;
594 snprintf(command,
FLAT_CMD,
"[SLBR%04d]", value);
596 if (!sendCommand(command, response))
599 if (strcmp(response,
"(OK)") != 0)
601 LOGF_ERROR(
"Unable to set brightness value", response);
608bool DeepSkyDadFP::sendCommand(
const char *
cmd,
char *res)
610 int nbytes_written = 0, nbytes_read = 0, rc = -1;
612 tcflush(PortFD, TCIOFLUSH);
620 LOGF_ERROR(
"Serial write error: %s.", errstr);
637 tcflush(PortFD, TCIOFLUSH);
void registerHandshake(std::function< bool()> callback)
registerHandshake Register a handshake function to be called once the initial connection to the devic...
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
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.
Provides interface to implement remotely controlled dust cover.
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.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n)
Process the client newSwitch command.
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
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
Provides interface to implement controllable light box/switch device.
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,...)
#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,...)