kopia lustrzana https://github.com/Hamlib/Hamlib
Add network_flush2 to support async messages from Flex TCP
This allow one to send a command to the Flex and process all the messages returned in the backend rather than thread. This then gives a synchronous behavior which clients expectpull/1561/head
rodzic
be0f7407f2
commit
3583b077e8
|
@ -379,6 +379,31 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
}
|
||||
|
||||
|
||||
// flush and keep what gets flushed based on stopset
|
||||
// Used by SmartSDR backend for example
|
||||
// return # of bytes read
|
||||
int network_flush2(hamlib_port_t *rp, unsigned char *stopset, char *buf, int buf_len)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
#ifdef __MINGW32__
|
||||
int ret = ioctlsocket(rp->fd, FIONREAD, &len);
|
||||
#else
|
||||
int ret = ioctl(rp->fd, FIONREAD, &len);
|
||||
#endif
|
||||
if (ret != 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: ioctl err '%s'\n", __func__, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
buf[0] = 0;
|
||||
if (len > buf_len) len = buf_len-1;
|
||||
read_string(rp, (unsigned char *)buf, len+1, (char*)stopset, 1, 0, 1);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
/**
|
||||
* \brief Clears any data in the read buffer of the socket
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ __BEGIN_DECLS
|
|||
int network_open(hamlib_port_t *p, int default_port);
|
||||
int network_close(hamlib_port_t *rp);
|
||||
void network_flush(hamlib_port_t *rp);
|
||||
int network_flush2(hamlib_port_t *rp, unsigned char *stopset, char *buf, int buf_len);
|
||||
int network_publish_rig_poll_data(RIG *rig);
|
||||
int network_publish_rig_transceive_data(RIG *rig);
|
||||
int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line);
|
||||
|
|
Ładowanie…
Reference in New Issue