Skip to content
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
29 changes: 17 additions & 12 deletions drivers/auxiliary/gemini_flatpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ bool GeminiFlatpanel::Handshake()
if (deviceRevision == GEMINI_REVISION_UNKNOWN)
{
LOG_ERROR("Handshake failed. Unable to communicate with the device.");
LOG_ERROR("Unexpected device ID.");
return false;
}

Expand Down Expand Up @@ -569,7 +568,7 @@ bool GeminiFlatpanel::extractIntValue(const char *response, int startPos, int *v
return true;
}

bool GeminiFlatpanel::sendCommand(const char *command, char *response, int timeout)
bool GeminiFlatpanel::sendCommand(const char *command, char *response, int timeout, bool log)
{
int nbytes_written = 0, nbytes_read = 0, rc = -1;

Expand All @@ -582,9 +581,12 @@ bool GeminiFlatpanel::sendCommand(const char *command, char *response, int timeo
tcflush(PortFD, TCIOFLUSH);
if ((rc = tty_write_string(PortFD, command, &nbytes_written)) != TTY_OK)
{
char errstr[MAXRBUF] = {0};
tty_error_msg(rc, errstr, MAXRBUF);
LOGF_ERROR("Serial write error: %s.", errstr);
if (log)
{
char errstr[MAXRBUF] = {0};
tty_error_msg(rc, errstr, MAXRBUF);
LOGF_ERROR("Serial write error: %s.", errstr);
}
return false;
}

Expand All @@ -593,9 +595,12 @@ bool GeminiFlatpanel::sendCommand(const char *command, char *response, int timeo

if ((rc = tty_nread_section(PortFD, response, MAXRBUF, commandTerminator, timeout, &nbytes_read)) != TTY_OK)
{
char errstr[MAXRBUF] = {0};
tty_error_msg(rc, errstr, MAXRBUF);
LOGF_ERROR("Serial read error: %s.", errstr);
if (log)
{
char errstr[MAXRBUF] = {0};
tty_error_msg(rc, errstr, MAXRBUF);
LOGF_ERROR("Serial read error: %s.", errstr);
}
return false;
}

Expand Down Expand Up @@ -623,7 +628,7 @@ bool GeminiFlatpanel::pingRevision1()
// It is used to check if the device is a revision 1 device
char response[MAXRBUF] = {0};

if (!sendCommand(">P000#", response))
if (!sendCommand(">P000#", response, SERIAL_TIMEOUT_SEC, false))
{
return false;
}
Expand All @@ -642,7 +647,7 @@ bool GeminiFlatpanel::pingRevision2()
// It is used to check if the device is a revision 2 device
char response[MAXRBUF] = {0};

if (!sendCommand(">H#", response))
if (!sendCommand(">H#", response, SERIAL_TIMEOUT_SEC, false))
{
return false;
}
Expand Down Expand Up @@ -855,7 +860,7 @@ bool GeminiFlatpanel::openCover()
return false;
}

if (!sendCommand(command, response, 30))
if (!sendCommand(command, response, SERIAL_TIMEOUT_SEC_LONG))
{
return false;
}
Expand All @@ -880,7 +885,7 @@ bool GeminiFlatpanel::closeCover()
return false;
}

if (!sendCommand(command, response, 30))
if (!sendCommand(command, response, SERIAL_TIMEOUT_SEC_LONG))
{
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/auxiliary/gemini_flatpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#define GEMINI_DEVICE_ID 99
#define GEMINI_MIN_BRIGHTNESS 0
#define GEMINI_MAX_BRIGHTNESS 255
#define SERIAL_TIMEOUT_SEC 30
#define SERIAL_TIMEOUT_SEC 10
#define SERIAL_TIMEOUT_SEC_LONG 120
#define NO_VALUE 1000 // Used to indicate that no value is provided

namespace Connection
Expand Down Expand Up @@ -95,7 +96,7 @@ class GeminiFlatpanel : public INDI::DefaultDevice, public INDI::LightBoxInterfa
void updateConfigStatus();

// Commands
bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC);
bool sendCommand(const char *command, char *response, int timeout = SERIAL_TIMEOUT_SEC, bool log = true);
bool pingRevision1();
bool pingRevision2();
bool getFirmwareVersion(int *version);
Expand Down
Loading