43static std::unique_ptr<DeepSkyDadFR1> dsdFR1(
new DeepSkyDadFR1());
75 FirmwareTP[0].
fill(
"Version",
"Version",
nullptr);
109 return "Deep Sky Dad FR1";
112bool DeepSkyDadFR1::Handshake()
115 return getInitialStatusData();
126 SpeedModeSP.
update(states, names, n);
130 if (current_mode == target_mode)
140 snprintf(
cmd,
DSD_RES,
"[SSPD%d]", target_mode);
141 bool rc = sendCommand(
cmd, response);
159 StepSizeSP.
update(states, names, n);
163 if (current_mode == target_mode)
173 snprintf(
cmd,
DSD_RES,
"[SSTP%d]", target_mode);
174 bool rc = sendCommand(
cmd, response);
190 return Rotator::ISNewSwitch(dev, name, states, names, n);
197 int angleInt = (int)(angle * 100);
199 if (!sendCommand(
cmd, response) || !sendCommand(
"[SMOV]", response))
202 if (strcmp(response,
"(OK)") == 0)
213 if (!sendCommand(
"[STOP]", response))
216 if (strcmp(response,
"(OK)") == 0)
228 snprintf(
cmd,
DSD_CMD,
"[SREV%d]", enabled ? 1 : 0);
229 if (!sendCommand(
cmd, response))
232 if (strcmp(response,
"(OK)") == 0)
244 int angleInt = (int)(angle * 100);
246 if (!sendCommand(
cmd, response))
249 if (strcmp(response,
"(OK)") == 0)
265bool DeepSkyDadFR1::getStatusData()
272 if (!sendCommand(
"[GMOV]", response))
275 sscanf(response,
"(%d)", &motorStatus);
277 if (!sendCommand(
"[GPOS]", response))
280 sscanf(response,
"(%d)", &motorPosition);
286 double motorPositionDouble = (double)motorPosition / (
double)100;
297bool DeepSkyDadFR1::getInitialStatusData()
300 if (!sendCommand(
"[GFRM]", response))
303 char versionString[6] = { 0 };
304 snprintf(versionString, 6,
"%s", response + 31);
305 FirmwareTP[0].setText(response);
310 if (!sendCommand(
"[GREV]", response))
313 sscanf(response,
"(%d)", &motorReversed);
316 if (motorReversed != wasReversed)
323 if (!sendCommand(
"[GSPD]", response))
326 if(strcmp(response,
"(2)") == 0)
328 else if(strcmp(response,
"(3)") == 0)
331 if (!sendCommand(
"[GSTP]", response))
334 if(strcmp(response,
"(1)") == 0)
336 else if(strcmp(response,
"(2)") == 0)
338 else if(strcmp(response,
"(4)") == 0)
340 else if(strcmp(response,
"(8)") == 0)
349bool DeepSkyDadFR1::sendCommand(
const char *
cmd,
char *res)
351 int nbytes_written = 0, nbytes_read = 0, rc = -1;
353 tcflush(
PortFD, TCIOFLUSH);
361 LOGF_ERROR(
"Serial write error: %s.", errstr);
378 tcflush(
PortFD, TCIOFLUSH);
void registerHandshake(std::function< bool()> callback)
registerHandshake Register a handshake function to be called once the initial connection to the devic...
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
void setDefaultPort(const char *port)
setDefaultPort Set default port. Call this function in initProperties() of your driver if you want to...
virtual bool AbortRotator() override
AbortRotator Abort all motion.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool updateProperties() override
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) override
Process the client newSwitch command.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
const char * getDefaultName() override
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
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)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
bool update(const ISState states[], const char *const names[], int n)
int findOnSwitchIndex() const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void SetCapability(uint32_t cap)
SetRotatorCapability sets the Rotator capabilities. All capabilities must be initialized.
INDI::PropertySwitch ReverseRotatorSP
INDI::PropertyNumber GotoRotatorNP
Connection::Serial * serialConnection
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
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.
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)