[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 5fc4e0b5d0efc8d6f2eaa
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2024-06-15 13:19:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 5fc4e0b5d0efc8d6f2eaa634046ce2940406b705 (commit) via 096f29cfd9adf7ce9f1e31193b4d6a4136a360ea (commit) via ce84fc68a5d7657d49170d3d0b60dd0a0f2b243f (commit) via eae88631733af0b7c8f290bfc9e84a73ce3c20e0 (commit) via 661efce725a61431d031e47682ac348674615ce7 (commit) via d160c620642125c66526beaf8d0d1c96d52886c3 (commit) via db73ef20e50907f017c26008098674f9d7467372 (commit) via b19c179ce7d455e6b2f294145e9614623d91dcf2 (commit) via 305e20948e1ada3b0a8db2e5a92dd2f27b4c3208 (commit) from ff0ed58edf3955596892ed5082ee44da89d94cf9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5fc4e0b5d0efc8d6f2eaa634046ce2940406b705 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jun 14 10:30:05 2024 -0500 Reduce timing on ts890 diff --git a/rigs/kenwood/ts890s.c b/rigs/kenwood/ts890s.c index ede63c181..a4dbd6182 100644 --- a/rigs/kenwood/ts890s.c +++ b/rigs/kenwood/ts890s.c @@ -491,7 +491,7 @@ struct rig_caps ts890s_caps = RIG_MODEL(RIG_MODEL_TS890S), .model_name = "TS-890S", .mfg_name = "Kenwood", - .version = BACKEND_VER ".15", + .version = BACKEND_VER ".16", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -506,8 +506,8 @@ struct rig_caps ts890s_caps = .serial_handshake = RIG_HANDSHAKE_NONE, .write_delay = 0, .post_write_delay = 0, - .timeout = 500, - .retry = 10, + .timeout = 200, + .retry = 1, .preamp = {12, RIG_DBLST_END,}, .attenuator = {6, 12, 18, RIG_DBLST_END,}, .max_rit = kHz(9.99), commit 096f29cfd9adf7ce9f1e31193b4d6a4136a360ea Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jun 14 10:28:44 2024 -0500 Show flrig agc labels but don't do anything with them yet. Mapping to Hamlib AGC levels is a bit complicated so deferring this until somebody needs it. diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index ff3e9e85a..29432c4ac 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -143,7 +143,7 @@ struct rig_caps flrig_caps = RIG_MODEL(RIG_MODEL_FLRIG), .model_name = "", .mfg_name = "FLRig", - .version = "20240418.0", + .version = "20240612.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1119,6 +1119,13 @@ static int flrig_open(RIG *rig) rig_get_split_vfo(rig, RIG_VFO_A, &split, &tx_vfo); + retval = flrig_transaction(rig, "rig.get_agc_labels", NULL, value, sizeof(value)); + + if (retval != RIG_OK) { RETURNFUNC(retval); } + + rig_debug(RIG_DEBUG_ERR, "%s: agc_labels=%s\n", __func__, value); + + RETURNFUNC(retval); } commit ce84fc68a5d7657d49170d3d0b60dd0a0f2b243f Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jun 14 09:57:05 2024 -0500 Remove debug from conf.c diff --git a/src/conf.c b/src/conf.c index 2807710b2..26273ef58 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1469,7 +1469,6 @@ int HAMLIB_API rig_set_conf(RIG *rig, hamlib_token_t token, const char *val) */ int HAMLIB_API rig_get_conf(RIG *rig, hamlib_token_t token, char *val) { - printf("tokendid=%lx, %s\n", token, val); return rig_get_conf2(rig, token, val, 128); } commit eae88631733af0b7c8f290bfc9e84a73ce3c20e0 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jun 14 09:40:55 2024 -0500 Improve orion.h behavior on timeouts diff --git a/rigs/tentec/orion.h b/rigs/tentec/orion.h index 4daf547b1..1f8abbfed 100644 --- a/rigs/tentec/orion.h +++ b/rigs/tentec/orion.h @@ -36,7 +36,7 @@ #include "rig.h" #include "riglist.h" -#define BACKEND_VER "20240612" +#define BACKEND_VER "20240613" #define TRUE 1 #define FALSE 0 @@ -214,10 +214,10 @@ RIG_MODEL(RIG_MODEL_TT565), .serial_stop_bits = 1, .serial_parity = RIG_PARITY_NONE, .serial_handshake = RIG_HANDSHAKE_HARDWARE, -.write_delay = 0, /* no delay between characters written */ +.write_delay = 1, /* no delay between characters written */ .post_write_delay = 0, /* ms delay between writes DEBUGGING HERE */ -.timeout = 2000, /* ms */ -.retry = 4, +.timeout = 200, /* ms */ +.retry = 1, .has_get_func = TT565_FUNCS, .has_set_func = TT565_FUNCS, commit 661efce725a61431d031e47682ac348674615ce7 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Jun 13 07:18:33 2024 -0500 Allow pstrotator to return az/el on 1st call to get_pos and add status values diff --git a/rigs/dummy/rot_pstrotator.c b/rigs/dummy/rot_pstrotator.c index caf1f911e..7beb58065 100644 --- a/rigs/dummy/rot_pstrotator.c +++ b/rigs/dummy/rot_pstrotator.c @@ -1,7 +1,6 @@ /* - i Hamlib Dummy backend - main file - * Copyright (c) 2001-2009 by Stephane Fillod - * + i Hamlib PSTRotator backend + * Copyright (c) 2024 Michael Black W9MDB * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,8 +40,7 @@ #define PSTROTATOR_ROT_PARM 0 #define PSTROTATOR_ROT_STATUS (ROT_STATUS_MOVING | ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_LEFT | ROT_STATUS_MOVING_RIGHT | \ - ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP | ROT_STATUS_MOVING_DOWN | \ - ROT_STATUS_LIMIT_UP | ROT_STATUS_LIMIT_DOWN | ROT_STATUS_LIMIT_LEFT | ROT_STATUS_LIMIT_RIGHT) + ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP | ROT_STATUS_MOVING_DOWN ) struct pstrotator_rot_priv_data { @@ -57,6 +55,8 @@ struct pstrotator_rot_priv_data int sockfd2; // the reply port for PSTRotator which is port+1 pthread_t threadid; + + int receiving; // true if we are receiving az/el data }; static int write_transaction(ROT *rot, char *cmd) @@ -213,9 +213,11 @@ static void *pstrotator_handler_start(void *arg) rs->pstrotator_handler_priv_data; pstrotator_handler_priv->args.rot = rot; pstrotator_handler_priv->pstrotator_handler_thread_run = 1; + priv->receiving = 0; while (pstrotator_handler_priv->pstrotator_handler_thread_run) { + int az = 0, el = 0; char buf[256]; readPacket(priv->sockfd2, buf, sizeof(buf), 1); @@ -228,6 +230,16 @@ static void *pstrotator_handler_start(void *arg) //dump_hex((unsigned char *)buf, strlen(buf)); int n = sscanf(buf, "AZ:%g", &priv->az); n += sscanf(buf, "EL:%g", &priv->el); + + if (n > 0) { priv->receiving = 1; } + + if (priv->az != az && priv->el != el) { priv->status = ROT_STATUS_MOVING; } + else if (priv->az < az) { priv->status = ROT_STATUS_MOVING_LEFT; } + else if (priv->az > az) { priv->status = ROT_STATUS_MOVING_RIGHT; } + else if (priv->el < el) { priv->status = ROT_STATUS_MOVING_DOWN; } + else if (priv->el > el) { priv->status = ROT_STATUS_MOVING_UP; } + else { priv->status = ROT_STATUS_NONE; } + //if (n > 0) rig_debug(RIG_DEBUG_CACHE, "%s: az=%.1f, el=%.1f\n", __func__, priv->az, priv->el); } @@ -267,10 +279,6 @@ static int pstrotator_rot_init(ROT *rot) static int pstrotator_rot_cleanup(ROT *rot) { struct rot_state *rs = ROTSTATE(rot); -#if 0 - struct pstrotator_rot_priv_data *priv = (struct pstrotator_rot_priv_data *) - rs->priv; -#endif rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -341,14 +349,26 @@ static int pstrotator_rot_open(ROT *rot) static int pstrotator_rot_close(ROT *rot) { + struct pstrotator_rot_priv_data *priv; + priv = (struct pstrotator_rot_priv_data *)ROTSTATE(rot)->priv; + pstrotator_handler_priv_data *pstrotator_handler_priv; + pstrotator_handler_priv = (pstrotator_handler_priv_data *) + rot->state.pstrotator_handler_priv_data; + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + pstrotator_handler_priv->pstrotator_handler_thread_run = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting for thread to stop\n", __func__); + pthread_join(priv->threadid, NULL); + rig_debug(RIG_DEBUG_VERBOSE, "%s: thread stopped\n", __func__); + priv->threadid = 0; + return RIG_OK; } +#if 0 static int pstrotator_set_conf(ROT *rot, hamlib_token_t token, const char *val) { -#if 0 struct pstrotator_rot_priv_data *priv; priv = (struct pstrotator_rot_priv_data *)ROTSTATE(rot)->priv; @@ -369,16 +389,14 @@ static int pstrotator_set_conf(ROT *rot, hamlib_token_t token, const char *val) } return RIG_OK; -#else - return -RIG_ENIMPL; -#endif } +#endif +#if 0 static int pstrotator_get_conf2(ROT *rot, hamlib_token_t token, char *val, int val_len) { -#if 0 struct pstrotator_rot_priv_data *priv; priv = (struct pstrotator_rot_priv_data *)ROTSTATE(rot)->priv; @@ -394,15 +412,15 @@ static int pstrotator_get_conf2(ROT *rot, hamlib_token_t token, char *val, } return RIG_OK; -#else - return -RIG_ENIMPL; -#endif } +#endif +#if 0 static int pstrotator_get_conf(ROT *rot, hamlib_token_t token, char *val) { return pstrotator_get_conf2(rot, token, val, 128); } +#endif @@ -433,62 +451,12 @@ static int pstrotator_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { struct pstrotator_rot_priv_data *priv = (struct pstrotator_rot_priv_data *) ROTSTATE(rot)->priv; -#if 0 - char buf[64]; - int n = 0; - fd_set rfds, efds; - int select_result; - struct timeval timeout; -#endif - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + write_transaction(rot, "<PST>AZ?</PST>"); write_transaction(rot, "<PST>EL?</PST>"); -#if 0 - - do - { - //read_string(&priv->port2, (unsigned char*)buf, sizeof(buf), stopset, stopset_len, 1, 1); - buf[0] = 0; - - // if moving we need to keep polling for updates until there are none - if (n == 2) - { - timeout.tv_sec = 0; - timeout.tv_usec = 0; - - FD_ZERO(&rfds); - FD_SET(priv->sockfd2, &rfds); - efds = rfds; - select_result = select(priv->sockfd2, &rfds, NULL, &efds, &timeout); - - if (select_result == 0) - { - //rig_debug(RIG_DEBUG_VERBOSE, "%s: timeout\n", __func__); - break; - } - else - { - rig_debug(RIG_DEBUG_VERBOSE, "%s: select_result=%d\n", __func__, select_result); - readPacket(priv->sockfd2, buf, sizeof(buf), 0); - } - } - else - { - readPacket(priv->sockfd2, buf, sizeof(buf), 1); - } - - dump_hex((unsigned char *)buf, strlen(buf)); - n += sscanf(buf, "AZ:%g", &priv->az); - n += sscanf(buf, "EL:%g", &priv->el); - - if (n > 2) { n = 2; } - } - while (strlen(buf) > 0); - -#endif - + hl_usleep(10 * 1000); *az = priv->az; *el = priv->el; @@ -532,7 +500,7 @@ struct rot_caps pstrotator_caps = ROT_MODEL(ROT_MODEL_PSTROTATOR), .model_name = "PstRotator", .mfg_name = "YO3DMU", - .version = "20240607.0", + .version = "20240613.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -562,9 +530,6 @@ struct rot_caps pstrotator_caps = .rot_open = pstrotator_rot_open, .rot_close = pstrotator_rot_close, - .set_conf = pstrotator_set_conf, - .get_conf = pstrotator_get_conf, - .set_position = pstrotator_rot_set_position, .get_position = pstrotator_rot_get_position, .park = pstrotator_rot_park, commit d160c620642125c66526beaf8d0d1c96d52886c3 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Jun 12 15:32:21 2024 -0500 Make Origin width timeout behave better diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index 89cf4d157..7edc53910 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -694,6 +694,7 @@ int tt565_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) char ttmode, ttreceiver; int retry; int timeout; + int widthOld = rig->state.cache.widthMainA; struct rig_state *rs = STATE(rig); ttreceiver = which_receiver(rig, vfo); @@ -739,8 +740,6 @@ int tt565_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return -RIG_EPROTO; } - /* Orion may need some time to "recover" from ?RxM before ?RxF */ - hl_usleep(100*1000); // was 80, now 100 -- still seeing infrequent failure /* Query passband width (filter) */ // since this fails at 80ms sometimes we won't retry and will reduce the timeout // Normally this comes back in about 30ms @@ -756,7 +755,9 @@ int tt565_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if (retval != RIG_OK) { - return retval; + // if the width call fails we will just reuse the old width + *width = widthOld; + return RIG_OK; } if (respbuf[1] != 'R' || respbuf[3] != 'F' || resp_len <= 4) diff --git a/rigs/tentec/orion.h b/rigs/tentec/orion.h index ac43d3543..4daf547b1 100644 --- a/rigs/tentec/orion.h +++ b/rigs/tentec/orion.h @@ -36,7 +36,7 @@ #include "rig.h" #include "riglist.h" -#define BACKEND_VER "20240606" +#define BACKEND_VER "20240612" #define TRUE 1 #define FALSE 0 commit db73ef20e50907f017c26008098674f9d7467372 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jun 10 22:26:21 2024 -0500 Add csntechnologies.net S.A.T. satellite rotor Thanks to Randy KB0NAV diff --git a/NEWS b/NEWS index b91c026ac..7a3747187 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Version 5.x -- future * Change FT1000MP Mark V model names to align with FT1000MP Version 4.6 + * Added csntechnoligies.net S.A.T Satellite rotor control * Added PSTRotator control * Added Flex SmartSDR slices A-H * Added Motorola Micom M2/M3 diff --git a/include/hamlib/rotlist.h b/include/hamlib/rotlist.h index a8ae9f754..cd49c7c10 100644 --- a/include/hamlib/rotlist.h +++ b/include/hamlib/rotlist.h @@ -87,6 +87,7 @@ #define ROT_MODEL_DUMMY ROT_MAKE_MODEL(ROT_DUMMY, 1) #define ROT_MODEL_NETROTCTL ROT_MAKE_MODEL(ROT_DUMMY, 2) #define ROT_MODEL_PSTROTATOR ROT_MAKE_MODEL(ROT_DUMMY, 3) +#define ROT_MODEL_SATROTCTL ROT_MAKE_MODEL(ROT_DUMMY, 4) /** diff --git a/rigs/dummy/netrotctl.c b/rigs/dummy/netrotctl.c index 27f4947f7..0b18c6357 100644 --- a/rigs/dummy/netrotctl.c +++ b/rigs/dummy/netrotctl.c @@ -373,3 +373,39 @@ struct rot_caps netrotctl_caps = .get_info = netrotctl_get_info, }; +/* + * S.A.T. rotator mimics net rotor but only minimal capabilities. + * Fails to work with net rotor since it fails dump_state. + */ + +static int satrotcrl_rot_init(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + return RIG_OK; +} + +struct rot_caps satrotctl_caps = +{ + ROT_MODEL(ROT_MODEL_SATROTCTL), + .model_name = "S.A.T. Satellite ctl", + .mfg_name = "csntechnologies.net", + .version = "20240609.0", + .copyright = "LGPL", + .status = RIG_STATUS_UNTESTED, + .rot_type = ROT_TYPE_AZEL, + .port_type = RIG_PORT_NETWORK, + .timeout = 400, + + .min_az = -180., + .max_az = 450., + .min_el = 0., + .max_el = 90., + + .priv = NULL, /* priv */ + + .rot_init = satrotcrl_rot_init, + .set_position = netrotctl_set_position, + .get_position = netrotctl_get_position, +}; + diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index ae761b93f..ed1a96136 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -1011,6 +1011,7 @@ DECLARE_INITROT_BACKEND(dummy) rot_register(&dummy_rot_caps); rot_register(&netrotctl_caps); rot_register(&pstrotator_caps); + rot_register(&satrotctl_caps); return RIG_OK; } diff --git a/rigs/dummy/rot_dummy.h b/rigs/dummy/rot_dummy.h index 8106b40dc..a71204843 100644 --- a/rigs/dummy/rot_dummy.h +++ b/rigs/dummy/rot_dummy.h @@ -40,5 +40,6 @@ extern struct rot_caps dummy_rot_caps; extern struct rot_caps netrotctl_caps; extern struct rot_caps pstrotator; +extern struct rot_caps satrotctl_caps; #endif /* _ROT_DUMMY_H */ commit b19c179ce7d455e6b2f294145e9614623d91dcf2 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jun 10 17:29:51 2024 -0500 Move pstrotator read to a separate thread so that get_pos can see real-time movement diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 82bc634e2..9d4ccf824 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -628,6 +628,7 @@ struct rot_state { int current_speed; /*!< Current speed 1-100, to be used when no change to speed is requested. */ hamlib_port_t rotport; /*!< Rotator port (internal use). */ hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */ + rig_ptr_t *pstrotator_handler_priv_data; }; diff --git a/rigs/dummy/rot_pstrotator.c b/rigs/dummy/rot_pstrotator.c index d89d34fab..caf1f911e 100644 --- a/rigs/dummy/rot_pstrotator.c +++ b/rigs/dummy/rot_pstrotator.c @@ -44,8 +44,6 @@ ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP | ROT_STATUS_MOVING_DOWN | \ ROT_STATUS_LIMIT_UP | ROT_STATUS_LIMIT_DOWN | ROT_STATUS_LIMIT_LEFT | ROT_STATUS_LIMIT_RIGHT) -static int simulating = 0; // do we need rotator emulation for debug? - struct pstrotator_rot_priv_data { azimuth_t az; @@ -56,67 +54,9 @@ struct pstrotator_rot_priv_data elevation_t target_el; rot_status_t status; - setting_t funcs; - value_t levels[RIG_SETTING_MAX]; - value_t parms[RIG_SETTING_MAX]; - - struct ext_list *ext_funcs; - struct ext_list *ext_levels; - struct ext_list *ext_parms; - - char *magic_conf; - -// hamlib_port_t port2; // the reply port for PSTRotator which is port+1 int sockfd2; // the reply port for PSTRotator which is port+1 -}; - -static const struct confparams pstrotator_ext_levels[] = -{ - { - TOK_EL_ROT_MAGICLEVEL, "MGL", "Magic level", "Magic level, as an example", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 1, .001 } } - }, - { - TOK_EL_ROT_MAGICFUNC, "MGF", "Magic func", "Magic function, as an example", - NULL, RIG_CONF_CHECKBUTTON - }, - { - TOK_EL_ROT_MAGICOP, "MGO", "Magic Op", "Magic Op, as an example", - NULL, RIG_CONF_BUTTON - }, - { - TOK_EL_ROT_MAGICCOMBO, "MGC", "Magic combo", "Magic combo, as an example", - "VALUE1", RIG_CONF_COMBO, { .c = { .combostr = { "VALUE1", "VALUE2", "NONE", NULL } } } - }, - { RIG_CONF_END, NULL, } -}; - -static const struct confparams pstrotator_ext_funcs[] = -{ - { - TOK_EL_ROT_MAGICEXTFUNC, "MGEF", "Magic ext func", "Magic ext function, as an example", - NULL, RIG_CONF_CHECKBUTTON - }, - { RIG_CONF_END, NULL, } -}; -static const struct confparams pstrotator_ext_parms[] = -{ - { - TOK_EP_ROT_MAGICPARM, "MGP", "Magic parm", "Magic parameter, as an example", - NULL, RIG_CONF_NUMERIC, { .n = { 0, 1, .001 } } - }, - { RIG_CONF_END, NULL, } -}; - -/* cfgparams are configuration item generally used by the backend's open() method */ -static const struct confparams pstrotator_cfg_params[] = -{ - { - TOK_CFG_ROT_MAGICCONF, "mcfg", "Magic conf", "Magic parameter, as an example", - "ROTATOR", RIG_CONF_STRING, { } - }, - { RIG_CONF_END, NULL, } + pthread_t threadid; }; static int write_transaction(ROT *rot, char *cmd) @@ -160,53 +100,166 @@ static int write_transaction(ROT *rot, char *cmd) return RIG_OK; } -static int pstrotator_rot_init(ROT *rot) +static void set_timeout(int fd, int sec, int usec) { - struct pstrotator_rot_priv_data *priv; - struct rot_state *rs = ROTSTATE(rot); + struct timeval timeout; + timeout.tv_sec = sec; + timeout.tv_usec = usec; + //rig_debug(RIG_DEBUG_VERBOSE, "%s: sec=%d, usec=%d, timeout = %.6lf\n", __func__, + // sec, usec, sec + usec / 1e6); - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, + sizeof(timeout)) < 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: setsockopt failed: %s\n", __func__, + strerror(errno)); + } +} - rs->priv = (struct pstrotator_rot_priv_data *) - calloc(1, sizeof(struct pstrotator_rot_priv_data)); +void readPacket(int sockfd, char *buf, int buf_len, int expected) +{ + struct sockaddr_in serverAddr; + socklen_t addrLen = sizeof(serverAddr); - if (!rs->priv) + buf[0] = 0; + + if (expected) { - return -RIG_ENOMEM; + set_timeout(sockfd, 1, 0); + } + else + { + set_timeout(sockfd, 0, 0); } - priv = rs->priv; + ssize_t n = recvfrom(sockfd, buf, buf_len, 0, (struct sockaddr *)&serverAddr, + &addrLen); - priv->ext_funcs = alloc_init_ext(pstrotator_ext_funcs); + if (n < 0) + { +#ifdef _WIN32 + int err = WSAGetLastError(); + + if (err == WSAEWOULDBLOCK || err == WSAETIMEDOUT) + { +#if 0 + + if (expected) + rig_debug(RIG_DEBUG_ERR, + "%s: recvfrom timed out. Is PSTRotator Setup/UDP Control enabled?\n", __func__); + +#endif + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: recvfrom error %d: %s\n", __func__, err, + strerror(errno)); + } - if (!priv->ext_funcs) +#else + + if (errno == EWOULDBLOCK || errno == EAGAIN) + { + if (expected) + rig_debug(RIG_DEBUG_ERR, + "%s: recvfrom timed out. Is PSTRotator Setup/UDP Control checked?\n", __func__); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: recvfrom error: %s\n", __func__, strerror(errno)); + } + +#endif + n = 0; + } + + buf[n] = '\0'; // Null-terminate the received data + strtok(buf, "\r\n"); // get rid of CRs and such + + //if (n > 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: buf=%s\n", __func__, buf); } +} + +#if defined(HAVE_PTHREAD) +#if 0 +typedef struct pstrotator_handler_args_sw +{ + int port; // port for reading PstRotator messages -- always +1 from base port +} pstrotator_handler_args; + +typedef struct pstrotator_handler_priv_data_s +{ + pthread_t thread_id; + pstrotator_handler_args args; +} pstrotator_handler_priv_data; +#endif + +static void *pstrotator_handler_start(void *arg) +{ + ROT *rot = (ROT *)arg; + struct rot_state *rs = STATE(rot); + struct pstrotator_rot_priv_data *priv = rs->priv; + pstrotator_handler_priv_data *pstrotator_handler_priv; + + rs->pstrotator_handler_priv_data = calloc(1, + sizeof(pstrotator_handler_priv_data)); + + if (rs->pstrotator_handler_priv_data == NULL) { - return -RIG_ENOMEM; + rig_debug(RIG_DEBUG_ERR, "%s: priv is NULL?\n", __func__); + return NULL; } - priv->ext_levels = alloc_init_ext(pstrotator_ext_levels); + pstrotator_handler_priv = (pstrotator_handler_priv_data *) + rs->pstrotator_handler_priv_data; + pstrotator_handler_priv->args.rot = rot; + pstrotator_handler_priv->pstrotator_handler_thread_run = 1; - if (!priv->ext_levels) + while (pstrotator_handler_priv->pstrotator_handler_thread_run) { - return -RIG_ENOMEM; + char buf[256]; + readPacket(priv->sockfd2, buf, sizeof(buf), 1); + + if (strlen(buf) == 0) + { + hl_usleep(20 * 1000); + continue; + } + + //dump_hex((unsigned char *)buf, strlen(buf)); + int n = sscanf(buf, "AZ:%g", &priv->az); + n += sscanf(buf, "EL:%g", &priv->el); + //if (n > 0) rig_debug(RIG_DEBUG_CACHE, "%s: az=%.1f, el=%.1f\n", __func__, priv->az, priv->el); } - priv->ext_parms = alloc_init_ext(pstrotator_ext_parms); + return RIG_OK; +} + +#endif + +static int pstrotator_rot_init(ROT *rot) +{ + struct pstrotator_rot_priv_data *priv; + struct rot_state *rs = ROTSTATE(rot); + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (!priv->ext_parms) + rs->priv = (struct pstrotator_rot_priv_data *) + calloc(1, sizeof(struct pstrotator_rot_priv_data)); + + if (!rs->priv) { return -RIG_ENOMEM; } + priv = rs->priv; + ROTPORT(rot)->type.rig = RIG_PORT_UDP_NETWORK; priv->az = priv->el = 0; priv->target_az = priv->target_el = 0; - priv->magic_conf = strdup("ROTATOR"); - - strcpy(ROTPORT(rot)->pathname, "192.0.0.1:12000"); + strcpy(ROTPORT(rot)->pathname, "192.168.56.1:12000"); return RIG_OK; } @@ -214,15 +267,13 @@ static int pstrotator_rot_init(ROT *rot) static int pstrotator_rot_cleanup(ROT *rot) { struct rot_state *rs = ROTSTATE(rot); +#if 0 struct pstrotator_rot_priv_data *priv = (struct pstrotator_rot_priv_data *) rs->priv; +#endif rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - free(priv->ext_funcs); - free(priv->ext_levels); - free(priv->ext_parms); - free(priv->magic_conf); free(rs->priv); rs->priv = NULL; @@ -230,30 +281,16 @@ static int pstrotator_rot_cleanup(ROT *rot) return RIG_OK; } -static void set_timeout(int fd, int sec, int usec) -{ - struct timeval timeout; - timeout.tv_sec = sec; - timeout.tv_usec = usec; - rig_debug(RIG_DEBUG_VERBOSE, "%s: sec=%d, usec=%d, timeout = %.6lf\n", __func__, - sec, usec, sec + usec / 1e6); - - if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, - sizeof(timeout)) < 0) - { - rig_debug(RIG_DEBUG_ERR, "%s: setsockopt failed: %s\n", __func__, - strerror(errno)); - } -} - static int pstrotator_rot_open(ROT *rot) { struct pstrotator_rot_priv_data *priv; int port = 0; int n1, n2, n3, n4; int sockfd; + int retval; struct sockaddr_in clientAddr; struct rot_state *rs = ROTSTATE(rot); + pthread_attr_t attr; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -289,6 +326,16 @@ static int pstrotator_rot_open(ROT *rot) priv->sockfd2 = sockfd; set_timeout(priv->sockfd2, 1, 0); + pthread_attr_init(&attr); + retval = pthread_create(&priv->threadid, &attr, pstrotator_handler_start, rot); + + if (retval != 0) + { + rig_debug(RIG_DEBUG_ERR, "%s; pthread_create error: %s\n", __func__, + strerror(errno)); + return -RIG_EINTERNAL; + } + return RIG_OK; } @@ -301,6 +348,7 @@ static int pstrotator_rot_close(ROT *rot) static int pstrotator_set_conf(ROT *rot, hamlib_token_t token, const char *val) { +#if 0 struct pstrotator_rot_priv_data *priv; priv = (struct pstrotator_rot_priv_data *)ROTSTATE(rot)->priv; @@ -321,12 +369,16 @@ static int pstrotator_set_conf(ROT *rot, hamlib_token_t token, const char *val) } return RIG_OK; +#else + return -RIG_ENIMPL; +#endif } static int pstrotator_get_conf2(ROT *rot, hamlib_token_t token, char *val, int val_len) { +#if 0 struct pstrotator_rot_priv_data *priv; priv = (struct pstrotator_rot_priv_data *)ROTSTATE(rot)->priv; @@ -342,6 +394,9 @@ static int pstrotator_get_conf2(ROT *rot, hamlib_token_t token, char *val, } return RIG_OK; +#else + return -RIG_ENIMPL; +#endif } static int pstrotator_get_conf(ROT *rot, hamlib_token_t token, char *val) @@ -359,85 +414,17 @@ static int pstrotator_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) rig_debug(RIG_DEBUG_VERBOSE, "%s called: %.2f %.2f\n", __func__, az, el); - if (simulating) - { - priv->target_az = az; - priv->target_el = el; - gettimeofday(&priv->tv, NULL); - } - else - { - char cmd[64]; - sprintf(cmd, "<PST><AZIMUTH>%f.2</AZIMUTH></PST>", az); - write_transaction(rot, cmd); - sprintf(cmd, "<PST><ELEVATION>%f.2</ELEVATION></PST>", el); - write_transaction(rot, cmd); - priv->az = az; - priv->el = el; - } - + char cmd[64]; + sprintf(cmd, "<PST><AZIMUTH>%f.2</AZIMUTH></PST>", az); + write_transaction(rot, cmd); + sprintf(cmd, "<PST><ELEVATION>%f.2</ELEVATION></PST>", el); + write_transaction(rot, cmd); + priv->az = az; + priv->el = el; return RIG_OK; } -void readPacket(int sockfd, char *buf, int buf_len, int expected) -{ - struct sockaddr_in serverAddr; - socklen_t addrLen = sizeof(serverAddr); - - buf[0] = 0; - - if (expected) - { - set_timeout(sockfd, 1, 0); - } - else - { - set_timeout(sockfd, 0, 0); - } - - ssize_t n = recvfrom(sockfd, buf, buf_len, 0, (struct sockaddr *)&serverAddr, - &addrLen); - - if (n < 0) - { -#ifdef _WIN32 - int err = WSAGetLastError(); - - if (err == WSAEWOULDBLOCK || err == WSAETIMEDOUT) - { - if (expected) - rig_debug(RIG_DEBUG_ERR, - "%s: recvfrom timed out. Is PSTRotator Setup/UDP Control enabled?\n", __func__); - } - else - { - rig_debug(RIG_DEBUG_ERR, "%s: recvfrom error %d: %s\n", __func__, err, - strerror(errno)); - } - -#else - - if (errno == EWOULDBLOCK || errno == EAGAIN) - { - if (expected) - rig_debug(RIG_DEBUG_ERR, - "%s: recvfrom timed out. Is PSTRotator Setup/UDP Control checked?\n", __func__); - } - else - { - rig_debug(RIG_DEBUG_ERR, "%s: recvfrom error: %s\n", __func__, strerror(errno)); - } - -#endif - n = 0; - } - - buf[n] = '\0'; // Null-terminate the received data - strtok(buf, "\r\n"); // get rid of CRs and such - - if (n > 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: buf=%s\n", __func__, buf); } -} /* * Get position of rotor, simulating slow rotation @@ -446,16 +433,20 @@ static int pstrotator_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { struct pstrotator_rot_priv_data *priv = (struct pstrotator_rot_priv_data *) ROTSTATE(rot)->priv; +#if 0 char buf[64]; int n = 0; fd_set rfds, efds; int select_result; struct timeval timeout; +#endif rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); write_transaction(rot, "<PST>AZ?</PST>"); write_transaction(rot, "<PST>EL?</PST>"); +#if 0 + do { //read_string(&priv->port2, (unsigned char*)buf, sizeof(buf), stopset, stopset_len, 1, 1); @@ -491,10 +482,13 @@ static int pstrotator_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) dump_hex((unsigned char *)buf, strlen(buf)); n += sscanf(buf, "AZ:%g", &priv->az); n += sscanf(buf, "EL:%g", &priv->el); - if (n > 2) n = 2; + + if (n > 2) { n = 2; } } while (strlen(buf) > 0); +#endif + *az = priv->az; *el = priv->el; @@ -559,12 +553,7 @@ struct rot_caps pstrotator_caps = .has_get_parm = PSTROTATOR_ROT_PARM, .has_set_parm = ROT_PARM_SET(PSTROTATOR_ROT_PARM), - .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, - - .extlevels = pstrotator_ext_levels, - .extfuncs = pstrotator_ext_funcs, - .extparms = pstrotator_ext_parms, - .cfgparams = pstrotator_cfg_params, + //.level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, .has_status = PSTROTATOR_ROT_STATUS, diff --git a/rigs/dummy/rot_pstrotator.h b/rigs/dummy/rot_pstrotator.h index 6e8d5e3c1..9375549a3 100644 --- a/rigs/dummy/rot_pstrotator.h +++ b/rigs/dummy/rot_pstrotator.h @@ -40,4 +40,23 @@ extern struct rot_caps pstrotator_caps; extern struct rot_caps netrotctl_caps; +#if defined(HAVE_PTHREAD) +typedef struct pstrotator_handler_args_sw +{ + ROT *rot; + int port; // port for reading PstRotator messages -- always +1 from base port +} pstrotator_handler_args; + +typedef struct pstrotator_handler_priv_data_s +{ + pthread_t thread_id; + pstrotator_handler_args args; + int pstrotator_handler_thread_run; + int sockfd2; + +} pstrotator_handler_priv_data; +#endif + + + #endif /* _ROT_PSTROTATOR_H */ commit 305e20948e1ada3b0a8db2e5a92dd2f27b4c3208 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jun 9 23:40:52 2024 -0500 Fix ptt for smartsdr slice so only the active slice gets positive ptt diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index b0f152545..dd7b04860 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -52,6 +52,7 @@ struct smartsdr_priv_data int slicenum; // slice 0-7 maps to A-H int seqnum; int ptt; + int tx; // when 1 this slice has PTT control double freqA; double freqB; rmode_t modeA; @@ -178,6 +179,7 @@ int smartsdr_init(RIG *rig) rs->model_name); RETURNFUNC(-RIG_ENIMPL); } + priv->ptt = 0; RETURNFUNC(RIG_OK); @@ -261,11 +263,14 @@ int smartsdr_open(RIG *rig) sprintf(cmd, "sub slice %d", priv->slicenum); //sprintf(cmd, "sub slice all"); smartsdr_transaction(rig, cmd); - do + + do { - hl_usleep(100*1000); - smartsdr_transaction(rig, NULL); - } while (priv->freqA == 0 && --loops > 0); + hl_usleep(100 * 1000); + smartsdr_transaction(rig, NULL); + } + while (priv->freqA == 0 && --loops > 0); + //smartsdr_transaction(rig, "info", buf, sizeof(buf)); //rig_debug(RIG_DEBUG_VERBOSE, "%s: info=%s", __func__, buf); @@ -453,7 +458,13 @@ static int smartsdr_parse_S(RIG *rig, char *s) { if (strcmp(state, "TRANSMITTING") == 0) { priv->ptt = 1; } else { priv->ptt = 0; } - rig_debug(RIG_DEBUG_VERBOSE, "%s: PTT state=%s, ptt=%d\n", __func__, state, priv->ptt); + + rig_debug(RIG_DEBUG_VERBOSE, "%s: PTT state=%s, ptt=%d\n", __func__, state, + priv->ptt); + } + else if (sscanf(p, "tx=%d\n", &priv->tx)) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: tx=%d\n", __func__, priv->tx); } } while ((p = strtok(NULL, sep))); @@ -519,7 +530,13 @@ int smartsdr_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) struct smartsdr_priv_data *priv = (struct smartsdr_priv_data *)STATE(rig)->priv; ENTERFUNC; smartsdr_transaction(rig, NULL); - *ptt = priv->ptt; + *ptt = 0; + + if (priv->tx) + { + *ptt = priv->ptt; + } + rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, *ptt); RETURNFUNC(RIG_OK); } diff --git a/rigs/flexradio/smartsdr_caps.h b/rigs/flexradio/smartsdr_caps.h index 75b563a3d..b00ca4e91 100644 --- a/rigs/flexradio/smartsdr_caps.h +++ b/rigs/flexradio/smartsdr_caps.h @@ -1,5 +1,5 @@ .mfg_name = "Flex-radio", - .version = "20240606.0", + .version = "20240609.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, ----------------------------------------------------------------------- Summary of changes: NEWS | 1 + include/hamlib/rotator.h | 1 + include/hamlib/rotlist.h | 1 + rigs/dummy/flrig.c | 9 +- rigs/dummy/netrotctl.c | 36 ++++ rigs/dummy/rot_dummy.c | 1 + rigs/dummy/rot_dummy.h | 1 + rigs/dummy/rot_pstrotator.c | 428 ++++++++++++++++++----------------------- rigs/dummy/rot_pstrotator.h | 19 ++ rigs/flexradio/smartsdr.c | 29 ++- rigs/flexradio/smartsdr_caps.h | 2 +- rigs/kenwood/ts890s.c | 6 +- rigs/tentec/orion.c | 7 +- rigs/tentec/orion.h | 8 +- src/conf.c | 1 - 15 files changed, 294 insertions(+), 256 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |