Astyle simts890.c

Man, this is ugly!
pull/1628/head
George Baltz N3GB 2024-11-06 10:19:40 -05:00
rodzic dd9696cf2d
commit 10292fd338
1 zmienionych plików z 54 dodań i 34 usunięć

Wyświetl plik

@ -70,7 +70,8 @@ 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 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 int fine = 0; // Fine tuning - step size off=10hz, on=1hz
// Clock data // Clock data
int autoset = 1; int autoset = 1;
@ -269,26 +270,26 @@ int main(int argc, char *argv[])
* 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 ??
"% 05d" // P3 RIT/XIT freq(Hz) "% 05d" // P3 RIT/XIT freq(Hz)
"%1d" // P4 RIT on/off "%1d" // P4 RIT on/off
"%1d" // 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
#endif #endif
char SFformat[] = "SF" // Input/Output const char SFformat[] = "SF" // Input/Output
"%1d" // P1 VFOA/VFOB "%1d" // P1 VFOA/VFOB
"%011d" // P2 Freq(Hz) "%011d" // P2 Freq(Hz)
"%1X;"; // P3 Mode "%1X;"; // P3 Mode
/* Initialization */ /* Initialization */
for (int i = 0; i < NBANDS; i++) for (int i = 0; i < NBANDS; i++)
@ -326,7 +327,8 @@ int main(int argc, char *argv[])
buf[1] = toupper(buf[1]); buf[1] = toupper(buf[1]);
if (strcmp(buf, "IF;") == 0) if (strcmp(buf, "IF;") == 0)
{ // Reads the tranceiver status {
// Reads the tranceiver status
#if defined(LEGACY) #if defined(LEGACY)
char ifbuf[256]; char ifbuf[256];
hl_usleep(mysleep * 1000); hl_usleep(mysleep * 1000);
@ -958,7 +960,8 @@ int main(int argc, char *argv[])
} }
} }
else if (strncmp(buf, "MD", 2) == 0) else if (strncmp(buf, "MD", 2) == 0)
{ // Sets and reads the operating mode status {
// Sets and reads the operating mode status
#if defined(LEGACY) #if defined(LEGACY)
if (buf[2] == ';') if (buf[2] == ';')
{ {
@ -969,6 +972,7 @@ int main(int argc, char *argv[])
{ {
sscanf(buf, "MD%1X", &(*vfoLR[0])->mode); sscanf(buf, "MD%1X", &(*vfoLR[0])->mode);
} }
#else #else
cmd_err = 1; cmd_err = 1;
#endif #endif
@ -1128,7 +1132,8 @@ int main(int argc, char *argv[])
sscanf(buf, "RL1%d", &rl); sscanf(buf, "RL1%d", &rl);
} }
else if (strncmp(buf, "FS", 2) == 0) else if (strncmp(buf, "FS", 2) == 0)
{ // FINE Function {
// FINE Function
if (buf[2] == ';') if (buf[2] == ';')
{ {
snprintf(buf, sizeof buf, "FS%d%d;", fine, fine); // For now snprintf(buf, sizeof buf, "FS%d%d;", fine, fine); // For now
@ -1137,19 +1142,22 @@ int main(int argc, char *argv[])
else else
{ {
if (buf[2] == '0' || buf[2] == '1') if (buf[2] == '0' || buf[2] == '1')
{ fine = buf[2] - '0'; } { fine = buf[2] - '0'; }
else else
{ cmd_err = 1; } { cmd_err = 1; }
} }
} }
else if (strcmp(buf, "RC;") == 0) else if (strcmp(buf, "RC;") == 0)
{ // RIT/XIT Frequency Clear {
// RIT/XIT Frequency Clear
rxit = 0; rxit = 0;
} }
else if (buf[0] == 'R' && (buf[1] =='D' || buf[1] == 'U')) // RD/RU else if (buf[0] == 'R' && (buf[1] == 'D' || buf[1] == 'U')) // RD/RU
{ // RIT/XIT Frequency Up/Down {
// RIT/XIT Frequency Up/Down
int dir = buf[1] == 'D' ? -1 : +1; int dir = buf[1] == 'D' ? -1 : +1;
int tempit; int tempit;
if (buf[2] == ';') if (buf[2] == ';')
{ {
tempit = rxit + (dir * (fine ? 1 : 10)); tempit = rxit + (dir * (fine ? 1 : 10));
@ -1158,43 +1166,55 @@ int main(int argc, char *argv[])
{ {
tempit = rxit + dir * atoi(buf + 2); tempit = rxit + dir * atoi(buf + 2);
} }
if (abs(tempit) > 9999) {cmd_err = 1; continue;} if (abs(tempit) > 9999) {cmd_err = 1; continue;}
/* Some weird rounding going on here - TBD */ /* Some weird rounding going on here - TBD */
rxit = tempit; rxit = tempit;
} }
else if (strcmp(buf, "RF;") == 0) else if (strcmp(buf, "RF;") == 0)
{ // RIT/XIT Frequency {
// RIT/XIT Frequency
snprintf(buf, sizeof buf, "RF%1d%04d;", rxit < 0 ? 1 : 0, abs(rxit)); snprintf(buf, sizeof buf, "RF%1d%04d;", rxit < 0 ? 1 : 0, abs(rxit));
OUTPUT(buf); OUTPUT(buf);
} }
else if (strncmp(buf, "RT", 2) == 0) else if (strncmp(buf, "RT", 2) == 0)
{ // RIT Function State, RIT Shift {
switch(buf[2]) { // RIT Function State, RIT Shift
switch (buf[2])
{
case ';': // Read case ';': // Read
snprintf(buf, sizeof buf, "RT%d;", rit); snprintf(buf, sizeof buf, "RT%d;", rit);
OUTPUT(buf); OUTPUT(buf);
break; break;
case '0': // Set case '0': // Set
case '1': case '1':
rit = buf[2] - '0'; rit = buf[2] - '0';
break; break;
case '2': // Shift case '2': // Shift
//TODO: set recv freq to vfo+rxit, clear rxit and rit //TODO: set recv freq to vfo+rxit, clear rxit and rit
break; break;
default: default:
cmd_err = 1; cmd_err = 1;
} }
} }
else if (strncmp(buf, "XT", 2) == 0) else if (strncmp(buf, "XT", 2) == 0)
{ // XIT Function State, XIT Shift {
switch(buf[2]) { // XIT Function State, XIT Shift
switch (buf[2])
{
case '0': // Set case '0': // Set
case '1': case '1':
xit = buf[2] - '0'; xit = buf[2] - '0';
break; break;
case '2': // Shift case '2': // Shift
//TODO: set xmit freq to vfo+rxit(Which vfo?), set split, clear rxit and xit //TODO: set xmit freq to vfo+rxit(Which vfo?), set split, clear rxit and xit
break; break;
default: default:
cmd_err = 1; cmd_err = 1;
} }