61 AccuracyNP[0].fill(
"ACCURACY",
"Degree (0=off)",
"%.2f", 0, 10, 0.1, 0);
66 DeviceIDNP[0].fill(
"DEVICE_ID",
"ID",
"%.0f", 1, 10, 1, 1);
107 LOG_INFO(
"Virtual Mechanical Angle is set to zero.");
111 return Rotator::ISNewSwitch(dev, name, states, names,
n);
126 snprintf(
cmd, 16,
"%d", (
int)(
backlash * 10 + 1600000));
152 int id =
static_cast<int>(values[0]);
154 snprintf(
cmd, 16,
"%d", 2200000 +
id);
160 strstr(resp,
"Device ID set to") ==
nullptr)
162 LOG_ERROR(
"Device did not confirm the new ID.");
172 return Rotator::ISNewNumber(dev, name, values, names,
n);
185 tcflush(
PortFD, TCIOFLUSH);
186 int nbytes_read_name = 0, nbytes_written = 0, rc = -1;
193 LOGF_ERROR(
"Serial write error: %s", errorMessage);
200 tcflush(
PortFD, TCIOFLUSH);
205 LOGF_ERROR(
"Serial write error: %s", errorMessage);
212 LOG_INFO(
"No data received, the device may not be WandererRotator, please check the serial port!");
213 LOGF_ERROR(
"Device read error: %s", errorMessage);
217 name[nbytes_read_name - 1] =
'\0';
225 int nbytes_read_version = 0;
226 char version[64] = {0};
229 version[nbytes_read_version - 1] =
'\0';
230 LOGF_INFO(
"Firmware Version:%s", version);
234 LOG_ERROR(
"The firmware is outdated, please upgrade to the latest firmware!");
240 LOG_WARN(
"The firmware is outdated, please upgrade as soon as possible.");
241 LOG_WARN(
"Firmware Upgrade Tool for Linux/Mac is now available for download on the WandererAstro website.");
246 char M_angle[64] = {0};
247 int nbytes_read_M_angle = 0;
249 M_angle[nbytes_read_M_angle - 1] =
'\0';
255 LOG_WARN(
"Virtual Mechanical Angle is too large, it is now set to zero!");
260 M_angle[nbytes_read_M_angle - 1] =
'\0';
265 char M_backlash[64] = {0};
266 int nbytes_read_M_backlash = 0;
268 M_backlash[nbytes_read_M_backlash - 1] =
'\0';
275 char M_reverse[64] = {0};
276 int nbytes_read_M_reverse = 0;
278 M_reverse[nbytes_read_M_reverse - 1] =
'\0';
290 int nbytes_read_M_id = 0;
293 M_id[nbytes_read_M_id - 1] =
'\0';
299 tcflush(
PortFD, TCIOFLUSH);
321 snprintf(
cmd, 16,
"%d", position);
335 int nbytes_written = 0, rc = -1;
340 LOGF_ERROR(
"Serial write error: %s", errorMessage);
360 snprintf(
cmd, 16,
"%d", position);
375 snprintf(
cmd, 16,
"%d", 1700001);
387 snprintf(
cmd, 16,
"%d", 1700000);
420 char resp[128] = {0};
430 else if (strncmp(resp,
"NP", 2) == 0)
437 else if (strncmp(resp,
"LIMIT", 5) == 0)
439 LOG_ERROR(
"Requested position has reached the limit.");
446 char *lastA = strrchr(resp,
'A');
449 char *angleStr = strrchr(resp,
'A');
450 angleStr = angleStr ? angleStr + 1 : resp;
469 int nbytes_written = 0, rc = -1;
475 LOGF_ERROR(
"Serial write error: %s", errorMessage);
487 int nbytes_written = 0, rc = -1;
488 std::string command_termination =
"\n";
494 LOGF_ERROR(
"Serial write error: %s", errorMessage);
bool updateProperty(PropertyType &property, ValueType *values, char *names[], int n, std::function< bool()> updater, bool saveConfig=false)
Generic helper function to update an INDI property based on an external operation.
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)
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 SetCapability(uint32_t cap)
SetRotatorCapability sets the Rotator capabilities. All capabilities must be initialized.
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....
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the reverse direction property in the configuration file
INDI::PropertyNumber BacklashNP
bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the reverse direction property in the configuration file
bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
bool Handshake() override
perform handshake with device to check communication
bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual const char * getRotatorHandshakeName()=0
bool AbortRotator() override
AbortRotator Abort all motion.
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
INDI::PropertyNumber AccuracyNP
IPState HomeRotator() override
WandererRotatorBase::HomeRotator.
INDI::PropertyNumber DeviceIDNP
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual const char * getDefaultName() override=0
virtual int getMinimumCompatibleFirmwareVersion()=0
virtual int getMovePositionOffset()
virtual int getStepsPerDegree()=0
bool Move(const char *cmd)
bool sendCommand(std::string command)
virtual int getLatestFirmwareVersion()
INDI::PropertySwitch SetZeroSP
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
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_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.
Implementations for common driver routines.
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
#define LOGF_WARN(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)