kopia lustrzana https://github.com/Hamlib/Hamlib
rodzic
12ce326350
commit
cc1f277e5f
|
@ -121,26 +121,8 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Open network port using rig.state data
|
||||
*
|
||||
* Open Open network port using rig.state data.
|
||||
* NB: The signal PIPE will be ignored for the whole application.
|
||||
*
|
||||
* \param rp Port data structure (must spec port id eg hostname:port)
|
||||
* \param default_port Default network socket port
|
||||
* \return RIG_OK or < 0 if error
|
||||
*/
|
||||
int network_open(hamlib_port_t *rp, int default_port)
|
||||
int network_init()
|
||||
{
|
||||
int fd; /* File descriptor for the port */
|
||||
int status;
|
||||
struct addrinfo hints, *res, *saved_res;
|
||||
struct in6_addr serveraddr;
|
||||
char hoststr[256], portstr[6] = "";
|
||||
|
||||
ENTERFUNC;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
WSADATA wsadata;
|
||||
int ret;
|
||||
|
@ -163,6 +145,32 @@ int network_open(hamlib_port_t *rp, int default_port)
|
|||
}
|
||||
|
||||
#endif
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Open network port using rig.state data
|
||||
*
|
||||
* Open Open network port using rig.state data.
|
||||
* NB: The signal PIPE will be ignored for the whole application.
|
||||
*
|
||||
* \param rp Port data structure (must spec port id eg hostname:port)
|
||||
* \param default_port Default network socket port
|
||||
* \return RIG_OK or < 0 if error
|
||||
*/
|
||||
int network_open(hamlib_port_t *rp, int default_port)
|
||||
{
|
||||
int fd; /* File descriptor for the port */
|
||||
int status;
|
||||
struct addrinfo hints, *res, *saved_res;
|
||||
struct in6_addr serveraddr;
|
||||
char hoststr[256], portstr[6] = "";
|
||||
|
||||
ENTERFUNC;
|
||||
|
||||
status = network_init();
|
||||
|
||||
if (status != RIG_OK) { RETURNFUNC(status); }
|
||||
|
||||
if (!rp)
|
||||
{
|
||||
|
@ -388,4 +396,28 @@ int network_close(hamlib_port_t *rp)
|
|||
}
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* \brief Open multicast server using rig.state data
|
||||
*
|
||||
* Open Open multicast server using rig.state data.
|
||||
* NB: The signal PIPE will be ignored for the whole application.
|
||||
*
|
||||
* \param rp Port data structure (must spec port id eg hostname:port -- hostname defaults to 224.0.1.1)
|
||||
* \param default_port Default network socket port
|
||||
* \return RIG_OK or < 0 if error
|
||||
*/
|
||||
int network_multicast_server(RIG *rig, const char *multicast_addr, int default_port)
|
||||
{
|
||||
int status;
|
||||
|
||||
ENTERFUNC;
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):network_multicast_server under development\n", __FILE__, __LINE__);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):ADDR=%s, port=%d\n", __FILE__, __LINE__, multicast_addr, default_port);
|
||||
status = network_init();
|
||||
|
||||
if (status != RIG_OK) { RETURNFUNC(status); }
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -29,6 +29,7 @@ __BEGIN_DECLS
|
|||
|
||||
/* Hamlib internal use, see rig.c */
|
||||
int network_open(hamlib_port_t *p, int default_port);
|
||||
int network_multicast_server(RIG *rig, const char *multicast_addr, int default_port);
|
||||
int network_close(hamlib_port_t *rp);
|
||||
void network_flush(hamlib_port_t *rp);
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
#include "iofunc.h"
|
||||
#include "serial.h"
|
||||
#include "sprintflst.h"
|
||||
#include "network.h"
|
||||
|
||||
#include "rigctl_parse.h"
|
||||
|
||||
|
@ -109,6 +110,7 @@ static struct option long_options[] =
|
|||
{"twiddle_timeout", 1, 0, 'W'},
|
||||
{"uplink", 1, 0, 'x'},
|
||||
{"debug-time-stamps", 0, 0, 'Z'},
|
||||
{"multicast-addr", 1, 0, 'M'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -142,6 +144,7 @@ static int volatile ctrl_c;
|
|||
|
||||
const char *portno = "4532";
|
||||
const char *src_addr = NULL; /* INADDR_ANY */
|
||||
const char *multicast_addr = "224.0.1.1";
|
||||
|
||||
#define MAXCONFLEN 1024
|
||||
|
||||
|
@ -542,6 +545,16 @@ int main(int argc, char *argv[])
|
|||
rig_set_debug_time_stamp(1);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (!optarg)
|
||||
{
|
||||
usage(); /* wrong arg count */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
multicast_addr = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(); /* unknown option? */
|
||||
exit(1);
|
||||
|
@ -733,6 +746,15 @@ int main(int argc, char *argv[])
|
|||
|
||||
saved_result = result;
|
||||
|
||||
retcode = network_multicast_server(my_rig, multicast_addr, 4532);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: network_multicast_server failed: %s\n", __FILE__,
|
||||
rigerror(retcode));
|
||||
// we will consider this non-fatal for now
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
sock_listen = socket(result->ai_family,
|
||||
|
@ -1222,6 +1244,7 @@ void usage(void)
|
|||
" -W, --twiddle_rit suppress VFOB getfreq so RIT can be twiddled\n"
|
||||
" -x, --uplink set uplink get_freq ignore, 1=Sub, 2=Main\n"
|
||||
" -Z, --debug-time-stamps enable time stamps for debug messages\n"
|
||||
" -M, --multicast-addr=addr set multicast addr, default 224.0.1.1\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
" -V, --version output version information and exit\n\n",
|
||||
portno);
|
||||
|
|
Ładowanie…
Reference in New Issue