diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index b90412679..93fbc2710 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1,7 +1,7 @@ /* * Hamlib Interface - API header * Copyright (c) 2000-2003 by Frank Singleton - * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (c) 2000-2012 by Stephane Fillod * * * This library is free software; you can redistribute it and/or @@ -170,7 +170,8 @@ typedef enum rig_port_e { RIG_PORT_ULTRA, /*!< IrDA Ultra protocol! */ RIG_PORT_RPC, /*!< RPC wrapper */ RIG_PORT_PARALLEL, /*!< Parallel port */ - RIG_PORT_USB /*!< USB port */ + RIG_PORT_USB, /*!< USB port */ + RIG_PORT_UDP_NETWORK /*!< UDP Network socket type */ } rig_port_t; /** diff --git a/src/iofunc.c b/src/iofunc.c index d57a1b42b..0cfc7f0bf 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -1,6 +1,6 @@ /* * Hamlib Interface - generic file based io functions - * Copyright (c) 2000-2009 by Stephane Fillod + * Copyright (c) 2000-2012 by Stephane Fillod * Copyright (c) 2000-2003 by Frank Singleton * * @@ -119,6 +119,7 @@ int HAMLIB_API port_open(hamlib_port_t *p) break; /* ez :) */ case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: /* FIXME: hardcoded network port */ status = network_open(p, 4532); if (status < 0) @@ -156,6 +157,7 @@ int HAMLIB_API port_close(hamlib_port_t *p, rig_port_t port_type) ret = usb_port_close(p); break; case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: ret = network_close(p); break; @@ -193,7 +195,7 @@ static ssize_t port_read(hamlib_port_t *p, void *buf, size_t count) } } return ret; - } else if (p->type.rig == RIG_PORT_NETWORK) + } else if (p->type.rig == RIG_PORT_NETWORK || p->type.rig == RIG_PORT_UDP_NETWORK) return recv(p->fd, buf, count, 0); else return read(p->fd, buf, count); @@ -203,7 +205,7 @@ static ssize_t port_write(hamlib_port_t *p, const void *buf, size_t count) { if (p->type.rig == RIG_PORT_SERIAL) return win32_serial_write(p->fd, buf, count); - else if (p->type.rig == RIG_PORT_NETWORK) + else if (p->type.rig == RIG_PORT_NETWORK || p->type.rig == RIG_PORT_UDP_NETWORK) return send(p->fd, buf, count, 0); else return write(p->fd, buf, count); diff --git a/src/network.c b/src/network.c index f45231852..a1ec05eda 100644 --- a/src/network.c +++ b/src/network.c @@ -1,6 +1,6 @@ /* * Hamlib Interface - network communication low-level support - * Copyright (c) 2000-2010 by Stephane Fillod + * Copyright (c) 2000-2012 by Stephane Fillod * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -102,7 +102,10 @@ int network_open(hamlib_port_t *rp, int default_port) memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; + if (rp->type.rig == RIG_PORT_UDP_NETWORK) + hints.ai_socktype = SOCK_DGRAM; + else + hints.ai_socktype = SOCK_STREAM; if (rp->pathname[0] == ':') { portstr = rp->pathname+1; diff --git a/src/rig.c b/src/rig.c index caaf8824f..651ef516a 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1,6 +1,6 @@ /* * Hamlib Interface - main file - * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (c) 2000-2012 by Stephane Fillod * Copyright (c) 2000-2003 by Frank Singleton * * @@ -30,7 +30,7 @@ * \brief Ham Radio Control Libraries interface * \author Stephane Fillod * \author Frank Singleton - * \date 2000-2011 + * \date 2000-2012 * * Hamlib provides a user-callable API, a set of "front-end" routines that * call rig-specific "back-end" routines which actually communicate with @@ -82,7 +82,7 @@ const char hamlib_version[21] = "Hamlib " PACKAGE_VERSION; * \brief Hamlib copyright notice */ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ - "Copyright (C) 2000-2011 Stephane Fillod\n" + "Copyright (C) 2000-2012 Stephane Fillod\n" "Copyright (C) 2000-2003 Frank Singleton\n" "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; @@ -94,6 +94,8 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ #define DEFAULT_SERIAL_PORT "\\\\.\\COM1" #elif BSD #define DEFAULT_SERIAL_PORT "/dev/cuaa0" +#elif MACOSX +#define DEFAULT_SERIAL_PORT "/dev/cu.usbserial" #else #define DEFAULT_SERIAL_PORT "/dev/ttyS0" #endif @@ -303,6 +305,7 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model) break; case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: strncpy(rs->rigport.pathname, "127.0.0.1:4532", FILPATHLEN); break; diff --git a/src/rotator.c b/src/rotator.c index 717133625..de9bf9979 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -1,6 +1,6 @@ /* * Hamlib Interface - main file - * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (c) 2000-2012 by Stephane Fillod * Copyright (c) 2000-2003 by Frank Singleton * * @@ -29,7 +29,7 @@ * \file src/rotator.c * \brief Rotator interface * \author Stephane Fillod - * \date 2000-2011 + * \date 2000-2012 * * Hamlib interface is a frontend implementing rotator wrapper functions. */ @@ -69,6 +69,8 @@ #define DEFAULT_SERIAL_PORT "\\\\.\\COM1" #elif BSD #define DEFAULT_SERIAL_PORT "/dev/cuaa0" +#elif MACOSX +#define DEFAULT_SERIAL_PORT "/dev/cu.usbserial" #else #define DEFAULT_SERIAL_PORT "/dev/ttyS0" #endif @@ -234,6 +236,7 @@ ROT * HAMLIB_API rot_init(rot_model_t rot_model) break; case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: strncpy(rs->rotport.pathname, "127.0.0.1:4533", FILPATHLEN); break; @@ -333,6 +336,8 @@ int HAMLIB_API rot_open(ROT *rot) break; /* ez :) */ case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: + /* FIXME: default port */ status = network_open(&rs->rotport, 4533); if (status < 0) return status; @@ -411,6 +416,7 @@ int HAMLIB_API rot_close(ROT *rot) usb_port_close(&rs->rotport); break; case RIG_PORT_NETWORK: + case RIG_PORT_UDP_NETWORK: network_close(&rs->rotport); break; default: diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 9e11eb47b..40482b03f 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -1,5 +1,5 @@ /* - * dumpcaps.c - Copyright (C) 2000-2011 Stephane Fillod + * dumpcaps.c - Copyright (C) 2000-2012 Stephane Fillod * This programs dumps the capabilities of a backend rig. * * @@ -175,6 +175,9 @@ int dumpcaps (RIG* rig, FILE *fout) case RIG_PORT_NETWORK: fprintf(fout, "Network link\n"); break; + case RIG_PORT_UDP_NETWORK: + fprintf(fout, "UDP Network link\n"); + break; case RIG_PORT_NONE: fprintf(fout, "None\n"); break; diff --git a/tests/dumpcaps_rot.c b/tests/dumpcaps_rot.c index b480639ff..6b3129f0f 100644 --- a/tests/dumpcaps_rot.c +++ b/tests/dumpcaps_rot.c @@ -1,5 +1,5 @@ /* - * dumpcaps_rot.c - Copyright (C) 2000-2010 Stephane Fillod + * dumpcaps_rot.c - Copyright (C) 2000-2012 Stephane Fillod * This programs dumps the capabilities of a backend rig. * * @@ -99,6 +99,9 @@ int dumpcaps_rot (ROT* rot, FILE *fout) case RIG_PORT_NETWORK: fprintf(fout, "Network link\n"); break; + case RIG_PORT_UDP_NETWORK: + fprintf(fout, "UDP Network link\n"); + break; case RIG_PORT_NONE: fprintf(fout, "None\n"); break; diff --git a/tests/rigmatrix.c b/tests/rigmatrix.c index 2e4203630..1a817bd1c 100644 --- a/tests/rigmatrix.c +++ b/tests/rigmatrix.c @@ -1,5 +1,5 @@ /* - * rigmatrix.c - Copyright (C) 2000,2001,2002 Stephane Fillod + * rigmatrix.c - Copyright (C) 2000-2012 Stephane Fillod * This program generates the supported rig matrix in HTML format. * The code is rather ugly since this is only a try out. * @@ -154,6 +154,9 @@ int print_caps_parameters(const struct rig_caps *caps, void *data) case RIG_PORT_NETWORK: printf("network"); break; + case RIG_PORT_UDP_NETWORK: + printf("UDP network"); + break; case RIG_PORT_NONE: printf("None"); break;