Do wait for a reply on each aor command

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2016 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.5
Stéphane Fillod, F8CFE 2005-04-15 18:18:42 +00:00
rodzic f3f29c4b7a
commit 26dfe2aa7d
1 zmienionych plików z 17 dodań i 4 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib AOR backend - main file * Hamlib AOR backend - main file
* Copyright (c) 2000-2005 by Stephane Fillod * Copyright (c) 2000-2005 by Stephane Fillod
* *
* $Id: aor.c,v 1.35 2005-04-15 17:48:40 fillods Exp $ * $Id: aor.c,v 1.36 2005-04-15 18:18:42 fillods Exp $
* *
* This library is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -75,6 +75,8 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, i
{ {
int retval; int retval;
struct rig_state *rs; struct rig_state *rs;
unsigned char ackbuf[BUFSZ];
int ack_len;
rs = &rig->state; rs = &rig->state;
@ -84,10 +86,14 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, i
if (retval != RIG_OK) if (retval != RIG_OK)
return retval; return retval;
/* will flush data on next transaction */ if (!data)
if (!data || !data_len) data = ackbuf;
return RIG_OK; if (!data_len)
data_len = &ack_len;
/*
* Do wait for a reply
*/
retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM)); retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM));
if (retval < 0) if (retval < 0)
return retval; return retval;
@ -99,6 +105,13 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, i
else else
data[BUFSZ-1] = '\0'; data[BUFSZ-1] = '\0';
if (data[0] == '?') {
/* command failed? resync with radio */
write_block(&rs->rigport, EOM, 1);
return -RIG_EPROTO;
}
return RIG_OK; return RIG_OK;
} }