]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
updated rigctl
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Mon, 25 May 2020 07:23:25 +0000 (08:23 +0100)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Mon, 25 May 2020 07:23:25 +0000 (08:23 +0100)
rigctl.c
rigctl_menu.c
soapy_discovery.c
transmitter.c
transmitter.h
tx_menu.c

index 2a6f0879a2a0063ba132fc328a4ceab92f7c17c1..26692ff9ff066eed17d261a7dfbbf8feb8bf70c2 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -194,94 +194,6 @@ void close_rigctl_ports() {
   }
 }
 
-//
-// Used to convert transmitter->ctcss_frequency into 1-39 value for TS2000.
-// This COULD be done with a simple table lookup - but I've already written the code
-// so at this point...
-//
-int convert_ctcss() {
-        int local_tone = 1; 
-        if(transmitter->ctcss_frequency == (double) 67.0) {
-           local_tone = 1; 
-        } else if (transmitter->ctcss_frequency == (double) 71.9) {
-           local_tone = 2; 
-        } else if (transmitter->ctcss_frequency == (double) 74.4) {
-           local_tone = 3; 
-        } else if (transmitter->ctcss_frequency == (double) 77.0) {
-           local_tone = 4; 
-        } else if (transmitter->ctcss_frequency == (double) 79.7) {
-           local_tone = 5; 
-        } else if (transmitter->ctcss_frequency == (double) 82.5) {
-           local_tone = 6; 
-        } else if (transmitter->ctcss_frequency == (double) 85.4) {
-           local_tone = 7; 
-        } else if (transmitter->ctcss_frequency == (double) 88.5) {
-           local_tone = 8; 
-        } else if (transmitter->ctcss_frequency == (double) 91.5) {
-           local_tone = 9; 
-        } else if (transmitter->ctcss_frequency == (double) 94.8) {
-           local_tone = 10; 
-        } else if (transmitter->ctcss_frequency == (double) 97.4) {
-           local_tone = 11; 
-        } else if (transmitter->ctcss_frequency == (double) 100.0) {
-           local_tone = 12; 
-        } else if (transmitter->ctcss_frequency == (double) 103.5) {
-           local_tone = 13; 
-        } else if (transmitter->ctcss_frequency == (double) 107.2) {
-           local_tone = 14; 
-        } else if (transmitter->ctcss_frequency == (double) 110.9) {
-           local_tone = 15; 
-        } else if (transmitter->ctcss_frequency == (double) 114.8) {
-           local_tone = 16; 
-        } else if (transmitter->ctcss_frequency == (double) 118.8) {
-           local_tone = 17; 
-        } else if (transmitter->ctcss_frequency == (double) 123.0) {
-           local_tone = 18; 
-        } else if (transmitter->ctcss_frequency == (double) 127.3) {
-           local_tone = 19; 
-        } else if (transmitter->ctcss_frequency == (double) 131.8) {
-           local_tone = 20; 
-        } else if (transmitter->ctcss_frequency == (double) 136.5) {
-           local_tone = 21; 
-        } else if (transmitter->ctcss_frequency == (double) 141.3) {
-           local_tone = 22; 
-        } else if (transmitter->ctcss_frequency == (double) 146.2) {
-           local_tone = 23; 
-        } else if (transmitter->ctcss_frequency == (double) 151.4) {
-           local_tone = 24; 
-        } else if (transmitter->ctcss_frequency == (double) 156.7) {
-           local_tone = 25; 
-        } else if (transmitter->ctcss_frequency == (double) 162.2) {
-           local_tone = 26; 
-        } else if (transmitter->ctcss_frequency == (double) 167.9) {
-           local_tone = 27; 
-        } else if (transmitter->ctcss_frequency == (double) 173.8) {
-           local_tone = 28; 
-        } else if (transmitter->ctcss_frequency == (double) 179.9) {
-           local_tone = 29; 
-        } else if (transmitter->ctcss_frequency == (double) 186.2) {
-           local_tone = 30; 
-        } else if (transmitter->ctcss_frequency == (double) 192.8) {
-           local_tone = 31; 
-        } else if (transmitter->ctcss_frequency == (double) 203.5) {
-           local_tone = 32; 
-        } else if (transmitter->ctcss_frequency == (double) 210.7) {
-           local_tone = 33; 
-        } else if (transmitter->ctcss_frequency == (double) 218.1) {
-           local_tone = 34; 
-        } else if (transmitter->ctcss_frequency == (double) 225.7) {
-           local_tone = 35; 
-        } else if (transmitter->ctcss_frequency == (double) 233.6) {
-           local_tone = 36; 
-        } else if (transmitter->ctcss_frequency == (double) 241.8) {
-           local_tone = 37; 
-        } else if (transmitter->ctcss_frequency == (double) 250.3) {
-           local_tone = 38; 
-        } else if (transmitter->ctcss_frequency == (double) 1750.0) {
-           local_tone = 39; 
-        }
-        return(local_tone);
-}
 int vfo_sm=0;   // VFO State Machine - this keeps track of
 
 // 
