Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one more check to ensure minimum count is met #1903

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions drivers/telescope/ioptronv3driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ bool Driver::sendCommandOk(const char *command)
return false;
}

bool Driver::sendCommand(const char *command, int count, char *response, uint8_t timeout, uint8_t debugLog)
bool Driver::sendCommand(const char *command,
int count,
char *response,
int minimumCount,
uint8_t timeout,
uint8_t debugLog)
{
int errCode = 0;
int nbytes_read = 0;
Expand Down Expand Up @@ -106,7 +111,7 @@ bool Driver::sendCommand(const char *command, int count, char *response, uint8_t
else
errCode = tty_read(PortFD, res, count, timeout, &nbytes_read);

if (errCode == TTY_OK)
if (errCode == TTY_OK && (minimumCount < 0 || minimumCount <= count))
break;
}

Expand Down Expand Up @@ -146,7 +151,7 @@ bool Driver::checkConnection(int fd)

for (int i = 0; i < 2; i++)
{
if (sendCommand(":MountInfo#", 4, res, 3) == false)
if (sendCommand(":MountInfo#", 4, res, -1, 3) == false)
{
usleep(50000);
continue;
Expand Down Expand Up @@ -250,7 +255,7 @@ bool Driver::getStatus(IOPInfo *info)
iopLongitude, iopLatitude, simData.simInfo.gpsStatus, simData.simInfo.systemStatus, simData.simInfo.trackRate,
simData.simInfo.slewRate, simData.simInfo.timeSource, simData.simInfo.hemisphere);
}
else if (sendCommand(":GLS#", -1, res) == false)
else if (sendCommand(":GLS#", -1, res, 23) == false)
return false;


Expand Down Expand Up @@ -712,7 +717,7 @@ bool Driver::getCoords(double *ra, double *de, IOP_PIER_STATE *pierState, IOP_CW
static_cast<uint32_t>(fabs(simData.de) * 60 * 60 * 100),
static_cast<uint32_t>(simData.ra * 15 * 60 * 60 * 100), simData.pier_state, simData.cw_state);
}
else if (sendCommand(":GEP#", -1, res, IOP_TIMEOUT, INDI::Logger::DBG_EXTRA_1) == false)
else if (sendCommand(":GEP#", -1, res, 20, IOP_TIMEOUT, INDI::Logger::DBG_EXTRA_1) == false)
return false;

if (strlen(res) != 20)
Expand Down Expand Up @@ -753,7 +758,7 @@ bool Driver::getUTCDateTime(double *JD, int *utcOffsetMinutes, bool *dayLightSav
abs(simData.utc_offset_minutes),
(simData.day_light_saving ? '1' : '0'), static_cast<uint64_t>((simData.JD - J2000) * 8.64e+7));
}
else if (sendCommand(":GUT#", -1, res) == false)
else if (sendCommand(":GUT#", -1, res, 18) == false)
return false;

if (strlen(res) != 18)
Expand Down
6 changes: 5 additions & 1 deletion drivers/telescope/ioptronv3driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ class Driver
/**************************************************************************
Communication
**************************************************************************/
bool sendCommand(const char *command, int count = 1, char *response = nullptr, uint8_t timeout = IOP_TIMEOUT,
bool sendCommand(const char *command,
int count = 1,
char *response = nullptr,
int minimumCount = -1,
uint8_t timeout = IOP_TIMEOUT,
uint8_t debugLog = INDI::Logger::DBG_DEBUG);
bool sendCommandOk(const char *command);
bool checkConnection(int fd);
Expand Down