Merge branch 'master' into streamline-vfo-targeting-and-split-functionality

pull/1481/head
Mikael Nousiainen 2023-11-20 10:16:15 +02:00
commit 7b341a2ad6
24 zmienionych plików z 894 dodań i 46 usunięć

Wyświetl plik

@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: bootstrap
run: |
sudo apt install libusb-1.0-0-dev

Wyświetl plik

@ -241,7 +241,7 @@ AC_CHECK_FUNC([gethostbyname],
[],
[AC_CHECK_LIB([ws2_32],
[main],
[NET_LIBS="$NET_LIBS -lws2_32"],
[NET_LIBS="$NET_LIBS -lws2_32 -liphlpapi"],
[],
[])
])

Wyświetl plik

@ -1282,11 +1282,11 @@ option above, will terminate each command string sent to the radio. This
character should not be a part of the input string.
.
.TP
.BR W ", " send_cmd_rx " \(aq" \fICmd\fP\(aq " " \fI[nbytes or terminator char\FP
.BR W ", " send_cmd_rx " \(aq" \fICmd\fP\(aq " " \fInbytes_or_terminator_char\fP
Send a raw command string to the radio and expect nbytes returned or the terminator char (e.g. ;).
.IP
This is useful for testing and troubleshooting radio commands and responses when
developing a backend. If the # of bytes requested is <= the number actually returned no timeout will occur.
developing a backend. If the # of bytes requested is <= the number actually returned no timeout will occur. If a char is provided it will be used to terminate reading the string so ';' is popular for Kenwood/Yaesu commands for example.
.IP
The command argument can have no spaces in it.
For binary protocols enter values as \\0xAA\\0xBB. Expect a

Wyświetl plik

@ -2255,6 +2255,7 @@ enum rig_function_e {
RIG_FUNCTION_IS_ASYNC_FRAME,
RIG_FUNCTION_PROCESS_ASYNC_FRAME,
RIG_FUNCTION_GET_CONF2,
RIG_FUNCTION_STOP_VOICE_MEM,
};
/**
@ -2273,7 +2274,8 @@ enum rig_caps_int_e {
RIG_CAPS_RIG_MODEL,
RIG_CAPS_PORT_TYPE,
RIG_CAPS_PTT_TYPE,
RIG_CAPS_HAS_GET_LEVEL
RIG_CAPS_HAS_GET_LEVEL,
RIG_CAPS_HAS_SET_LEVEL,
};
enum rig_caps_cptr_e {
@ -2287,7 +2289,7 @@ enum rig_caps_cptr_e {
* \brief Function to return int value from rig->caps
* Does not support > 32-bit rig_caps values
*/
extern HAMLIB_EXPORT (long long) rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps);
extern HAMLIB_EXPORT (uint64_t) rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps);
/**
* \brief Function to return char pointer value from rig->caps

Wyświetl plik

@ -716,7 +716,7 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig)
modeFLRigCheck, modeMap[i].mode_flrig);
if (modeMap[i].mode_flrig
&& strcmp(modeMap[i].mode_flrig, modeFLRigCheck) == 0)
&& strstr(modeMap[i].mode_flrig, modeFLRigCheck))
{
return (modeMap[i].mode_hamlib);
}

Wyświetl plik

@ -955,6 +955,7 @@ const struct rig_caps ic7300_caps =
.stop_morse = icom_stop_morse,
.wait_morse = rig_wait_morse,
.send_voice_mem = icom_send_voice_mem,
.stop_voice_mem = icom_stop_voice_mem,
.set_clock = ic7300_set_clock,
.get_clock = ic7300_get_clock,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
@ -1278,6 +1279,7 @@ struct rig_caps ic9700_caps =
.stop_morse = icom_stop_morse,
.wait_morse = rig_wait_morse,
.send_voice_mem = icom_send_voice_mem,
.stop_voice_mem = icom_stop_voice_mem,
.set_clock = ic9700_set_clock,
.get_clock = ic9700_get_clock,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
@ -1552,6 +1554,7 @@ const struct rig_caps ic705_caps =
.stop_morse = icom_stop_morse,
.wait_morse = rig_wait_morse,
.send_voice_mem = icom_send_voice_mem,
.stop_voice_mem = icom_stop_voice_mem,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
};
@ -1822,6 +1825,7 @@ const struct rig_caps ic905_caps =
.stop_morse = icom_stop_morse,
.wait_morse = rig_wait_morse,
.send_voice_mem = icom_send_voice_mem,
.stop_voice_mem = icom_stop_voice_mem,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS,
};

Wyświetl plik

@ -609,6 +609,7 @@ struct rig_caps ic7610_caps =
.stop_morse = icom_stop_morse,
.wait_morse = rig_wait_morse,
.send_voice_mem = icom_send_voice_mem,
.stop_voice_mem = icom_stop_voice_mem,
.set_clock = ic7610_set_clock,
.get_clock = ic7610_get_clock,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS

Wyświetl plik

@ -6960,7 +6960,8 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
case RIG_FUNC_DUAL_WATCH:
if ((RIG_IS_IC9100) ||
(RIG_IS_IC9700))
(RIG_IS_IC9700) ||
(RIG_IS_ID5100))
{
fct_cn = C_CTL_FUNC;
fct_sc = S_MEM_DUALMODE;
@ -8923,6 +8924,10 @@ int icom_get_level_raw(RIG *rig, setting_t level, int cmd, int subcmd,
RETURNFUNC(RIG_OK);
}
int icom_stop_voice_mem(RIG *rig, vfo_t vfo)
{
return icom_send_voice_mem(rig, vfo, 0);
}
/*
* icom_send_voice_mem
* Assumes rig!=NULL, rig->state.priv!=NULL

Wyświetl plik

@ -35,7 +35,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20231113"
#define BACKEND_VER "20231116"
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)
@ -395,6 +395,7 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq,
int icom_send_morse(RIG *rig, vfo_t vfo, const char *msg);
int icom_stop_morse(RIG *rig, vfo_t vfo);
int icom_send_voice_mem(RIG *rig, vfo_t vfo, int bank);
int icom_stop_voice_mem(RIG *rig, vfo_t vfo);
/* Exposed routines */
int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo);
int icom_set_raw(RIG *rig, int cmd, int subcmd, int subcmdbuflen,

Wyświetl plik

@ -154,7 +154,7 @@ int id5100_set_vfo(RIG *rig, vfo_t vfo)
if (vfo == RIG_VFO_A || vfo == RIG_VFO_B)
{
// and 0x25 works in this mode
priv->x25cmdfails = 0;
priv->x25cmdfails = 1;
if (priv->dual_watch)
{
@ -222,6 +222,24 @@ int id5100_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
return retval;
}
int id5100_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
unsigned char ackbuf[MAXFRAMELEN];
int ack_len = sizeof(ackbuf), retval;
int fct_cn, fct_sc; /* Command Number, Subcommand */
unsigned char fctbuf[MAXFRAMELEN];
int fct_len = 0;
const struct icom_priv_caps *priv_caps = rig->caps->priv;
const struct cmdparams *extcmds = priv_caps->extcmds;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
ENTERFUNC;
value_t value;
RETURNFUNC(icom_get_func(rig, vfo, func, status));
}
/*
*/
static struct icom_priv_caps id5100_priv_caps =
@ -237,7 +255,7 @@ const struct rig_caps id5100_caps =
RIG_MODEL(RIG_MODEL_ID5100),
.model_name = "ID-5100",
.mfg_name = "Icom",
.version = BACKEND_VER ".6",
.version = BACKEND_VER ".7",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_MOBILE,
@ -344,7 +362,7 @@ const struct rig_caps id5100_caps =
.decode_event = icom_decode_event,
.set_func = icom_set_func,
.get_func = icom_get_func,
.get_func = id5100_get_func,
.set_level = icom_set_level,
.get_level = icom_get_level,
.set_parm = icom_set_parm,

Wyświetl plik

@ -564,28 +564,6 @@ static int ts590_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
SNPRINTF(levelbuf, sizeof(levelbuf), "RA%02d", (val.i == 12) ? 1 : 0);
break;
case RIG_LEVEL_METER:
switch (val.i)
{
case RIG_METER_SWR:
kenwood_val = 1;
break;
case RIG_METER_COMP:
kenwood_val = 2;
break;
case RIG_METER_ALC:
kenwood_val = 3;
break;
default:
RETURNFUNC(-RIG_EINVAL);
}
SNPRINTF(levelbuf, sizeof(levelbuf), "RM%d", kenwood_val);
break;
case RIG_LEVEL_CWPITCH:
if (val.i > 1000 || val.i < 300)
{
@ -1594,7 +1572,7 @@ const struct rig_caps ts590_caps =
RIG_MODEL(RIG_MODEL_TS590S),
.model_name = "TS-590S",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".9",
.version = BACKEND_VER ".10",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1792,7 +1770,7 @@ const struct rig_caps fx4_caps =
RIG_MODEL(RIG_MODEL_FX4),
.model_name = "FX4/C/CR/L",
.mfg_name = "BG2FX",
.version = BACKEND_VER ".8",
.version = BACKEND_VER ".9",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -1986,7 +1964,7 @@ const struct rig_caps ts590sg_caps =
RIG_MODEL(RIG_MODEL_TS590SG),
.model_name = "TS-590SG",
.mfg_name = "Kenwood",
.version = BACKEND_VER ".6",
.version = BACKEND_VER ".7",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,

Wyświetl plik

@ -8,7 +8,7 @@ DISTCLEANFILES =
bin_PROGRAMS =
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818
check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275
simelecraft_SOURCES = simelecraft.c
simkenwood_SOURCES = simkenwood.c

20
simulators/sim.h 100644
Wyświetl plik

@ -0,0 +1,20 @@
#include "../src/misc.h"
#include <errno.h>
#define WRITE(f,b,l) write_sim(f,(const unsigned char*)b,l,__func__,__LINE__)
int write_sim(int fd, const unsigned char *buf, int buflen, const char *func,
int linenum)
{
int n;
dump_hex(buf, buflen);
n = write(fd, buf, buflen);
if (n <= 0)
{
fprintf(stderr, "%s(%d) buf='%s' write error %d: %s\n", func, linenum, buf, n,
strerror(errno));
}
return n;
}

Wyświetl plik

@ -18,6 +18,7 @@ struct ip_mreq
#define BUFSIZE 256
int vfo = 0; // 0=A, !0=B
float freqA = 14074000;
float freqB = 14074500;
char tx_vfo = '0';
@ -121,7 +122,11 @@ again:
case 0x88: printf("PTT OFF\n"); break;
case 0x07: printf("MODE\n"); break;
case 0x07:
printf("MODE %0xx\n", buf[0]);
if (vfo == 0) modeA = buf[0];
else modeB = buf[0];
break;
case 0x05: printf("CLAR ON\n"); break;
@ -129,7 +134,10 @@ again:
case 0xF5: printf("FREQ\n"); break;
case 0x81: printf("VFO TOGGLE\n"); break;
case 0x81:
vfo = !vfo;
printf("VFO TOGGLE, %s active\n", vfo==0?"VFOA":"VFOB");
break;
case 0x02: printf("SPLIT ON\n"); break;

Wyświetl plik

@ -0,0 +1,603 @@
// simicom will show the pts port to use for rigctl on Unix
// using virtual serial ports on Windows is to be developed yet
// Needs a lot of improvement to work on all Icoms
// gcc -g -Wall -o simicom simicom.c -lhamlib
// On mingw in the hamlib src directory
// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32
#define _XOPEN_SOURCE 700
// since we are POSIX here we need this
#if 0
struct ip_mreq
{
int dummy;
};
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/time.h>
#include <hamlib/rig.h>
#include "../src/misc.h"
#include <termios.h>
#include <unistd.h>
#define BUFSIZE 256
#define X25
int civ_731_mode = 0;
vfo_t current_vfo = RIG_VFO_A;
int split = 0;
// we make B different from A to ensure we see a difference at startup
float freqA = 14074000;
float freqB = 14074500;
mode_t modeA = RIG_MODE_PKTUSB;
mode_t modeB = RIG_MODE_PKTUSB;
int datamodeA = 0;
int datamodeB = 0;
pbwidth_t widthA = 0;
pbwidth_t widthB = 1;
ant_t ant_curr = 0;
int ant_option = 0;
int ptt = 0;
int satmode = 0;
int agc_time = 1;
int ovf_status = 0;
int powerstat = 1;
int transceive = 0;
int keyspd = 20;
int rigtime = 1230;
void dumphex(const unsigned char *buf, int n)
{
for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); }
printf("\n");
}
int
frameGet(int fd, unsigned char *buf)
{
int i = 0, n;
memset(buf, 0, BUFSIZE);
unsigned char c;
again:
while (read(fd, &c, 1) > 0)
{
buf[i++] = c;
//printf("i=%d, c=0x%02x\n",i,c);
if (c == 0xfd)
{
char mytime[256];
date_strget(mytime, sizeof(mytime), 1);
printf("%s:", mytime); dumphex(buf, i);
// echo
n = write(fd, buf, i);
if (n != i) { printf("%s: error on write: %s\n", __func__, strerror(errno)); }
return i;
}
if (i > 2 && c == 0xfe)
{
printf("Turning power on due to 0xfe string\n");
powerstat = 1;
int j;
for (j = i; j < 175; ++j)
{
if (read(fd, &c, 1) < 0) { break; }
}
i = 0;
goto again;
}
}
printf("Error??? c=x%02x\n", c);
return 0;
}
void frameParse(int fd, unsigned char *frame, int len)
{
double freq;
int n = 0;
dumphex(frame, len);
if (frame[0] != 0xfe && frame[1] != 0xfe)
{
printf("expected fe fe, got ");
dumphex(frame, len);
return;
}
switch (frame[4])
{
case 0x03:
//from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2);
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
{
printf("get_freqA\n");
to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2);
}
else
{
printf("get_freqB\n");
to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2);
}
frame[10] = 0xfd;
if (powerstat)
{
n = write(fd, frame, 11);
}
break;
case 0x04:
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN)
{
printf("get_modeA\n");
frame[5] = modeA;
frame[6] = widthA;
}
else
{
printf("get_modeB\n");
frame[5] = modeB;
frame[6] = widthB;
}
frame[7] = 0xfd;
n = write(fd, frame, 8);
break;
case 0x05:
freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2);
printf("set_freq to %.0f\n", freq);
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; }
else { freqB = freq; }
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
case 0x06:
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; }
else { modeB = frame[6]; }
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
case 0x07:
switch (frame[5])
{
case 0x00: current_vfo = RIG_VFO_A; break;
case 0x01: current_vfo = RIG_VFO_B; break;
case 0xa0: current_vfo = freq = freqA; freqA = freqB; freqB = freq; break;
case 0xb0: current_vfo = RIG_VFO_MAIN; break;
case 0xd0: current_vfo = RIG_VFO_MAIN; break;
case 0xd1: current_vfo = RIG_VFO_SUB; break;
}
printf("set_vfo to %s\n", rig_strvfo(current_vfo));
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
case 0x0f:
if (frame[5] == 0) { split = 0; }
else if (frame[5] == 1) { split = 1; }
else { frame[6] = split; }
if (frame[5] == 0xfd)
{
printf("get split %d\n", 1);
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
printf("set split %d\n", 1);
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
}
break;
case 0x12: // we're simulating the 3-byte version -- not the 2-byte
if (frame[5] != 0xfd)
{
printf("Set ant %d\n", -1);
ant_curr = frame[5];
ant_option = frame[6];
dump_hex(frame, 8);
}
else
{
printf("Get ant\n");
}
frame[5] = ant_curr;
frame[6] = ant_option;
frame[7] = 0xfd;
printf("write 8 bytes\n");
dump_hex(frame, 8);
n = write(fd, frame, 8);
break;
case 0x14:
switch (frame[5])
{
static int power_level = 0;
case 0x07:
case 0x08:
if (frame[6] != 0xfd)
{
frame[6] = 0xfb;
dumphex(frame, 7);
n = write(fd, frame, 7);
printf("ACK x14 x08\n");
}
else
{
to_bcd(&frame[6], (long long)128, 2);
frame[8] = 0xfb;
dumphex(frame, 9);
n = write(fd, frame, 9);
printf("SEND x14 x08\n");
}
break;
case 0x0a:
printf("Using power level %d\n", power_level);
power_level += 10;
if (power_level > 250) { power_level = 0; }
to_bcd(&frame[6], (long long)power_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
break;
case 0x0c:
dumphex(frame, 10);
printf("subcmd=0x0c #1\n");
if (frame[6] != 0xfd) // then we have data
{
printf("subcmd=0x0c #1\n");
keyspd = from_bcd(&frame[6], 2);
frame[6] = 0xfb;
n = write(fd, frame, 7);
}
else
{
printf("subcmd=0x0c #1\n");
to_bcd(&frame[6], keyspd, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
}
break;
}
break;
case 0x15:
switch (frame[5])
{
static int meter_level = 0;
case 0x07:
frame[6] = ovf_status;
frame[7] = 0xfd;
n = write(fd, frame, 8);
ovf_status = ovf_status == 0 ? 1 : 0;
break;
case 0x11:
printf("Using meter level %d\n", meter_level);
meter_level += 10;
if (meter_level > 250) { meter_level = 0; }
to_bcd(&frame[6], (long long)meter_level, 2);
frame[8] = 0xfd;
n = write(fd, frame, 9);
break;
}
case 0x16:
switch (frame[5])
{
case 0x5a:
if (frame[6] == 0xfe)
{
satmode = frame[6];
}
else
{
frame[6] = satmode;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
break;
}
break;
case 0x19: // miscellaneous things
frame[5] = 0x94;
frame[6] = 0xfd;
n = write(fd, frame, 7);
break;
case 0x1a: // miscellaneous things
switch (frame[5])
{
case 0x03: // width
if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; }
else { frame[6] = widthB; }
frame[7] = 0xfd;
n = write(fd, frame, 8);
break;
case 0x04: // AGC TIME
printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]);
if (frame[6] == 0xfd) // the we are reading
{
frame[6] = agc_time;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
printf("AGC_TIME RESPONSE******************************");
agc_time = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
}
break;
case 0x05:
// FE FE 70 E0 1A 05 00 92 00 FD
printf("0x05 received\n");
if (frame[6] == 0x00 && frame[7] == 0x92)
{
if (frame[8] == 0x00)
{
printf("0x05 0x00 0x92 received\n");
transceive = frame[8];
frame[6] = 0xfb;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
frame[8] = transceive;
frame[9] = 0xfb;
frame[10] = 0xfd;
n = write(fd, frame, 11);
}
}
// FE FE 70 E0 1A 05 00 41 00 FD
else if (frame[6] == 0x00 && frame[7] == 0x41)
{
if (frame[8] != 0xfd)
{
printf("0x05 0x00 0x41 received\n");
rigtime = frame[8] * 100 + frame[9];
frame[6] = 0xfb;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
frame[8] = rigtime / 100;
frame[9] = rigtime % 100;
frame[10] = 0xfd;
n = write(fd, frame, 11);
}
}
break;
case 0x06: // Data mode
if (frame[6] == 0xfd) // then we're replying with mode
{
frame[6] = datamodeA;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
datamodeA = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
}
break;
}
break;
case 0x1c:
switch (frame[5])
{
case 0:
if (frame[6] == 0xfd)
{
frame[6] = ptt;
frame[7] = 0xfd;
n = write(fd, frame, 8);
}
else
{
ptt = frame[6];
frame[4] = 0xfb;
frame[5] = 0xfd;
n = write(fd, frame, 6);
}
break;
}
break;
case 0x25:
printf("x25 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
case 0x26:
printf("x26 send nak\n");
frame[4] = 0xfa;
frame[5] = 0xfd;
n = write(fd, frame, 6);
break;
default: printf("cmd 0x%02x unknown\n", frame[4]);
}
if (n == 0) { printf("Write failed=%s\n", strerror(errno)); }
// don't care about the rig type yet
}
#if defined(WIN32) || defined(_WIN32)
int openPort(char *comport) // doesn't matter for using pts devices
{
int fd;
fd = open(comport, O_RDWR);
if (fd < 0)
{
perror(comport);
}
return fd;
}
#else
int openPort(char *comport) // doesn't matter for using pts devices
{
int fd = posix_openpt(O_RDWR);
char *name = ptsname(fd);
if (name == NULL)
{
perror("pstname");
return -1;
}
printf("name=%s\n", name);
if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1)
{
perror("posix_openpt");
return -1;
}
return fd;
}
#endif
void rigStatus()
{
char vfoa = current_vfo == RIG_VFO_A ? '*' : ' ';
char vfob = current_vfo == RIG_VFO_B ? '*' : ' ';
printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA,
datamodeA,
widthA,
freqA);
printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB,
datamodeB,
widthB,
freqB);
}
int main(int argc, char **argv)
{
unsigned char buf[256];
int fd = openPort(argv[1]);
printf("%s: %s\n", argv[0], rig_version());
printf("x25/x26 command rejected\n");
#if defined(WIN32) || defined(_WIN32)
if (argc != 2)
{
printf("Missing comport argument\n");
printf("%s [comport]\n", argv[0]);
exit(1);
}
#endif
while (1)
{
int len = frameGet(fd, buf);
if (len <= 0)
{
close(fd);
fd = openPort(argv[1]);
}
if (powerstat)
{
frameParse(fd, buf, len);
}
else
{
hl_usleep(1000 * 1000);
}
rigStatus();
}
return 0;
}

