From c760d12ff1787b14f628e89a7a9380a559a31d4f Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sun, 22 Jan 2023 22:49:27 +0530
Subject: [PATCH] rigctl: ZZAR - take care of the sign of the agc threshold
 reply

---
 rigctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/rigctl.c b/rigctl.c
index df87081..6024661 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -973,7 +973,12 @@ gboolean parse_extended_cmd(char *command, CLIENT *client) {
       // read/set RX0 AGC Threshold
       if (command[4] == ';') {
         // send reply back
-        sprintf(reply, "ZZAR%+04d;", (int)(receiver[0]->agc_gain));
+        memset(reply, '\0', 10);
+        if (receiver[0]->agc_gain >= 0) {
+            sprintf(reply, "ZZAR+%+03d;", (int)(receiver[0]->agc_gain));
+        } else {
+            sprintf(reply, "ZZAR-%+03d;", (int)(receiver[0]->agc_gain));
+        }
         send_resp(client->fd, reply);
       } else {
         int threshold = atoi(&command[4]);
-- 
2.45.2