kopia lustrzana https://github.com/Hamlib/Hamlib
commit
0bd214f2c4
|
@ -1,3 +1,4 @@
|
||||||
|
//#define TRACE /* Full traffic trace if enabled */
|
||||||
// can run this using rigctl/rigctld and socat pty devices
|
// can run this using rigctl/rigctld and socat pty devices
|
||||||
// gcc -o simts890 -l hamlib simts890.c
|
// gcc -o simts890 -l hamlib simts890.c
|
||||||
#define _XOPEN_SOURCE 700
|
#define _XOPEN_SOURCE 700
|
||||||
|
@ -20,7 +21,16 @@ struct ip_mreq
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
//#include <hamlib/rig.h>
|
//#include <hamlib/rig.h>
|
||||||
|
|
||||||
|
/* Definitions */
|
||||||
|
/* The TS-890S has some undocumented commands, left over from older
|
||||||
|
* Kenwood models. They have newer counterparts with more functionality,
|
||||||
|
* but are still around for legacy software. If you want to see if your
|
||||||
|
* app is only using the latest-and-greatest, comment out the next define.
|
||||||
|
*/
|
||||||
|
#define LEGACY
|
||||||
|
// Size of command buffer
|
||||||
#define BUFSIZE 256
|
#define BUFSIZE 256
|
||||||
|
// Number of selectable bands
|
||||||
#define NBANDS 11
|
#define NBANDS 11
|
||||||
/* Type we're emulating - K=The Americas(default), E=Europe */
|
/* Type we're emulating - K=The Americas(default), E=Europe */
|
||||||
#if !defined(TYPE)
|
#if !defined(TYPE)
|
||||||
|
@ -29,8 +39,13 @@ struct ip_mreq
|
||||||
/* Define a macro for sending response back to the app
|
/* Define a macro for sending response back to the app
|
||||||
* This will allow us to reroute output to a buffering routine
|
* This will allow us to reroute output to a buffering routine
|
||||||
* Needed to handle multiple commands in a single message
|
* Needed to handle multiple commands in a single message
|
||||||
|
* Also makes it easy to trace
|
||||||
*/
|
*/
|
||||||
|
#if defined(TRACE)
|
||||||
|
#define OUTPUT(s) {printf("Resp:\"%s\"\n", s); write(fd, s, strlen(s)); }
|
||||||
|
#else
|
||||||
#define OUTPUT(s) write(fd, s, strlen(s))
|
#define OUTPUT(s) write(fd, s, strlen(s))
|
||||||
|
#endif
|
||||||
|
|
||||||
int mysleep = 20;
|
int mysleep = 20;
|
||||||
|
|
||||||
|
@ -55,6 +70,9 @@ int rl = 0;
|
||||||
int is = 0;
|
int is = 0;
|
||||||
int sp = 0; // Split OFF/ON
|
int sp = 0; // Split OFF/ON
|
||||||
int split_op = 0; // Split frequency setting operation in progress
|
int split_op = 0; // Split frequency setting operation in progress
|
||||||
|
int rit = 0, xit = 0, rxit =
|
||||||
|
0; // RIT off/on, XIT off/on, Offset freq(-9999<=rxit<=+9999)
|
||||||
|
int fine = 0; // Fine tuning - step size off=10hz, on=1hz
|
||||||
// Clock data
|
// Clock data
|
||||||
int autoset = 1;
|
int autoset = 1;
|
||||||
int tzs[2] = {36, 56}; // 0=primary(EST), 1=auxiliary(UTC)
|
int tzs[2] = {36, 56}; // 0=primary(EST), 1=auxiliary(UTC)
|
||||||
|
@ -246,30 +264,32 @@ int main(int argc, char *argv[])
|
||||||
kvfop_t *const vfoAB[2] = {&vfoA, &vfoB}; // 0=A, 1=B, fixed
|
kvfop_t *const vfoAB[2] = {&vfoA, &vfoB}; // 0=A, 1=B, fixed
|
||||||
kvfop_t *vfoLR[2] = {&vfoA, &vfoB}; // 0=Left, 1=Right, can change
|
kvfop_t *vfoLR[2] = {&vfoA, &vfoB}; // 0=Left, 1=Right, can change
|
||||||
|
|
||||||
|
#if defined(LEGACY)
|
||||||
/* The IF command is not documented for the TS-890S, and is supposed
|
/* The IF command is not documented for the TS-890S, and is supposed
|
||||||
* to be supplanted by SF. However, it is still there for legacy S/W.
|
* to be supplanted by SF. However, it is still there for legacy S/W.
|
||||||
* This description is taken from the TS-590S/SG manual, with values
|
* This description is taken from the TS-590S/SG manual, with values
|
||||||
* reflecting a real TS-890S.
|
* reflecting a real TS-890S.
|
||||||
*/
|
*/
|
||||||
char IFformat[] = "IF" // Output only
|
const char IFformat[] = "IF" // Output only
|
||||||
"%011d" // P1 freq(Hz)
|
"%011d" // P1 freq(Hz)
|
||||||
" " // P2 ??
|
" " // P2 ??
|
||||||
" 0000" // P3 RIT/XIT freq(Hz)
|
"% 05d" // P3 RIT/XIT freq(Hz)
|
||||||
"0" // P4 RIT on/off
|
"%1d" // P4 RIT on/off
|
||||||
"0" // P5 XIT on/off
|
"%1d" // P5 XIT on/off
|
||||||
"000" // P6,P7 mem channel
|
"000" // P6,P7 mem channel
|
||||||
"%1d" // P8 RX/TX
|
"%1d" // P8 RX/TX
|
||||||
"%1X" // P9 Operating mode (See OM command)
|
"%1X" // P9 Operating mode (See OM command)
|
||||||
"0" // P10 Function?
|
"0" // P10 Function?
|
||||||
"0" // P11 Scan status?
|
"0" // P11 Scan status?
|
||||||
"%1d" // P12 Simplex=0/Split=1
|
"%1d" // P12 Simplex=0/Split=1
|
||||||
"0" // P13 Tone/CTCSS (not on TS-890S)
|
"0" // P13 Tone/CTCSS (not on TS-890S)
|
||||||
"00" // P14 Tone/CTCSS freq (not on TS-890S)
|
"00" // P14 Tone/CTCSS freq (not on TS-890S)
|
||||||
"0;"; // P15 Always zero
|
"0;"; // P15 Always zero
|
||||||
char SFformat[] = "SF" // Input/Output
|
#endif
|
||||||
"%1d" // P1 VFOA/VFOB
|
const char SFformat[] = "SF" // Input/Output
|
||||||
"%011d" // P2 Freq(Hz)
|
"%1d" // P1 VFOA/VFOB
|
||||||
"%1X;"; // P3 Mode
|
"%011d" // P2 Freq(Hz)
|
||||||
|
"%1X;"; // P3 Mode
|
||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
for (int i = 0; i < NBANDS; i++)
|
for (int i = 0; i < NBANDS; i++)
|
||||||
|
@ -296,7 +316,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (getmyline(fd, buf) > 0)
|
if (getmyline(fd, buf) > 0)
|
||||||
{
|
{
|
||||||
// printf("Cmd:\"%s\"\n", buf);
|
#if defined(TRACE)
|
||||||
|
printf("Cmd:\"%s\"\n", buf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// else { return 0; }
|
// else { return 0; }
|
||||||
|
@ -306,11 +328,17 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (strcmp(buf, "IF;") == 0)
|
if (strcmp(buf, "IF;") == 0)
|
||||||
{
|
{
|
||||||
|
// Reads the tranceiver status
|
||||||
|
#if defined(LEGACY)
|
||||||
char ifbuf[256];
|
char ifbuf[256];
|
||||||
hl_usleep(mysleep * 1000);
|
hl_usleep(mysleep * 1000);
|
||||||
sprintf(ifbuf, IFformat, (*vfoLR[0])->freq,
|
sprintf(ifbuf, IFformat, (*vfoLR[0])->freq, rxit, rit, xit,
|
||||||
(ptt + ptt_mic + ptt_data + ptt_tune) > 0 ? 1 : 0, (*vfoLR[0])->mode, sp);
|
(ptt + ptt_mic + ptt_data + ptt_tune) > 0 ? 1 : 0,
|
||||||
|
(*vfoLR[0])->mode, sp);
|
||||||
OUTPUT(ifbuf);
|
OUTPUT(ifbuf);
|
||||||
|
#else
|
||||||
|
cmd_err = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (strncmp(buf, "AN", 2) == 0)
|
else if (strncmp(buf, "AN", 2) == 0)
|
||||||
{
|
{
|
||||||
|
@ -931,6 +959,24 @@ int main(int argc, char *argv[])
|
||||||
sscanf(&buf[3], "%1X", &(*vfoLR[idx])->mode);
|
sscanf(&buf[3], "%1X", &(*vfoLR[idx])->mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strncmp(buf, "MD", 2) == 0)
|
||||||
|
{
|
||||||
|
// Sets and reads the operating mode status
|
||||||
|
#if defined(LEGACY)
|
||||||
|
if (buf[2] == ';')
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "MD%X;", (*vfoLR[0])->mode);
|
||||||
|
OUTPUT(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sscanf(buf, "MD%1X", &(*vfoLR[0])->mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
cmd_err = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else if (strncmp(buf, "RM", 2) == 0)
|
else if (strncmp(buf, "RM", 2) == 0)
|
||||||
{
|
{
|
||||||
// Meter
|
// Meter
|
||||||
|
@ -1085,6 +1131,94 @@ int main(int argc, char *argv[])
|
||||||
puts(buf);
|
puts(buf);
|
||||||
sscanf(buf, "RL1%d", &rl);
|
sscanf(buf, "RL1%d", &rl);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(buf, "FS", 2) == 0)
|
||||||
|
{
|
||||||
|
// FINE Function
|
||||||
|
if (buf[2] == ';')
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof buf, "FS%d%d;", fine, fine); // For now
|
||||||
|
OUTPUT(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (buf[2] == '0' || buf[2] == '1')
|
||||||
|
{ fine = buf[2] - '0'; }
|
||||||
|
else
|
||||||
|
{ cmd_err = 1; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "RC;") == 0)
|
||||||
|
{
|
||||||
|
// RIT/XIT Frequency Clear
|
||||||
|
rxit = 0;
|
||||||
|
}
|
||||||
|
else if (buf[0] == 'R' && (buf[1] == 'D' || buf[1] == 'U')) // RD/RU
|
||||||
|
{
|
||||||
|
// RIT/XIT Frequency Up/Down
|
||||||
|
int dir = buf[1] == 'D' ? -1 : +1;
|
||||||
|
int tempit;
|
||||||
|
|
||||||
|
if (buf[2] == ';')
|
||||||
|
{
|
||||||
|
tempit = rxit + (dir * (fine ? 1 : 10));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempit = rxit + dir * atoi(buf + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abs(tempit) > 9999) {cmd_err = 1; continue;}
|
||||||
|
|
||||||
|
/* Some weird rounding going on here - TBD */
|
||||||
|
rxit = tempit;
|
||||||
|
}
|
||||||
|
else if (strcmp(buf, "RF;") == 0)
|
||||||
|
{
|
||||||
|
// RIT/XIT Frequency
|
||||||
|
snprintf(buf, sizeof buf, "RF%1d%04d;", rxit < 0 ? 1 : 0, abs(rxit));
|
||||||
|
OUTPUT(buf);
|
||||||
|
}
|
||||||
|
else if (strncmp(buf, "RT", 2) == 0)
|
||||||
|
{
|
||||||
|
// RIT Function State, RIT Shift
|
||||||
|
switch (buf[2])
|
||||||
|
{
|
||||||
|
case ';': // Read
|
||||||
|
snprintf(buf, sizeof buf, "RT%d;", rit);
|
||||||
|
OUTPUT(buf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '0': // Set
|
||||||
|
case '1':
|
||||||
|
rit = buf[2] - '0';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2': // Shift
|
||||||
|
//TODO: set recv freq to vfo+rxit, clear rxit and rit
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cmd_err = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strncmp(buf, "XT", 2) == 0)
|
||||||
|
{
|
||||||
|
// XIT Function State, XIT Shift
|
||||||
|
switch (buf[2])
|
||||||
|
{
|
||||||
|
case '0': // Set
|
||||||
|
case '1':
|
||||||
|
xit = buf[2] - '0';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '2': // Shift
|
||||||
|
//TODO: set xmit freq to vfo+rxit(Which vfo?), set split, clear rxit and xit
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cmd_err = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strncmp(buf, "CK", 2) == 0)
|
else if (strncmp(buf, "CK", 2) == 0)
|
||||||
{
|
{
|
||||||
// All the clock functions
|
// All the clock functions
|
||||||
|
|
Ładowanie…
Reference in New Issue