kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'bindings'
Fixed int[10] type variables (and other int[FIXLEN] type) handling in bindings There is a bug in (all) bindings: the attenuator list is inaccessible. The different languages (interpreters) shows it in different modes. The problem is that the necessary typemaps are missed in current master tree (for SWIG). You can check it if you grab the bindings/pytest.py|perltest.pl|tcltest.tcl from my bindings branch (https://sourceforge.net/u/airween/hamlib/ci/bindings/tree/bindings/), and run with the current tree. You can see the results: Python: Attenuators: <Swig Object of type 'rot_reset_t *' at 0x7f4170341990> (note, that there is an another bug in SWIG, but it doesn't affects this issue (the type of attenuator isn't 'rot_reset_t *')) Perl: Not an ARRAY reference at ./perltest.pl line 69. Tcl: Attenuators: _b8c1a3c20e7f0000_p_int After the apply the patch, the results will these: Python: Attenuators: [10, 20, 30, 0, 0, 0, 0, 0] Perl: Attenuators: 10 20 30 0 0 0 0 0 Tcl: Attenuators: 10 20 30 0 0 0 0 0 73, Ervin HA2OSHamlib-3.1
commit
547fa410ef
|
@ -44,6 +44,87 @@
|
|||
%include cstring.i
|
||||
#ifdef SWIGPYTHON
|
||||
%include python/file.i
|
||||
|
||||
%typemap(out) int [ANY] {
|
||||
int len,i;
|
||||
len = $1_dim0;
|
||||
$result = PyList_New(len);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyList_SetItem($result,i,PyInt_FromLong((long)$1[i]));
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(varout) int [ANY] {
|
||||
int len,i;
|
||||
len = $1_dim0;
|
||||
$result = PyList_New(len);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyList_SetItem($result,i,PyInt_FromLong((long)$1[i]));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPERL
|
||||
|
||||
%typemap(out) int [ANY] {
|
||||
AV * av = newAV();
|
||||
int i = 0,len = 0;
|
||||
len = $1_dim0;
|
||||
|
||||
for (i = 0; i < len ; i++) {
|
||||
SV* perlval = newSV(0);
|
||||
sv_setiv(perlval, (IV)$1[i]);
|
||||
av_push(av, perlval);
|
||||
}
|
||||
$result = newRV_noinc((SV *)av);
|
||||
sv_2mortal( $result );
|
||||
argvi++;
|
||||
}
|
||||
|
||||
%typemap(argout) int [ANY] {
|
||||
AV * av = newAV();
|
||||
int i = 0,len = 0;
|
||||
len = $1_dim0;
|
||||
|
||||
for (i = 0; i < len ; i++) {
|
||||
SV* perlval = newSV(0);
|
||||
sv_setiv(perlval, (IV)$1[i]);
|
||||
av_push(av, perlval);
|
||||
}
|
||||
$result = newRV_noinc((SV *)av);
|
||||
sv_2mortal( $result );
|
||||
argvi++;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGTCL
|
||||
|
||||
%typemap(out) int [ANY] {
|
||||
int i, len, l;
|
||||
len = $1_dim0;
|
||||
|
||||
Tcl_Obj * list = Tcl_NewListObj(len, NULL);
|
||||
for(i=0; i < len; i++) {
|
||||
Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i]));
|
||||
}
|
||||
Tcl_SetObjResult(interp, list);
|
||||
}
|
||||
|
||||
%typemap(varout) int [ANY] {
|
||||
int i, len, l;
|
||||
len = $1_dim0;
|
||||
|
||||
Tcl_Obj * list = Tcl_NewListObj(len, NULL);
|
||||
for(i=0; i < len; i++) {
|
||||
Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj($1[i]));
|
||||
}
|
||||
|
||||
$result = list;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
%apply double *OUTPUT { double *distance, double *azimuth };
|
||||
|
@ -52,8 +133,10 @@
|
|||
%apply double *OUTPUT { double *longitude, double *latitude };
|
||||
%apply char *OUTPUT { char *locator_res };
|
||||
|
||||
#ifndef SWIG_CSTRING_UNIMPL
|
||||
/* longlat2locator */
|
||||
%cstring_bounded_output(char *locator_res, 13)
|
||||
#endif
|
||||
|
||||
%immutable confparams::name;
|
||||
%immutable confparams::label;
|
||||
|
@ -81,6 +164,10 @@
|
|||
%include <hamlib/rotlist.h>
|
||||
%include <hamlib/rotator.h>
|
||||
|
||||
%inline {
|
||||
typedef const char * const_char_string;
|
||||
}
|
||||
|
||||
/*
|
||||
* The Rig "class"
|
||||
*/
|
||||
|
|
|
@ -40,6 +40,9 @@ $rig->set_mode($Hamlib::RIG_MODE_CW, $Hamlib::RIG_PASSBAND_NORMAL);
|
|||
|
||||
print "ITU region:\t\t$rig->{state}->{itu_region}\n";
|
||||
print "Backend copyright:\t$rig->{caps}->{copyright}\n";
|
||||
print "Model:\t\t\t$rig->{caps}->{model_name}\n";
|
||||
print "Manufacturer:\t\t$rig->{caps}->{mfg_name}\n";
|
||||
print "Backend version:\t$rig->{caps}->{version}\n";
|
||||
$inf = $rig->get_info();
|
||||
|
||||
print "get_info:\t\t$inf\n";
|
||||
|
@ -62,6 +65,9 @@ print "get_channel status:\t$rig->{error_status} = ".Hamlib::rigerror($rig->{err
|
|||
|
||||
print "VFO:\t\t\t".Hamlib::rig_strvfo($chan->{vfo}).", $chan->{freq}\n";
|
||||
|
||||
$att = $rig->{caps}->{attenuator};
|
||||
print "Attenuators:\t\t@$att\n";
|
||||
|
||||
print "\nSending Morse, '73'\n";
|
||||
$rig->send_morse($Hamlib::RIG_VFO_A, "73");
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ def StartUp ():
|
|||
print "get_channel status:\t",my_rig.error_status
|
||||
|
||||
print "VFO:\t\t\t",Hamlib.rig_strvfo(chan.vfo),", ",chan.freq
|
||||
print "Attenuators:\t\t", my_rig.caps.attenuator
|
||||
|
||||
print "\nSending Morse, '73'"
|
||||
my_rig.send_morse(Hamlib.RIG_VFO_A, "73")
|
||||
|
|
|
@ -30,7 +30,6 @@ typedef struct Rig {
|
|||
} Rig;
|
||||
|
||||
typedef char * char_string;
|
||||
typedef const char * const_char_string;
|
||||
typedef channel_t * channel_t_p;
|
||||
typedef channel_t * const_channel_t_p;
|
||||
|
||||
|
@ -225,7 +224,9 @@ typedef channel_t * const_channel_t_p;
|
|||
*/
|
||||
%extend Rig {
|
||||
|
||||
#ifndef SWIG_CSTRING_UNIMPL
|
||||
%cstring_bounded_output(char *returnstr, MAX_RETURNSTR);
|
||||
#endif
|
||||
|
||||
Rig(int rig_model) {
|
||||
Rig *r;
|
||||
|
|
|
@ -29,8 +29,6 @@ typedef struct Rot {
|
|||
int do_exception;
|
||||
} Rot;
|
||||
|
||||
typedef const char * const_char_string;
|
||||
|
||||
%}
|
||||
|
||||
/*
|
||||
|
|
|
@ -36,6 +36,14 @@ puts "ITU_region:\t[$state cget -itu_region]"
|
|||
# The following works well also
|
||||
# puts ITU_region:[[my_rig cget -state] cget -itu_region]
|
||||
|
||||
set rigcaps [my_rig cget -caps]
|
||||
#set model [$rigcaps cget -model_name]
|
||||
puts "Model:\t\t[$rigcaps cget -model_name]"
|
||||
puts "Manufacturer:\t\t[$rigcaps cget -mfg_name]"
|
||||
puts "Backend version:\t[$rigcaps cget -version]"
|
||||
puts "Backend license:\t[$rigcaps cget -copyright]"
|
||||
puts "Attenuators:\t[$rigcaps cget -attenuator]"
|
||||
|
||||
puts "getinfo:\t[my_rig get_info]"
|
||||
|
||||
my_rig set_level "VOX" 1
|
||||
|
|
Ładowanie…
Reference in New Issue