Initial release

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1165 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.4
Stéphane Fillod, F8CFE 2002-09-08 22:31:01 +00:00
rodzic bcdd5ad08c
commit dee8c252f4
7 zmienionych plików z 437 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,41 @@
# hamlibtcl, hamlibperl, etc. are temproray modules names
# They will be generated in separate subdirs in the future
#lib_LTLIBRARIES = @BINDING_LA@
#EXTRA_LTLIBRARIES = hamlibperl.la hamlibtcl.la
lib_LTLIBRARIES = hamlibperl.la hamlibtcl.la
INCLUDES = @INCLUDES@ -Dbool=char -I/usr/lib/perl/5.6.1/CORE -I@TCL_SRC_DIR@/generic
# Perl binding
#hamlibperl_la_INCLUDES = @INCLUDES@ -Dbool=char -I/usr/lib/perl/5.6.1/CORE
hamlibperl_la_SOURCES = hamlibperl_wrap.c
hamlibperl_la_LDFLAGS = -no-undefined -module
hamlibperl_la_LIBADD = ../src/libhamlib.la
hamlibperl_wrap.c: hamlib.swg
swig -perl5 -shadow @INCLUDES@ -o $@ $<
# Tcl binding
#hamlibtcl_la_INCLUDES = @INCLUDES@ -I@TCL_SRC_DIR@/generic
hamlibtcl_la_SOURCES = hamlibtcl_wrap.c
hamlibtcl_la_LDFLAGS = -no-undefined -module @TCL_LIB_SPEC@
hamlibtcl_la_LIBADD = ../src/libhamlib.la
hamlibtcl_wrap.c: hamlib.swg
swig -tcl @INCLUDES@ -o $@ $<
rig.swg: ../include/hamlib/rig.h ../include/hamlib/riglist.h
rotator.swg: ../include/hamlib/rotator.h ../include/hamlib/rotlist.h
hamlib.swg: ignore.swg rig.swg rotator.swg
EXTRA_DIST = hamlib.swg ignore.swg rig.swg rotator.swg
CLEANFILES = hamlibperl_wrap.c hamlib.pm hamlibtcl_wrap.c

Wyświetl plik

