summaryrefslogtreecommitdiff
path: root/comms/ktrack/files/patch-ktrack_hamlibwrapper.cpp
blob: f0519b8022eb9c6190fa08c713353da8c6de705a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- ktrack/hamlibwrapper.cpp.orig	Sun Jan 18 03:25:00 2004
+++ ktrack/hamlibwrapper.cpp	Thu Feb 23 11:23:18 2006
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <kapplication.h>
+#include <math.h>
 
 #include "hamlibwrapper.h"
 
@@ -100,6 +101,7 @@
   // open the rig
   if (rig_open(downlinkRig) != RIG_OK) {
     retval--;
+    downlinkRig->caps->rig_model=RIG_MODEL_DUMMY;
   }
 
 
@@ -116,8 +118,9 @@
     uplinkRig=rig_init(urig);
     uplinkRig->state.rigport.parm.serial.rate=uspeed;
     strcpy(downlinkRig->state.rigport.pathname, uport);
-    if (rig_open(downlinkRig) != RIG_OK) {
+    if (rig_open(uplinkRig) != RIG_OK) {
 			retval--;
+			uplinkRig->caps->rig_model=RIG_MODEL_DUMMY;
     }
   }
 
@@ -248,13 +251,16 @@
   int errorcode;
   freq_t frequency=0;
   mutex.lock();
-  errorcode=rig_get_freq(downlinkRig, downlinkvfo, &frequency);
-  if (errorcode!=RIG_OK) {
-    fprintf(stderr, "WARNING: Error fetching frequency from Radio! Using default Frequency!\n");
-    errorstring=rigerror(errorcode);
-    if (errorstring)
-      fprintf(stderr, "The reported error was: %s\n", errorstring);
-    frequency=433000000;
+  if (downlinkRig->caps->rig_model != RIG_MODEL_DUMMY) {
+    errorcode=rig_get_freq(downlinkRig, downlinkvfo, &frequency);
+    if (errorcode!=RIG_OK) {
+      fprintf(stderr, "WARNING: Error fetching frequency from Radio! Using default Frequency!\n");
+      errorstring=rigerror(errorcode);
+      if (errorstring)
+        fprintf(stderr, "The reported error was: %s\n", errorstring);
+      downlinkRig->caps->rig_model = RIG_MODEL_DUMMY;
+      frequency=433000000;
+    }
   }
   // sleep on dummy rig - that saves CPU power
   if (downlinkRig->caps->rig_model == RIG_MODEL_DUMMY)