Skip to content

Commit e344e20

Browse files
committed
Merge GitHub PR Hamlib#1970
2 parents ee42a8c + 6441c1d commit e344e20

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

rotators/skywatcher/skywatcher.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,25 @@ static int skywatcher_cmd(ROT *rot, const char *cmd, char *response,
6060
rig_flush(port);
6161
size_t cmd_len = strlen(cmd);
6262
ERROR_CHECK(write_block(port, (unsigned char *) cmd, cmd_len));
63-
// echo from the device
63+
// Some firmwares echo the commands and some don't, so this may be the echo
64+
// of the command sent above or the response
6465
int code = read_string(port, (unsigned char *) response, response_len, "\r", 1,
6566
0, 1);
6667

6768
if (code < 0)
6869
{
69-
return -code;
70+
return code;
7071
}
7172

72-
// the actual response
73-
code = read_string(port, (unsigned char *) response, response_len, "\r", 1, 0,
73+
// If we got echo from the device, then get the actual response
74+
if (response[0] == ':') {
75+
code = read_string(port, (unsigned char *) response, response_len, "\r", 1, 0,
7476
1);
7577

76-
if (code < 0)
77-
{
78-
return -code;
78+
if (code < 0)
79+
{
80+
return code;
81+
}
7982
}
8083

8184
// nullify last \r

0 commit comments

Comments
 (0)