@ -0,0 +1,75 @@
%module hamlib
%{
/*
* Hamlib bindings - swig interface file
* Copyright (c) 2001,2002 by Stephane Fillod
*
* $Id: hamlib.swg,v 1.1 2002-09-08 22:31:01 fillods Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <hamlib/rig.h>
#include <hamlib/rotator.h>
%}
/*
* symbols that won't be wrapped
*/
%include "ignore.swg"
%include <hamlib/rig_dll.h>
%include <hamlib/riglist.h>
%include <hamlib/rig.h>
%include <hamlib/rotlist.h>
%include <hamlib/rotator.h>
/* needed because rig.swg and rotator.swg macros require identifiers like arg (no spaces) */
%header %{
typedef char * char_string;
typedef const char * const_char_string;
typedef channel_t * channel_t_p;
typedef channel_t * const_channel_t_p;
%}
/*
* The Rig "class"
*/
%include "rig.swg"
/*
* The Rot "class"
*/
%include "rotator.swg"
/*
* Put binding specific code in separate files
*
%include "perl.i"
%include "tcl.i"
%include "python.i"
%include "whatever.i"
*/

Wyświetl plik

@ -0,0 +1,48 @@
/* unsupported Hamlib's calls */
%ignore rig_debug;
/* useless macros */
%ignore _RIG_H;
%ignore _RIGLIST_H;
%ignore RIG_DUMMY;
%ignore RIG_BACKEND_DUMMY;
%ignore RIG_YAESU;
%ignore RIG_BACKEND_YAESU;
%ignore RIG_KENWOOD;
%ignore RIG_BACKEND_KENWOOD;
%ignore RIG_ICOM;
%ignore RIG_BACKEND_ICOM;
%ignore RIG_PCR;
%ignore RIG_BACKEND_PCR;
%ignore RIG_AOR;
%ignore RIG_BACKEND_AOR;
%ignore RIG_JRC;
%ignore RIG_BACKEND_JRC;
%ignore RIG_RADIOSHACK;
%ignore RIG_BACKEND_RADIOSHACK;
%ignore RIG_UNIDEN;
%ignore RIG_BACKEND_UNIDEN;
%ignore RIG_DRAKE;
%ignore RIG_BACKEND_DRAKE;
%ignore RIG_LOWE;
%ignore RIG_BACKEND_LOWE;
%ignore RIG_RACAL;
%ignore RIG_BACKEND_RACAL;
%ignore RIG_WJ;
%ignore RIG_BACKEND_WJ;
%ignore RIG_EK;
%ignore RIG_BACKEND_EK;
%ignore RIG_SKANTI;
%ignore RIG_BACKEND_SKANTI;
%ignore RIG_WINRADIO;
%ignore RIG_BACKEND_WINRADIO;
%ignore RIG_TENTEC;
%ignore RIG_BACKEND_TENTEC;
%ignore RIG_ALINCO;
%ignore RIG_BACKEND_ALINCO;
%ignore RIG_KACHINA;
%ignore RIG_BACKEND_KACHINA;
%ignore RIG_RPC;
%ignore RIG_BACKEND_RPC;
%ignore RIG_GNURADIO;
%ignore RIG_BACKEND_GNURADIO;

Wyświetl plik

@ -0,0 +1,19 @@
#!/usr/bin/perl
# make sure the module is there, hint: "ln -s .lib/hamlibperl.so hamlib.so"
use hamlib;
print "Version: $hamlib::hamlib_version\n";
print "FM: $hamlib::RIG_MODE_FM\n";
hamlib::rig_set_debug(5);
$rig = new hamlib::Rig($hamlib::RIG_MODEL_DUMMY);
$rig->open();
$rig->set_freq(12000000, $hamlib::RIG_VFO_A);
print "ITU region: $rig->{state}->{itu_region}\n";
print "Copyright: $rig->{caps}->{copyright}\n";
$rig->close();

146
bindings/rig.swg 100644
Wyświetl plik

@ -0,0 +1,146 @@
/*
* Hamlib bindings - Rig interface
* Copyright (c) 2001,2002 by Stephane Fillod
*
* $Id: rig.swg,v 1.1 2002-09-08 22:31:01 fillods Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
%inline %{
typedef struct Rig {
RIG *rig;
struct rig_caps *caps; /* shortcut to RIG->caps */
struct rig_state *state; /* shortcut to RIG->state */
} Rig;
%}
/*
* decalre wrapper method with one argument besides RIG* (no target vfo)
*/
#define METHOD1(f, t1) int f (t1 _##t1) \
{ return rig_##f(self->rig, _##t1); }
#define METHOD2(f, t1, t2) int f (t1 _##t1##_1, t2 _##t2##_2) \
{ return rig_##f(self->rig, _##t1##_1, _##t2##_2); }
/*
* decalre wrapper method with one argument besides RIG* and vfo
*/
#define METHOD1V(f, t1) int f (t1 _##t1, vfo_t vfo = RIG_VFO_CURR) \
{ return rig_##f(self->rig, vfo, _##t1); }
/*
* decalre wrapper method with two arguments besides RIG* and vfo
*/
#define METHOD2V(f, t1, t2) int f (t1 _##t1##_1, t2 _##t2##_2, vfo_t vfo = RIG_VFO_CURR) \
{ return rig_##f(self->rig, vfo, _##t1##_1, _##t2##_2); }
%extend Rig {
Rig(rig_model_t rig_model) {
Rig *r;
r = (Rig*)malloc(sizeof(Rig));
if (!r)
return NULL;
r->rig = rig_init(rig_model);
if (!r->rig) {
free(r);
return NULL;
}
/* install shortcuts */
r->caps = r->rig->caps;
r->state = &r->rig->state;
return r;
}
~Rig () {
rig_cleanup(self->rig);
free(self);
}
int open () {
return rig_open(self->rig);
}
int close () {
return rig_close(self->rig);
}
/* set methods */
METHOD1V(set_freq, freq_t)
METHOD2V(set_mode, rmode_t, pbwidth_t)
METHOD1(set_vfo, vfo_t)
METHOD1V(set_ptt, ptt_t)
METHOD1V(set_rptr_shift, rptr_shift_t)
METHOD1V(set_rptr_offs, shortfreq_t)
METHOD1V(set_ctcss_tone, tone_t)
METHOD1V(set_dcs_code, tone_t)
METHOD1V(set_ctcss_sql, tone_t)
METHOD1V(set_dcs_sql, tone_t)
METHOD1V(set_split_freq, freq_t)
METHOD2V(set_split_mode, rmode_t, pbwidth_t)
METHOD1V(set_split, split_t)
METHOD1V(set_rit, shortfreq_t)
METHOD1V(set_xit, shortfreq_t)
METHOD1V(set_ts, shortfreq_t)
METHOD2V(set_level, setting_t, value_t)
METHOD1V(set_ant, ant_t)
METHOD2V(set_func, setting_t, int)
METHOD1V(set_bank, int)
METHOD1V(set_mem, int)
METHOD2(set_parm, setting_t, value_t)
METHOD1(set_powerstat, powerstat_t)
METHOD1(set_channel, const_channel_t_p)
METHOD1(set_trn, int)
METHOD1(has_set_level, setting_t)
METHOD1(has_set_parm, setting_t)
METHOD1(has_set_func, setting_t)
METHOD1(reset, reset_t)
METHOD1V(send_dtmf, const_char_string)
// METHOD1V(recv_dtmf, char_string, int *length)
METHOD1V(send_morse, const_char_string)
METHOD1V(vfo_op, vfo_op_t)
METHOD2V(scan, scan_t, int)
METHOD1(has_scan, scan_t)
METHOD1(has_vfo_op, vfo_op_t)
METHOD1(passband_normal, rmode_t)
METHOD1(passband_narrow, rmode_t)
METHOD1(passband_wide, rmode_t)
METHOD1(ext_token_lookup, const_char_string) /* level & parm */
METHOD1(token_lookup, const_char_string) /* conf */
int set_conf_s(const char *name, const char *val) {
token_t tok = rig_token_lookup(self->rig, name);
/* FIXME: token not found */
return rig_set_conf(self->rig, tok, val);
}
int set_ext_parm_s(const char *name, value_t val) {
token_t tok = rig_ext_token_lookup(self->rig, name);
/* FIXME: token not found */
return rig_set_ext_parm(self->rig, tok, val);
}
int set_ext_level_s(const char *name, value_t val, vfo_t vfo = RIG_VFO_CURR) {
token_t tok = rig_ext_token_lookup(self->rig, name);
/* FIXME: token not found */
return rig_set_ext_level(self->rig, vfo, tok, val);
}
METHOD2(set_conf, token_t, const_char_string)
METHOD2(set_ext_parm, token_t, value_t)
METHOD2V(set_ext_level, token_t, value_t)
/* TODO: get_ext_parm_list, level, conf, .. */
/* TODO: all the get functions */
};

Wyświetl plik

@ -0,0 +1,87 @@
/*
* Hamlib bindings - Rotator interface
* Copyright (c) 2001,2002 by Stephane Fillod
*
* $Id: rotator.swg,v 1.1 2002-09-08 22:31:01 fillods Exp $
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
%inline %{
typedef struct Rot {
ROT *rot;
struct rot_caps *caps; /* shortcut to ROT->caps */
struct rot_state *state; /* shortcut to ROT->state */
} Rot;
%}
/*
* decalre wrapper method with 0,1,2 arguments besides ROT*
*/
#define ROTMETHOD0(f) int f () \
{ return rot_##f(self->rot); }
#define ROTMETHOD1(f, t1) int f (t1 _##t1) \
{ return rot_##f(self->rot, _##t1); }
#define ROTMETHOD2(f, t1, t2) int f (t1 _##t1##_1, t2 _##t2##_2) \
{ return rot_##f(self->rot, _##t1##_1, _##t2##_2); }
%extend Rot {
Rot(rot_model_t rot_model) {
Rot *r;
r = (Rot*)malloc(sizeof(Rot));
if (!r)
return NULL;
r->rot = rot_init(rot_model);
if (!r->rot) {
free(r);
return NULL;
}
/* install shortcuts */
r->caps = r->rot->caps;
r->state = &r->rot->state;
return r;
}
~Rot () {
rot_cleanup(self->rot);
free(self);
}
ROTMETHOD0(open)
ROTMETHOD0(close)
ROTMETHOD2(set_position, azimuth_t, elevation_t)
ROTMETHOD0(stop)
ROTMETHOD0(park)
ROTMETHOD1(reset, rot_reset_t)
ROTMETHOD2(move, int, int)
ROTMETHOD1(token_lookup, const_char_string) /* conf */
int set_conf_s(const char *name, const char *val) {
token_t tok = rot_token_lookup(self->rot, name);
/* FIXME: token not found */
return rot_set_conf(self->rot, tok, val);
}
ROTMETHOD2(set_conf, token_t, const_char_string)
/* TODO: get_ext_parm_list, level, conf, .. */
/* TODO: all the get functions */
};

Wyświetl plik

@ -0,0 +1,21 @@
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
load ".libs/hamlibtcl.so" Hamlib
puts $hamlib_version\n
# Init RIG_MODEL_DUMMY
Rig my_rig $RIG_MODEL_DUMMY
my_rig open
my_rig set_freq 145550000
# note: get_level may not be implemented yet!
puts [my_rig get_level $RIG_LEVEL_STRENGTH]
my_rig close
my_rig cleanup
exit 0