kopia lustrzana https://github.com/Hamlib/Hamlib
Implement the first user of the deferred set_conf entries.
Testing with simrotorez shows the correct sequence of actions and correct commands being received.pull/1568/head
rodzic
86a7a0636c
commit
81a8745fca
|
@ -629,6 +629,7 @@ struct rot_state {
|
||||||
hamlib_port_t rotport; /*!< Rotator port (internal use). */
|
hamlib_port_t rotport; /*!< Rotator port (internal use). */
|
||||||
hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */
|
hamlib_port_t rotport2; /*!< 2nd Rotator port (internal use). */
|
||||||
rig_ptr_t *pstrotator_handler_priv_data;
|
rig_ptr_t *pstrotator_handler_priv_data;
|
||||||
|
deferred_config_header_t config_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h> /* Standard library definitions */
|
#include <stdlib.h> /* Standard library definitions */
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "register.h"
|
#include "register.h"
|
||||||
#include "iofunc.h"
|
#include "iofunc.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#include "rotorez.h"
|
#include "rotorez.h"
|
||||||
|
|
||||||
|
@ -1087,12 +1089,21 @@ static int rotorez_rot_set_conf(ROT *rot, hamlib_token_t token, const char *val)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: c = %c, *val = %c\n", __func__, c, *val);
|
|
||||||
SNPRINTF(cmdstr, sizeof(cmdstr), "%c", c);
|
SNPRINTF(cmdstr, sizeof(cmdstr), "%c", c);
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n",
|
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s, *val = %c\n",
|
||||||
__func__, cmdstr, *val);
|
__func__, cmdstr, *val);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We cannot send anything to the rotator if it isn't open yet.
|
||||||
|
* Queue any set_conf commands and let rot_open reprocess them
|
||||||
|
* after it has done it's job.
|
||||||
|
*/
|
||||||
|
if (!ROTSTATE(rot)->comm_state)
|
||||||
|
{
|
||||||
|
err = queue_deferred_config(&ROTSTATE(rot)->config_queue, token, val);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
err = rotorez_send_priv_cmd(rot, cmdstr);
|
err = rotorez_send_priv_cmd(rot, cmdstr);
|
||||||
|
|
||||||
if (err != RIG_OK)
|
if (err != RIG_OK)
|
||||||
|
|
|
@ -377,6 +377,7 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||||
hamlib_port_t *rotp2 = ROTPORT2(rot);
|
hamlib_port_t *rotp2 = ROTPORT2(rot);
|
||||||
int status;
|
int status;
|
||||||
int net1, net2, net3, net4, port;
|
int net1, net2, net3, net4, port;
|
||||||
|
deferred_config_item_t *item;
|
||||||
|
|
||||||
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||||
|
|
||||||
|
@ -522,6 +523,22 @@ int HAMLIB_API rot_open(ROT *rot)
|
||||||
|
|
||||||
rs->comm_state = 1;
|
rs->comm_state = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now that the rotator port is officially opened, we can
|
||||||
|
* send the deferred configuration info.
|
||||||
|
*/
|
||||||
|
while ((item = rs->config_queue.first))
|
||||||
|
{
|
||||||
|
rs->config_queue.first = item->next;
|
||||||
|
status = rot_set_conf(rot, item->token, item->value);
|
||||||
|
free(item->value);
|
||||||
|
free(item);
|
||||||
|
if (status != RIG_OK)
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maybe the backend has something to initialize
|
* Maybe the backend has something to initialize
|
||||||
* In case of failure, just close down and report error code.
|
* In case of failure, just close down and report error code.
|
||||||
|
|
Ładowanie…
Reference in New Issue