From 0f0705d014d4e400761bd5d275e7c9ab1b374380 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Mon, 8 Mar 2021 23:26:44 -0600 Subject: [PATCH] Fix python binding for future deprecation of distutils.sysconfig Hopefully works on MacOS Also hopefully works on python2 https://github.com/Hamlib/Hamlib/issues/477 --- bindings/Makefile.am | 2 +- bindings/ignore.swg | 1 + bindings/py3test.py | 5 ++++- bindings/rig.swg | 11 +++++++++++ include/hamlib/rig.h | 2 -- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bindings/Makefile.am b/bindings/Makefile.am index b01407a83..5e4f81f7b 100644 --- a/bindings/Makefile.am +++ b/bindings/Makefile.am @@ -3,7 +3,7 @@ # more information on swig at http://www.swig.org # -AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/bindings $(PYTHON_CPPFLAGS) \ +AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/include -I$(top_srcdir)/bindings \ $(TCL_INCLUDE_SPEC) AM_CFLAGS = -fno-strict-aliasing diff --git a/bindings/ignore.swg b/bindings/ignore.swg index abc48022d..37d6c96dc 100644 --- a/bindings/ignore.swg +++ b/bindings/ignore.swg @@ -194,6 +194,7 @@ %ignore rig_passband_normal; %ignore rig_passband_narrow; %ignore rig_passband_wide; +%ignore rig_get_vfo_info; %ignore rot_open; %ignore rot_close; diff --git a/bindings/py3test.py b/bindings/py3test.py index 1c8d27895..5a31cd1ba 100755 --- a/bindings/py3test.py +++ b/bindings/py3test.py @@ -39,7 +39,7 @@ def StartUp(): print("freq:\t\t\t%s" % my_rig.get_freq()) my_rig.set_freq(Hamlib.RIG_VFO_A, 145550000) - (mode, width) = my_rig.get_mode() + (mode, width) = my_rig.get_mode(Hamlib.RIG_VFO_A) print("mode:\t\t\t%s\nbandwidth:\t\t%s" % (Hamlib.rig_strrmode(mode), width)) @@ -83,6 +83,9 @@ def StartUp(): print("get_channel status:\t%s" % my_rig.error_status) print("VFO:\t\t\t%s, %s" % (Hamlib.rig_strvfo(chan.vfo), chan.freq)) print("Attenuators:\t\t%s" % my_rig.caps.attenuator) + # Can't seem to get get_vfo_info to work + #(freq, width, mode, split) = my_rig.get_vfo_info(Hamlib.RIG_VFO_A,freq,width,mode,split) + #print("Rig vfo_info:\t\tfreq=%s, mode=%s, width=%s, split=%s" % (freq, mode, width, split)) print("\nSending Morse, '73'") my_rig.send_morse(Hamlib.RIG_VFO_A, "73") diff --git a/bindings/rig.swg b/bindings/rig.swg index 19f5be1d5..0d1c05fd9 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -70,6 +70,10 @@ typedef channel_t * const_channel_t_p; { self->error_status = rig_##f(self->rig _VFO_ARG, _##t1); } #define METHOD3_INIT(f, t1, t2, t3, i3) void f (t1 _##t1##_1, t2 _##t2##_2, t3 _##t3##_3 = i3 _VFO_DECL) \ { self->error_status = rig_##f(self->rig _VFO_ARG, _##t1##_1, _##t2##_2, _##t3##_3); } +#define METHOD4(f, t1) void f ( vfo_t vfo, t1 _##t1) \ + { self->error_status = rig_##f(self->rig _VFO_ARG, _##t1); } +#define METHOD4_INIT(f, t1, t2, t3, t4, i4) void f (t1 _##t1##_1, t2 _##t2##_2, t3 _##t3##_3, ##t4##_4 = i4 _VFO_DECL) \ + { self->error_status = rig_##f(self->rig _VFO_ARG, _##t1##_1, _##t2##_2, _##t3##_3 _##t4##_4); } /* * declare wrapper method with one output argument besides RIG* (no target vfo) */ @@ -445,6 +449,7 @@ typedef channel_t * const_channel_t_p; METHOD1VGET(get_xit, shortfreq_t) METHOD1VGET(get_ts, shortfreq_t) extern void get_ant(ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, value_t * OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR); + extern void get_vfo_info (split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo = RIG_VFO_CURR); METHOD1VGET(get_mem, int) METHOD1GET(get_powerstat, powerstat_t) METHOD1GET(get_trn, int) @@ -600,6 +605,11 @@ void Rig_get_ant(Rig *self, ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, value { self->error_status = rig_get_ant(self->rig, vfo, ant, option, ant_curr, ant_tx, ant_rx); } +void Rig_get_vfo_info (Rig *self, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo) +{ + self->error_status = rig_get_vfo_info(self->rig, vfo, freq, mode, width, split); +} + struct channel *Rig_get_chan_all(Rig *self) { @@ -618,4 +628,5 @@ struct channel *Rig_get_chan_all(Rig *self) return chans; } + %} diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 5a892f732..17173886b 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2339,11 +2339,9 @@ extern HAMLIB_EXPORT(int) rig_get_vfo HAMLIB_PARAMS((RIG *rig, vfo_t *vfo)); -#if 0 extern HAMLIB_EXPORT(int) rig_get_vfo_info HAMLIB_PARAMS((RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width, split_t *split)); -#endif extern HAMLIB_EXPORT(int) rig_get_vfo_list HAMLIB_PARAMS((RIG *rig, char *buf, int buflen));