Some progress getting SB4100 to work

https://github.com/Hamlib/Hamlib/issues/1541
pull/1542/head
Mike Black W9MDB 2024-04-22 11:27:29 -05:00
rodzic 2b27553155
commit f8a67d716e
3 zmienionych plików z 43 dodań i 14 usunięć

Wyświetl plik

@ -47,12 +47,12 @@ extern int barret950_get_freq(RIG *rig, vfo_t vfo, freq_t freq);
*/
static const char *barrett4100_get_info(RIG *rig)
{
char *response = NULL;
static char *response;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = barrett_transaction(rig, "M:MIB GM", 0, &response);
retval = barrett_transaction2(rig, "M:MIB GM", 64, &response);
if (retval == RIG_OK)
{
@ -64,7 +64,7 @@ static const char *barrett4100_get_info(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "MIB GM: %s\n", response);
}
retval = barrett_transaction(rig, "M:FF GM", 0, &response);
retval = barrett_transaction2(rig, "M:FF GM", 0, &response);
if (retval == RIG_OK)
{
@ -73,10 +73,10 @@ static const char *barrett4100_get_info(RIG *rig)
}
else
{
rig_debug(RIG_DEBUG_VERBOSE, "FF GM: %s\n", response);
rig_debug(RIG_DEBUG_VERBOSE, "M:MIB GM: %s\n", response);
}
retval = barrett_transaction(rig, "M:FF BWA", 0, &response);
retval = barrett_transaction2(rig, "M:FF BWA", 0, &response);
if (retval == RIG_OK)
{
@ -88,7 +88,7 @@ static const char *barrett4100_get_info(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "FF BWA: %s\n", response);
}
retval = barrett_transaction(rig, "M:FF GRFA", 0, &response);
retval = barrett_transaction2(rig, "M:FF GRFA", 0, &response);
if (retval == RIG_OK)
{
@ -108,22 +108,24 @@ static int barrett4100_open(RIG *rig)
int retval;
char *response;
ENTERFUNC;
retval = barrett_transaction2(rig, "M:REMOTE SENTER2,1", 0, &response);
retval = barrett_transaction2(rig, "M:REMOTE SENTER2,1", 3, &response);
if (retval != RIG_OK || response[0] != 's')
rig_debug(RIG_DEBUG_ERR, "%s: back from REMOTE SENTER2: got %d\n", __func__, retval);
if (response[0] != 's')
{
rig_debug(RIG_DEBUG_ERR, "%s: REMOTE SENTER2 error: got %s\n", __func__,
response);
}
barrett4100_get_info(rig);
//barrett4100_get_info(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s: success, ret=%d\n", __func__, retval);
RETURNFUNC(RIG_OK);
}
static int barrett4100_close(RIG *rig)
{
char *response;
int retval = barrett_transaction2(rig, "M:REMOTE SENTER0", 0, &response);
int retval = barrett_transaction2(rig, "M:REMOTE SENTER0", 18, &response);
if (retval != RIG_OK)
{
@ -231,6 +233,7 @@ int barrett4100_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d); response=%s\n", __func__, __LINE__,
response);
return retval;
}
@ -238,7 +241,7 @@ struct rig_caps barrett4100_caps =
{
RIG_MODEL(RIG_MODEL_BARRETT_4100),
.model_name = "4100",
.mfg_name = "Barrett",
.mfg_name = "Rhode&Schwarz",
.version = BACKEND_VER ".1",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,

Wyświetl plik

@ -53,6 +53,15 @@ DECLARE_INITRIG_BACKEND(barrett)
return RIG_OK;
}
void barrett_flush(RIG *rig)
{
hamlib_port_t *rp = RIGPORT(rig);
int timesave = rig->state.timeout;
rig->state.timeout = 0;
rig_flush(rp);
rig->state.timeout = timesave;
}
// this version is for 4100
int barrett_transaction2(RIG *rig, char *cmd, int expected, char **result)
@ -60,8 +69,16 @@ int barrett_transaction2(RIG *rig, char *cmd, int expected, char **result)
char cmd_buf[MAXCMDLEN];
struct barrett_priv_data *priv = STATE(rig)->priv;
int retval;
hamlib_port_t *rp = RIGPORT(rig);
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%c%s%s", 0x0a, cmd, EOM);
barrett_flush(rig);
retval = write_block(rp, (unsigned char *) cmd_buf, strlen(cmd_buf));
if (retval < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s(%d): error in write_block\n", __func__, __LINE__);
return retval;
}
retval = read_block(RIGPORT(rig), (unsigned char *) priv->ret_data, expected);
if (retval < 0)
@ -69,6 +86,15 @@ int barrett_transaction2(RIG *rig, char *cmd, int expected, char **result)
rig_debug(RIG_DEBUG_ERR, "%s(%d): error in read_block\n", __func__, __LINE__);
return retval;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %d bytes read\n", __func__, __LINE__, retval);
if (priv->ret_data[0] == 0x13) // we'll return from the 1st good char
{
*result = &(priv->ret_data[1]);
}
else // some commands like IAL don't give XOFF but XON is there -- is this a bug?
{
*result = &(priv->ret_data[0]);
}
return retval;
}
@ -92,7 +118,7 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%s", cmd, EOM);
}
rig_flush(rp);
barrett_flush(rig);
retval = write_block(rp, (unsigned char *) cmd_buf, strlen(cmd_buf));
if (retval < 0)
@ -715,7 +741,7 @@ int barrett_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
default: return -RIG_ENIMPL;
}
rig_flush(rp);
barrett_flush(rig);
retval = write_block(rp, (unsigned char *) cmd_buf, strlen(cmd_buf));
if (retval < 0)

Wyświetl plik

@ -24,7 +24,7 @@
#include "hamlib/rig.h"
#define BACKEND_VER "20220113"
#define BACKEND_VER "20240422"
#define EOM "\x0d"
#define TRUE 1