34#define iEAFFOCUS_TIMEOUT 4
35#define TEMPERATURE_THRESHOLD 0.1
65 TemperatureNP[0].
fill(
"TEMPERATURE",
"Celsius",
"%2.2f", 0., 50., 0., 50.);
68 SetZeroSP[0].
fill(
"SETZERO",
"Set Current Position to 0",
ISS_OFF);
133 int nbytes_written = 0, nbytes_read = 0, rc = -1;
135 int ieafpos, ieafmodel, ieaflast;
137 tcflush(
PortFD, TCIOFLUSH);
153 tcflush(
PortFD, TCIOFLUSH);
154 resp[nbytes_read] =
'\0';
155 sscanf(resp,
"%6d%2d%4d", &ieafpos, &ieafmodel, &ieaflast);
157 if ((ieafmodel == 2) || (ieafmodel == 3))
173bool iEAFFocus::updateInfo()
175 int nbytes_written = 0, nbytes_read = 0, rc = -1;
178 char joedeviceinfo[16] = {0};
179 int ieafpos, ieafmove, ieaftemp, ieafdir;
181 tcflush(
PortFD, TCIOFLUSH);
194 tcflush(
PortFD, TCIOFLUSH);
196 resp[nbytes_read] =
'\0';
198 sscanf(resp,
"%14s", joedeviceinfo);
199 rc = sscanf(resp,
"%7d%1d%5d%1d", &ieafpos, &ieafmove, &ieaftemp, &ieafdir);
203 LOGF_ERROR(
"Could not parse response %s", resp);
207 m_isMoving = ieafmove == 1;
209 m_Reversed = (ieafdir == 0);
216 TemperatureNP.
apply();
220 if (m_Reversed != currentlyReversed)
266bool iEAFFocus::MoveMyFocuser(uint32_t position)
268 int nbytes_written = 0, rc = -1;
271 snprintf(
cmd, 12,
":FM%7u#", position);
274 tcflush(
PortFD, TCIOFLUSH);
290 int nbytes_written = 0, rc = -1;
293 if (enabled == m_Reversed)
297 tcflush(
PortFD, TCIOFLUSH);
311void iEAFFocus::setZero()
313 int nbytes_written = 0, rc = -1;
315 tcflush(
PortFD, TCIOFLUSH);
348void iEAFFocus::GetFocusParams ()
358 uint32_t targetPos = targetTicks;
362 rc = MoveMyFocuser(targetPos);
377 int relativeTicks = ((dir ==
FOCUS_INWARD) ? -ticks : ticks) * (m_Reversed ? -1 : 1);
378 uint32_t newPosition =
FocusAbsPosNP[0].getValue() + relativeTicks;
379 newPosition = std::max(0u, std::min(
static_cast<uint32_t
>(
FocusAbsPosNP[0].getMax()), newPosition));
381 auto rc = MoveMyFocuser(newPosition);
410 tcflush(
PortFD, TCIOFLUSH);
void setDefaultBaudRate(BaudRate newRate)
setDefaultBaudRate Set default baud rate. The default baud rate is 9600 unless otherwise changed by t...
void setDefaultPollingPeriod(uint32_t msec)
setDefaultPollingPeriod Change the default polling period to call TimerHit() function in the driver.
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.
uint32_t getPollingPeriod() const
getPollingPeriod Return the polling period.
void defineProperty(INumberVectorProperty *property)
int SetTimer(uint32_t ms)
Set a timer to call the function TimerHit after ms milliseconds.
INDI::PropertyNumber FocusRelPosNP
INDI::PropertySwitch FocusReverseSP
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
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,...
Connection::Serial * serialConnection
void setState(IPState state)
void apply(const char *format,...) const ATTRIBUTE_FORMAT_PRINTF(2
bool isNameMatch(const char *otherName) const
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, double timeout, IPState state)
void fill(const char *device, const char *name, const char *label, const char *group, IPerm permission, ISRule rule, double timeout, IPState state)
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
const char * getDefaultName() override
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
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 SetFocuserMaxPosition(uint32_t ticks) override
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
virtual IPState MoveAbsFocuser(uint32_t ticks) override
MoveFocuser the focuser to an absolute position.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
#define TEMPERATURE_THRESHOLD
std::unique_ptr< iEAFFocus > ieafFocus(new iEAFFocus())
#define iEAFFOCUS_TIMEOUT
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Implementations for common driver routines.
#define DEBUG(priority, msg)
Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");.
#define LOGF_ERROR(fmt,...)
#define DEBUGF(priority, msg,...)