@@ -2616,21 +2528,45 @@ int parse_cmd(void *data) {
   char reply[80];
   reply[0]='\0';
   gboolean implemented=TRUE;
+  gboolean errord=FALSE;
 
   switch(command[0]) {
     case 'A':
       switch(command[1]) {
+        case 'C': //AC
+          // set/read internal atu status
+          implemented=FALSE;
+          break;
         case 'G': //AG
           // set/read AF Gain
-          if(command[3]==';') {
-            // send reply back
-            sprintf(reply,"AG0%03d;",(int)(receiver[0]->volume*100.0));
+          if(command[2]==';') {
+            // send reply back (covert from 0..1 to 0..255)
+            sprintf(reply,"AG0%03d;",(int)(receiver[0]->volume*255.0));
             send_resp(client->fd,reply) ;
           } else if(command[6]==';') {
             int gain=atoi(&command[3]);
-            receiver[0]->volume=(double)gain/100.0;
+            receiver[0]->volume=(double)gain/255.0;
             update_af_gain();
           }
+        case 'I': //AI
+          // set/read Auto Information
+          implemented=FALSE;
+          break;
+        case 'L': // AL
+          // set/read Auto Notch level
+          implemented=FALSE;
+          break;
+        case 'M': // AM
+          // set/read Auto Mode
+          implemented=FALSE;
+          break;
+        case 'N': // AN
+          // set/read Antenna Connection
+          implemented=FALSE;
+          break;
+        case 'S': // AS
+          // set/read Auto Mode Function Parameters
+          implemented=FALSE;
           break;
         default:
           implemented=FALSE;
@@ -2639,14 +2575,26 @@ int parse_cmd(void *data) {
       break;
     case 'B':
       switch(command[1]) {
+        case 'C': //BC
+          // set/read Beat Canceller
+          implemented=FALSE;
+          break;
         case 'D': //BD
           //band down 1 band
           band_minus(receiver[0]->id);
           break;
+        case 'P': //BP
+          // set/read Manual Beat Canceller frequency
+          implemented=FALSE;
+          break;
         case 'U': //BU
           //band up 1 band
           band_plus(receiver[0]->id);
           break;
+        case 'Y': //BY
+          // read busy signal
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2654,6 +2602,42 @@ int parse_cmd(void *data) {
       break;
     case 'C':
       switch(command[1]) {
+        case 'A': //CA
+          // set/read CW Auto Tune
+          implemented=FALSE;
+          break;
+        case 'G': //CG
+          // set/read Carrier Gain
+          implemented=FALSE;
+          break;
+        case 'I': //CI
+          // sets the current frequency to the CALL Channel
+          implemented=FALSE;
+          break;
+        case 'M': //CM
+          // sets/reads the Packet Cluster Tune function
+          implemented=FALSE;
+          break;
+        case 'N': //CN
+          // sets/reads CTCSS function
+          if(command[3]==';') {
+            sprintf(reply,"CN%02d;",transmitter->ctcss+1);
+            send_resp(client->fd,reply) ;
+          } else if(command[4]==';') {
+            int i=atoi(&command[2])-1;
+            transmitter_set_ctcss(transmitter,transmitter->ctcss_enabled,i);
+          }
+          break;
+        case 'T': //CT
+          // sets/reads CTCSS status
+          if(command[3]==';') {
+            sprintf(reply,"CT%d;",transmitter->ctcss_enabled);
+            send_resp(client->fd,reply) ;
+          } else if(command[3]==';') {
+            int state=atoi(&command[2]);
+            transmitter_set_ctcss(transmitter,state,transmitter->ctcss);
+          }
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2661,10 +2645,18 @@ int parse_cmd(void *data) {
       break;
     case 'D':
       switch(command[1]) {
+        case 'C': //DC
+          // set/read TX band status
+          implemented=FALSE;
+          break;
         case 'N': //DN
           // move VFO A down 1 step size
           vfo_id_step(VFO_A,-1);
           break;
+        case 'Q': //DQ
+          // set/read DCS function status
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2672,6 +2664,10 @@ int parse_cmd(void *data) {
       break;
     case 'E':
       switch(command[1]) {
+        case 'X': //EX
+          // set/read the extension menu
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2709,15 +2705,42 @@ int parse_cmd(void *data) {
             vfo_update();
           }
           break;
+        case 'C': //FC
+          // set/read the sub receiver VFO frequency menu
+          implemented=FALSE;
+          break;
+        case 'D': //FD
+          // set/read the filter display dot pattern
+          implemented=FALSE;
+          break;
         case 'R': //FR
           // set/read transceiver receive VFO
           if(command[2]==';') {
-            sprintf(reply,"FR0;");
+            sprintf(reply,"FR%d;",active_receiver->id);
             send_resp(client->fd,reply) ;
           } else if(command[3]==';') {
-            // ignore set command
+            int id=atoi(&command[2]);
+            switch(id) {
+              case 0:
+                active_receiver=receiver[id];
+                break;
+              case 1:
+                if(receivers==2) {
+                  active_receiver=receiver[id];
+                } else {
+                  implemented=FALSE;
+                }
+                break;
+              default:
+                implemented=FALSE;
+                break;
+            }
           }
           break;
+        case 'S': //FS
+          // set/read the fine tune function status
+          implemented=FALSE;
+          break;
         case 'T': //FT
           // set/read transceiver transmit VFO
           if(command[2]==';') {
@@ -2731,7 +2754,73 @@ int parse_cmd(void *data) {
           break;
         case 'W': //FW
           // set/read filter width
-          implemented=FALSE;
+          // make sure filter is filterVar1
+          if(vfo[active_receiver->id].filter!=filterVar1) {
+            vfo_filter_changed(filterVar1);
+          }
+          FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
+          FILTER *filter=&mode_filters[filterVar1];
+          int val=0;
+          if(command[2]==';') {
+            switch(vfo[active_receiver->id].mode) {
+              case modeCWL:
+              case modeCWU:
+                val=filter->low;
+                break;
+              case modeAM:
+              case modeSAM:
+                val=filter->low>=-4000;
+                break;
+              case modeFMN:
+                val=active_receiver->deviation==5000;
+                break;
+              default:
+                implemented=FALSE;
+                break;
+            }
+            if(implemented) {
+              sprintf(reply,"FW%04d;",val);
+              send_resp(client->fd,reply) ;
+            }
+          } else if(command[6]==';') {
+            int fw=atoi(&command[2]);
+            int val=
+            filter->low=fw;
+            switch(vfo[active_receiver->id].mode) {
+              case modeCWL:
+              case modeCWU:
+                filter->low=fw;
+                filter->high=fw;
+                break;
+              case modeFMN:
+                if(fw==0) {
+                  filter->low=-4000;
+                  filter->high=4000;
+                  active_receiver->deviation=2500;
+                } else {
+                  filter->low=-8000;
+                  filter->high=8000;
+                  active_receiver->deviation=5000;
+                }
+                break;
+              case modeAM:
+              case modeSAM:
+                if(fw==0) {
+                  filter->low=-4000;
+                  filter->high=4000;
+                } else {
+                  filter->low=-8000;
+                  filter->high=8000;
+                }
+                break;
+              default:
+                implemented=FALSE;
+                break;
+            }
+            if(implemented) {
+              vfo_filter_changed(filterVar1);
+            }
+          }
           break;
         default:
           implemented=FALSE;
@@ -2743,11 +2832,11 @@ int parse_cmd(void *data) {
         case 'T': //GT
           // set/read RX1 AGC
           if(command[2]==';') {
-            sprintf(reply,"GT%03d;",receiver[0]->agc);
+            sprintf(reply,"GT%03d;",receiver[0]->agc*5);
             send_resp(client->fd,reply) ;
           } else if(command[5]==';') {
             // update RX1 AGC
-            receiver[0]->agc=atoi(&command[2]);
+            receiver[0]->agc=atoi(&command[2])/5;
             vfo_update();
           }
           break;
@@ -2767,16 +2856,25 @@ int parse_cmd(void *data) {
       switch(command[1]) {
         case 'D': //ID
           // get ID
-          strcpy(reply,"ID019;");
+          strcpy(reply,"ID019;"); // TS-2000
           send_resp(client->fd,reply);
           break;
         case 'F': //IF
-          sprintf(reply,"IF%011lld%04lld%+06lld%d%d000%d%d%d0%d0000;",
+          sprintf(reply,"IF%011lld%04lld%+06lld%d%d000%d%d%d0%d%d%02d0;",
                   vfo[VFO_A].ctun?vfo[VFO_A].ctun_frequency:vfo[VFO_A].frequency,
                   step,vfo[VFO_A].rit,vfo[VFO_A].rit_enabled,transmitter==NULL?0:transmitter->xit_enabled,
-                  mox,split,0,split?1:0);
+                  mox,split,0,split?1:0,transmitter->ctcss_enabled,transmitter->ctcss);
           send_resp(client->fd,reply);
           break;
+        case 'S': //IS
+          // set/read IF shift
+          if(command[2]==';') {
+            strcpy(reply,"IS 0000;");
+            send_resp(client->fd,reply);
+          } else {
+            implemented=FALSE;
+          }
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2791,6 +2889,36 @@ int parse_cmd(void *data) {
       break;
     case 'K':
       switch(command[1]) {
+        case 'S': //KS
+          // set/read keying speed
+          if(command[2]==';') {
+            sprintf(reply,"KS%03d;",cw_keyer_speed);
+            send_resp(client->fd,reply);
+          } else if(command[5]==';') {
+            int speed=atoi(&command[2]);
+            if(speed>=1 && speed<=60) {
+              cw_keyer_speed=speed;
+#ifdef LOCALCW
+              keyer_update();
+#endif
+              vfo_update();
+            }
+          } else {
+          }
+          break;
+        case 'Y': //KY
+          // convert the chaaracters into Morse Code
+          if(command[2]==';') {
+            sprintf(reply,"KY%d;",cw_busy);
+            send_resp(client->fd,reply);
+          } else if(command[27]==';') {
+            if(cw_busy==0) {
+              strncpy(cw_buf,&command[3],24);
+              cw_busy=1;
+            }
+          } else {
+          }
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2798,6 +2926,24 @@ int parse_cmd(void *data) {
       break;
     case 'L':
       switch(command[1]) {
+        case 'K': //LK
+          // set/read key lock
+          if(command[2]==';') {
+            sprintf(reply,"LK%d%d;",locked,locked);
+            send_resp(client->fd,reply);
+          } else if(command[27]==';') {
+            locked=command[2]=='1';
+            vfo_update();
+          }
+          break;
+        case 'M': //LM
+          // set/read keyer recording status
+          implemented=FALSE;
+          break;
+        case 'T': //LT
+          // set/read ALT fucntion status
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2805,15 +2951,113 @@ int parse_cmd(void *data) {
       break;
     case 'M':
       switch(command[1]) {
+        case 'C': //MC
+          // set/read Memory Channel
+          implemented=FALSE;
+          break;
         case 'D': //MD
           // set/read operating mode
           if(command[2]==';') {
-            sprintf(reply,"MD%d;",vfo[VFO_A].mode+1);
+            int mode=1;
+            switch(vfo[VFO_A].mode) {
+              case modeLSB:
+                mode=1;
+                break;
+              case modeUSB:
+                mode=2;
+                break;
+              case modeCWL:
+                mode=7;
+                break;
+              case modeCWU:
+                mode=3;
+                break;
+              case modeFMN:
+                mode=4;
+                break;
+              case modeAM:
+              case modeSAM:
+                mode=5;
+                break;
+              case modeDIGL:
+                mode=6;
+                break;
+              case modeDIGU:
+                mode=9;
+                break;
+              default:
+                break;
+            }
+            sprintf(reply,"MD%d;",mode);
             send_resp(client->fd,reply);
           } else if(command[3]==';') {
-            vfo_mode_changed(atoi(&command[2])-1);
+            int mode=modeUSB;
+            switch(atoi(&command[2])) {
+              case 1:
+                mode=modeLSB;
+                break;
+              case 2:
+                mode=modeUSB;
+                break;
+              case 3:
+                mode=modeCWU;
+                break;
+              case 4:
+                mode=modeFMN;
+                break;
+              case 5:
+                mode=modeAM;
+                break;
+              case 6:
+                mode=modeDIGL;
+                break;
+              case 7:
+                mode=modeCWL;
+                break;
+              case 9:
+                mode=modeDIGU;
+                break;
+              default:
+                break;
+            }
+            vfo_mode_changed(mode);
+          }
+          break;
+        case 'F': //MF
+          // set/read Menu
+          implemented=FALSE;
+          break;
+        case 'G': //MG
+          // set/read Menu Gain (-12..60 converts to 0..100)
+          if(command[2]==';') {
+            sprintf(reply,"MG%03d;",(int)(((mic_gain+12.0)/72.0)*100.0));
+            send_resp(client->fd,reply);
+          } else if(command[5]==';') {
+            double gain=(double)atoi(&command[2]);
+            gain=((gain/100.0)*72.0)-12.0;
+            set_mic_gain(gain);
           }
           break;
+        case 'L': //ML
+          // set/read Monitor Function Level
+          implemented=FALSE;
+          break;
+        case 'O': //MO
+          // set/read Monitor Function On/Off
+          implemented=FALSE;
+          break;
+        case 'R': //MR
+          // read Memory Channel
+          implemented=FALSE;
+          break;
+        case 'U': //MU
+          // set/read Memory Group
+          implemented=FALSE;
+          break;
+        case 'W': //MW
+          // Write Memory Channel
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2822,7 +3066,7 @@ int parse_cmd(void *data) {
     case 'N':
       switch(command[1]) {
         case 'B': //NB
-          // set/read NB1
+          // set/read noise blanker
           if(command[2]==';') {
             sprintf(reply,"NB%d;",active_receiver->nb);
             send_resp(client->fd,reply);
@@ -2834,6 +3078,40 @@ int parse_cmd(void *data) {
             update_noise();
           }
           break;
+        case 'L': //NL
+          // set/read noise blanker level
+          implemented=FALSE;
+          break;
+        case 'R': //NR
+          // set/read noise reduction
+          if(command[2]==';') {
+            int n=0;
+            if(active_receiver->nr) {
+              n=1;
+            } else if(active_receiver->nr2) {
+              n=2;
+            }
+            sprintf(reply,"NR%d;",n);
+            send_resp(client->fd,reply);
+          } else if(command[3]==';') {
+            int n=atoi(&command[2]);
+            switch(n) {
+              case 0: // NR OFF
+                active_receiver->nr=0;
+                active_receiver->nr2=0;
+                break;
+              case 1: // NR ON
+                active_receiver->nr=1;
+                active_receiver->nr2=0;
+                break;
+              case 2: // NR2 ON
+                active_receiver->nr=0;
+                active_receiver->nr2=1;
+                break;
+            }
+            update_noise();
+          }
+          break;
         case 'T': //NT
           // set/read ANF
           if(command[2]==';') {
@@ -2852,6 +3130,18 @@ int parse_cmd(void *data) {
       break;
     case 'O':
       switch(command[1]) {
+        case 'F': //OF
+          // set/read offset frequency
+          implemented=FALSE;
+          break;
+        case 'I': //OI
+          // set/read offset frequency
+          implemented=FALSE;
+          break;
+        case 'S': //OS
+          // set/read offset function status
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2859,6 +3149,19 @@ int parse_cmd(void *data) {
       break;
     case 'P':
       switch(command[1]) {
+        case 'A': //PA
+          // set/read preamp function status
+          if(command[2]==';') {
+            sprintf(reply,"PA%d0;",active_receiver->preamp);
+            send_resp(client->fd,reply);
+          } else if(command[4]==';') {
+            active_receiver->preamp=command[2]=='1';
+          }
+          break;
+        case 'B': //PB
+          // set/read FRU-3A playback status
+          implemented=FALSE;
+          break;
         case 'C': //PC
           // set/read PA Power
           if(command[2]==';') {
@@ -2868,6 +3171,35 @@ int parse_cmd(void *data) {
             setDrive((double)atoi(&command[2]));
           }
           break;
+        case 'I': //PI
+          // store in program memory channel
+          implemented=FALSE;
+          break;
+        case 'K': //PK
+          // read packet cluster data
+          implemented=FALSE;
+          break;
+        case 'L': //PL
+          // set/read speach processor input/output level
+          if(command[2]==';') {
+            sprintf(reply,"PL%03d000;",(int)((transmitter->compressor_level/20.0)*100.0));
+            send_resp(client->fd,reply);
+          } else if(command[8]==';') {
+            command[5]='\0';
+            double level=(double)atoi(&command[2]);
+            level=(level/100.0)*20.0;
+            transmitter_set_compressor_level(transmitter,level);
+            vfo_update();
+          }
+          break;
+        case 'M': //PM
+          // recall program memory
+          implemented=FALSE;
+          break;
+        case 'R': //PR
+          // set/read speech processor function
+          implemented=FALSE;
+          break;
         case 'S': //PS
           // set/read Power (always ON)
           if(command[2]==';') {
@@ -2884,6 +3216,18 @@ int parse_cmd(void *data) {
       break;
     case 'Q':
       switch(command[1]) {
+        case 'C': //QC
+          // set/read DCS code
+          implemented=FALSE;
+          break;
+        case 'I': //QI
+          // store in quick memory
+          implemented=FALSE;
+          break;
+        case 'R': //QR
+          // set/read quick memory channel data
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2891,6 +3235,29 @@ int parse_cmd(void *data) {
       break;
     case 'R':
       switch(command[1]) {
+        case 'A': //RA
+          // set/read Attenuator function
+          if(command[2]==';') {
+            int att=0;
+            if(have_rx_gain) {
+              att=(int)(adc_attenuation[active_receiver->adc]+12);
+              att=(int)(((double)att/60.0)*99.0);
+            } else {
+              att=(int)(adc_attenuation[active_receiver->adc]);
+              att=(int)(((double)att/31.0)*99.0);
+            }
+            sprintf(reply,"RA%02d00;",att);
+            send_resp(client->fd,reply);
+          } else if(command[4]==';') {
+            int att=atoi(&command[2]);
+            if(have_rx_gain) {
+              att=(int)((((double)att/99.0)*60.0)-12.0);
+            } else {
+              att=(int)(((double)att/99.0)*31.0);
+            }
+            set_attenuation_value((double)att);
+          }
+          break;
         case 'C': //RC
           // clears RIT
           if(command[2]==';') {
@@ -2912,6 +3279,18 @@ int parse_cmd(void *data) {
             vfo_update();
           }
           break;
+        case 'G': //RG
+          // set/read RF gain status
+          implemented=FALSE;
+          break;
+        case 'L': //RL
+          // set/read noise reduction level
+          implemented=FALSE;
+          break;
+        case 'M': //RM
+          // set/read meter function
+          implemented=FALSE;
+          break;
         case 'T': //RT
           // set/read RIT enable
           if(command[2]==';') {
@@ -2949,6 +3328,297 @@ int parse_cmd(void *data) {
       break;
     case 'S':
       switch(command[1]) {
+        case 'A': //SA
+          // set/read stallite mode status
+          if(command[2]==';') {
+            sprintf(reply,"SA%d%d%d%d%d%d%dSAT?    ;",sat_mode==SAT_MODE|sat_mode==RSAT_MODE,0,0,0,sat_mode=SAT_MODE,sat_mode=RSAT_MODE,0);
+            send_resp(client->fd,reply);
+          } else if(command[9]==';') {
+            if(command[2]=='0') {
+              sat_mode=SAT_NONE;
+            } else if(command[2]=='1') {
+              if(command[6]=='0' && command[7]=='0') {
+                sat_mode=SAT_NONE;
+              } else if(command[6]=='1' && command[7]=='0') {
+                sat_mode=SAT_MODE;
+              } else if(command[6]=='0' && command[7]=='1') {
+                sat_mode=RSAT_MODE;
+              } else {
+                implemented=FALSE;
+              }
+            }
+          } else {
+            implemented=FALSE;
+          }
+          break;
+        case 'B': //SB
+          // set/read SUB,TF-W status
+          implemented=FALSE;
+          break;
+        case 'C': //SC
+          // set/read SCAN function status
+          implemented=FALSE;
+          break;
+        case 'D': //SD
+          // set/read CW break-in time delay
+          if(command[2]==';') {
+            sprintf(reply,"SD%04d;",(int)fmin(cw_keyer_hang_time,1000));
+            send_resp(client->fd,reply);
+          } else if(command[6]==';') {
+            int b=fmin(atoi(&command[2]),1000);
+            cw_breakin=b==0;
+            cw_keyer_hang_time=b;
+          } else {
+            implemented=FALSE;
+          }
+          break;
+        case 'H': //SH
+          {
+          // set/read filter high
+          // make sure filter is filterVar1
+          if(vfo[active_receiver->id].filter!=filterVar1) {
+            vfo_filter_changed(filterVar1);
+          }
+          FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
+          FILTER *filter=&mode_filters[filterVar1];
+         if(command[2]==';') {
+            int fh=5;
+            int high=filter->high;
+            if(vfo[active_receiver->id].mode==modeLSB) {
+              high=abs(filter->low);
+            }
+            if(high<=1400) {
+              fh=0;
+            } else if(high<=1600) {
+              fh=1;
+            } else if(high<=1800) {
+              fh=2;
+            } else if(high<=2000) {
+              fh=3;
+            } else if(high<=2200) {
+              fh=4;
+            } else if(high<=2400) {
+              fh=5;
+            } else if(high<=2600) {
+              fh=6;
+            } else if(high<=2800) {
+              fh=7;
+            } else if(high<=3000) {
+              fh=8;
+            } else if(high<=3400) {
+              fh=9;
+            } else if(high<=4000) {
+              fh=10;
+            } else {
+              fh=11;
+            }
+            sprintf(reply,"SH%02d;",fh);
+            send_resp(client->fd,reply) ;
+          } else if(command[4]==';') {
+            int i=atoi(&command[2]);
+            int fh=100;
+            switch(vfo[active_receiver->id].mode) {
+              case modeLSB:
+              case modeUSB:
+              case modeFMN:
+                switch(i) {
+                  case 0:
+                    fh=1400;
+                    break;
+                  case 1:
+                    fh=1600;
+                    break;
+                  case 2:
+                    fh=1800;
+                    break;
+                  case 3:
+                    fh=2000;
+                    break;
+                  case 4:
+                    fh=2200;
+                    break;
+                  case 5:
+                    fh=2400;
+                    break;
+                  case 6:
+                    fh=2600;
+                    break;
+                  case 7:
+                    fh=2800;
+                    break;
+                  case 8:
+                    fh=3000;
+                    break;
+                  case 9:
+                    fh=3400;
+                    break;
+                  case 10:
+                    fh=4000;
+                    break;
+                  case 11:
+                    fh=5000;
+                    break;
+                  default:
+                    fh=100;
+                    break;
+                }
+                break;
+              case modeAM:
+              case modeSAM:
+                switch(i) {
+                  case 0:
+                    fh=10;
+                    break;
+                  case 1:
+                    fh=100;
+                    break;
+                  case 2:
+                    fh=200;
+                    break;
+                  case 3:
+                    fh=500;
+                    break;
+                  default:
+                    fh=100;
+                    break;
+                }
+                break;
+            }
+            if(vfo[active_receiver->id].mode==modeLSB) {
+              filter->low=-fh;
+            } else {
+              filter->high=fh;
+            }
+            vfo_filter_changed(filterVar1);
+          }
+          }
+          break;
+        case 'I': //SI
+          // enter satellite memory name
+          implemented=FALSE;
+          break;
+        case 'L': //SL
+          {
+          // set/read filter low
+          // make sure filter is filterVar1
+          if(vfo[active_receiver->id].filter!=filterVar1) {
+            vfo_filter_changed(filterVar1);
+          }
+          FILTER *mode_filters=filters[vfo[active_receiver->id].mode];
+          FILTER *filter=&mode_filters[filterVar1];
+         if(command[2]==';') {
+            int fl=2;
+            int low=filter->low;
+            if(vfo[active_receiver->id].mode==modeLSB) {
+              low=abs(filter->high);
+            }
+          
+            if(low<=10) {
+              fl=0;
+            } else if(low<=50) {
+              fl=1;
+            } else if(low<=100) {
+              fl=2;
+            } else if(low<=200) {
+              fl=3;
+            } else if(low<=300) {
+              fl=4;
+            } else if(low<=400) {
+              fl=5;
+            } else if(low<=500) {
+              fl=6;
+            } else if(low<=600) {
+              fl=7;
+            } else if(low<=700) {
+              fl=8;
+            } else if(low<=800) {
+              fl=9;
+            } else if(low<=900) {
+              fl=10;
+            } else {
+              fl=11;
+            }
+            sprintf(reply,"SL%02d;",fl);
+            send_resp(client->fd,reply) ;
+          } else if(command[4]==';') {
+            int i=atoi(&command[2]);
+            int fl=100;
+            switch(vfo[active_receiver->id].mode) {
+              case modeLSB:
+              case modeUSB:
+              case modeFMN:
+                switch(i) {
+                  case 0:
+                    fl=10;
+                    break;
+                  case 1:
+                    fl=50;
+                    break;
+                  case 2:
+                    fl=100;
+                    break;
+                  case 3:
+                    fl=200;
+                    break;
+                  case 4:
+                    fl=300;
+                    break;
+                  case 5:
+                    fl=400;
+                    break;
+                  case 6:
+                    fl=500;
+                    break;
+                  case 7:
+                    fl=600;
+                    break;
+                  case 8:
+                    fl=700;
+                    break;
+                  case 9:
+                    fl=800;
+                    break;
+                  case 10:
+                    fl=900;
+                    break;
+                  case 11:
+                    fl=1000;
+                    break;
+                  default:
+                    fl=100;
+                    break;
+                }
+                break;
+              case modeAM:
+              case modeSAM:
+                switch(i) {
+                  case 0:
+                    fl=10;
+                    break;
+                  case 1:
+                    fl=100;
+                    break;
+                  case 2:
+                    fl=200;
+                    break;
+                  case 3:
+                    fl=500;
+                    break;
+                  default:
+                    fl=100;
+                    break;
+                }
+                break;
+            }
+            if(vfo[active_receiver->id].mode==modeLSB) {
+              filter->high=-fl;
+            } else {
+              filter->low=fl;
+            }
+            vfo_filter_changed(filterVar1);
+          }
+          }
+          break;
         case 'M': //SM
           // read the S meter
           if(command[3]==';') {
@@ -2959,6 +3629,43 @@ int parse_cmd(void *data) {
             }
           }
           break;
+        case 'Q': //SQ
+          // set/read Squelch level
+          if(command[3]==';') {
+            int p1=atoi(&command[2]);
+            if(p1==0) { // Main receiver
+              sprintf(reply,"SQ%d%03d;",p1,(int)((double)active_receiver->squelch/100.0*255.0));
+              send_resp(client->fd,reply);
+            }
+          } else if(command[6]==';') {
+            if(command[2]=='0') {
+              int p2=atoi(&command[3]);
+              active_receiver->squelch=(int)((double)p2/255.0*100.0);
+              set_squelch();
+            }
+          } else {
+          }
+          break;
+        case 'R': //SR
+          // reset transceiver
+          implemented=FALSE;
+          break;
+        case 'S': //SS
+          // set/read program scan pause frequency
+          implemented=FALSE;
+          break;
+        case 'T': //ST
+          // set/read MULTI/CH channel frequency steps
+          implemented=FALSE;
+          break;
+        case 'U': //SU
+          // set/read program scan pause frequency
+          implemented=FALSE;
+          break;
+        case 'V': //SV
+          // execute memory transfer function
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2966,12 +3673,40 @@ int parse_cmd(void *data) {
       break;
     case 'T':
       switch(command[1]) {
+        case 'C': //TC
+          // set/read internal TNC mode
+          implemented=FALSE;
+          break;
+        case 'D': //TD
+          // send DTMF memory channel data
+          implemented=FALSE;
+          break;
+        case 'I': //TI
+          // read TNC LED status
+          implemented=FALSE;
+          break;
+        case 'N': //TN
+          // set/read sub-tone frequency
+          implemented=FALSE;
+          break;
+        case 'O': //TO
+          // set/read TONE function
+          implemented=FALSE;
+          break;
+        case 'S': //TS
+          // set/read TF-SET function
+          implemented=FALSE;
+          break;
         case 'X': //TX
           // set transceiver to TX mode
           if(command[2]==';') {
             mox_update(1);
           }
           break;
+        case 'Y': //TY
+          // set/read microprocessor firmware type
+          implemented=FALSE;
+          break;
         default:
           implemented=FALSE;
           break;
@@ -2979,6 +3714,10 @@ int parse_cmd(void *data) {
       break;
     case 'U':
       switch(command[1]) {
+        case 'L': //UL
+          // detects the PLL unlock status
+          implemented=FALSE;
+          break;
         case 'P': //UP
           // move VFO A up by step
           if(command[2]==';') {
@@ -2991,6 +3730,36 @@ int parse_cmd(void *data) {
       break;
     case 'V':
       switch(command[1]) {
+        case 'D': //VD
+          // set/read VOX delay time
+          implemented=FALSE;
+          break;
+        case 'G': //VG
+          // set/read VOX gain (0..9)
+          if(command[2]==';') {
+            // convert 0.0..1.0 to 0..9
+            sprintf(reply,"VG%03d;",(int)((vox_threshold*100.0)*0.9));
+            send_resp(client->fd,reply);
+          } else if(command[5]==';') {
+            // convert 0..9 to 0.0..1.0
+            vox_threshold=atof(&command[2])/9.0;
+            vfo_update();
+          }
+          break;
+        case 'R': //VR
+          // emulate VOICE1 or VOICE2 key
+          implemented=FALSE;
+          break;
+        case 'X': //VX
+          // set/read VOX status
+          if(command[2]==';') {
+            sprintf(reply,"VX%d;",vox_enabled);
+            send_resp(client->fd,reply);
+          } else if(command[3]==';') {
+            vox_enabled=atoi(&command[2]);
+            vfo_update();
+          }
+          break;
         default:
           implemented=FALSE;
           break;
@@ -3043,7 +3812,8 @@ int parse_cmd(void *data) {
   }
 
   if(!implemented) {
-    g_print("RIGCTL: UNIMPLEMENTED COMMAND: %s\n",info->command);
+    if(rigctl_debug) g_print("RIGCTL: UNIMPLEMENTED COMMAND: %s\n",info->command);
+    send_resp(client->fd,"?;");
   }
 
   g_free(info->command);
index 289c2dd2e43bfc03240a8e445e41aa4381b8ec50..5ccf950b3fb030f11b8d011f3f64d9f94b23193e 100644 (file)
@@ -72,6 +72,7 @@ static void serial_value_changed_cb(GtkWidget *widget, gpointer data) {
 
 static void rigctl_debug_cb(GtkWidget *widget, gpointer data) {
   rigctl_debug=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+  g_print("---------- RIGCTL DEBUG %s ----------\n",rigctl_debug?"ON":"OFF");
 }
 
 static void rigctl_enable_cb(GtkWidget *widget, gpointer data) {
index a41da2aa6c52b24858ee13f2841443113967ec7a..e1eaa4f8df0be5963ea5533082b9c32de7139a21 100644 (file)
@@ -34,10 +34,10 @@ static void get_info(char *driver) {
   SoapySDRKwargs args={};
   int software_version=0;
   int rtlsdr_val=0;
-  char fw_version[64];
-  char gw_version[64];
-  char hw_version[64];
-  char p_version[64];
+  char fw_version[16];
+  char gw_version[16];
+  char hw_version[16];
+  char p_version[16];
 
   fprintf(stderr,"soapy_discovery: get_info: %s\n", driver);
 
index 4f0222baf61697e91ba6cc77c1a75e72e1f4dc5e..7a2d3b3b1ea0367892fba66ea6ba99765c5bb004 100644 (file)
@@ -93,6 +93,13 @@ static int cw_shape = 0;
 extern double cwramp48[];              // see cwramp.c, for 48 kHz sample rate
 extern double cwramp192[];             // see cwramp.c, for 192 kHz sample rate
 
+double ctcss_frequencies[CTCSS_FREQUENCIES]= {
+  67.0,71.9,74.4,77.0,79.7,82.5,85.4,88.5,91.5,94.8,
+  97.4,100.0,103.5,107.2,110.9,114.8,118.8,123.0,127.3,131.8,
+  136.5,141.3,146.2,151.4,156.7,162.2,167.9,173.8,179.9,186.2,
+  192.8,203.5,210.7,218.1,225.7,233.6,241.8,250.3
+};
+
 static void init_analyzer(TRANSMITTER *tx);
 
 static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
@@ -121,12 +128,12 @@ void transmitter_set_am_carrier_level(TRANSMITTER *tx) {
   SetTXAAMCarrierLevel(tx->id, tx->am_carrier_level);
 }
 
-void transmitter_set_ctcss(TRANSMITTER *tx,int run,double frequency) {
-  tx->ctcss=run;
-  tx->ctcss_frequency=frequency;
-fprintf(stderr,"transmitter_set_ctcss: ctcss_frequency=%f run=%d\n",tx->ctcss_frequency,tx->ctcss);
-  SetTXACTCSSFreq(tx->id, tx->ctcss_frequency);
-  SetTXACTCSSRun(tx->id, tx->ctcss);
+void transmitter_set_ctcss(TRANSMITTER *tx,int state,int i) {
+g_print("transmitter_set_ctcss: state=%d i=%d frequency=%0.1f\n",state,i,ctcss_frequencies[i]);
+  tx->ctcss_enabled=state;
+  tx->ctcss=i;
+  SetTXACTCSSFreq(tx->id, ctcss_frequencies[tx->ctcss]);
+  SetTXACTCSSRun(tx->id, tx->ctcss_enabled);
 }
 
 void transmitter_set_compressor_level(TRANSMITTER *tx,double level) {
@@ -208,12 +215,12 @@ void transmitter_save_state(TRANSMITTER *tx) {
   sprintf(value,"%d",tx->attenuation);
   setProperty(name,value);
 #endif
+  sprintf(name,"transmitter.%d.ctcss_enabled",tx->id);
+  sprintf(value,"%d",tx->ctcss_enabled);
+  setProperty(name,value);
   sprintf(name,"transmitter.%d.ctcss",tx->id);
   sprintf(value,"%d",tx->ctcss);
   setProperty(name,value);
-  sprintf(name,"transmitter.%d.ctcss_frequency",tx->id);
-  sprintf(value,"%f",tx->ctcss_frequency);
-  setProperty(name,value);
   sprintf(name,"transmitter.%d.deviation",tx->id);
   sprintf(value,"%d",tx->deviation);
   setProperty(name,value);
@@ -309,12 +316,12 @@ void transmitter_restore_state(TRANSMITTER *tx) {
   value=getProperty(name);
   if(value) tx->attenuation=atoi(value);
 #endif
+  sprintf(name,"transmitter.%d.ctcss_enabled",tx->id);
+  value=getProperty(name);
+  if(value) tx->ctcss_enabled=atoi(value);
   sprintf(name,"transmitter.%d.ctcss",tx->id);
   value=getProperty(name);
   if(value) tx->ctcss=atoi(value);
-  sprintf(name,"transmitter.%d.ctcss_frequency",tx->id);
-  value=getProperty(name);
-  if(value) tx->ctcss_frequency=atof(value);
   sprintf(name,"transmitter.%d.deviation",tx->id);
   value=getProperty(name);
   if(value) tx->deviation=atoi(value);
@@ -772,8 +779,8 @@ fprintf(stderr,"create_transmitter: id=%d buffer_size=%d mic_sample_rate=%d mic_
   tx->single_on=0;
 
   tx->attenuation=0;
-  tx->ctcss=0;
-  tx->ctcss_frequency=100.0;
+  tx->ctcss=11;
+  tx->ctcss_enabled=FALSE;
 
   tx->deviation=2500;
   tx->am_carrier_level=0.5;
@@ -851,7 +858,7 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%p iq_output_buf
     SetTXAEQRun(tx->id, 0);
   }
 
-  transmitter_set_ctcss(tx,tx->ctcss,tx->ctcss_frequency);
+  transmitter_set_ctcss(tx,tx->ctcss_enabled,tx->ctcss);
   SetTXAAMSQRun(tx->id, 0);
   SetTXAosctrlRun(tx->id, 0);
 
index ad10695bff8aa03980d3d0e199b4ee2168b17138..2e9fc288d64129bce3b23b2b919159613356d587 100644 (file)
@@ -22,6 +22,9 @@
 
 #include <gtk/gtk.h>
 
+#define CTCSS_FREQUENCIES 38
+extern double ctcss_frequencies[CTCSS_FREQUENCIES];
+
 typedef struct _transmitter {
   int id;
   int dac;
@@ -77,7 +80,7 @@ typedef struct _transmitter {
   int auto_on;
   int single_on;
 
-  double ctcss_frequency;
+  gboolean ctcss_enabled;
   int ctcss;
 
   int deviation;
@@ -128,7 +131,7 @@ extern void tx_set_filter(TRANSMITTER *tx,int low,int high);
 extern void transmitter_set_deviation(TRANSMITTER *tx);
 extern void transmitter_set_am_carrier_level(TRANSMITTER *tx);
 extern void tx_set_pre_emphasize(TRANSMITTER *tx,int state);
-extern void transmitter_set_ctcss(TRANSMITTER *tx,int run,double frequency);
+extern void transmitter_set_ctcss(TRANSMITTER *tx,int state,int i);
 
 extern void add_mic_sample(TRANSMITTER *tx,float mic_sample);
 extern void add_freedv_mic_sample(TRANSMITTER *tx,float mic_sample);
index 3ee551357d9c62ded2800b28216702ea31e8eb2c..a025cc23ee4155d44fdb9b05baad1c2326380cd9 100644 (file)
--- a/tx_menu.c
+++ b/tx_menu.c
@@ -103,13 +103,20 @@ static void am_carrier_level_value_changed_cb(GtkWidget *widget, gpointer data)
 
 static void ctcss_cb (GtkWidget *widget, gpointer data) {
   int state=gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-  transmitter_set_ctcss(transmitter,state,transmitter->ctcss_frequency);
+  transmitter_set_ctcss(transmitter,state,transmitter->ctcss);
 }
 
+static void ctcss_frequency_cb(GtkWidget *widget, gpointer data) {
+  int i=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+  transmitter_set_ctcss(transmitter,transmitter->ctcss_enabled,i);
+}
+
+/*
 static void ctcss_spin_cb (GtkWidget *widget, gpointer data) {
   double frequency=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget));
   transmitter_set_ctcss(transmitter,transmitter->ctcss,frequency);
 }
+*/
 
 static void tune_use_drive_cb (GtkWidget *widget, gpointer data) {
   transmitter->tune_use_drive=gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
@@ -228,6 +235,7 @@ static void tune_value_changed_cb(GtkWidget *widget, gpointer data) {
 
 void tx_menu(GtkWidget *parent) {
   int i;
+  char temp[32];
 
   parent_window=parent;
 
@@ -490,11 +498,23 @@ void tx_menu(GtkWidget *parent) {
   col=0;
 
   GtkWidget *ctcss_b=gtk_check_button_new_with_label("CTCSS Enable");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctcss_b), transmitter->ctcss);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctcss_b), transmitter->ctcss_enabled);
   gtk_widget_show(ctcss_b);
   gtk_grid_attach(GTK_GRID(grid),ctcss_b,col,row,1,1);
   g_signal_connect(ctcss_b,"toggled",G_CALLBACK(ctcss_cb),NULL);
 
+
+  col++;
+  GtkWidget *ctcss_frequency_b=gtk_combo_box_text_new();
+  for(i=0;i<CTCSS_FREQUENCIES;i++) {
+    sprintf(temp,"%0.1f",ctcss_frequencies[i]);
+    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(ctcss_frequency_b),NULL,temp);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(ctcss_frequency_b),transmitter->ctcss==i);
+  }
+  gtk_grid_attach(GTK_GRID(grid),ctcss_frequency_b,col,row,1,1);
+  g_signal_connect(ctcss_frequency_b,"changed",G_CALLBACK(ctcss_frequency_cb),NULL);
+
+/*
   col++;
   GtkWidget *ctcss_spin=gtk_spin_button_new_with_range(67.0,250.3,0.1);
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(ctcss_spin),(double)transmitter->ctcss_frequency);
@@ -503,7 +523,7 @@ void tx_menu(GtkWidget *parent) {
   
   row++;
   col=0;
-
+*/
   GtkWidget *tune_use_drive_b=gtk_check_button_new_with_label("Tune use drive");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tune_use_drive_b), transmitter->tune_use_drive);
   gtk_widget_show(tune_use_drive_b);