]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Added RFGAIN to client/server
authorc vw <dl1ycf@darc.de>
Fri, 17 Dec 2021 17:15:43 +0000 (18:15 +0100)
committerc vw <dl1ycf@darc.de>
Fri, 17 Dec 2021 17:15:43 +0000 (18:15 +0100)
client_server.c
client_server.h
ext.c
sliders.c

index 874f5dd5660dd6a6704868525272472ba4e09395..600eff7e506f207ca7e51fba99c376829402245b 100644 (file)
@@ -622,6 +622,23 @@ g_print("server_client_thread: CMD_RESP_RX_AGC_GAIN\n");
          g_idle_add(ext_remote_command,agc_gain_command);
          }
          break;
+      case CMD_RESP_RX_GAIN:
+g_print("server_client_thread: CMD_RESP_RX_GAIN\n");
+         {
+         RFGAIN_COMMAND *command=g_new(RFGAIN_COMMAND,1);
+         command->header.data_type=header.data_type;
+         command->header.version=header.version;
+         command->header.context.client=client;
+         bytes_read=recv_bytes(client->socket,(char *)&command->id,sizeof(RFGAIN_COMMAND)-sizeof(header));
+         if(bytes_read<0) {
+           g_print("server_client_thread: read %d bytes for RFGAIN_COMMAND\n",bytes_read);
+           perror("server_client_thread");
+           // dialog box?
+           return NULL;
+         }
+         g_idle_add(ext_remote_command,command);
+         }
+         break;
       case CMD_RESP_RX_ATTENUATION:
 g_print("server_client_thread: CMD_RESP_RX_ATTENUATION\n");
          {
@@ -1268,6 +1285,22 @@ g_print("send_agc_gain rx=%d gain=%d\n",rx,gain);
   }
 }
 
+void send_rfgain(int s, int id, double gain) {
+  RFGAIN_COMMAND command;
+g_print("send_rfgain rx=%d gain=%f\n",id,gain);
+  command.header.sync=REMOTE_SYNC;
+  command.header.data_type=htons(CMD_RESP_RX_GAIN);
+  command.header.version=htonl(CLIENT_SERVER_VERSION);
+  command.id=id;
+  command.gain=htond(gain);
+  int bytes_sent=send_bytes(s,(char *)&command,sizeof(command));
+  if(bytes_sent<0) {
+    perror("send_command");
+  } else {
+    g_print("send_command RFGAIN: %d\n",bytes_sent);
+  }
+}
+
 void send_attenuation(int s,int rx,int attenuation) {
   ATTENUATION_COMMAND command;
   short a=(short)attenuation;
@@ -2188,6 +2221,22 @@ g_print("AGC_COMMAND: rx=%d agc=%d\n",rx,a);
         receiver[rx]->agc_thresh=(double)thresh;
         }
         break;
+      case CMD_RESP_RX_GAIN:
+        {
+       RFGAIN_COMMAND command;
+        bytes_read=recv_bytes(client_socket,(char *)&command.id,sizeof(command)-sizeof(header));
+        if(bytes_read<0) {
+          g_print("client_thread: read %d bytes for RFGAIN_CMD\n",bytes_read);
+          perror("client_thread");
+          // dialog box?
+          return NULL;
+        }
+        int rx=command.id;
+        double gain=ntohd(command.gain);
+g_print("CMD_RESP_RX_GAIN: new=%f rx=%d old=%f\n",gain,rx,adc[receiver[rx]->adc].gain);
+        adc[receiver[rx]->adc].gain=gain;
+        }
+        break;
       case CMD_RESP_RX_ATTENUATION:
         {
         ATTENUATION_COMMAND attenuation_cmd;
index c3a1ec01125279ed98c04bd406c21f111a8a182b..f4309112219faaf5b6aa078bce381674c832c2eb 100644 (file)
@@ -69,6 +69,7 @@ enum {
   CMD_RESP_RX_VOLUME,
   CMD_RESP_RX_AGC_GAIN,
   CMD_RESP_RX_ATTENUATION,
+  CMD_RESP_RX_GAIN,
   CMD_RESP_RX_SQUELCH,
   CMD_RESP_RX_FPS,
   CMD_RESP_RX_SELECT,
@@ -346,6 +347,12 @@ typedef struct __attribute__((__packed__)) _attenuation_command {
   uint16_t attenuation;
 } ATTENUATION_COMMAND;
 
+typedef struct __attribute__((__packed__)) _rfgain_command {
+  HEADER header;
+  uint8_t id;
+  uint16_t gain;
+} RFGAIN_COMMAND;
+
 typedef struct __attribute__((__packed__)) _squelch_command {
   HEADER header;
   uint8_t id;
@@ -495,6 +502,7 @@ extern void send_volume(int s,int rx,int volume);
 extern void send_agc(int s,int rx,int agc);
 extern void send_agc_gain(int s,int rx,int gain,int hang,int thresh);
 extern void send_attenuation(int s,int rx,int attenuation);
+extern void send_rfgain(int s,int rx, double gain);
 extern void send_squelch(int s,int rx,int enable,int squelch);
 extern void send_noise(int s,int rx,int nb,int nb2,int nr,int nr2,int anf,int snb);
 extern void send_band(int s,int rx,int band);
diff --git a/ext.c b/ext.c
index d2af6e8fa8ff73d3420226adbc27ba78eac5e61f..135a88b9752ca7f4c4f426a11a40f6fd3daaa877 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -812,6 +812,13 @@ g_print("AGC_COMMAND: set_agc id=%d agc=%d\n",rx->id,rx->agc);
       send_agc_gain(client->socket,rx->id,(int)rx->agc_gain,(int)rx->agc_hang,(int)rx->agc_thresh);
       }
       break;
+    case CMD_RESP_RX_GAIN:
+      {
+      RFGAIN_COMMAND *command=(RFGAIN_COMMAND *) data;
+      double td=ntohd(command->gain);
+      set_rf_gain(command->id, td);
+      }
+      break;
     case CMD_RESP_RX_ATTENUATION:
       {
       ATTENUATION_COMMAND *attenuation_command=(ATTENUATION_COMMAND *)data;
index 365ba04b85b7e33f1ce94f3275c91d8f215d57ed..1631650d3305a82399a58b18ee82a6a49a0e72a2 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -391,6 +391,12 @@ void set_af_gain(int rx,double value) {
 
 static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) {
     adc[active_receiver->adc].gain=gtk_range_get_value(GTK_RANGE(rf_gain_scale));
+#ifdef CLIENT_SERVER
+    if (radio_is_remote) {
+      send_rfgain(client_socket, active_receiver->id, adc[active_receiver->adc].gain);
+    }
+    return;
+#endif
     switch(protocol) {
 #ifdef SOAPYSDR
       case SOAPYSDR_PROTOCOL: