kenwood: send the whole buffer at once, added kenwood_cmd

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2885 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.11
Alessandro Zummo, IZ1PRB 2010-04-24 13:50:24 +00:00
rodzic 092dd5915e
commit 328e67a44d
2 zmienionych plików z 25 dodań i 6 usunięć

Wyświetl plik

@ -172,16 +172,27 @@ transaction_write:
serial_flush(&rs->rigport);
if (cmdstr) {
char *cmd;
int len = strlen(cmdstr);
retval = write_block(&rs->rigport, cmdstr, strlen(cmdstr));
if (retval != RIG_OK)
cmd = malloc(len + 2);
if (cmd == NULL) {
retval = -RIG_ENOMEM;
goto transaction_quit;
}
memcpy(cmd, cmdstr, len);
/* XXX the if is temporary, until all invocations are fixed */
/* XXX eventually a buffer could be used and write_block called once */
if (cmdstr[len - 1] != ';' && cmdstr[len - 1] != '\r')
retval = write_block(&rs->rigport, &caps->cmdtrm, 1);
if (cmdstr[len - 1] != ';' && cmdstr[len - 1] != '\r') {
cmd[len] = '\r';
len++;
}
retval = write_block(&rs->rigport, cmd, len);
free(cmd);
if (retval != RIG_OK)
goto transaction_quit;

Wyświetl plik

@ -23,6 +23,7 @@
#ifndef _KENWOOD_H
#define _KENWOOD_H 1
#include <string.h>
#include "token.h"
#define BACKEND_VER "0.7"
@ -164,7 +165,7 @@ extern const struct rig_caps r5000_caps;
extern const struct rig_caps ts480_caps;
/* use when not interested in the answer, bit want to check its len */
/* use when not interested in the answer, but want to check its len */
static int inline kenwood_simple_transaction(RIG *rig, const char *cmd, size_t expected)
{
char buf[10];
@ -178,4 +179,11 @@ static int inline kenwood_simple_cmd(RIG *rig, const char *cmd)
return kenwood_safe_transaction(rig, cmd, buf, 10, 0);
}
/* answer is the same as the command */
static int inline kenwood_cmd(RIG *rig, const char *cmd)
{
char buf[10];
return kenwood_safe_transaction(rig, cmd, buf, 10, strlen(cmd) + 1);
}
#endif /* _KENWOOD_H */