35 #include <sys/ioctl.h>
43 static std::unique_ptr<DeepSkyDadFR1> dsdFR1(
new DeepSkyDadFR1());
75 IUFillText(&FirmwareT[0],
"Version",
"Version",
nullptr);
109 return "Deep Sky Dad FR1";
112 bool DeepSkyDadFR1::Handshake()
115 return getInitialStatusData();
122 if (strcmp(SpeedModeSP.
name, name) == 0)
130 if (current_mode == target_mode)
140 snprintf(
cmd,
DSD_RES,
"[SSPD%d]", target_mode);
141 bool rc = sendCommand(
cmd, response);
145 SpeedModeS[current_mode].s =
ISS_ON;
155 else if (strcmp(StepSizeSP.
name, name) == 0)
163 if (current_mode == target_mode)
173 snprintf(
cmd,
DSD_RES,
"[SSTP%d]", target_mode);
174 bool rc = sendCommand(
cmd, response);
178 StepSizeS[current_mode].s =
ISS_ON;
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)
265 bool 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;
297 bool DeepSkyDadFR1::getInitialStatusData()
300 if (!sendCommand(
"[GFRM]", response))
303 char versionString[6] = { 0 };
304 snprintf(versionString, 6,
"%s", response + 31);
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)
349 bool 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 intial connection to the device...
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
Initilize 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.
const char * getDeviceName() const
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.
INumberVectorProperty GotoRotatorNP
void SetCapability(uint32_t cap)
SetRotatorCapability sets the Rotator capabilities. All capabilities must be initialized.
ISwitchVectorProperty ReverseRotatorSP
ISwitch ReverseRotatorS[2]
Connection::Serial * serialConnection
virtual bool initProperties() override
Initilize 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.
void ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Update the value of an existing switch vector property.
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.
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 IDSetNumber(const INumberVectorProperty *nvp, const char *fmt,...)
void IDSetSwitch(const ISwitchVectorProperty *svp, const char *fmt,...)
void IDSetText(const ITextVectorProperty *tvp, const char *fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOGF_ERROR(fmt,...)