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
49 #define TAF_acc_max 99
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))
345 for(
int i = 0; i < n; i++)
347 usteps = atoi(names[i]);
396 bool res =
SyncFocuser((uint32_t) rint(values[0]));
401 bool res =
setParkPos((uint32_t) rint(values[0]));
406 uint32_t val = (uint32_t) rint(values[0]);
428 bool res =
setGoToAcc((uint32_t) rint(values[0]));
527 tcflush(
PortFD, TCIOFLUSH);
529 int nbytes_written = 0, rc = -1;
548 resp[nbytes_read] =
'\0';
549 if(rc !=
TTY_OK || nbytes_read == 0 || resp[nbytes_read - 1] !=
'#')
568 resp[nbytes_read] =
'\0';
569 if(rc !=
TTY_OK || resp[0] !=
'1')
577 return resp[0] ==
'1';
588 resp[nbytes_read] =
'\0';
606 int len = strlen(resp);
617 int pos = -1, speed = -1;
623 if(sscanf(resp,
"?%d %d %f#", &pos, &speed, &temp) <= 0)
643 TempN[0].value = temp;
661 int parkPos = -1, maxPos = -1, manualSpeed = -1, goToSpeed = -1, gotoAcc = -1, manAcc = -1, manDec = -1;
666 if(sscanf(resp,
"~%d %d %d %d %d %d %d#", &parkPos, &maxPos, &manualSpeed, &goToSpeed, &gotoAcc, &manAcc, &manDec) <= 0)
703 snprintf(
cmd, 64,
":F%c,%d#", item, deviceValue);
746 int reverse = -1, log2_micro = -1, resolution = -1, curr_10ma = -1, steprot = -1;
751 if(sscanf(resp,
"M%d %d %d %d %d#", &reverse, &log2_micro, &resolution, &curr_10ma, &steprot) <= 0)
762 uint32_t micro = (1 << log2_micro);
763 bool microFound =
false;
768 if(micro == thisMicro)
796 for(; value != 0; bitPos++)
819 snprintf(
cmd, 64,
":FS,%d#", value);
827 snprintf(
cmd, 64,
":FG,%d#", position);
862 DefaultDevice::saveConfigItems(fp);
const char * getDeviceName() const
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.
INumberVectorProperty FocusSpeedNP
INumberVectorProperty FocusSyncNP
INumberVectorProperty FocusAbsPosNP
INumberVectorProperty FocusRelPosNP
ISwitchVectorProperty FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
@ FOCUSER_HAS_VARIABLE_SPEED
INumberVectorProperty FocusMaxPosNP
ISwitchVectorProperty FocusAbortSP
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
INumberVectorProperty PresetNP
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
ISwitchVectorProperty RebootDeviceSP
bool setManualSpeed(uint32_t value)
void deleteOtherProperties()
ISwitchVectorProperty CfgMotorMicrostepsSP
INumberVectorProperty CfgMotorResolutionNP
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)
Process the client newSwitch command.
bool sendAndReceiveBool(const char *const msg)
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)
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
bool setMotorStepsPerRevolution(uint32_t value)
bool send(const char *const msg)
INumberVectorProperty TempNP
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()
INumberVectorProperty CfgManualSpeedNP
bool setMotorMicrosteps(uint32_t value)
INumberVectorProperty CfgGoToAccNP
bool setMotorResolution(uint32_t value)
ITextVectorProperty DeviceVersionTP
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)
INumberVectorProperty CfgMotorStepsPerRevolutionNP
INumber CfgMotorStepsPerRevolutionN[1]
INumber CfgMotorCurrentN[1]
ISwitch CfgMotorMicrostepsS[TAF_MICROS_N]
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
bool ISNewNumberHelper(INumberVectorProperty *NP, double values[], char *names[], int n, bool res)
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
INumberVectorProperty CfgManualDecNP
bool SetFocuserSpeed(int value)
SetFocuserSpeed Set Focuser speed.
bool setParkPos(uint32_t value)
INumberVectorProperty CfgParkPosNP
bool setManualDec(uint32_t value)
INumber CfgMotorResolutionN[1]
INumberVectorProperty CurSpeedNP
virtual IPState MoveAbsFocuser(uint32_t ticks)
MoveFocuser the focuser to an absolute position.
virtual bool initProperties()
Initilize properties initial state and value. The child class must implement this function.
virtual bool Handshake()
perform handshake with device to check communication
INumber CfgManualSpeedN[1]
bool updateMotionConfig()
INumberVectorProperty CfgMotorCurrentNP
INumberVectorProperty CfgManualAccNP
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 IUSaveConfigNumber(FILE *fp, const INumberVectorProperty *nvp)
Add a number vector property value to the configuration file.
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,...)
int IUUpdateNumber(INumberVectorProperty *nvp, double values[], char *names[], int n)
Update all numbers in a number vector property.
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,...)
Number vector property descriptor.
#define TAF_steprot_default
std::unique_ptr< TeenAstroFocuser > teenAstroFocuser(new TeenAstroFocuser())
#define TAF_speed_default
#define TAF_FOCUSER_TIMEOUT
#define TAF_FOCUSER_BUFSIZE
#define TAF_STEP(min, max)