Wyświetl plik

@ -391,6 +391,10 @@ int main(int argc, char *argv[])
continue;
}
else if (strcmp(buf, "RX;") == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
}
else if (strlen(buf) > 0)
{
fprintf(stderr, "Unknown command: %s\n", buf);

Wyświetl plik

@ -394,6 +394,10 @@ int main(int argc, char *argv[])
{
continue;
}
else if (strcmp(buf, "RX;") == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
}
else if (strncmp(buf, "TX", 2) == 0)
{
ptt = ptt_mic = ptt_data = ptt_tune = 0;
@ -456,6 +460,11 @@ int main(int argc, char *argv[])
{
sscanf(buf, "OM1%d", &modeSub);
}
else if (strcmp(buf,"RM;") == 0)
{
sprintf(buf, "RM2%04d;", 10);
write(fd, buf, strlen(buf));
}
else if (strlen(buf) > 0)
{
fprintf(stderr, "Unknown command: %s\n", buf);

Wyświetl plik

@ -514,26 +514,32 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
if (!strcmp(val, "RIG"))
{
rs->pttport.type.ptt = RIG_PTT_RIG;
rig->caps->ptt_type = RIG_PTT_RIG;
}
else if (!strcmp(val, "RIGMICDATA"))
{
rs->pttport.type.ptt = RIG_PTT_RIG_MICDATA;
rig->caps->ptt_type = RIG_PTT_RIG_MICDATA;
}
else if (!strcmp(val, "DTR"))
{
rs->pttport.type.ptt = RIG_PTT_SERIAL_DTR;
rig->caps->ptt_type = RIG_PTT_SERIAL_DTR;
}
else if (!strcmp(val, "RTS"))
{
rs->pttport.type.ptt = RIG_PTT_SERIAL_RTS;
rig->caps->ptt_type = RIG_PTT_SERIAL_RTS;
}
else if (!strcmp(val, "Parallel"))
{
rs->pttport.type.ptt = RIG_PTT_PARALLEL;
rig->caps->ptt_type = RIG_PTT_PARALLEL;
}
else if (!strcmp(val, "CM108"))
{
rs->pttport.type.ptt = RIG_PTT_CM108;
rig->caps->ptt_type = RIG_PTT_CM108;
}
else if (!strcmp(val, "GPIO"))
{
@ -542,6 +548,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val)
else if (!strcmp(val, "GPION"))
{
rs->pttport.type.ptt = RIG_PTT_GPION;
rig->caps->ptt_type = RIG_PTT_GPION;
}
else if (!strcmp(val, "None"))
{

Wyświetl plik

@ -2615,7 +2615,7 @@ void *HAMLIB_API rig_get_function_ptr(rig_model_t rig_model,
* \param RIG* and rig_caps_int_e
* \return the corresponding long value -- -RIG_EINVAL is the only error possible
*/
long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
uint64_t HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
enum rig_caps_int_e rig_caps)
{
const struct rig_caps *caps = rig_get_caps(rig_model);
@ -2651,6 +2651,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model,
return caps->port_type;
case RIG_CAPS_HAS_GET_LEVEL:
rig_debug(RIG_DEBUG_TRACE, "%s(%d): return %08"PRIll"\n", __func__, __LINE__, caps->has_get_level);
return caps->has_get_level;
default:

Wyświetl plik

@ -984,6 +984,111 @@ void *multicast_publisher(void *arg)
return NULL;
}
#ifdef __MINGW32__
#include <winsock2.h>
#include <iphlpapi.h>
int is_wireless()
{
DWORD dwSize = 0;
DWORD dwRetVal = 0;
ULONG flags = GAA_FLAG_INCLUDE_PREFIX;
PIP_ADAPTER_ADDRESSES pAddresses = NULL, pCurrAddresses = NULL;
// First call to determine actual memory size needed
GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &dwSize);
pAddresses = (IP_ADAPTER_ADDRESSES *)malloc(dwSize);
// Second call to get the actual data
dwRetVal = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &dwSize);
if (dwRetVal == NO_ERROR)
{
for (pCurrAddresses = pAddresses; pCurrAddresses != NULL;
pCurrAddresses = pCurrAddresses->Next)
{
// printf("Adapter name: %s\n", pCurrAddresses->AdapterName);
// printf("Adapter description: %ls\n", pCurrAddresses->Description);
// printf("Adapter type: ");
if (pCurrAddresses->IfType == IF_TYPE_IEEE80211)
{
// printf("Wireless\n\n");
return 1;
}
else
{
// printf("Not Wireless\n\n");
}
}
}
else
{
//printf("GetAdaptersAddresses failed with error: %lu\n", dwRetVal);
}
if (pAddresses)
{
free(pAddresses);
}
return 0;
}
#else
#ifndef __APPLE__
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
#include <linux/wireless.h>
#include <ifaddrs.h>
int is_wireless_linux(const char *ifname)
{
int sock = socket(AF_INET, SOCK_DGRAM, 0);
struct iwreq pwrq;
memset(&pwrq, 0, sizeof(pwrq));
strncpy(pwrq.ifr_name, ifname, IFNAMSIZ);
if (ioctl(sock, SIOCGIWNAME, &pwrq) != -1)
{
close(sock);
return 1; // Wireless
}
close(sock);
return 0; // Not wireless
}
int is_wireless()
{
struct ifaddrs *ifaddr, *ifa;
if (getifaddrs(&ifaddr) == -1)
{
perror("getifaddrs");
return 0;
}
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL)
{
continue;
}
int iswireless = is_wireless_linux(ifa->ifa_name);
//printf("%s is %s\n", ifa->ifa_name, iswireless ? "wireless" : "not wireless");
if (iswireless) {freeifaddrs(ifaddr); return 1;}
}
freeifaddrs(ifaddr);
return 0;
}
#endif
#endif
void *multicast_receiver(void *arg)
{
char data[4096];
@ -1025,7 +1130,15 @@ void *multicast_receiver(void *arg)
dest_addr.sin_family = AF_INET;
#ifdef __MINGW32__
// Windows cannot bind to multicast group addresses for some unknown reason
dest_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (is_wireless())
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: no wireless detect so INADDR_ANY is being used\n", __func__);
}
else
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: wireless detected so localhost is being used\n", __func__);
dest_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
}
#else
dest_addr.sin_addr.s_addr = inet_addr(args->multicast_addr);
#endif

42
tests/callback.c 100644
Wyświetl plik

@ -0,0 +1,42 @@
int callback(const struct rig_caps *caps, rig_ptr_t rigp)
{
RIG *rig = (RIG *) rigp;
rig = rig_init(caps->rig_model);
if (!rig)
{
fprintf(stderr, "Unknown rig num: %u\n", caps->rig_model);
fprintf(stderr, "Please check riglist.h\n");
exit(1); /* whoops! something went wrong (mem alloc?) */
}
const char *port = "/dev/pts/3";
strcpy(rig->state.rigport.pathname, port);
printf("%20s:", caps->model_name);
fflush(stdout);
struct timeval start, end;
gettimeofday(&start, NULL);
rig_open(rig);
gettimeofday(&end, NULL);
double dstart = start.tv_sec + start.tv_usec / 1e6;
double dend = end.tv_sec + end.tv_usec / (double)1e6;
printf(" %.1f\n", dend - dstart);
rig_close(rig); /* close port */
rig_cleanup(rig); /* if you care about memory */
return 1;
}
int main(int argc, char *argv[])
{
RIG rig;
printf("testing rig timeouts when rig powered off\n");
/* Turn off backend debugging output */
rig_set_debug_level(RIG_DEBUG_NONE);
rig_load_all_backends();
rig_list_foreach(callback, &rig);
return 0;
}

Wyświetl plik

@ -720,9 +720,18 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
{
if ((retcode = scanfc(fin, "%c", &cmd)) < 1)
{
if (last_cmd==0)
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d, last_cmd=[empty]\n",
__func__,
retcode);
}
else
{
rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d, last_cmd=%c\n",
__func__,
retcode, last_cmd);
}
return (RIGCTL_PARSE_ERROR);
}
@ -3353,7 +3362,7 @@ declare_proto_rig(get_level)
fprintf(fout, "%s%c", s, resp_sep);
}
//fputc('\n', fout);
fputc('\n', fout);
RETURNFUNC2(RIG_OK);
}
level = rig_parse_level(arg1);

Wyświetl plik

@ -867,6 +867,26 @@ int main(int argc, char *argv[])
freeaddrinfo(saved_result); /* No longer needed */
exit(2);
}
int optval = 1;
#ifdef __MINGW32__
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, (PCHAR)&optval, sizeof(optval)) < 0)
#else
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
#endif
{
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP address reuse: %s\n", __func__,
strerror(errno));
}
// Windows does not have SO_REUSEPORT. However, SO_REUSEADDR works in a similar way.
#if defined(SO_REUSEPORT)
if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP port reuse: %s\n", __func__,
strerror(errno));
}
#endif
#if 0
if (setsockopt(sock_listen,

Wyświetl plik

@ -11,7 +11,7 @@
#include <hamlib/config.h>
#define SERIAL_PORT "/dev/ttyUSB0"
#define SERIAL_PORT "/dev/pts/2"
int main(int argc, const char *argv[])
@ -38,9 +38,9 @@ int main(int argc, const char *argv[])
* allocate memory, setup & open port
*/
hamlib_port_t myport;
if (argc < 2)
{
hamlib_port_t myport;
/* may be overridden by backend probe */
myport.type.rig = RIG_PORT_SERIAL;
myport.parm.serial.rate = 9600;
@ -48,7 +48,6 @@ int main(int argc, const char *argv[])
myport.parm.serial.stop_bits = 1;
myport.parm.serial.parity = RIG_PARITY_NONE;
myport.parm.serial.handshake = RIG_HANDSHAKE_NONE;
strncpy(myport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1);
rig_load_all_backends();
myrig_model = rig_probe(&myport);
@ -59,6 +58,7 @@ int main(int argc, const char *argv[])
}
my_rig = rig_init(myrig_model);
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), SERIAL_PORT);
if (!my_rig)
{
@ -77,6 +77,9 @@ int main(int argc, const char *argv[])
exit(2);
}
uint64_t levels = rig_get_caps_int(my_rig->caps->rig_model, RIG_CAPS_HAS_GET_LEVEL);
printf("HAS_GET_LEVEL=0x%8lx, SWR=%8llx,true=%d\n", levels, levels & RIG_LEVEL_SWR, (levels & RIG_LEVEL_SWR) == RIG_LEVEL_SWR);
char val[256];
retcode = rig_get_conf2(my_rig, rig_token_lookup(my_rig, "write_delay"), val,
sizeof(val));