Hamlib 4.7~git
Loading...
Searching...
No Matches
cache.h
1/*
2 * Hamlib Interface - rig state cache routines
3 * Copyright (c) 2000-2012 by Stephane Fillod
4 * Copyright (c) 2000-2003 by Frank Singleton
5 *
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22/* SPDX-License-Identifier: LGPL-2.1-or-later */
23
24#ifndef _CACHE_H
25#define _CACHE_H
26
27#include "hamlib/rig.h"
28
29__BEGIN_DECLS
30
31/* It should be noted that there are two distinct cache implementations
32 * in Hamlib. This one is for the app-facing side, providing cached status
33 * (freq, mode, band, etc) for application queries. The other is used by
34 * backends for rig status probes, watchdog timers, and other hardware related
35 * tasks. Also note that they use different times - timespec vs timeval.
36 * - n3gb 2025-05-14
37 */
38
45struct rig_cache {
46 int timeout_ms; // the cache timeout for invalidating itself
47 vfo_t vfo;
48 //freq_t freq; // to be deprecated in 4.1 when full Main/Sub/A/B caching is implemented in 4.1
49 // other abstraction here is based on dual vfo rigs and mapped to all others
50 // So we have four possible states of rig
51 // MainA, MainB, SubA, SubB
52 // Main is the Main VFO and Sub is for the 2nd VFO
53 // Most rigs have MainA and MainB
54 // Dual VFO rigs can have SubA and SubB too
55 // For dual VFO rigs simplex operations are all done on MainA/MainB -- ergo this abstraction
56 freq_t freqCurr; // Other VFO
57 freq_t freqOther; // Other VFO
58 freq_t freqMainA; // VFO_A, VFO_MAIN, and VFO_MAINA
59 freq_t freqMainB; // VFO_B, VFO_SUB, and VFO_MAINB
60 freq_t freqMainC; // VFO_C, VFO_MAINC
61 freq_t freqSubA; // VFO_SUBA -- only for rigs with dual Sub VFOs
62 freq_t freqSubB; // VFO_SUBB -- only for rigs with dual Sub VFOs
63 freq_t freqSubC; // VFO_SUBC -- only for rigs with 3 Sub VFOs
64 freq_t freqMem; // VFO_MEM -- last MEM channel
65 rmode_t modeCurr;
66 rmode_t modeOther;
67 rmode_t modeMainA;
68 rmode_t modeMainB;
69 rmode_t modeMainC;
70 rmode_t modeSubA;
71 rmode_t modeSubB;
72 rmode_t modeSubC;
73 rmode_t modeMem;
74 pbwidth_t widthCurr; // if non-zero then rig has separate width for MainA
75 pbwidth_t widthOther; // if non-zero then rig has separate width for MainA
76 pbwidth_t widthMainA; // if non-zero then rig has separate width for MainA
77 pbwidth_t widthMainB; // if non-zero then rig has separate width for MainB
78 pbwidth_t widthMainC; // if non-zero then rig has separate width for MainC
79 pbwidth_t widthSubA; // if non-zero then rig has separate width for SubA
80 pbwidth_t widthSubB; // if non-zero then rig has separate width for SubB
81 pbwidth_t widthSubC; // if non-zero then rig has separate width for SubC
82 pbwidth_t widthMem; // if non-zero then rig has separate width for Mem
83 ptt_t ptt;
84 split_t split;
85 vfo_t split_vfo; // split caches two values
86 struct timespec time_freqCurr;
87 struct timespec time_freqOther;
88 struct timespec time_freqMainA;
89 struct timespec time_freqMainB;
90 struct timespec time_freqMainC;
91 struct timespec time_freqSubA;
92 struct timespec time_freqSubB;
93 struct timespec time_freqSubC;
94 struct timespec time_freqMem;
95 struct timespec time_vfo;
96 struct timespec time_modeCurr;
97 struct timespec time_modeOther;
98 struct timespec time_modeMainA;
99 struct timespec time_modeMainB;
100 struct timespec time_modeMainC;
101 struct timespec time_modeSubA;
102 struct timespec time_modeSubB;
103 struct timespec time_modeSubC;
104 struct timespec time_modeMem;
105 struct timespec time_widthCurr;
106 struct timespec time_widthOther;
107 struct timespec time_widthMainA;
108 struct timespec time_widthMainB;
109 struct timespec time_widthMainC;
110 struct timespec time_widthSubA;
111 struct timespec time_widthSubB;
112 struct timespec time_widthSubC;
113 struct timespec time_widthMem;
114 struct timespec time_ptt;
115 struct timespec time_split;
116 int satmode; // if rig is in satellite mode
117};
118
119/* Access macros */
120#define CACHE(r) ((r)->cache_addr)
121//#define HAMLIB_CACHE(r) ((struct rig_cache *)rig_data_pointer(r, RIG_PTRX_CACHE))
122
123/* Function templates
124 * Does not include those marked as part of HAMLIB_API
125 */
126int rig_set_cache_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
127int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq);
128void rig_cache_show(RIG *rig, const char *func, int line);
129
130__END_DECLS
131
132#endif
unsigned int vfo_t
VFO definition.
Definition rig.h:544
uint64_t rmode_t
Radio mode.
Definition rig.h:1392
shortfreq_t pbwidth_t
Definition rig.h:676
split_t
Split mode.
Definition rig.h:473
double freq_t
Frequency type.
Definition rig.h:484
ptt_t
PTT status.
Definition rig.h:707
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:290
Hamlib rig data structures.
Rig cache data.
Definition cache.h:45