[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 584eddbb6ea7a21a1ddc2
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: n0nb <n0...@us...> - 2025-09-23 13:35:36
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Hamlib -- Ham radio control libraries".
The branch, master has been updated
via 584eddbb6ea7a21a1ddc2306c7773a5d98ca467b (commit)
via 54bd989e72d035422d7bf7be0a6f6bff56d7fec7 (commit)
via 8b9e271ce17de367378053cb88123ea72c975cba (commit)
via 5f89ab7d569f077ee6384521ba8ee17357648054 (commit)
from 1557d848ed6add017f0c5ad5a1efe276bb704e98 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 584eddbb6ea7a21a1ddc2306c7773a5d98ca467b
Merge: 1557d848e 54bd989e7
Author: Nate Bargmann <n0...@n0...>
Date: Tue Sep 23 08:15:05 2025 -0500
Merge GitHub PR #1921
commit 54bd989e72d035422d7bf7be0a6f6bff56d7fec7
Author: Daniele Forsi IU5HKX <iu...@gm...>
Date: Sun Sep 7 08:39:43 2025 +0200
Add various get and set methods for amplifiers to the bindings
Adds get_ext_level, has_get_level, has_set_level, set_ext_level,
set_level.
Brings function coverage of amplifier.c above 90%.
diff --git a/bindings/amplifier.swg b/bindings/amplifier.swg
index 136e9d5c1..c8ae0167c 100644
--- a/bindings/amplifier.swg
+++ b/bindings/amplifier.swg
@@ -99,9 +99,17 @@ typedef struct Amp {
AMPMETHOD1(token_lookup, const_char_string) /* conf */
- /* set functions */
+ /* get and set functions */
+ AMP_GENERATE_HAS_GET_SET(level)
+
+#ifdef SWIGPYTHON
+ AMP_GET_VALUE_T(ext_level)
+#endif
+
AMPMETHOD1(set_freq, freq_t)
AMPMETHOD1(set_powerstat, powerstat_t)
+ AMPMETHOD2(set_level, setting_t, value_t)
+ AMPMETHOD2(set_ext_level, hamlib_token_t, value_t)
void set_conf(const char *name, const char *val) {
hamlib_token_t tok = amp_token_lookup(self->amp, name);
diff --git a/bindings/macros.swg b/bindings/macros.swg
index 97a69d994..614292698 100644
--- a/bindings/macros.swg
+++ b/bindings/macros.swg
@@ -27,6 +27,21 @@ Common SWIG macros
}
%enddef
+/*
+ * Macro AMP_GENERATE_HAS_GET_SET
+ *
+ * Creates two methods amp_has_get_*() and amp_has_set_*()
+ *
+ * setting:
+ * the last part of the function name (eg. func, level, ...)
+ *
+ * example: AMP_GENERATE_HAS_GET_SET(level) creates the bindings for
+ * amp_has_get_level() and amp_has_set_level()
+ */
+%define AMP_GENERATE_HAS_GET_SET(setting)
+ GENERATE_HAS_GET_SET(amp, setting)
+%enddef
+
/*
* Macro ROT_GENERATE_HAS_GET_SET
*
@@ -107,6 +122,18 @@ PyObject * ##function_name(hamlib_token_t token)
}
%enddef
+/*
+* Macro AMP_GET_VALUE_T
+*
+* function_name:
+* the name that will be seen in the bindings when appended to get_
+* and that creates a valid Hamlib function when appended to amp_get_
+* eg. AMP_GET_VALUE_T(level) creates Rot.get_level() that calls amp_get_level()
+*/
+%define AMP_GET_VALUE_T(function_name)
+ GET_VALUE_T(amp_, get_ ##function_name, self->amp, AMP_)
+%enddef
+
/*
* Macro ROT_GET_LONG
*
diff --git a/bindings/python/test_Hamlib_Amp_class.py b/bindings/python/test_Hamlib_Amp_class.py
index df2749b31..c90358fe9 100755
--- a/bindings/python/test_Hamlib_Amp_class.py
+++ b/bindings/python/test_Hamlib_Amp_class.py
@@ -18,14 +18,19 @@ class TestClass:
"""Check that nothing was added or removed"""
expected_callables = ['close',
'get_conf',
+'get_ext_level',
'get_freq',
'get_info',
'get_level',
'get_powerstat',
+'has_get_level',
+'has_set_level',
'open',
'reset',
'set_conf',
+'set_ext_level',
'set_freq',
+'set_level',
'set_powerstat',
'token_lookup']
assert expected_callables == self.actual_callables
diff --git a/bindings/python/test_amp.py b/bindings/python/test_amp.py
index f5eeef872..106fe4c2d 100755
--- a/bindings/python/test_amp.py
+++ b/bindings/python/test_amp.py
@@ -62,6 +62,9 @@ class TestClass:
assert amp.set_freq(0) is None
assert amp.set_freq(123.45) is None
assert amp.get_freq() == 123.45
+
+ assert amp.has_set_level(Hamlib.AMP_LEVEL_SWR) == Hamlib.AMP_LEVEL_NONE
+ assert amp.has_get_level(Hamlib.AMP_LEVEL_SWR) == Hamlib.AMP_LEVEL_SWR
assert amp.get_level(Hamlib.AMP_LEVEL_NONE) is None
level = amp.get_level(Hamlib.AMP_LEVEL_SWR)
assert isinstance(level, float)
@@ -71,6 +74,13 @@ class TestClass:
assert isinstance(level, str)
level = amp.get_level(123456)
assert level is None
+ value = Hamlib.value_t()
+ value.i = 2
+ assert amp.set_level(Hamlib.AMP_LEVEL_SWR, value) is None
+ assert amp.set_ext_level(Hamlib.AMP_LEVEL_SWR, value) is None
+ level = amp.get_ext_level(Hamlib.AMP_LEVEL_SWR)
+ assert level is None
+
assert amp.set_powerstat(Hamlib.RIG_POWER_ON) is None
assert amp.get_powerstat() == Hamlib.RIG_POWER_ON
commit 8b9e271ce17de367378053cb88123ea72c975cba
Author: Daniele Forsi IU5HKX <iu...@gm...>
Date: Sat Sep 6 23:06:16 2025 +0200
Add various get and set methods for rotators to the bindings
Adds has_get_func, has_get_level, has_get_parm, has_set_func,
has_set_level, has_set_parm.
Brings tests coverage of rot_settings.c to 100%.
diff --git a/bindings/macros.swg b/bindings/macros.swg
index b149cf4f5..97a69d994 100644
--- a/bindings/macros.swg
+++ b/bindings/macros.swg
@@ -27,6 +27,21 @@ Common SWIG macros
}
%enddef
+/*
+ * Macro ROT_GENERATE_HAS_GET_SET
+ *
+ * Creates two methods rot_has_get_*() and rot_has_set_*()
+ *
+ * setting:
+ * the last part of the function name (eg. func, level, ...)
+ *
+ * example: ROT_GENERATE_HAS_GET_SET(func) creates the bindings for
+ * rot_has_get_func() and rot_has_set_func()
+ */
+%define ROT_GENERATE_HAS_GET_SET(setting)
+ GENERATE_HAS_GET_SET(rot, setting)
+%enddef
+
/*
* Macro GET_TOKEN
*
diff --git a/bindings/python/test_Hamlib_Rot_class.py b/bindings/python/test_Hamlib_Rot_class.py
index 731f5b069..a69508cbb 100755
--- a/bindings/python/test_Hamlib_Rot_class.py
+++ b/bindings/python/test_Hamlib_Rot_class.py
@@ -26,6 +26,12 @@ class TestClass:
'get_level',
'get_parm',
'get_position',
+'has_get_func',
+'has_get_level',
+'has_get_parm',
+'has_set_func',
+'has_set_level',
+'has_set_parm',
'move',
'open',
'park',
diff --git a/bindings/python/test_rot.py b/bindings/python/test_rot.py
index 3e0b5c292..a5e94659b 100755
--- a/bindings/python/test_rot.py
+++ b/bindings/python/test_rot.py
@@ -100,6 +100,8 @@ class TestClass:
assert rot.get_ext_parm(self.TOK_EP_ROT_MAGICPARM) == 7
# Dummy rotator doesn't support functions
+ assert rot.has_set_func(Hamlib.ROT_FUNC_NONE) == Hamlib.ROT_FUNC_NONE
+ assert rot.has_get_func(Hamlib.ROT_FUNC_NONE) == Hamlib.ROT_FUNC_NONE
status = 0
assert rot.set_func(Hamlib.ROT_FUNC_NONE, status) is None
assert rot.get_func(Hamlib.ROT_FUNC_NONE) is None
diff --git a/bindings/rotator.swg b/bindings/rotator.swg
index 8691e4730..22c911d7a 100644
--- a/bindings/rotator.swg
+++ b/bindings/rotator.swg
@@ -120,6 +120,10 @@ typedef struct Rot {
ROTMETHOD2(set_conf, hamlib_token_t, const_char_string)
+ ROT_GENERATE_HAS_GET_SET(func)
+ ROT_GENERATE_HAS_GET_SET(level)
+ ROT_GENERATE_HAS_GET_SET(parm)
+
#ifdef SWIGPYTHON
ROT_GET_LONG(func)
ROT_GET_LONG(ext_func)
commit 5f89ab7d569f077ee6384521ba8ee17357648054
Author: Daniele Forsi IU5HKX <iu...@gm...>
Date: Sun Sep 7 08:28:04 2025 +0200
Add a SWIG macro for "has_get" and "has_set" bindings
diff --git a/bindings/macros.swg b/bindings/macros.swg
index 29396a47a..b149cf4f5 100644
--- a/bindings/macros.swg
+++ b/bindings/macros.swg
@@ -2,6 +2,31 @@
Common SWIG macros
*/
+/*
+ * Macro GENERATE_HAS_GET_SET
+ *
+ * Creates two methods *_has_get_*() and *_has_set_*()
+ *
+ * function_prefix:
+ * the first part of the function name (eg. one of: amp_ rig_ rot_)
+ * this is also the name of the member of the "self" object
+ *
+ * setting:
+ * the last part of the function name (eg. func, level, ...)
+ *
+ * example: GENERATE_HAS_GET_SET(rig, func) creates the bindings for
+ * rig_has_get_func() and rig_has_set_func()
+ */
+%define GENERATE_HAS_GET_SET(function_prefix, setting)
+ setting_t has_get_##setting##(setting_t setting) {
+ return function_prefix##_has_get_##setting##($self->##function_prefix##, setting);
+ }
+
+ setting_t has_set_##setting##(setting_t setting) {
+ return function_prefix##_has_set_##setting##($self->##function_prefix##, setting);
+ }
+%enddef
+
/*
* Macro GET_TOKEN
*
-----------------------------------------------------------------------
Summary of changes:
bindings/amplifier.swg | 10 ++++-
bindings/macros.swg | 67 ++++++++++++++++++++++++++++++++
bindings/python/test_Hamlib_Amp_class.py | 5 +++
bindings/python/test_Hamlib_Rot_class.py | 6 +++
bindings/python/test_amp.py | 10 +++++
bindings/python/test_rot.py | 2 +
bindings/rotator.swg | 4 ++
7 files changed, 103 insertions(+), 1 deletion(-)
hooks/post-receive
--
Hamlib -- Ham radio control libraries
|