kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'jaebird-master'
Flush the buffer for the network protocol used with the PiHPSDR backend.astyle-formatting
commit
cb9ec24cd3
|
@ -33,6 +33,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "hamlib/rig.h"
|
#include "hamlib/rig.h"
|
||||||
|
#include "network.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "register.h"
|
#include "register.h"
|
||||||
|
@ -242,7 +243,13 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasiz
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* flush anything in the read buffer before command is sent */
|
||||||
|
if (rs->rigport.type.rig == RIG_PORT_NETWORK || rs->rigport.type.rig == RIG_PORT_UDP_NETWORK) {
|
||||||
|
network_flush(&rs->rigport);
|
||||||
|
} else {
|
||||||
serial_flush(&rs->rigport);
|
serial_flush(&rs->rigport);
|
||||||
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, cmd, len);
|
retval = write_block(&rs->rigport, cmd, len);
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
|
@ -107,8 +107,8 @@ const struct rig_caps pihpsdr_caps = {
|
||||||
.port_type = RIG_PORT_NETWORK,
|
.port_type = RIG_PORT_NETWORK,
|
||||||
.write_delay = 0,
|
.write_delay = 0,
|
||||||
.post_write_delay = 50, /* ms */
|
.post_write_delay = 50, /* ms */
|
||||||
.timeout = 200,
|
.timeout = 0,
|
||||||
.retry = 10,
|
.retry = 0,
|
||||||
.has_get_func = PIHPSDR_FUNC_ALL,
|
.has_get_func = PIHPSDR_FUNC_ALL,
|
||||||
.has_set_func = PIHPSDR_FUNC_ALL,
|
.has_set_func = PIHPSDR_FUNC_ALL,
|
||||||
.has_get_level = PIHPSDR_LEVEL_ALL,
|
.has_get_level = PIHPSDR_LEVEL_ALL,
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_NETINET_IN_H
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
@ -73,6 +74,8 @@
|
||||||
static int wsstarted;
|
static int wsstarted;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NET_BUFFER_SIZE 64
|
||||||
|
|
||||||
static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
|
@ -103,6 +106,26 @@ static void handle_error (enum rig_debug_level_e lvl, const char *msg)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Clears any data in the read buffer of the socket
|
||||||
|
*
|
||||||
|
* \param rp Port data structure
|
||||||
|
*/
|
||||||
|
void network_flush(hamlib_port_t* rp)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
char buffer[NET_BUFFER_SIZE] = { 0 };
|
||||||
|
for (;;) {
|
||||||
|
ioctl(rp->fd, FIONREAD, &len);
|
||||||
|
if (len > 0) {
|
||||||
|
len = read(rp->fd, &buffer, len < NET_BUFFER_SIZE ? len : NET_BUFFER_SIZE);
|
||||||
|
rig_debug(RIG_DEBUG_WARN, "Network data cleared: %s\n", buffer);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Open network port using rig.state data
|
* \brief Open network port using rig.state data
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,6 +30,7 @@ __BEGIN_DECLS
|
||||||
/* Hamlib internal use, see rig.c */
|
/* Hamlib internal use, see rig.c */
|
||||||
int network_open(hamlib_port_t *p, int default_port);
|
int network_open(hamlib_port_t *p, int default_port);
|
||||||
int network_close(hamlib_port_t *rp);
|
int network_close(hamlib_port_t *rp);
|
||||||
|
void network_flush(hamlib_port_t *rp);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue