diff --git a/tcl/Makefile.am b/tcl/Makefile.am new file mode 100644 index 000000000..c4798f26a --- /dev/null +++ b/tcl/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = @INCLUDES@ -I/usr/include/tcl8.2 + +LDFLAGS = -no-undefined -module -avoid-version +if HAMLIBTCL +lib_LTLIBRARIES = libhamlibtcl.la +#lib_LTLIBRARIES = @LTHAMLIBTCL@ +libhamlibtcl_la_SOURCES = hamlibtcl.c +#libhamlibtcl_la_LDFLAGS = -no-undefined -module -avoid-version +libhamlibtcl_la_LIBADD = ../src/libhamlib.la +#EXTRA_LTLIBRARIES = libhamlibtcl.la + +lib_LIBRARIES = libhamlibtcl.a +#lib_LIBRARIES = @LIBHAMLIBTCL@ +libhamlibtcl_a_SOURCES = hamlibtcl.c +libhamlibtcl_a_LIBADD = ../src/libhamlib.la +#EXTRA_LIBRARIES = libhamlibtcl.a +else +BUILT_SOURCES = hamlibtcl.c +endif + +noinst_SCRIPTS = tcltest.tcl +EXTRA_DIST = tcltest.tcl diff --git a/tcl/Makefile.in b/tcl/Makefile.in new file mode 100644 index 000000000..7904e303d --- /dev/null +++ b/tcl/Makefile.in @@ -0,0 +1,430 @@ +# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AR = @AR@ +AS = @AS@ +CC = @CC@ +CXX = @CXX@ +DLLTOOL = @DLLTOOL@ +DLL_PRELOAD = @DLL_PRELOAD@ +ECHO = @ECHO@ +EXEEXT = @EXEEXT@ +INCLTDL = @INCLTDL@ +LIBHAMLIBTCL = @LIBHAMLIBTCL@ +LIBLTDL = @LIBLTDL@ +LIBOBJS = @LIBOBJS@ +LIBTOOL = @LIBTOOL@ +LIBWINRADIO = @LIBWINRADIO@ +LN_S = @LN_S@ +LTHAMLIBTCL = @LTHAMLIBTCL@ +LTLIBWINRADIO = @LTLIBWINRADIO@ +MAKEINFO = @MAKEINFO@ +NET = @NET@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +RIGMATRIX = @RIGMATRIX@ +STRIP = @STRIP@ +VERSION = @VERSION@ +V_MAJOR = @V_MAJOR@ +V_MINOR = @V_MINOR@ +WINDRES = @WINDRES@ +WINRADIODEPS = @WINRADIODEPS@ +WINRADIOLNK = @WINRADIOLNK@ +hamlibdocdir = @hamlibdocdir@ + +INCLUDES = @INCLUDES@ -I/usr/include/tcl8.2 + +LDFLAGS = -no-undefined -module -avoid-version +@HAMLIBTCL_TRUE@lib_LTLIBRARIES = libhamlibtcl.la +#lib_LTLIBRARIES = @LTHAMLIBTCL@ +@HAMLIBTCL_TRUE@libhamlibtcl_la_SOURCES = hamlibtcl.c +#libhamlibtcl_la_LDFLAGS = -no-undefined -module -avoid-version +@HAMLIBTCL_TRUE@libhamlibtcl_la_LIBADD = ../src/libhamlib.la +#EXTRA_LTLIBRARIES = libhamlibtcl.la + +@HAMLIBTCL_TRUE@lib_LIBRARIES = libhamlibtcl.a +#lib_LIBRARIES = @LIBHAMLIBTCL@ +@HAMLIBTCL_TRUE@libhamlibtcl_a_SOURCES = hamlibtcl.c +@HAMLIBTCL_TRUE@libhamlibtcl_a_LIBADD = ../src/libhamlib.la +#EXTRA_LIBRARIES = libhamlibtcl.a +@HAMLIBTCL_FALSE@BUILT_SOURCES = hamlibtcl.c + +noinst_SCRIPTS = tcltest.tcl +EXTRA_DIST = tcltest.tcl +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../include/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(lib_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../include +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ +@HAMLIBTCL_TRUE@libhamlibtcl_a_DEPENDENCIES = ../src/libhamlib.la +@HAMLIBTCL_TRUE@libhamlibtcl_a_OBJECTS = hamlibtcl.$(OBJEXT) +LTLIBRARIES = $(lib_LTLIBRARIES) + +libhamlibtcl_la_LDFLAGS = +@HAMLIBTCL_TRUE@libhamlibtcl_la_DEPENDENCIES = ../src/libhamlib.la +@HAMLIBTCL_TRUE@libhamlibtcl_la_OBJECTS = hamlibtcl.lo +SCRIPTS = $(noinst_SCRIPTS) + +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/hamlibtcl.P +SOURCES = $(libhamlibtcl_a_SOURCES) $(libhamlibtcl_la_SOURCES) +OBJECTS = $(libhamlibtcl_a_OBJECTS) $(libhamlibtcl_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu tcl/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLIBRARIES: + +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) + +distclean-libLIBRARIES: + +maintainer-clean-libLIBRARIES: + +install-libLIBRARIES: $(lib_LIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \ + $(RANLIB) $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LIBRARIES)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libhamlibtcl.a: $(libhamlibtcl_a_OBJECTS) $(libhamlibtcl_a_DEPENDENCIES) + -rm -f libhamlibtcl.a + $(AR) cru libhamlibtcl.a $(libhamlibtcl_a_OBJECTS) $(libhamlibtcl_a_LIBADD) + $(RANLIB) libhamlibtcl.a + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +libhamlibtcl.la: $(libhamlibtcl_la_OBJECTS) $(libhamlibtcl_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libhamlibtcl_la_LDFLAGS) $(libhamlibtcl_la_OBJECTS) $(libhamlibtcl_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = tcl + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu tcl/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLIBRARIES install-libLTLIBRARIES +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLIBRARIES uninstall-libLTLIBRARIES +uninstall: uninstall-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(libdir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-libLTLIBRARIES \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLIBRARIES clean-compile clean-libtool \ + clean-libLTLIBRARIES clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLIBRARIES distclean-compile \ + distclean-libtool distclean-libLTLIBRARIES \ + distclean-tags distclean-depend distclean-generic \ + clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-libLTLIBRARIES maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \ +clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \ +install-libLIBRARIES mostlyclean-compile distclean-compile \ +clean-compile maintainer-clean-compile mostlyclean-libtool \ +distclean-libtool clean-libtool maintainer-clean-libtool \ +mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tcl/hamlibtcl.c b/tcl/hamlibtcl.c new file mode 100644 index 000000000..c61e0753d --- /dev/null +++ b/tcl/hamlibtcl.c @@ -0,0 +1,178 @@ +/* hamlib - (C) Frank Singleton 2000 (vk3fcs@ix.netcom.com) + * + * hamlibtcl.c - Copyright (C) 2001 Stephane Fillod + * This program defines the Hamlib API and rig capabilities structures that + * will be used for obtaining rig capabilities. TCL bindings. + * + * + * $Id: hamlibtcl.c,v 1.1 2001-06-20 06:02:56 f4cfe Exp $ + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include + +/* + * since there's no long long support in tcl API, + * freq_t is mapped to double object, which has enough + * significant digits for frequencies up to tens of GHz. + */ + + +int DoRig(ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); +int DoRigLib(ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]); + + +int +DoRigLib(ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *resultPtr; + int error; + char *subcmd; + + /* objc gives the number of "objects" = arguments to + the command */ + if (objc != 2 && objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "cmd ?model?"); + return TCL_ERROR; + } + + /* Process the arguments + objv is an array holding the arguments */ + + /* Use Tcl_GetIntFromObj to put an integer value + into a variable from the argument list */ + + subcmd = Tcl_GetString(objv[1]); + resultPtr = Tcl_GetObjResult(interp); + + /* TODO: make use of flex here! */ + + if (!strcasecmp(subcmd, "version")) { + Tcl_SetStringObj(resultPtr, hamlib_version, -1); + } else if (!strcasecmp(subcmd, "help")) { + Tcl_SetStringObj(resultPtr, "no help yet!", -1); + } else if (!strcasecmp(subcmd, "init")) { + rig_model_t model; + RIG *tcl_rig; + char rigcmd_name[16]; + static int rigcmd_cpt=0; + + error = Tcl_GetIntFromObj(interp, objv[2], (int*)&model); + if (error != TCL_OK) + return error; + tcl_rig = rig_init(model); + if (!tcl_rig) + return TCL_ERROR; + sprintf(rigcmd_name, "rig%d", rigcmd_cpt++); + Tcl_CreateObjCommand(interp, rigcmd_name, DoRig, + (ClientData)tcl_rig, (Tcl_CmdDeleteProc *)NULL); + Tcl_SetStringObj(resultPtr, rigcmd_name, -1); + } else { + return TCL_ERROR; + } + return TCL_OK; +} + +int +DoRig(ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *resultPtr; + int error; + char *subcmd; + RIG *tcl_rig = (RIG*)clientData; + + if (!tcl_rig) + return TCL_ERROR; + +#if 0 + /* objc gives the number of "objects" = arguments to + the command */ + if (!(objc == 2 || objc == 3)) { + Tcl_WrongNumArgs(interp, 1, objv, "var1 var2 ?var3?"); + return TCL_ERROR; + } +#endif + + /* Process the arguments + objv is an array holding the arguments */ + + /* Use Tcl_GetIntFromObj to put an integer value + into a variable from the argument list */ + + subcmd = Tcl_GetString(objv[1]); + resultPtr = Tcl_GetObjResult(interp); + + /* TODO: make use of flex here! */ + + if (!strcasecmp(subcmd, "open")) { + rig_open(tcl_rig); + return TCL_OK; + } else if (!strcasecmp(subcmd, "set_freq")) { + double d; + freq_t freq; + + error = Tcl_GetDoubleFromObj(interp, objv[2], &d); + if (error != TCL_OK) + return error; + freq = (freq_t)d; + + rig_set_freq(tcl_rig, RIG_VFO_CURR, freq); + return TCL_OK; + } else if (!strcasecmp(subcmd, "get_strength")) { + int strength; + + rig_get_strength(tcl_rig, RIG_VFO_CURR, &strength); + Tcl_SetIntObj(resultPtr, strength); + return TCL_OK; + } else if (!strcasecmp(subcmd, "close")) { + + rig_close(tcl_rig); + return TCL_OK; + } else if (!strcasecmp(subcmd, "cleanup")) { + + rig_cleanup(tcl_rig); + return TCL_OK; + } else { + return TCL_ERROR; + } + return TCL_OK; +} + + + +int Hamlib_Init(Tcl_Interp *interp) +{ + int ret; + + if ((ret=Tcl_PkgProvide(interp, "Hamlib", "1.0")) != TCL_OK) + return ret; + + /* Register the commands in the package */ + + Tcl_CreateObjCommand(interp, "rig", DoRigLib, + (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); + + return TCL_OK; +} + diff --git a/tcl/tcltest.tcl b/tcl/tcltest.tcl new file mode 100755 index 000000000..e2142f7e1 --- /dev/null +++ b/tcl/tcltest.tcl @@ -0,0 +1,19 @@ +#!/bin/sh +# the next line restarts using tclsh \ +exec tclsh "$0" "$@" + +load "../tcl/.libs/libhamlibtcl.so" Hamlib +#load "./hamlibtcl.so" Hamlib + +puts [rig version]\n + +# Init RIG_MODEL_DUMMY +set my_rig [rig init 1] +$my_rig open +$my_rig set_freq 145550000 +$my_rig get_strength +$my_rig close +$my_rig cleanup + + +exit 0