32#define TAF_curr_default 500
33#define TAF_curr_min 100
34#define TAF_curr_max 1600
35#define TAF_micro_default (1<<4)
36#define TAF_micro_min (1<<2)
37#define TAF_micro_max (1<<7)
38#define TAF_steprot_default 200
39#define TAF_steprot_min 10
40#define TAF_steprot_max 800
41#define TAF_pos_default 0
43#define TAF_pos_max 2000000000UL
44#define TAF_speed_default 20
45#define TAF_speed_min 1
46#define TAF_speed_max 999
47#define TAF_acc_default 30
50#define TAF_res_default 16
52#define TAF_res_max 512
54#define TAF_UI_STEPS 100.0
55#define TAF_STEP(min,max) (((max)-(min))/(TAF_UI_STEPS))
58#define TAF_FOCUSER_TIMEOUT 2
59#define TAF_FOCUSER_BUFSIZE 128
79 return "TeenAstroFocuser";
89 if (strncmp(resp,
"$ TeenAstro Focuser ", 20))
353 for(
int i = 0; i < n; i++)
355 usteps = atoi(names[i]);
391 NP.
update(values, names, n);
404 bool res =
SyncFocuser((uint32_t) rint(values[0]));
409 bool res =
setParkPos((uint32_t) rint(values[0]));
414 uint32_t val = (uint32_t) rint(values[0]);
436 bool res =
setGoToAcc((uint32_t) rint(values[0]));
535 tcflush(
PortFD, TCIOFLUSH);
537 int nbytes_written = 0, rc = -1;
556 resp[nbytes_read] =
'\0';
557 if(rc !=
TTY_OK || nbytes_read == 0 || resp[nbytes_read - 1] !=
'#')
576 resp[nbytes_read] =
'\0';
577 if(rc !=
TTY_OK || resp[0] !=
'1')
585 return resp[0] ==
'1';
596 resp[nbytes_read] =
'\0';
614 int len = strlen(resp);
625 int pos = -1, speed = -1;
631 if(sscanf(resp,
"?%d %d %f#", &pos, &speed, &temp) <= 0)
651 TempN[0].value = temp;
669 int parkPos = -1, maxPos = -1, manualSpeed = -1, goToSpeed = -1, gotoAcc = -1, manAcc = -1, manDec = -1;
674 if(sscanf(resp,
"~%d %d %d %d %d %d %d#", &parkPos, &maxPos, &manualSpeed, &goToSpeed, &gotoAcc, &manAcc, &manDec) <= 0)
711 snprintf(
cmd, 64,
":F%c,%d#", item, deviceValue);
754 int reverse = -1, log2_micro = -1, resolution = -1, curr_10ma = -1, steprot = -1;
759 if(sscanf(resp,
"M%d %d %d %d %d#", &reverse, &log2_micro, &resolution, &curr_10ma, &steprot) <= 0)
770 uint32_t micro = (1 << log2_micro);
771 bool microFound =
false;
776 if(micro == thisMicro)
804 for(; value != 0; bitPos++)
827 snprintf(
cmd, 64,
":FS,%d#", value);
835 snprintf(
cmd, 64,
":FG,%d#", position);
870 DefaultDevice::saveConfigItems(fp);
virtual bool saveConfigItems(FILE *fp)
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.
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
void addDebugControl()
Add Debug control to the driver.
INDI::PropertyNumber FocusRelPosNP
INDI::PropertySwitch FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
INDI::PropertyNumber FocusSyncNP
@ FOCUSER_HAS_VARIABLE_SPEED
INDI::PropertyNumber FocusSpeedNP
INDI::PropertySwitch FocusAbortSP
INDI::PropertyNumber FocusMaxPosNP
INDI::PropertyNumber FocusAbsPosNP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
INDI::PropertyNumber PresetNP
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
void save(FILE *f) const
save Save property to configuration file.
void setLabel(const char *label)
bool isNameMatch(const char *otherName) const
void setGroupName(const char *name)
bool update(const double values[], const char *const names[], int n)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
ISwitchVectorProperty RebootDeviceSP
bool setManualSpeed(uint32_t value)
void deleteOtherProperties()
ISwitchVectorProperty CfgMotorMicrostepsSP
bool setMotorCurrent(uint32_t value)
bool setManualAcc(uint32_t value)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
bool sendAndReceiveBool(const char *const msg)
INDI::PropertyNumber CfgMotorCurrentNP
bool setConfigItem(char item, uint32_t deviceValue)
void deleteMainControlProperties()
void defineOtherProperties()
virtual bool AbortFocuser()
AbortFocuser all focus motion.
virtual void TimerHit()
Callback function to be called once SetTimer duration elapses.
bool saveConfigItems(FILE *fp)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
bool setMotorStepsPerRevolution(uint32_t value)
INDI::PropertyNumber CfgManualSpeedNP
bool send(const char *const msg)
INumberVectorProperty TempNP
INDI::PropertyNumber CfgMotorResolutionNP
void initPositionPropertiesRanges(uint32_t maxPos)
bool ReverseFocuser(bool enable)
ReverseFocuser Reverse focuser motion direction.
virtual bool SyncFocuser(uint32_t value)
SyncFocuser Set current position to ticks without moving the focuser.
void defineMainControlProperties()
INDI::PropertyNumber CfgManualAccNP
bool setMotorMicrosteps(uint32_t value)
bool setMotorResolution(uint32_t value)
ITextVectorProperty DeviceVersionTP
INDI::PropertyNumber CfgManualDecNP
ISwitchVectorProperty GoToParkSP
const char * getDefaultName()
bool SetFocuserMaxPosition(uint32_t value)
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
bool sendAndReceive(const char *const msg, char *resp, int bufsize)
ISwitchVectorProperty EraseEEPROMSP
bool updateDeviceVersion()
bool sendAndExpectTimeout(const char *const msg, char *resp, int bufsize)
ISwitch CfgMotorMicrostepsS[TAF_MICROS_N]
INDI::PropertyNumber CfgGoToAccNP
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
virtual bool updateProperties()
Updates the state and definition of properties based on the current connection status....
bool SetFocuserSpeed(int value)
SetFocuserSpeed Set Focuser speed.
bool setParkPos(uint32_t value)
bool setManualDec(uint32_t value)
INumberVectorProperty CurSpeedNP
virtual IPState MoveAbsFocuser(uint32_t ticks)
MoveFocuser the focuser to an absolute position.
INDI::PropertyNumber CfgMotorStepsPerRevolutionNP
virtual bool initProperties()
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
INDI::PropertyNumber CfgParkPosNP
virtual bool Handshake()
Performs a device-specific handshake after a connection is established. This method should be overrid...
bool ISNewNumberHelper(INDI::PropertyNumber &NP, double values[], char *names[], int n, bool res)
bool updateMotionConfig()
bool goTo(uint32_t position)
bool setGoToAcc(uint32_t value)
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
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 IUFillNumberVector(INumberVectorProperty *nvp, INumber *np, int nnp, const char *dev, const char *name, const char *label, const char *group, IPerm p, double timeout, IPState s)
Assign attributes for a number vector property. The vector's auxiliary elements will be set to NULL.
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 IUFillNumber(INumber *np, const char *name, const char *label, const char *format, double min, double max, double step, double value)
Assign attributes for a number property. The number'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 DEBUG(priority, msg)
Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");.
#define DEBUGF(priority, msg,...)
#define TAF_steprot_default
#define TAF_speed_default
#define TAF_FOCUSER_TIMEOUT
std::unique_ptr< TeenAstroFocuser > teenAstroFocuser(new TeenAstroFocuser())
#define TAF_FOCUSER_BUFSIZE
#define TAF_STEP(min, max)