diff --git a/.gitignore b/.gitignore index 671f89b16..189feded2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ build-aux/ doc/hamlib.cfg doc/hamlib.info doc/stamp-vti +doc/hamlib.html doc/version.texi hamlib-*.tar.gz include/config.h diff --git a/Android.mk b/Android.mk index 438ffe761..95f82b78f 100644 --- a/Android.mk +++ b/Android.mk @@ -23,6 +23,7 @@ include $(TOP_PATH)/kenwood/Android.mk include $(TOP_PATH)/kit/Android.mk include $(TOP_PATH)/lowe/Android.mk include $(TOP_PATH)/m2/Android.mk +include $(TOP_PATH)/meade/Android.mk include $(TOP_PATH)/pcr/Android.mk include $(TOP_PATH)/prm80/Android.mk include $(TOP_PATH)/racal/Android.mk diff --git a/Makefile.am b/Makefile.am index a518a36a4..42373f927 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ SUBDIRS = macros include lib \ ## Static list of distributed directories. $(BACKEND_LIST) is dynamically ## assigned by 'configure' so list rig backends statically. DIST_SUBDIRS = macros include lib src c++ bindings tests doc android scripts\ - adat alinco aor barrett drake dorji dummy flexradio icom icmarine jrc\ + adat alinco aor barrett drake dorji dummy elad flexradio icom icmarine jrc\ kachina kenwood kit lowe pcr prm80 racal rft rs skanti tapr tentec\ tuner uniden wj yaesu winradio\ $(ROT_BACKEND_LIST) diff --git a/NEWS b/NEWS index e0595d4fa..139ebcfc2 100644 --- a/NEWS +++ b/NEWS @@ -5,8 +5,35 @@ Copyright (C) 2000-2018 Stephane Fillod, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net +Version 4.0 + 2019-??-?? + * API/ABI changes, advance ABI to 4 0 0. + * Add GPIO and GPION options for DCD. Jeroen Vreeken + * New backend: ELAD FDM DUO. Giovanni, HB9EIK. + Version 3.3 - 2018-??-?? + 2018-08-12 + * New models, R&S xk2100, TRXMAnager, Meade LX200 + * HTML manual is now generated at 'make dist' so users don't + need GNU Info tools installed. TNX Greg, N1DAM for the suggestion. + * Handle longer udev generated file names up to 512 characters + * Add debug time stamps with new '-Z' option and '--debug-time-stamps' + options to rigctl, rotctl, rigctld, and rotctld utilities. + * rigctld/rotctld continue working after serial or TCP device + disappears. + * Updates and fixes to FT-817, K3, IC-7300, AOR 3030, TM-D710, + OMNI VII, TH-D72, Flrig, TS-590, piHPSDR, TS-2000, and netrigctl. + * Update utility manual pages (section 1) and remove their reference + material from the Info manual so it only needs to be update in one + file. + * Add new general project manual pages (section 7) and edit the Info + manual to match. These should not change much so keeping them in + sync should not be too much of a burden. The Info manual may be + removed at some point in the future. + * Last planned release of the present API/ABI. Future releases will + require recompilation and relinking by client programs using the C + library interface (programs that only use the network daemons should + be unaffected). Version 3.2 2018-03-15 diff --git a/configure.ac b/configure.ac index c198523e5..7f0231809 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl however, the use of '~' should be fine as apt (others?) will treat dnl it as an earlier version than the actual release. TNX KA6MAL dnl PACKAGE_NAME + " " + PACKAGE_VERSION must not exceed 20 chars! AC_INIT([Hamlib], - [3.3~git], + [4.0~git], [hamlib-developer@lists.sourceforge.net], [hamlib], [http://www.hamlib.org]) @@ -49,15 +49,15 @@ dnl added to AC_CONFIG_FILES near the end of this file. See README.developer dnl Beware of duplication should a backend directory include both rig and dnl rotor definitions, e.g. "dummy". Optional backends will not be listed dnl here but will be added later, e.g. "winradio". -BACKEND_LIST="adat alinco aor barrett dorji drake dummy flexradio icom icmarine jrc kachina kenwood kit lowe pcr prm80 racal rft rs skanti tapr tentec tuner uniden wj yaesu" -ROT_BACKEND_LIST="amsat ars celestron cnctrk easycomm ether6 fodtrack gs232a heathkit m2 rotorez sartek spid ts7400 prosistel" +BACKEND_LIST="adat alinco aor barrett dorji drake dummy elad flexradio icom icmarine jrc kachina kenwood kit lowe pcr prm80 racal rft rs skanti tapr tentec tuner uniden wj yaesu" +ROT_BACKEND_LIST="amsat ars celestron cnctrk easycomm ether6 fodtrack gs232a heathkit m2 meade rotorez sartek spid ts7400 prosistel" dnl See README.release on setting these values # Values given to -version-info when linking. See libtool documentation. # Set them here to keep c++/Makefile and src/Makefile in sync. -ABI_VERSION=3 -ABI_REVISION=3 -ABI_AGE=1 +ABI_VERSION=4 +ABI_REVISION=0 +ABI_AGE=0 AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version]) AC_DEFINE_UNQUOTED([ABI_REVISION], [$ABI_REVISION], [Frontend ABI revision]) @@ -787,7 +787,9 @@ android/Makefile prosistel/Makefile dorji/Makefile barrett/Makefile -hamlib.pc]) +meade/Makefile +hamlib.pc +elad/Makefile]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am index a06d195af..9a6c6e5ff 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -2,13 +2,14 @@ EXTRA_DIST = hamlib.cfg index.doxygen hamlib.css footer.html \ Hamlib_design.eps Hamlib_design.png dist_man_MANS = man1/rigctl.1 man1/rigctld.1 man1/rigmem.1 man1/rigsmtr.1 \ - man1/rigswr.1 man1/rotctl.1 man1/rotctld.1 + man1/rigswr.1 man1/rotctl.1 man1/rotctld.1 man7/hamlib.7 \ + man7/hamlib-primer.7 man7/hamlib-utilities.7 htmldir = $(docdir)/html dist_html_DATA = Hamlib_design.png hamlib.html SRCDOCLST = ../src/rig.c ../src/rotator.c ../src/tones.c ../src/locator.c \ - ../src/event.c ../src/conf.c ../src/mem.c ../src/settings.c + ../src/event.c ../src/conf.c ../src/mem.c ../src/settings.c info_TEXINFOS = hamlib.texi hamlib_TEXINFOS = nutshell.texi getting_started.texi utility_programs.texi \ diff --git a/doc/README.man-pages b/doc/README.man-pages new file mode 100644 index 000000000..88434b3d2 --- /dev/null +++ b/doc/README.man-pages @@ -0,0 +1,155 @@ +Guidelines for updating and authoring new man pages. + + +Overview +======== + +The man pages are written in the roff formatting language. See roff(7) ("man +roff") for an overview. roff is implemented on modern Unix like systems by +groff (GNU roff) which is a suite of programs and macro definition files that +make up the roff system. + +Documentation written in roff can be transformed into a number of formats for +final publication. For the Hamlib project, the output formats are the classic +man(1) format to a terminal screen, HTML, and PDF. While groff includes a +number of macro pacakges suitable for a variety of document styles, Hamlib +source files are written using the man(7) macro package. The layout of Hamlib +man pages generally follow the format specified in man-pages(7). The macros +used in the man pages format is specified in groff_man(7). + +The use of mdoc from the BSD projects has been considered and may be used in +the future if the need arises. Conversely, the classic man macros are +reasonably well understood, fairly simple, easy to use, can be processed by a +wide range of tools, and fits the Hamlib philosophy of being as approachable +as possible. To be fair, mdoc is very comprehensive and would allow many more +formatting choices to be available for the various output formats. At some +point mdoc may well be the better choice. + +The latest versions of the manual pages referenced above may be found at: + + http://man7.org/linux/man-pages/dir_section_7.html + +For information on mdoc, see: + + http://mandoc.bsd.lv/ + + +Recommended Practices +===================== + +Sections +-------- + +The man pages are sorted into various sections depending on the part of the +system they document. For Hamlib, the man pages fall into one of three +categories. The placement is as follows: + + Section Hamlib subject domain + 1 Executables, rigctl, rotctl, etc. + 3 Hamlib library constants and functions. + 7 General Hamlib information. + +Macros and escapes +------------------ + +The use of man macros to mark up the roff source files is strongly encouraged. +In some cases, the use of lower level troff font escapes, such as "\fBxxx\fP", +is required, but should be used sparingly. Such escapes are hard to read and +not all editors can highlight the escape correctly. + +The default font for HTML and PDF is Roman (often Times Roman on the local +system) and rarely needs to be specified directly with the ".R" macro. Text +may be bolded using the ".B" macro or italicized using the ".I" macro. A set +of combination macros exist that combine alternating sequences of styled text +such as ".BR" for alternating Bold and Roman text. + +In the OPTIONS and COMMANDS sections of the utility pages there are complex +constructs of the form of: + + .BR M ", " set_mode " \(aq" \fIMode\fP "\(aq \(aq" \fIPassband\fP \(aq + +The result is that the command strings will be in Bold, the punctuation will +be in Roman, and the names of the variables will be in Italics using the low +level troff font escapes. Quoted strings are required to ensure spacing +between items as the ".BR" macro uses (and other combination macros) spaces to +separate its arguments. As you can see, the font escapes are hard to read as +they must be run up tight against the text. + +Special symbols such as copyright or trademark glyphs and styled quotation +marks do require roff escapes inlined with the text. Several such escapes +can be found in the Hamlib roff source files: + + Escape Description + \(aq ASCII single quote + \(oq Styled opening single quote + \(cq Styled closing single quote + \(lq Styled opening double quote + \(rq Styled closing double quote + \(co Copyright symbol + +Besides the macros documented in man(7), the following troff macros are used +in the Hamlib man pages: + + Macro Description + .br Line break (analogous to '\n' in C) + .sp Line break plus an additional blank line + .nf Do not justify following text (encloses the .MT block) + .fi Resume justification + +Structure +--------- + +In addition to the standard man page sections of NAME, SYNPOPSIS, etc., the +Hamlib utility (section 1) man pages add the sections COMMANDS, READLINE, +PROTOCOL, DIAGNOSTICS, COPYRIGHT, and COLOPHON depending on the individual +utility. + + +Layout Tips +=========== + +Keep in mind that roff documents are most often processed in a single pass, +i.e. the document processor reads the file from top to bottom and formats the +text per the macros and escapes found along the way. Anything that is not a +macro or an escape gets rendered into the output file and that includes blank +lines. As a result, best practice is to not include blank lines in the +running text. Instead use the ".PP" or ".IP" macros to indicate a paragraph +or an indented paragraph break. To provide vertical spac between elements of +the source document, a single '.' on a line will be discarded by the document +processor. This provides a way to visually separate paragraphs and headings. + +Note: While the man macro package recognizes ".LP" and ".P" as synonyms for +".PP", some tools may only recognize ".PP". One such tool is the older +'man2html' converter. + +Blank lines may be included as part of an example block placed between the +".EX" and ".EE" macros. Lines between these macros are rendered in HTML and +PDF as blocks of constant width text and should be verbatim input or output +from the shell, programs, or blocks of source code. + +Examples should be indented from the blocks of text. The ".RS 0.5i" macro is +used for indentation of normal text blocks while ".RS 1.0i" is used for +indented text blocks, such as a block indented using the ".TP" macro. For +each case the indented block must be followed by the ".RE" macro to return the +next block of text to the normal indentation level. + +Normal section headings use the ".SH" macro which provides for vertical space +between the previous text and the heading and also begins the next block of +running text. All text blocks must follow a heading. Headings are normally +composed of one word in all capital letters. + +Sub-headings use the ".SS" macro which provides vertical space above the +previous block of text and indents the sub-heading to about half the distance +from the left margin and the block of text that follows. Only one level of +sub-headings is provided. + + +Getting Help +============ + +If something is unclear on how to format a new or updated man page, simply +post your question to the mailing list: + + hamlib-developer@lists.sourceforge.net + +73! diff --git a/doc/getting_started.texi b/doc/getting_started.texi index c8fb24357..956982f8d 100644 --- a/doc/getting_started.texi +++ b/doc/getting_started.texi @@ -1,13 +1,13 @@ -There are several ways to obtain a working installation of Hamlib. In -the following sections discuss installing from a package manager, -building from source, and installing Hamlib project supplied binaries on -Microsoft Windows@registeredsymbol{}. +There are several ways to obtain a working installation of Hamlib. +The following sections discuss installing from a package manager, +building from source, and installing Hamlib project supplied binaries +on Microsoft Windows@registeredsymbol{}. @menu * Unix binary packages:: * Source options:: * Building from source:: -* MS Windows 32 binaries:: +* Microsft Windows binaries:: @end menu @node Unix binary packages @@ -31,17 +31,17 @@ the documentation for your chosen distribution be your guide. Distribution packages are most often official Hamlib releases and in some cases could be quite old and lacking support for newer radios or -rotors. In some cases support is improved in existing radio or rotor -back ends and bugs are fixed in newer releases. Often times to get -the improved support/bug fixes, building from source will be required. -Relax, it's not hard. :-) +rotators. In some cases support is improved in existing radio or +rotator back ends and bugs are fixed in newer releases. Often times +to get the improved support/bug fixes, building from source will be +required. Relax, it's not hard. :-) Source code is available as official releases, testing snapshots, daily development snapshots, and the bleeding edge of development -directly from the @url{http://git-scm.com/, Git} repository. As a -rule, even the bleeding edge tarballs should configure and compile -without error even though certain implementation work may be in -progress and may be incomplete or have errors. +directly from the @url{https://github.com/Hamlib/Hamlib, Git +repository}. As a rule, even the bleeding edge tarballs should +configure and compile without error even though certain implementation +work may be in progress and may be incomplete or have errors. @menu * Source releases:: @@ -56,9 +56,12 @@ progress and may be incomplete or have errors. @cindex Source, obtaining releases Official Hamlib source releases, commonly called @dfn{tarballs} can be -found on the @url{http://sourceforge.net/projects/hamlib/files/hamlib/, -SourceForge.net Hamlib files} Web page. The most recent release is -listed first. +found on the +@url{http://sourceforge.net/projects/hamlib/files/hamlib/, +SourceForge.net Hamlib files} Web page. As a convenience, release +archives are also mirrored at the +@url{https://github.com/Hamlib/Hamlib/releases, GitHub Hamlib +releases} page. The most recent release is listed first. @node Source snapshots @subsection Getting source snapshots @@ -66,20 +69,25 @@ listed first. @cindex Source, getting snapshots @cindex Source, obtaining snapshots @cindex Source, daily snapshots +@cindex Source, release candidates +@cindex Source, RC -Testing release candidates and daily snapshots of the development -repository are available via the World Wide Web from -@url{http://n0nb.users.sourceforge.net/, Hamlib Git daily snapshots}. -These are not official releases but are provided for testing new -features and bug fixes. +Testing release candidates (RCs) are posted during the period (often a +few weeks) before a planned release. Beginning with the 3.2 release, +RCs are hosted by the @url{https://github.com/Hamlib/Hamlib/releases, +GitHub release archive}. RCs are identifed by having a @i{~rc} +suffix. -Testing release snapshots are only posted for a few weeks before a -planned release. The daily development snapshot is made and posted -each day by around 1030 UTC. Daily snapshots @i{should} compile but -sometimes a bug creeps in that prevents compilation. If that should -happen, please report it to the -@email{hamlib-developer@@lists.sourceforge.net, hamlib-developer -mailing list}. +Daily snapshots of the development repository are available via the +World Wide Web from @url{http://n0nb.users.sourceforge.net/, Hamlib +Git daily snapshots}. These are not official releases but are +provided for testing new features and bug fixes. + +The daily development snapshot is made and posted each day by around +1030 UTC. Daily snapshots @i{should} compile but sometimes a bug +creeps in that prevents compilation. If that should happen, please +report it to the @email{hamlib-developer@@lists.sourceforge.net, +hamlib-developer mailing list}. @node Git clone @subsection Git repository @@ -102,6 +110,12 @@ To clone the repository use the following command: git clone git://git.code.sf.net/p/hamlib/code hamlib @end example +or: + +@example +git clone https://github.com/Hamlib/Hamlib.git +@end example + Odds are that you will want to run the above command in a sub directory of your home directory. The @file{hamlib} directory will be created by Git and the @dfn{master} branch will be checked out for you @@ -120,13 +134,13 @@ repository. @cindex Source, building from Building from source will be required for various reasons. Perhaps -only an older release is provided by your distribution, or you'd like -to test recent changes to Hamlib---either a specific back end or API -changes---and offer a report to the developers, or you'd like to take -part in development and offer your contribution to the project, or -you'd just like to learn how to build a relatively comprehensive +only an older release is provided by your distribution, or you would +like to test recent changes to Hamlib---either a specific back end or +API changes---and offer a report to the developers, or you'd like to +take part in development and offer your contribution to the project, +or you'd just like to learn how to build a relatively comprehensive package from source. Any is a good reason to build from the source -code. +code archive. Before going further, this manual assumes familiarity with working from the command prompt in a Linux/BSD/Unix like system's @dfn{shell} @@ -150,7 +164,7 @@ Let's get started. * Other make targets:: * Parallel build trees:: * Adding debugging symbols:: -* Compiling MS Windows 32:: +* Compiling Microsoft Windows:: @end menu @node Compiling source tarballs @@ -161,16 +175,16 @@ Let's get started. Before proceeding, it is essential to read the information in the files, @file{README}, @file{INSTALL}, and @file{README.betatester} supplied in the Hamlib @dfn{top-level} directory which will be named -something like @file{hamlib-3.0~git} where the latter part is -the release version. In this case the @samp{3.0~git} indicates this is -a development snapshot of the Git master branch. These files -provide detailed information for compiling Hamlib and will vary some -from release to release. +something like @file{hamlib-3.3~git} where the latter part is the +release version. In this case the @samp{3.3~git} indicates this is a +development snapshot of the Git master branch. These files provide +detailed information for compiling Hamlib and will vary some from +release to release. -Compiling from a source tarball whether it is an official release or -a testing or daily development snapshot follows the same set of commands, -known as the @dfn{three step} which are each run from the top-level -directory: +Compiling from a source tarball whether it is an official release or a +testing or daily development snapshot follows the same set of +commands, known as the @dfn{three step} which are each run from the +top-level directory: @example ./configure @@ -192,7 +206,7 @@ sudo make install The @command{./configure} command examines your system and checks it for any packages that are required or good to have options for compiling Hamlib. The leading @file{./} tells the shell to only run -the @command{configure} command found in the current directory. It's +the @command{configure} command found in the current directory. It is always possible that a @command{configure} command could be lurking elsewhere and we don't want to run that! @@ -216,9 +230,9 @@ LinuxCommand.org reference above. @end quotation Of course, things are usually complicated a bit by options and Hamlib -is no exception. The good news is that the defaults, i.e. no options, -work well in most situations. Options are needed to enable the -compilation of certain portions of Hamlib such as the language +is no exception. The good news is that the defaults, i.e., no +options, work well in most situations. Options are needed to enable +the compilation of certain portions of Hamlib such as the language bindings. Optional features usually require that more development tools are installed. The @file{INSTALL}, and @file{README.betatester} files in the Hamlib top-level directory will have details on the @@ -249,16 +263,20 @@ exist during installation as will several other directories in it. Installing in your home directory means that @dfn{root}, or superuser (administrator) privileges are not required when running @command{make install}. On the other hand, some extra work will need to be done so -other programs can use the library. (TODO: describe this in an -appendix). +other programs can use the library. + +@ignore +(TODO: describe library hackery in an appendix). +@end ignore Another useful option is @samp{--help} which will give a few screens full of options for @command{configure}. If in a desktop environment the scroll bar can be used to scroll back up through the output. In either a terminal or a virtual console Linux supports the -@key{Shift-PageUp} key combination to scroll back up. As luck would -have it, @key{Shift-PageDown} can be used to scroll down toward the -end of the output and the shell prompt. +@key{Shift-PageUp} key combination to scroll back up. Converesely +@key{Shift-PageDown} can be used to scroll down toward the end of the +output and the shell prompt (Shift-UpArrow/Shift-DownArrow may also +work to scroll one line at a time). After a fair amount of time, depending on your computer, and a lot of screen output, @command{configure} will finish its job. So long as @@ -349,19 +367,9 @@ as root from any directory. @quotation Note Subsequent installations of Hamlib will not need to have -@command{ldconfig} run after each installation so long as no new -backend libraries nor a newer major version of Hamlib were installed. - -A developer adding a new backend (see @file{README.developer}) will -need to run @command{ldconfig} for the new back end library to be -found by the library loader (this refers a new back end, i.e. a -sibling to the existing Icom, Kenwood, Yaesu, etc.@: back ends, not a -new model in an existing back end). - -Likewise, any time a new back end appears in a source tarball, -@command{ldconfig} will need to be run for the library loader to find -it. There is no harm running @command{ldconfig} after each run of -@command{make install}. +@command{ldconfig} run after each installation if a newer major +version of Hamlib was not installed, i.e. when recompiling the same +version during development. @end quotation On some distributions a bit of configuration will be needed before @@ -425,7 +433,10 @@ To remove even the generated @file{Makefile}s, run @command{make distclean} from the top-level directory. After this target is run, @command{configure} will need to be run again to regenerate the @file{Makefile}s. This command may not be as useful as the -@file{Makefile}s do not take up much space. +@file{Makefile}s do not take up much space, however it can be useful +for rebuilding the @file{Makefile}s when modifying a +@file{Makefile.am} or @file{confgure.ac} during build system +development. @node Parallel build trees @subsection Parallel build trees @@ -458,16 +469,14 @@ Run: @command{../hamlib/configure CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0"} @end example -from a build directory intended for a debugging build. +from a sibling build directory intended for a debugging build. The @samp{-ggdb3} option tells the C compiler, this case the GNU C -Compiler, @command{gcc}, to add special symbols useful for -@command{gdb}. The @samp{-O0} option tells @command{gcc} to turn off +Compiler, @command{gcc}, to add special symbols useful for GDB, the +GNU debugger. The @samp{-O0} option tells @command{gcc} to turn off all optimizations which will make it easier to follow some variables that might otherwise be optimized away. @samp{CFLAGS} and -@samp{CXXFLAGS} may be set independently for each compiler (sadly, a -bug in the build system source file in Hamlib 1.2.15.3 and earlier did -not preserve @samp{CXXFLAGS}). +@samp{CXXFLAGS} may be set independently for each compiler. @quotation Note There are a number compiler options available for controlling debugging @@ -475,13 +484,13 @@ symbols and setting optimization levels. Please consult the compiler's manual for all the details. @end quotation -@node Compiling MS Windows 32 -@subsection Compiling for MS Windows 32 bit architectures -@cindex Compiling for MS Windows 32 -@cindex MS Windows 32, compiling +@node Compiling Microsoft Windows +@subsection Compiling for Microsoft Windows +@cindex Compiling for Microsoft Windows +@cindex Microsoft Windows, compiling Currently compiling is done on a Debian 8 (Jessie) virtual machine -using @url{http://www.mingw.org/, MinGW32}. @file{README.build-win32} +using @url{http://www.mingw.org/, MinGW}. @file{README.build-win32} in the @file{scripts} directory has details on how this is accomplished. @@ -489,23 +498,28 @@ Work is ongoing to correct build issues in the @url{http://www.cygwin.com/, Cygwin} environment running on MS Windows. -@node MS Windows 32 binaries -@section Pre-compiled binaries for MS Windows 32 bit architectures -@cindex Pre-compiled binaries for MS Windows 32 -@cindex MS Windows 32, compiled binaries -@cindex MS Windows 32, pre-compiled binaries +@node Microsft Windows binaries +@section Pre-compiled binaries for Microsoft Windows +@cindex Pre-compiled binaries for Microsoft Windows +@cindex Microsoft Windows, compiled binaries +@cindex Microsoft Windows, pre-compiled binaries -Pre-compiled binaries for MS Windows 32 bit architectures (Windows NT -and newer) are available for both official releases and daily -development snapshots. Official releases are available through the +Pre-compiled binaries for Microsoft Windows 32 and 64 bit +architectures (Windows NT and newer) are available for both official +releases and daily development snapshots. Official releases are +available through the @url{http://sourceforge.net/projects/hamlib/files/hamlib/, -SourceForge.net file download service}. Daily development snapshots -are available from @url{http://n0nb.users.sourceforge.net/}. +SourceForge.net file download service}. As an alternative, official +releases are also available though the +@url{https://github.com/Hamlib/Hamlib/releases, Hamlib archive at +GitHub}. Daily development snapshots are available from +@url{http://n0nb.users.sourceforge.net/}. Beginning with the Hamlib 1.2.15.3 release a self-extracting installer is available. Among its features are selecting which portions of Hamlib are installed. The @env{PATH} environment variable will need -to be set manually per the included @file{README.win32-bin} file. +to be set manually per the included @file{README.w32-bin} or +@file{README.w64-bin} file. Daily development snapshots feature both a .ZIP archive and the self extracting installer. diff --git a/doc/hamlib.texi b/doc/hamlib.texi index a383244fa..1845c09ce 100644 --- a/doc/hamlib.texi +++ b/doc/hamlib.texi @@ -12,7 +12,7 @@ updated @value{UPDATED}), which is a development effort to provide a consistent programming interface for programmers wanting to incorporate radio and rotor control into their programs. -Copyright @copyright{} 2013 Nate Bargmann +Copyright @copyright{} 2013,2018 Nate Bargmann @quotation Permission is granted to copy, distribute and/or modify this document under diff --git a/doc/man1/rigmem.1 b/doc/man1/rigmem.1 index 2f413102f..6c66e7c72 100644 --- a/doc/man1/rigmem.1 +++ b/doc/man1/rigmem.1 @@ -39,7 +39,7 @@ from the command line only. . .PP Keep in mind that Hamlib is BETA level software. While a lot of backend -libraries lack complete rig support, the basic functions are usually well +libraries lack complete radio support, the basic functions are usually well supported. . .PP @@ -84,15 +84,15 @@ Set radio serial speed to .I baud rate. .IP -Uses maximum serial speed from rig backend capabilities as the default. +Uses maximum serial speed from radio backend capabilities as the default. . .TP .BR \-c ", " \-\-civaddr = \fIid\fP Use .I id -as the CI-V address to communicate with the rig. +as the CI-V address to communicate with the radio. .IP -Only useful for Icom and some Ten-Tec rigs. +Only useful for Icom and some Ten-Tec radios. .IP .BR Note : The @@ -243,7 +243,7 @@ if an error was returned by .B 3 the .B Hamlib -backend has no memory support implemented and/or the rig has no memory access +backend has no memory support implemented and/or the radio has no memory access available. . . diff --git a/doc/man1/rigsmtr.1 b/doc/man1/rigsmtr.1 index 155be8778..f7205fb4a 100644 --- a/doc/man1/rigsmtr.1 +++ b/doc/man1/rigsmtr.1 @@ -35,7 +35,7 @@ rigsmtr \- measure S-Meter vs azimuth using Hamlib .B rigsmtr uses .B Hamlib -to control a rig to measure S-Meter value versus antenna azimuth. +to control a radio to measure S-Meter value versus antenna azimuth. . .PP It rotates the antenna from minimum azimuth to maximum azimuth. @@ -46,12 +46,13 @@ and the corresponding S-Meter level in dB relative to S9 are then printed on .BR stdout . . .PP -To work correctly, rigsmtr needs a rig that could measure S-Meter and a Hamlib -backend that is able to retrieve it, connected to a Hamlib supported rotator. +To work correctly, rigsmtr needs a radio that could measure S-Meter and a +Hamlib backend that is able to retrieve it, connected to a Hamlib supported +rotator. . .PP Keep in mind that Hamlib is BETA level software. While a lot of backend -libraries lack complete rig support, the basic functions are usually well +libraries lack complete radio support, the basic functions are usually well supported. . .PP @@ -96,15 +97,15 @@ Set radio serial speed to .I baud rate. .IP -Uses maximum serial speed from rig backend capabilities as the default. +Uses maximum serial speed from radio backend capabilities as the default. . .TP .BR \-c ", " \-\-civaddr = \fIid\fP Use .I id -as the CI-V address to communicate with the rig. +as the CI-V address to communicate with the radio. .IP -Only useful for Icom and some Ten-Tec rigs. +Only useful for Icom and some Ten-Tec radios. .IP .BR Note : The @@ -231,7 +232,7 @@ if an error was returned by . .TP .B 3 -if the rig doesn't have the required capabilities. +if the radio doesn't have the required capabilities. . . .SH EXAMPLE diff --git a/doc/man1/rigswr.1 b/doc/man1/rigswr.1 index 7a892a3be..521f28161 100644 --- a/doc/man1/rigswr.1 +++ b/doc/man1/rigswr.1 @@ -75,7 +75,7 @@ needs a radio that can measure VSWR and a backend that supports reading VSWR from the radio. .PP Keep in mind that Hamlib is BETA level software. While a lot of backend -libraries lack complete rig support, the basic functions are usually well +libraries lack complete radio support, the basic functions are usually well supported. . .PP @@ -120,14 +120,14 @@ Set radio serial speed to .I baud rate. .IP -Uses maximum serial speed from rig backend capabilities as the default. +Uses maximum serial speed from radio backend capabilities as the default. .TP .BR \-c ", " \-\-civaddr = \fIid\fP Use .I id -as the CI-V address to communicate with the rig. +as the CI-V address to communicate with the radio. .IP -Only useful for Icom and some Ten-Tec rigs. +Only useful for Icom and some Ten-Tec radios. .IP .BR Note : The diff --git a/doc/man7/hamlib-primer.7 b/doc/man7/hamlib-primer.7 new file mode 100644 index 000000000..dea2ee5af --- /dev/null +++ b/doc/man7/hamlib-primer.7 @@ -0,0 +1,838 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" +.\" For layout and available macros, see man(7), man-pages(7), groff_man(7) +.\" Please adjust the date whenever revising the manpage. +.\" +.\" Please keep this file in sync with doc/getting_started.texi +.\" +.TH HAMLIB-PRIMER "7" "2018-05-27" "Hamlib" "Hamlib Information Manual" +. +. +.SH NAME +. +hamlib-primer \- compiling and using the radio and rotator control library +. +. +.SH DESCRIPTION +. +There are several ways to obtain a working installation of Hamlib. +. +The following sections discuss installing from a package manager, building +from source, and installing Hamlib project supplied binaries on Microsoft +Windows\*R. +. +. +.SS Installing binary packages on Linux and BSD +. +The easiest way to install a released version of Hamlib on a Linux based +distribution or a BSD variant is through the provided +.IR "package manager" . +. +While package managers vary according to the distribution (it's easy to lump +BSD variants in this group too) their end goal is to provide ready to use +software packages. +. +Since such a wide variety of package managers exist, it is best to recommend +that the documentation for your chosen distribution be your guide. +. +. +.SS A variety of Hamlib sources +. +Distribution packages are most often official Hamlib releases and in some +cases could be quite old and lacking support for newer radios or rotators. +. +In some cases support is improved in existing radio or rotator back ends and +bugs are fixed in newer releases. +. +Often times to get the improved support/bug fixes, building from source will +be required. +. +Relax, it's not hard. :-) +. +.PP +Source code is available as official releases, testing snapshots, daily +development snapshots, and the bleeding edge of development directly from the +.UR https://github.com/Hamlib/Hamlib +Git repository +.UE . +. +As a rule, even the bleeding edge tarballs should configure and compile +without error even though certain implementation work may be in progress and +may be incomplete or have errors. +. +. +.SS Getting released source +. +. +Official Hamlib source releases, commonly called +.I tarballs +can be +found on the +.UR http://sourceforge.net/projects/hamlib/files/hamlib/ +SourceForge.net Hamlib files +.UE +Web page. +. +As a convenience, release archives are also mirrored at the +.UR https://github.com/Hamlib/Hamlib/releases +GitHub Hamlib releases +.UE +page. +. +The most recent release is listed first. +. +. +.SS Getting source snapshots +. +Testing release candidates (RCs) are posted during the period (often a few +weeks) before a planned release. +. +Beginning with the 3.2 release, RCs are hosted by the +.UR https://github.com/Hamlib/Hamlib/releases +GitHub release archive +.UE . +. +RCs are identifed by having a +.I ~rc +suffix. +. +.PP +Daily snapshots of the development repository are available via the World Wide +Web from +.UR http://n0nb.users.sourceforge.net/ +Hamlib Git daily snapshots +.UE . +. +These are not official releases but are provided for testing new features and +bug fixes. +. +.PP +The daily development snapshot is made and posted each day by around 1030 UTC. +. +Daily snapshots +.I should +compile but sometimes a bug creeps in that prevents compilation. +. +If that should happen, please report it to the +.MT hamlib-developer@@lists.sourceforge.net +hamlib-developer mailing list +.ME . +. +. +.SS Git repository +. +The source repository can be +.I cloned +which copies the repository to your computer including its entire history, +branches, and release tag information. +. +In other words, once the +.BR git "(1) " clone +command is finished a complete copy of the Hamlib development will be on your +computer. +. +You can do quite a lot with this as nothing is hidden from view since the +entire history of Hamlib is right there all the way from the very first commit +to the present. +. +None of the meta-data is hidden away on some central server. +. +.PP +To clone the repository use the following command: +. +.sp +.RS 0.5i +.EX +git clone https://git.code.sf.net/p/hamlib/code hamlib +.EE +.RE +. +.PP +or: +.sp +.RS 0.5i +.EX +git clone https://github.com/Hamlib/Hamlib.git +.EE +.RE +. +.PP +. +Odds are that you will want to run the above command in a sub directory of +your home directory. +. +The +.I hamlib +directory will be created by Git and the +.I master +branch will be checked out for you as the +.IR "working copy" . +. +The master branch is one of several branches used in Hamlib development. +. +It is the main branch of new features and bug fixes. +. +The working copy will be the latest revision of every file at the time of the +clone. +. +Later updates from the developers will require using another Git command to +update your local repository. +. +. +.SS Building from source +. +Building from source will be required for various reasons. +. +Perhaps only an older release is provided by your distribution, or you would like +to test recent changes to Hamlib\(emeither a specific back end or API +changes\(emand offer a report to the developers, or you would like to take part in +development and offer your contribution to the project, or you would just like to +learn how to build a relatively comprehensive package from source. +. +Any is a good reason to build from the source code archive. +. +.PP +Before going further, this manual assumes familiarity with working from the +command prompt in a Linux/BSD/Unix like system's +.I shell +environment, either in a +.I virtual console +(a text only screen with no graphics) or in a +.I terminal +in a desktop environment +.RB ( xterm , +.BR rxvt , +.BR konsole , +.BR gnome\-terminal , +.BR xfce4\-terminal , +.BR terminal , +etc.). +. +If this is new to you, take some time and read up on using the shell. +. +A good tutorial can be found at +.UR http://linuxcommand.org/ +LinuxCommand.org +.UE +which also offers an in-depth book that can be purchased or downloaded for no +cost (the Hamlib project is not associated with nor has any interest in the +sale of this book, it just looks like a very good effort on the part of its +author). +. +.PP +Let's get started. +. +. +.SS Compiling source tarballs +. +Before proceeding, it is essential to read the information in the files, +.IR README , +.IR INSTALL , +and +.I README.betatester +supplied in the Hamlib +.I top-level +directory which will be named +something like +.I hamlib-3.3~git +where the latter part is the release version. +. +In this case the +.I 3.3~git +indicates this is a development snapshot of the Git master branch. +. +These files provide detailed information for compiling Hamlib and will vary +some from release to release. +. +.PP +Compiling from a source tarball whether it is an official release or a testing +or daily development snapshot follows the same set of commands, known as the +.I three step +which are each run from the top-level directory: +. +.sp +.RS 0.5i +.EX +\&./configure +make +sudo make install +.EE +.RE +. +.SS configure +. +The +.IB ./ configure +command examines your system and checks it for any packages that are required +or good to have options for compiling Hamlib. +. +The leading +.I ./ +tells the shell to only run the +.B configure +command found in the current directory. +. +It is always possible that a +.B configure +command could be lurking elsewhere and we don't want to run that! +. +.PP +Run: +. +.sp +.RS 0.5i +.EX +\&./configure +.EE +.RE +. +.PP +from the top-level directory. +. +.IP +.BR Note : +Some distributions are configured so commands can only be run from directories +listed in the +.B PATH +environment variable. +. +The +.I ./ +is necessary or the +.B configure +command will not be run as the +.I current directory +(defined as +.IR . ) +is not in the +.BR PATH . +. +This is considered a default security feature so that only programs provided +by the distribution are run. +. +.B PATH +can be modified for your own session, but that is a topic for the +LinuxCommand.org reference above. +. +.PP +Of course, things are usually complicated a bit by options and Hamlib is no +exception. +. +The good news is that the defaults, i.e., no options, work well in most +situations. +. +Options are needed to enable the compilation of certain portions of Hamlib +such as the language bindings. +. +Optional features usually require that more development tools are installed. +. +The +.I INSTALL +and +.I README.betatester +files in the Hamlib top-level directory will have details on the options +available for that release. +. +.PP +A useful option is +.B \-\-prefix +which tells +.B configure +where in the file system hierarchy Hamlib should be installed. +. +If it is not given, Hamlib will be installed in the +.I /usr/local +file system hierarchy. +. +Perhaps you want to install to your home directory instead: +. +.sp +.RS 0.5i +.EX +\&./configure \-\-prefix=$HOME/local +.EE +.RE +. +.IP +.BR Note : +For practice you may wish to start out using the +.BR \-\-prefix = \fI$HOME/local\fP +option to install the Hamlib files into your home directory and avoid +overwriting any version of Hamlib installed into the system directories. +. +The code examples in the remainder of this manual will assume Hamlib has been +installed to +.IR $HOME/local . +. +.PP +All of the files will be installed in the +.I local +directory of your home directory. +. +.I local +will be created if it does not exist during installation as will several other +directories in it. +. +Installing in your home directory means that +.IR root , +or superuser (administrator) privileges are not required when running +.BR "make install" . +. +On the other hand, some extra work will need to be done so other programs can +use the library. +. +.\" (TODO: describe library hackery in an appendix). +. +.PP +Another useful option is +.B \-\-help +which will give a few screens full of options for +.BR configure . +. +If in a desktop environment the scroll bar can be used to scroll back up +through the output. +. +In either a terminal or a virtual console Linux supports the Shift\-PageUp key +combination to scroll back up. +. +Conversely, Shift\-PageDown can be used to scroll down toward the end of the +output and the shell prompt (Shift\-UpArrow/Shift\-DownArrow may also work to +scroll one line at a time). +. +.PP +After a fair amount of time, depending on your computer, and a lot of screen +output, +.B configure +will finish its job. +. +So long as the few lines previous to the shell prompt don't say \(lqerror\(rq +or some such failure message Hamlib is ready to be compiled. +. +If there is an error and all of the required packages listed in +.I README.betatester +have been installed, please ask for help on the +.MT hamlib\-developer@@lists.sourceforge.net +hamlib-developer mailing list +.ME . +. +. +.SS make +. +The +.BR make (1) +command is responsible for running the +.I compiler +which reads the source files and from the instructions it finds in them writes +.I object +files which are the binary instructions the CPU of a computer can execute. +. +.B make +then calls the +.I linker +which puts the object files together in the correct order to create the Hamlib +library files and its executable programs. +. +.PP +Run: +. +.sp +.RS 0.5i +.EX +make +.EE +.RE +. +.PP +from the top-level directory. +. +.PP +Any error that causes +.B make +to stop early is cause for a question to the +.MT hamlib\-developer@@lists.sourceforge.net +hamlib-developer mailing list +.ME . +. +.PP +In general +.B make +will take longer than +.B configure +to complete its run. +. +As it is a system command, and therefore found in the +.BR PATH , +prefixing +.B make +with +.I ./ +will cause a \(lqcommand not found\(rq error from the shell. +. +. +.SS make install +. +Assuming that you have not set the installation prefix to your home directory, +root (administrator) privileges will be required to install Hamlib to the +system directories. +. +Two popular methods exist for gaining root privileges, +.BR su (1) +and +.BR sudo (8). +. +.B sudo +is probably the most popular these days, particularly when using the +.UR http://www.ubuntu.com +Ubuntu +.UE +family of distributions. +. +.PP +Run: +. +.sp +.RS 0.5i +.EX +sudo make install +.EE +.RE +. +.PP +as root from the top-level directory. +. +.PP +Running +.B make install +will call the installer to put all of the newly compiled files and other files +(such as this document) in predetermined places set by the +.B \-\-prefix +option to +.B configure +in the directory hierarchy (yes, this is by design and +.B make +is not just flinging files any old place!). +. +.PP +A lot of screen output will be generated. +. +Any errors will probably be rather early in the process and will likely be +related to your +.I username +not having write permissions in the system directory structure. +. +. +.SS ldconfig +. +Once the installation is complete one more step is required if Hamlib has +never been installed from a local build before. +. +The +.B ldconfig +command tells the system library loader where to find the newly installed +Hamlib libraries. +. +It too will need to be run with root privileges: +. +.PP +Run: +. +.sp +.RS 0.5i +.EX +sudo ldconfig +.EE +.RE +. +.PP +as root from any directory. +. +.PP +.BR Note : +Subsequent installations of Hamlib will not need to have +.B ldconfig +run after each installation if a newer version of Hamlib was not installed, +i.e. when recompiling the same version during development. +. +.PP +On some distributions a bit of configuration will be needed before +.B ldconfig +will add locally compiled software to its database. +. +Please consult your distribution's documentation. +. +. +.SS Bootstrapping from a \(aqgit clone\(aq +. +Choosing to build from from a +.B git clone +requires a few more development tools (notice a theme here?) as detailed in +.IR README.developer . +. +The most critical will be the GNU Autotools +.RB ( autoconf , +.BR automake , +.BR libtool , +and more) from which the build system consisting of +.BR configure , +the various +.IR Makefile.in s +throughout the directory structure, and the final +.IR Makefile s +are generated. +. +.PP +In the top-level directory is the +.B bootstrap +script from which the build system is +.IR bootsrapped\(emthe +process of generating the Hamlib build system from +.I configure.ac +and the various +.IR Makefile.am s. +. +At its completion the +.B configure +script will be present to configure the build system. +. +.PP +Next +.B configure +is run with any needed build options +.RB ( "configure \-\-help" +is useful) to enable certain features or provide paths for locating needed +build dependencies, etc. +. +Environment variables intended for the preprocessor and/or compiler may also +be set on the +.B configure +command line. +. +.PP +After the configuration is complete, the build may proceed with the +.B make +step as for the source tarballs above. +. +Or +.B configure \-\-help +may be run, and +.B configure +run again with specific options in which case the +.IR Makefile s +will be regenerated and the build can proceed with the new configuration. +. +. +.SS Other make targets +. +Besides +.BR "make install" , +other +.I targets +exist when running +.BR make . +. +Running +.B make clean +from the top-level directory removes all of the generated object and +executable files generated by running +.B make +freeing up considerable disk space. +. +.PP +.BR Note : +During development of individual source files, it is not necessary to +run +.B make clean +each time before +.BR make . +. +Simply run +.B make +and only the modified file(s) and any objects that depend on them will be +recompiled. +. +This speeds up development time considerably. +. +.PP +To remove even the generated +.IR Makefile s, +run +.B make distclean +from the top-level directory. +. +After this target is run, +.B configure +will need to be run again to regenerate the +.IR Makefile s. +. +This command may not be as useful as the +.IR Makefile s +do not take up much space, however it can be useful for rebuilding the +.IR Makefile s +when modifying a +.I Makefile.am +or +.I confgure.ac +during build system development. +. +. +.SS Parallel build trees +. +One feature of the GNU build system used by Hamlib is that the object files +can be kept in a directory structure separate from the source files. +. +While this has no effect on the +.B make +targets described above, it does help the developer find files in the source +tree! +. +One such way of using parallel builds is described in +.IR README.developer . +. +.PP +Parallel builds can be very useful as one build directory can be configured +for a release and another build directory can be configured for debugging with +different options passed to +.B configure +from each directory. +. +The generated +.IR Makefile s +are unique to each build directory and will not interfere with each other. +. +. +.SS Adding debugging symbols +. +When additional debugging symbols are needed with, for example, the GNU +Debugger, +.BR gdb , +the needed compiler and linker options are passed as environment variables. +. +.PP +Run: +.sp +.RS 0.5i +.EX +\&../hamlib/configure CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0" +.EE +.RE +. +.PP +from a sibling build directory intended for a debugging build. +. +.PP +The +.B \-ggdb3 +option tells the C compiler, in this case the GNU C Compiler, +.BR gcc , +to add special symbols useful for GDB, the GNU debugger. +. +The +.B -O0 +option tells +.B gcc +to turn off all optimizations which will make it easier to follow some +variables that might otherwise be optimized away. +. +.B CFLAGS +and +.B CXXFLAGS +may be set independently for each compiler. +. +.PP +.BR Note : +There are a number compiler options available for controlling debugging +symbols and setting optimization levels. +. +Please consult the compiler's manual for all the details. +. +. +.SS Compiling for Microsoft Windows +. +Currently compiling is done on a Debian 8 (Jessie) virtual machine using +.UR http://www.mingw.org +MinGW +.UE . +.I README.build-win32 +in the +.I scripts +directory has details on how this is accomplished. +. +. +.SS Pre-compiled binaries for Microsoft Windows +. +Pre-compiled binaries for Microsoft Windows 32 and 64 bit architectures +(Windows NT and newer) are available for both official releases and daily +development snapshots. +. +Official releases are available through the +.UR http://sourceforge.net/projects/hamlib/files/hamlib/ +SourceForge.net file download service +.UE . +. +As an alternative, official releases are also available though the +.UR https://github.com/Hamlib/Hamlib/releases +Hamlib archive at GitHub +.UE . +. +Daily development snapshots are available from the +.UR http://n0nb.users.sourceforge.net/ +daily snapshots page +.UE . +. +.PP +Beginning with the Hamlib 1.2.15.3 release a self-extracting installer is +available. +. +Among its features are selecting which portions of Hamlib are installed. +. +The +.B PATH +environment variable will need to be set manually per the included +.I README.w32-bin +or +.I README.w64-bin +file. +. +.PP +Daily development snapshots feature both a .ZIP archive and the self +extracting installer. +. +.PP +Bug reports and questions about these archives should be sent to the +.MT hamlib-developer@@lists.sourceforge.net +hamlib-developer mailing list +.ME . +. +. +.SH COPYING +. +This file is part of Hamlib, a project to develop a library that simplifies +radio and rotator control functions for developers of software primarily of +interest to radio amateurs and those interested in radio communications. +. +.PP +Copyright \(co 2001-2018 Hamlib Group (various contributors) +. +.PP +This is free software; see the file COPYING for copying conditions. There is +NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +. +. +.SH SEE ALSO +. +.BR git (1), +.BR hamlib (7), +.BR ldconfig (8), +.BR make (1), +.BR su (1), +.BR sudo (8) +. +. +.SH COLOPHON +. +Links to the Hamlib Wiki, Git repository, release archives, and daily snapshot +archives: +.IP +.UR http://www.hamlib.org +hamlib.org +.UE . diff --git a/doc/man7/hamlib-utilities.7 b/doc/man7/hamlib-utilities.7 new file mode 100644 index 000000000..8b369c08f --- /dev/null +++ b/doc/man7/hamlib-utilities.7 @@ -0,0 +1,835 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" +.\" For layout and available macros, see man(7), man-pages(7), groff_man(7) +.\" Please adjust the date whenever revising the manpage. +.\" +.\" Please keep this file in sync with doc/utility-programs.texi +.\" +.TH HAMLIB-UTILITIES "7" "2018-05-27" "Hamlib" "Hamlib Information Manual" +. +. +.SH NAME +. +hamlib-utilties \- radio and rotator control utilities of Hamlib +. +. +.SH DESCRIPTION +. +Included with the Hamlib distribution are several utility programs. +. +Besides providing a way for developers to test new code and bug fixes, the +programs also offer a reference implementation for interfacing to the Hamlib +library functions both through the +.B C +.SM API +(Application Programming Interface) and offering a network accessible +.SM API. +. +.PP +This page summarizes the two test programs, +.BR rigctl (1) +for testing radio back ends and +.BR rotctl (1) +for testing rotator back ends and the two network daemons, +.BR rigctld (1) +and +.BR rotcltd (1) +for radio and rotator access via network sockets. +. +Also included are three demonstation utilities, +.BR rigmem (1), +.BR rigsmtr (1), +and +.BR rigswr (1) +which provide functional examples of how Hamlib may be used to accomplish +various tasks. +. +. +.SH rigctl +. +.BR rigctl (1) +is the most frequently used Hamlib utility. +. +As the other +.I ctl +utilities share many of the same characteristics, much of the introductory +information presented in this section is applicable to the other utility +programs. +. +. +.SS Introduction to rigctl +. +Most likely the first of the Hamlib utility programs that is used is +.BR rigctl (1). +. +rigctl is a character based interactive program and a command line program +able to set or query a radio's value with a single command. +. +rigctl is invoked from a shell command prompt with various options and +additional commands. +. +.PP +In its most simple use as a +.I "command line" +program, rigctl is used to set frequency and mode by typing commands after any +rigctl options: +. +.sp +.RS 0.5i +.EX +rigctl F 14205000 +.br +rigctl M USB 2400 +.EE +.RE +. +.PP +and then query those values: +. +.sp +.RS 0.5i +.EX +rigctl f +.br +rigctl m +.EE +.RE +. +.PP +Entering +.I "interactive mode" +is a simple matter of not placing any commands after any rigctl options: +. +.sp +.RS 0.5i +.EX +rigctl +.EE +.RE +. +.PP +Entering interactive mode allows successive commands to be entered without +exiting rigctl. +. +Recent additions to rigctl allow command editing and history recall through +use of the +.UR https://tiswww.case.edu/php/chet/readline/rltop.html +Readline +.UE +library. +. +.PP +Interactive mode is indicated by the spartan prompt: +. +.sp +.RS 0.5i +.EX +Rig command: +.EE +.RE +. +.PP +Commands are given at the prompt and follow the general rule that upper case +letters set a value and lower case letters query a value: +. +.sp +.RS 0.5i +.EX +Rig command: M +.br +Mode: USB +.br +Passband: 2500 +.sp +Rig command: m +.br +Mode: USB +.br +Passband: 2500 +.sp +Rig command: +.EE +.RE +. +.PP +An additional prompt is printed when more information is required by the +command. +. +For \f(CWM\fP above, rigctl prompted for the \f(CWMode\fP and \f(CWPassband\fP +values. +. +For \f(CWm\fP above, rigctl returned the \f(CWMode\fP and \f(CWPassband\fP +values without further prompts. +. +The command prompt is returned after each command invocation. +. +.PP +The above examples invoked rigctl without specifying a radio model. +. +This is a feature where the Hamlib internal radio model 1 +.I dummy +is used instead. +. +The dummy radio provides a way to test Hamlib functions without the need for +actual radio hardware. +. +However, to develop the Hamlib backend capability for a given radio, having +the actual radio connected to the computer is necessary for debugging. +. +.PP +For example, to quickly set frequency on an Elecraft K3: +. +.sp +.RS 0.5i +.EX +rigctl -m 229 -r /dev/rig F 3900000 +.EE +.RE +. +.PP +and to query the frequency and then mode: +. +.sp +.RS 0.5i +.EX +rigctl -m 229 -r /dev/rig f +.br +3900000 +.sp +rigctl -m 229 -r /dev/rig m +.br +LSB +.br +2000 +.EE +.RE +. +.PP +.BR Note : +the returned values do not have the prompt strings associated with interactive +mode as shown above. +. +.PP +The +.B \-m +option takes a numeric value that corresponds to a given radio back end model. +. +The +.B \-r +option takes the path to the port device on +.SM POSIX +and the device name on Microsoft Windows. +. +.PP +.BR Note : +A complete list of supported radio models may be seen by use of the +.B -l +option: +. +.sp +.RS 0.5i +.EX +rigctl -l +.br + Rig # Mfg Model Version Status +.br + 1 Hamlib Dummy 0.5 Beta +.br + 2 Hamlib NET rigctl 0.3 Beta +.br + 101 Yaesu FT-847 0.5 Beta +.br + 103 Yaesu FT-1000D 0.0.6 Alpha +.br +\&. +.br +\&. +.br +\&. +.br + 2702 Rohde&Schwarz EB200 0.1 Untested +.br + 2801 Philips/Simoco PRM8060 0.1 Alpha +.br + 2901 ADAT www.adat.ch ADT-200A 1.36 Beta +.EE +.RE +. +.PP +The list is long so use \f(CWShift\-PageUp\fP/\f(CWShift\-PageDown\fP on +Linux, \f(CWScrollLock\fP then \f(CWPageUp\fP/\f(CWPageDown\fP on Free BSD, or +use the scrollbar to the virtual terminal window +.RB ( cmd +window on Microsoft Windows) or the output can be piped to +.BR more (1) +or +.BR less (1), +e.g. \(lq\f(CWrigctl -l | more\fP\(rq to scroll back up the list. +. +The list is sorted numerically by model number since Hamlib 1.2.15.1. +. +Model numbers of a manufacturer/protocol family are grouped together. +. +. +.SS rigctl reference +. +The complete reference for rigctl can be found in the +.BR rigctl (1) +manual page. +. +. +.SH rotctl +. +Identical in function to +.BR rigctl (1), +.BR rotctl (1) +provides a means for testing Hamlib functions useful for rotator control and +QTH (Maidenhead gridsquare system, see +.UR https://en.wikipedia.org/wiki/Maidenhead_Locator_System +Maidenhead Locator System +.UE ) +locator computations. +. +As rotators have a much narrower scope than radios, there are fewer command +line options and commands for rotctl. +. +. +.SS Introduction to rotctl +. +.BR rotctl (1) +is a character based interactive program and a command line program able to +set or query a rotator's value with a single command. +. +rotctl is invoked from a shell command prompt with various options and +additional commands. +. +.PP +In its most simple use as a +.I "command line" +program, rotctl is used to set azimuth position and (optionally) elevation by +typing commands after any rotctl options: +. +.sp +.RS 0.5i +.EX +rotctl P 145.0 23.0 +.br +rotctl M 8 25 +.EE +.RE +. +.PP +and then query those values: +. +.sp +.RS 0.5i +.EX +rotctl p +.EE +.RE +. +.PP +Entering +.I "interactive mode" +is a simple matter of not placing any commands after any rotctl options: +. +.sp +.RS 0.5i +.EX +rotctl +.EE +.RE +. +.PP +Entering interactive mode allows successive commands to be entered without +exiting rotctl. +. +Interactive mode allows for command editing and history recall through the use +of the +.UR https://tiswww.case.edu/php/chet/readline/rltop.html +Readline +.UE +library. +. +.PP +Interactive mode is indicated by the spartan prompt: +. +.sp +.RS 0.5i +.EX +Rotator command: +.EE +.RE +. +.PP +Commands are given at the prompt: +. +.sp +.RS 0.5i +.EX +Rotator command: M +.br +Direction: 16 +.br +Speed: 60 +.sp +Rotator command: p +.br +Azimuth: 11.352000 +.br +Elevation: 0.000000 +.sp +Rotator command: p +.br +Azimuth: 27.594000 +.br +Elevation: 0.000000 +.sp +Rotator command: +.EE +.RE +. +.PP +An additional prompt is printed when more information is required by the +command. +. +For \f(CWM\fP above, rotctl prompted for the \f(CWDirection\fP and +\f(CWSpeed\fP values. +. +For \f(CWp\fP above, rotctl returned the \f(CWAzimuth\fP and \f(CWElevation\fP +values without further prompts. +. +The command prompt is returned after each command invocation. +. +.PP +The above examples invoked rotctl without specifying a rotator model. +. +This is a feature where the Hamlib internal rotator model 1 +.I dummy +is used instead. +. +The dummy rotator provides a way to test Hamlib functions without the need for +actual rotator hardware. +. +However, to develop back end capability for a given rotator, having the actual +controller connected to the computer is necessary for debugging. +. +.PP +For example, to quickly set position for RotorEZ: +. +.sp +.RS 0.5i +.EX +rotctl -m 401 -r /dev/rotor P 100.0 0.0 +.EE +.RE +. +.PP +and to query the position: +. +.sp +.RS 0.5i +.EX +rotctl -m 401 -r /dev/rotor p +.br +100.000000 +.br +0.000000 +.EE +.RE +. +.PP +The returned values do not have the prompt strings associated with interactive +mode as shown above. +. +.PP +The +.B -m +option takes a numeric value that corresponds to a given rotator back end model. +. +The +.B -r +option takes the path to the port device on +.SM POSIX +or the device name on Microsoft Windows. +. +.PP +.BR Note : +A complete list of supported rotator models may be seen by use of the +.B -l +option: +. +.sp +.RS 0.5i +.EX +rotctl -l +.br + Rot # Mfg Model Version Status +.br + 1 Hamlib Dummy 0.5 Beta +.br + 2 Hamlib NET rotctl 0.3 Beta +.br + 201 Hamlib EasycommI 0.3 Beta +.br + 202 Hamlib EasycommII 0.3 Beta +.br +\&. +.br +\&. +.br +\&. +.br + 1201 AMSAT IF-100 0.1 Untested +.br + 1301 LA7LKA ts7400 0.1 Beta +.br + 1401 Celestron NexStar 0.1 Untested +.EE +.RE +. +.PP +The list is long so use \f(CWShift\-PageUp\fP/\f(CWShift\-PageDown\fP on +Linux, \f(CWScrollLock\fP then \f(CWPageUp\fP/\f(CWPageDown\fP on Free BSD, or +use the scrollbar to the virtual terminal window +.RB ( cmd +window on Microsoft Windows) or the output can be piped to +.BR more (1) +or +.BR less (1), +e.g. \(lq\f(CWrotctl -l | more\fP\(rq to scroll back up the list. +. +The list is sorted numerically by model number since Hamlib 1.2.15.1. +. +Model numbers of a manufacturer/protocol family are grouped together. +. +. +.SS rotctl reference +. +The complete reference for rotctl can be found in the +.BR rotctl (1) +manual page. +. +. +.SH rigctld +. +The +.BR rigctld (1) +program is a network server that accepts the familiar commands of +.BR rigctl (1) +and provides the response data over a +.SM TCP/IP +network socket to an application. +. +In this manner an application can access a rigctld instance from nearly +anywhere (caveat, no security is currently provided by rigctld). +. +Applications using rigctld do not link directly to Hamlib nor use its C API. +. +. +.SS Introduction to rigctld +. +.BR rigctld (1) +communicates to a client through a +.SM TCP +network socket using text commands shared with +.BR rigctl (1). +. +The protocol is simple; commands are sent to rigctld on one line and rigctld +responds to +.B get +commands with the requested values, one per line, when successful, otherwise, +it responds with one line +.B RPRT +.IR x , +where +.I x +is a negative number indicating the Hamlib error code. +. +Commands that do not return values respond with the line +.B RPRT +.IR x , +where +.I x +is zero when successful, otherwise a negative number indicating the Hamlib +error code. +. +Each line is terminated with a newline, +.IR \en , +character. +. +This protocol is primarily for use by the +.B NET rigctl +(radio model 2) backend. +. +.PP +A separate Extended Response protocol extends the above behavior by echoing +the received command string as a header, any returned values as a key: value +pair, and the +.B RPRT +.I x +string as the end of response marker which includes the Hamlib success or +failure value. +. +Consider using this protocol for clients that will interact with +rigctld directly through a TCP network socket. +. +.PP +Multiple radios can be controlled on different TCP ports by use of multiple +rigctld processes each listening on a unique TCP port. +. +It is hoped that rigctld will be especially useful for client authors using +languages such as +.UR http://www.perl.org/ +Perl +.UE , +.UR http://www.python.org/ +Python +.UE , +.UR http://php.net/ +PHP +.UE , +.UR http://www.ruby-lang.org/en/ +Ruby +.UE , +.UR http://www.tcl.tk/ +TCL +.UE , +and others. +. +. +.SS rigctld reference +. +The complete reference for rigctld can be found in the +.BR rigctld (1) +manual page. +. +. +.SH rotctld +. +The +.BR rotctld (1) +program is a network server that accepts the familiar commands of +.BR rotctl (1) +and provides the response data over a \f(CWTCP/IP\fP network socket to an +application. +. +In this manner an application can access a rotctld instance from nearly +anywhere (caveat, no security is currently provided by rotctld). +. +Applications using rotctld do not link directly to Hamlib nor use its C API. +. +. +.SS Introduction to rotctld +. +.BR rotctld (1) +communicates to a client through a +.SM TCP +network socket using text commands shared with +.BR rotctl (1). +. +The protocol is simple, commands are sent to rotctld on one line and +rotctld responds to +.B get +commands with the requested values, one per line, when successful, otherwise, +it responds with one line +.B RPRT +.IR x , +where +.I x +is a negative number indicating the Hamlib error code. +. +Commands that do not return values respond with the line +.B RPRT +.IR x , +where +.I x +is zero when successful, otherwise a negative number indicating +the Hamlib error code. +. +Each line is terminated with a newline, +.I \en +character. +. +This protocol is primarily for use by the +.B NET rotctl +(rotator model 2) backend. +. +.PP +A separate Extended Response protocol extends the above behavior by echoing +the received command string as a header, any returned values as a key: value +pair, and the +.B RPRT +.I x +string as the end of response marker which includes the Hamlib success or +failure value. +. +Consider using this protocol for clients that will interact with +rotctld directly through a TCP network socket. +. +.PP +Multiple rotators can be controlled on different TCP ports by use of multiple +rotctld processes each listening on a unique TCP port. +. +It is hoped that rotctld will be especially useful for client authors using +languages such as +.UR http://www.perl.org/ +Perl +.UE , +.UR http://www.python.org/ +Python +.UE , +.UR http://php.net/ +PHP +.UE , +.UR http://www.ruby-lang.org/en/ +Ruby +.UE , +.UR http://www.tcl.tk/ +TCL +.UE , +and others. +. +. +.SS rotctld reference +. +The complete reference for rotctld can be found in the +.BR rotctld (1) +manual page. +. +. +.SH rigmem +. +.B rigmem +may be used to backup and restore memory of radio transceivers and receivers. +. +. +.SS Introduction to rigmem +. +Backup and restore memory of radio transceivers and receivers. +.B rigmem +accepts +.IR command s +from the command line only. +. +. +.SS rigmem reference +. +The complete reference for rigmem can be found in the +.BR rigmem (1) +manual page. +. +. +.SH rigsmtr +. +.B rigsmtr +uses +.B Hamlib +to control a radio to measure S-Meter value versus antenna azimuth. +. +. +.SS Introduction to rigsmtr +. +rigsmtr rotates the antenna from minimum azimuth to maximum azimuth. +Every second, or +.I time_step +if specified in seconds, it retrieves the signal strength. Azimuth in degrees +and the corresponding S-Meter level in dB relative to S9 are then printed on +.BR stdout . +. +.PP +To work correctly, rigsmtr needs a radio that could measure S-Meter and a Hamlib +backend that is able to retrieve it, connected to a Hamlib supported rotator. +. +. +.SS rigsmtr reference +. +The complete reference for rigsmtr can be found in the +.BR rigsmtr (1) +manual page. +. +. +.SH rigswr +. +.B rigswr +may be used to measure VSWR vs frequency. +. +. +.SS Introduction to rigswr +. +rigswr uses Hamlib to control a radio to measure VSWR (Voltage Standing +Wave Ratio) over a frequency range. + +It scans frequencies from +.I start_freq +to +.I stop_freq +with an optional increment of +.I freq_step +(default step is 100 kHz). +. +All values must be entered as an integer in Hertz (cycles per second). + +.BR Note : +rigswr assumes that +.I start_freq is less than or equal to +.IR stop_freq . +. +If it is greater, rigswr will exit without doing anything. +. +.PP +For each frequency, rigswr transmits at 25% of total POWER during 0.5 second +in CW mode and reads VSWR. +. +.PP +Frequency and the corresponding VSWR are then printed on stdout. +. +.PP +To work correctly, rigswr needs a radio that can measure VSWR and a +Hamlib backend that supports reading VSWR from the radio. +. +. +.SS rigswr reference +. +The complete reference for rigswr can be found in the +.BR rigswr (1) +manual page. +. +. +.SH COPYING +. +This file is part of Hamlib, a project to develop a library that simplifies +radio and rotator control functions for developers of software primarily of +interest to radio amateurs and those interested in radio communications. +. +.PP +Copyright \(co 2001-2018 Hamlib Group (various contributors) +. +.PP +This is free software; see the file COPYING for copying conditions. There is +NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +. +. +.SH SEE ALSO +. +.BR less (1), +.BR more (1), +.BR rigctl (1), +.BR rigctld (1), +.BR rotctl (1), +.BR rotctld (1), +.BR rigmem (1), +.BR rigsmtr (1), +.BR rigswr (1), +.BR hamlib (7), +.BR hamlib-primer (7) +. +. +.SH COLOPHON +. +Links to the Hamlib Wiki, Git repository, release archives, and daily snapshot +archives: +.IP +.UR http://www.hamlib.org +hamlib.org +.UE . diff --git a/doc/man7/hamlib.7 b/doc/man7/hamlib.7 new file mode 100644 index 000000000..58988ed83 --- /dev/null +++ b/doc/man7/hamlib.7 @@ -0,0 +1,345 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" +.\" For layout and available macros, see man(7), man-pages(7), groff_man(7) +.\" Please adjust the date whenever revising the manpage. +.\" +.\" Please keep this file in sync with doc/nutshell.texi +.\" +.TH HAMLIB "7" "2018-05-21" "Hamlib" "Hamlib Information Manual" +. +. +.SH NAME +. +hamlib \- radio and rotator control library +. +. +.SH DESCRIPTION +. +The +.BR "Ham Radio Control Libraries" , +.B Hamlib +for short, is a development effort to provide a consistent interface for +programmers wanting to incorporate radio and rotator control in their +programs. +. +.PP +Hamlib is not a complete user application, rather, it is a software layer +intended to make controlling various radios and other amateur radio station +(shack) hardware much easier. +. +Hamlib will allow authors of software such as logging programs, digital +communications programs, or those wanting to develop the ultimate radio +control software to concentrate on the user interface and the basic function +of the program rather than radio control. +. +Hamlib consists of several parts, the programming library, utility programs, +and library interfaces to other programming languages. +. +.PP +Most recent amateur radio transceivers allow external control of their +functions through a serial interface. +. +Unfortunately, control commands are not always consistent across a +manufacturer's product line and each manufacturer's product line differs +greatly from its competitors. +. +.PP +Hamlib attempts to solve this problem by presenting a +.I virtual radio +to the programmer by providing an interface to actions such as setting a given +Variable Frequency Oscillator's (VFO) frequency, setting the operating mode, +querying the radio of its current status and settings, and giving the +application a list of a given radio's capabilities. +. +Unfortunately, what can be accomplished by Hamlib is limited by the radios +themselves and some offer very limited capability. +. +.PP +Other devices, such as antenna rotators, can be placed into the Hamlib control +scheme. +. +Other recent developments include network interface servers and a USB +interface capability. +. +Language bindings are provided for +.BR C ", " C++ ", " Perl ", " Python ", " Lua " and " TCL +(more to come). +. +. +.SS Overview +. +Hamlib is a +.I front end +library providing a +.B C +language Application Programming Interface (API) to programmers wishing to +integrate radio or rotator control in their applications. +. +Hamlib presents a +.I virtual radio +or +.I virtual rotator +that is a consistent interface to an application despite wide differences in +radio and rotator interfaces and capabilities. +. +.PP +The front end library uses a number of +.I back end +libraries to translate from the front end to the various individual radio and +rotator models. +. +A back end library handles conversion of the front end variables to the format +needed by the radio or rotator device it controls. +. +The back end libraries are generally grouped by manufacturer and in some cases +by a common control protocol. +. +.PP +Hamlib also provides an interface library for each of several common +.I scripting +languages such as +.UR http://www.perl.org +.B Perl +.UE , +.UR http://www.python.org +.B Python +.UE , +.UR https://www.lua.org +.B Lua +.UE , +and +.UR http://www.tcl.tk +.B TCL +.UE . +. +These language +.I bindings +are +generated through the use of +.UR http://www.swig.org +.B SWIG +.UE , +a parser/generator for multiple language interfaces to a +.B C +library. +. +A natively generated +.B C++ +language interface is also provided. +. +.PP +Besides the C and supplemental APIs, Hamlib also provides a pair of network +daemons that provide a text command based API for controlling an attached +radio or rotator through a +.BR TCP / IP +network connection. +. +The daemons then handle the interface to the Hamlib C API. +. +.PP +More than one type of device, radio or rotator, may be controlled at a +time, however, there is generally a limit of one device per serial port +or other port. +. +. +.SS Hamlib project information +. +The Hamlib Project was founded by Frank Singleton, VK3FCS/KM5WS in July 2000. +. +Shortly after Stephane Fillod, F8CFE, joined Frank on the Hamlib project and +the API and implementation development led to a reasonable level of maturity +in a few years. +. +A major milestone was reached when Hamlib 1.2.0 was released in March 2004. +. +The API and Application Binary Interface (ABI) interfaces have remained stable +since that time up to the latest release of 3.2 in early 2018. +. +.PP +Development continues through the major version number +.RI 3. x +series and beyond. +. +While some API tweaks are planned, ABI compatibility with the prior +.RI 1.2. x +releases remains a priority. +. +Other goals include streamlining the build system (done), improving the SWIG +generated language bindings (done), improving the overall documentation (this +man page with more in progress), and other updates as warranted. +. +.PP +The Project is hosted by +.UR https://sourceforge.net +SourceForge.net +.UE +at the +.UR https://sourceforge.net/projects/hamlib/ +Hamlib project page +.UE . +. +As +.UR https://github.com +GitHub +.UE +has become a very popular project hosting site, Hamlib also has a dedicated +.UR https://github.com/Hamlib/Hamlib +GitHub project page +.UE . +. +GitHub also hosts the +.UR http://www.hamlib.org +hamlib.org +.UE +Web site and the +.UR https://github.com/Hamlib/Hamlib/wiki +Hamlib Wiki +.UE . +. +.PP +Development discussion and most user support take place on the +.UR https://sourceforge.net/p/hamlib/mailman/ +hamlib-developer mailing list +.UE . +While there are +.UR https://sourceforge.net/p/hamlib/discussion/ +SourceForge.net discussion forums +.UE , +they are rarely used and not as closely read by the developers as the mailing +list. +. +.PP +For +.IR "source code management" , +the project uses +.UR http://git-scm.com/ +.B Git +.UE , +a fast, distributed content tracker. +. +Among its features is that every developer has the complete Hamlib +development history available locally. +. +For more information on using Git, see +.BR hamlib\-git (7). +. +.IP +.BR Note : +while a canonical Git repository is hosted at SourceForge, its availability is +not essential to continued development although development work flows would +change temporarily. +. +Several developers find the GitHub Web interface easier to use and lately +development has centered around GitHub rather than SourceForge. +. +. +.SS Applications using Hamlib +. +A number of application developers have taken advantage of Hamlib's +capabilities to implement radio and/or rotator control. +. +While not exhaustive, a list is maintained at the Hamlib Wiki, +.UR https://github.com/Hamlib/Hamlib/wiki/Applications-and-Screen-Shots +Applications/Screenshots +.UE . +Developers are encouraged to request their applications be added to the +gallery by way of the hamlib-developer mailing list. +. +. +.SS Using Hamlib with your program +. +As with other Free Software projects, Hamlib relies heavily on copyleft +licensing to encourage development contributions and provide an open +atmosphere for development. +. +Hamlib's source code is released under two +licenses, the +.B Lesser General Public License +(LGPL) for the library portion, and the +.B General Public License +(GPL) for the utility programs. +. +.PP +The LGPL allows the library to be used (linked) by programs regardless of +their individual license. +. +However, any contributions to the library source remain under copyleft which +means that the library source code may not be used in violation of the terms +of the LGPL. +. +.PP +The utility program source files are released under the GPL. +. +Any direct use of these sources must be in a form that complies with the terms +of the GPL. +. +Concepts learned by studying these sources for the purpose of understanding +the Hamlib API is not covered nor prohibited by the GPL, however, directly +copying GPL sources into any work that is incompatible with the terms of the +GPL is prohibited. +. +. +.SS Radios with a clone capability +. +Hamlib's focus is on controlling radios that employ a port and command +protocol for setting frequency, mode, VFO, PTT, etc. +. +Most VHF/UHF transceivers do not employ such control capability but do provide +for cloning the memory contents from radio to another of the same model. +. +A related project, +.UR http://chirp.danplanet.com +CHIRP +.UE , +aims to support radios with such a clone capability. +. +Please contact the CHIRP project for support of such radios. +. +. +.SS Pronouncing Hamlib +. +English speakers seem to have two alternate pronunciations for our project: +. +.nf +.IP \(bu 4 +Hamlib (Ham \- lib, long \(oqi\(cq, as in library.) IPA style: /\(aqham læb/ +. +.IP \(bu 4 +Hamlib (Ham \- lib, short \(oqi\(cq, as in liberty.) IPA style: /\(aqham lɪb/ +.fi +. +.PP +Then again, we have people who say Linux \(lqL-eye-nux\(rq and those who say +\(lqL-in-nux\(rq... +. +.PP +If you're French, the above does not apply! :-) +. +. +.SH COPYING +. +This file is part of Hamlib, a project to develop a library that simplifies +radio and rotator control functions for developers of software primarily of +interest to radio amateurs and those interested in radio communications. +. +.PP +Copyright \(co 2001-2018 Hamlib Group (various contributors) +. +.PP +This is free software; see the file COPYING for copying conditions. There is +NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +. +. +.SH SEE ALSO +. +.BR hamlib-primer (7) +. +. +.SH COLOPHON +. +Links to the Hamlib Wiki, Git repository, release archives, and daily snapshot +archives: +.IP +.UR http://www.hamlib.org +hamlib.org +.UE . diff --git a/doc/nutshell.texi b/doc/nutshell.texi index 2f78c64fb..c34052990 100644 --- a/doc/nutshell.texi +++ b/doc/nutshell.texi @@ -1,33 +1,34 @@ The @dfn{Ham Radio Control Libraries}, @dfn{Hamlib} for short, is a development effort to provide a consistent interface for programmers -wanting to incorporate radio control in their programs. +wanting to incorporate radio and rotator control in their programs. Hamlib is not a complete user application, rather, it is a software -layer intended to make controlling various radios and other shack -hardware much easier. Hamlib will allow authors of such software as -logging programs, digital communications programs, or those wanting to -develop the ultimate radio control software to concentrate on the user -interface and the basic function of the program rather than radio -control. Hamlib consists of several parts, the programming library, -utility programs, and library interfaces to other programming languages. +layer intended to make controlling various radios and other amateur +radio station (shack) hardware much easier. Hamlib will allow authors +of software such as logging programs, digital communications programs, +or those wanting to develop the ultimate radio control software to +concentrate on the user interface and the basic function of the +program rather than radio control. Hamlib consists of several parts, +the programming library, utility programs, and library interfaces to +other programming languages. Most recent amateur radio transceivers allow external control of their -functions through a serial interface. Unfortunately, control commands -are not always consistent across a manufacturer's product line and each -manufacturer's product line differs greatly from its competitors. +functions through a serial interface. Unfortunately, control commands +are not always consistent across a manufacturer's product line and +each manufacturer's product line differs greatly from its competitors. -Hamlib attempts to solve this problem by presenting a "virtual radio" to -the programmer by providing an interface to actions such as setting a -given VFO's frequency, setting the operating mode, querying the radio of -its current status and settings, and giving the application a list of a -given radio's capabilities. Unfortunately, what can be accomplished by -Hamlib is limited by the radios themselves and some offer very limited -capability. +Hamlib attempts to solve this problem by presenting a "virtual radio" +to the programmer by providing an interface to actions such as setting +a given Variable Frequency Oscillator's (VFO) frequency, setting the +operating mode, querying the radio of its current status and settings, +and giving the application a list of a given radio's capabilities. +Unfortunately, what can be accomplished by Hamlib is limited by the +radios themselves and some offer very limited capability. -Other devices, such as antenna rotors, can be placed into the Hamlib -control scheme. Other recent developments include network interface -servers and a USB interface capability. Language bindings are provided -for C, C++, Perl, Python, Lua and TCL (more to come). +Other devices, such as antenna rotators, can be placed into the Hamlib +control scheme. Other recent developments include network interface +servers and a USB interface capability. Language bindings are +provided for C, C++, Perl, Python, Lua and TCL (more to come). @menu * Overview:: @@ -44,20 +45,20 @@ for C, C++, Perl, Python, Lua and TCL (more to come). @cindex Front end library @cindex Virtual radio -@cindex Virtual rotor +@cindex Virtual rotator Hamlib is a @dfn{front end} library providing a @emph{C} language Application Programming Interface @acronym{API} to programmers wishing -to integrate radio or rotor control in their applications. Hamlib -presents a @dfn{virtual radio} or @dfn{virtual rotor} that is a -consistent interface to an application despite wide differences in radio -and rotor interfaces and capabilities. +to integrate radio or rotator control in their applications. Hamlib +presents a @dfn{virtual radio} or @dfn{virtual rotator} that is a +consistent interface to an application despite wide differences in +radio and rotator interfaces and capabilities. @cindex Back end library The front end library uses a number of @dfn{back end} libraries to translate from the front end to the various individual radio and -rotor models. A back end library handles conversion of the -front end variables to the format needed by the radio or rotor -device it controls. The back end libraries are generally grouped by +rotator models. A back end library handles conversion of the front +end variables to the format needed by the radio or rotator device it +controls. The back end libraries are generally grouped by manufacturer and in some cases by a common control protocol. @quotation @@ -78,23 +79,25 @@ of Hamlib's design. @cindex Languages, scripting @cindex Interface, languages Hamlib also provides an interface library for each of several common -@dfn{scripting} languages such as @url{http://www.perl.org, Perl, Perl}, -@url{http://www.python.org, Python, Python}, @url{https://www.lua.org, Lua, Lua} -and @url{http://www.tcl.tk, TCL, TCL}. These language @dfn{bindings} are -generated through the use of @url{http://www.swig.org, SWIG, SWIG} a parser/generator -for multiple language interfaces to a C library. A native generated @emph{C++} +@dfn{scripting} languages such as @url{http://www.perl.org, Perl, +Perl}, @url{http://www.python.org, Python, Python}, +@url{https://www.lua.org, Lua, Lua} and @url{http://www.tcl.tk, TCL, +TCL}. These language @dfn{bindings} are generated through the use of +@url{http://www.swig.org, SWIG, SWIG} a parser/generator for multiple +language interfaces to a C library. A native generated @emph{C++} language interface is also provided. @cindex Daemon, network @cindex Network, daemon Besides the C and supplemental APIs, Hamlib also provides a pair of network daemons that provide a text command based API for controlling -an attached radio or rotor through a @emph{TCP/IP} network connection. -The daemons then handle the interface to the Hamlib C API. +an attached radio or rotator through a @emph{TCP/IP} network +connection. The daemons then handle the interface to the Hamlib C +API. -More than one type of device, radio or rotor, may be controlled at a -time, however, there is generally a limit of one device per serial port -or other port. +More than one type of device, radio or rotator, may be controlled at a +time, however, there is generally a limit of one device per serial +port or other port. @node The Hamlib project @section Hamlib project information @@ -102,50 +105,47 @@ or other port. @cindex Project, Hamlib The Hamlib Project was founded by Frank Singleton,VK3FCS/KM5WS in July -2000. Shortly after Stephane Fillod, F8CFE, joined Frank on the Hamlib -project and the API and implementation development led to a reasonable -level of maturity in a few years. A major milestone was reached when -Hamlib 1.2.0 was released in March 2004. The API and Application -Binary Interface (@acronym{ABI}) interfaces have remained stable since -that time up to the latest release of 1.2.15.3 in late 2012. +2000. Shortly after Stephane Fillod, F8CFE, joined Frank on the +Hamlib project and the API and implementation development led to a +reasonable level of maturity in a few years. A major milestone was +reached when Hamlib 1.2.0 was released in March 2004. The API and +Application Binary Interface (@acronym{ABI}) interfaces have remained +stable since that time up to the latest release of 3.2 in early 2018. -Development continues with a bump of the public version number to 3.0 -(essentially simply dropping the ``1.'' of previous releases). While some -API tweaks are planned, ABI compatibility with the prior 1.2.@i{x} -releases remains a priority. Other goals include streamlining the -build system (done), improving the SWIG generated language bindings -(in progress), improving the overall documentation (this manual, in -progress), and other updates as warranted. +Development continues through the major version number 3.x and beyond. +While some API tweaks are planned, ABI compatibility with the prior +1.2.@i{x} releases remains a priority. Other goals include +streamlining the build system (done), improving the SWIG generated +language bindings (done), improving the overall documentation (this +manual, in progress), and other updates as warranted. The Project is hosted by @url{https://sourceforge.net/, SourceForge.net} at the @url{https://sourceforge.net/projects/hamlib/, -Hamlib project page} and the -@url{http://sourceforge.net/apps/mediawiki/hamlib/index.php, Hamlib -Wiki}. +Hamlib project page}. As @url{https://github.com/, GitHub} has become +a very popular project hosting site, Hamlib also has a dedicated +@url{https://github.com/Hamlib/Hamlib, GitHub project page}. GitHub +also hosts the @url{http://www.hamlib.org, hamlib.org} Web site and +the @url{https://github.com/Hamlib/Hamlib/wiki, Hamlib Wiki}. Development discussion and most user support take place on the -@url{https://sourceforge.net/p/hamlib/mailman/, hamlib-developer mailing -list}. While there are +@url{https://sourceforge.net/p/hamlib/mailman/, hamlib-developer +mailing list}. While there are @url{https://sourceforge.net/p/hamlib/discussion/, SourceForge.net -discussion forums}, they are rarely used and not as closely read by the -developers as the mailing list. +discussion forums}, they are rarely used and not as closely read by +the developers as the mailing list. For @dfn{source code management}, the project uses @url{http://git-scm.com/, Git}, a fast, distributed content tracker. Among its features is that every developer has the complete Hamlib -development history available locally. While a canonical Git -repository is hosted as SourceForge, its availability is not essential to -continued development, although development work flows would change -temporarily. For more information on using Git, @pxref{Working with -Git}. +development history available locally. For more information on using +Git, @pxref{Working with Git}. @quotation Note -The SourceForge.net Web interface to the Hamlib Git repository is -currently broken (a ticket is pending) as of late February, 2013. A -mirror exists at @url{https://github.com/N0NB/hamlib, GitHub} which -supports browsing via the Web and other Git commands. Access of the -SF.net repository by other means (SSH or Git protocols) is unaffected -by this issue. +While a canonical Git repository is hosted as SourceForge, its +availability is not essential to continued development, although +development work flows would change temporarily. Several developers +find the GitHub Web interface easier to use and lately development has +centered around GitHub rather than SourceForge. @end quotation @node Applications using Hamlib @@ -154,9 +154,9 @@ by this issue. @cindex Applications, using Hamlib A number of application developers have taken advantage of Hamlib's -capabilities to implement radio and/or rotor control. While not +capabilities to implement radio and/or rotator control. While not exhaustive, a list is maintained at the Hamlib Wiki, -@url{https://sourceforge.net/apps/mediawiki/hamlib/, +@url{https://github.com/Hamlib/Hamlib/wiki/Applications-and-Screen-Shots, Applications/Screenshots}. Developers are encouraged to request their applications be added to the gallery by way of the hamlib-developer mailing list. @@ -166,16 +166,17 @@ mailing list. @cindex Hamlib licensing @cindex Licensing, Hamlib -As with other Free Software projects, Hamlib relies heavily on copyleft -licensing to encourage development contributions and provide an open -atmosphere for development. Hamlib's source code is released under two -licenses, the @acronym{LGPL} for the library portion, and the -@acronym{GPL} for the utility programs. +As with other Free Software projects, Hamlib relies heavily on +copyleft licensing to encourage development contributions and provide +an open atmosphere for development. Hamlib's source code is released +under two licenses, the Lesser General Public License (@acronym{LGPL}) +for the library portion, and the General Public License +(@acronym{GPL}) for the utility programs. The LGPL allows the library to be used (linked) by programs regardless -of their individual license. However, any contributions to the library -source remain under copyleft which means that the library source code -may not be used in violation of the terms of the LGPL. +of their individual license. However, any contributions to the +library source remain under copyleft which means that the library +source code may not be used in violation of the terms of the LGPL. The utility program source files are released under the GPL. Any direct use of these sources must be in a form that complies with the terms of @@ -192,12 +193,12 @@ with the terms of the GPL is prohibited. @cindex Cloning, radio Hamlib's focus is on controlling rigs that employ a port and command -protocol for setting frequency, mode, VFO, PTT, etc. Most VHF/UHF +protocol for setting frequency, mode, VFO, PTT, etc. Most VHF/UHF transceivers do not employ such control capability but do provide for -cloning the memory contents from radio to another of the same model. A -related project, @url{http://chirp.danplanet.com/, CHIRP}, aims to -support rigs with such a clone capability. Please contact the CHIRP -project for support of such rigs. +cloning the memory contents from radio to another of the same model. +A related project, @url{http://chirp.danplanet.com/, CHIRP}, aims to +support radios with such a clone capability. Please contact the CHIRP +project for support of such radios. @node Pronunciation @section Pronouncing Hamlib diff --git a/doc/utility_programs.texi b/doc/utility_programs.texi index e3716ccb1..4191c7ff1 100644 --- a/doc/utility_programs.texi +++ b/doc/utility_programs.texi @@ -1,13 +1,16 @@ Included with the Hamlib distribution are several utility programs. Besides providing a way for developers to test new code and bug fixes, the programs also offer a reference implementation for interfacing to -the Hamlib library functions both through the C API and offering a -network accessible API. +the Hamlib library functions both through the C API (Application +Programming Interface) and offering a network accessible API. This chapter focuses on the two test programs, @command{rigctl} for -testing radio back ends and @command{rotctl} for testing rotor back +testing radio back ends and @command{rotctl} for testing rotator back ends and the two network daemons, @command{rigctld} and -@command{rotcltd} for radio and rotor access via network sockets. +@command{rotcltd} for radio and rotator access via network sockets. +Also included are three demonstation utilities, @command{rigmem}, +@command{rigsmtr}, and @command{rigswr} which provide functional +examples of how Hamlib may be used to accomplish various tasks. @menu @@ -15,6 +18,9 @@ ends and the two network daemons, @command{rigctld} and * rotctl:: * rigctld:: * rotctld:: +* rigmem:: +* rigsmtr:: +* rigswr:: @end menu @node rigctl @@ -22,16 +28,13 @@ ends and the two network daemons, @command{rigctld} and @cindex rigctl @command{rigctl} is the most frequently used Hamlib utility. As the -other utilities share many of the same characteristics, much of the -introductory information presented in this section is applicable to -the other utility programs. +other ctl utilities share many of the same characteristics, much of +the introductory information presented in this section is applicable +to the other utility programs. @menu * Introduction to rigctl:: -* rigctl invocation:: -* rigctl command line options:: -* rigctl commands:: -* rigctl readline support:: +* rigctl reference:: @end menu @node Introduction to rigctl @@ -73,7 +76,7 @@ commands after any @command{rigctl} options: Entering @dfn{interactive mode} allows successive commands to be entered without exiting @command{rigctl}. Recent additions to @command{rigctl} allow command editing and history recall through use -of the @url{ http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html, +of the @url{https://tiswww.case.edu/php/chet/readline/rltop.html, Readline} library. Interactive mode is indicated by the spartan prompt: @@ -135,7 +138,8 @@ interactive mode as shown above. The @option{-m} option takes a numeric value that corresponds to a given radio back end model. The @option{-r} option takes the path to -the port device on @acronym{POSIX} and the device name on MS Windows. +the port device on @acronym{POSIX} and the device name on Microsoft +Windows. @quotation Note A complete list of supported radio models may be seen by use of the @@ -160,979 +164,38 @@ A complete list of supported radio models may be seen by use of the The list is long so use @kbd{@key{SHIFT}-PageUp}/ @kbd{@key{SHIFT}-PageDown} on Linux, @kbd{@key{ScrollLock}} then @kbd{@key{PageUp}}/@kbd{@key{PageDown}} on Free BSD, or use the -scrollbar to the virtual terminal window (@command{cmd} window on MS -Windows) or the output can be piped to '@command{more}' or +scrollbar to the virtual terminal window (@command{cmd} window on +Microsoft Windows) or the output can be piped to '@command{more}' or '@command{less}', e.g.@: '@kbd{rigctl -l | more}' to scroll back up the list. The list is sorted numerically by model number since Hamlib -1.2.15.1. Model numbers of a manufacturer/ protocol family are +1.2.15.1. Model numbers of a manufacturer/protocol family are grouped together. @end quotation -@node rigctl invocation -@subsection @command{rigctl} invocation -@cindex @command{rigctl} invocation -@cindex invocation, @command{rigctl} +@node rigctl reference +@subsection @command{rigctl} reference +@cindex @command{rigctl} reference +@cindex reference, @command{rigctl} -Here are some additional examples for invoking @command{rigctl} for -various situations. +The complete reference for @command{rigctl} can be found in the +@kbd{rigctl}(1) Unix manual page. -@noindent -Start @command{rigctl} for a Yaesu FT-920 using a @acronym{USB} to serial -adapter on Linux in interactive mode: - -@example -rigctl -m 114 -r /dev/ttyUSB1 -@end example - -@noindent -Start @command{rigctl} for a Yaesu FT-920 using @file{COM1} on MS -Windows while generating TRACE output to @file{stderr}: - -@example -rigctl -m 114 -r COM1 -vvvvv -@end example - -@noindent -Start @command{rigctl} for a Yaesu FT-920 using a @acronym{USB} to -serial adapter on Linux while setting baud rate and stop bits: - -@example -rigctl -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 -@end example - -@noindent -Start @command{rigctl} for an Elecraft K3 using a @acronym{USB} to -serial adapter on Linux while specifying a command terminator for the -@command{w} command: - -@example -rigctl -m 229 -r /dev/ttyUSB0 -t';' -@end example - -@noindent -Connect to a running @command{rigctld} with radio model 2 (@code{NET -rigctl}) on the local host and specifying the @acronym{TCP} port, -setting frequency and mode: - -@example -rigctl -m 2 -r localhost:4532 F 7253500 M LSB 0 -@end example - -@strong{N.B.} On MS Windows @kbd{localhost} may need to be replaced -with the actual loopback @acronym{IP} address--@kbd{127.0.0.1}--or the -address passed to @command{rigctld} with the @option{-T} option. - -@node rigctl command line options -@subsection @command{rigctl} command line options -@cindex @command{rigctl} command line options -@cindex Command line options, @command{rigctl} - -The @command{rigctl} command line options (not to be confused with -@command{rigctl} commands) control the action of various features. -Options consist of both ``short options''--a single hyphen '@kbd{-}' -followed by a single letter and ``long options''--two hyphens -'@kbd{--}' followed by several letters often comprising one or more -words separated by a hyphen. - -@command{rigctl} accepts the following options: - -@table @option -@item -m -@itemx --model=@var{id} -Select radio model number. See model list (use @kbd{rigctl -l}). - -@strong{N.B.} @command{rigctl} (or third party software) will use rig -model 2 for NET rigctl (@command{rigctld}). - -@item -r -@itemx --rig-file=@var{device} -Use @var{device} as the file name of the port the radio is connected. -Often a serial port, but could be a USB to serial adapter. Typically -@file{/dev/ttyS0} , @file{/dev/ttyS1} , @file{/dev/ttyUSB0} , etc.@: -on Linux or @file{COM1} , @file{COM2} , etc.@: on MS Windows. The -special string @kbd{uh-rig} may be given to enable micro-ham device -support. -@ifhtml -@* -@end ifhtml - -@item -p -@itemx --ptt-file=@var{device} -Use @var{device} as the file name of the Push-To-Talk device using a -device file as described above. -@ifhtml -@* -@end ifhtml - -@item -d -@itemx --dcd-file=@var{device} -Use @var{device} as the file name of the Data Carrier Detect device -using a device file as described above. -@ifhtml -@* -@end ifhtml - -@item -P -@itemx --ptt-type=@var{type} -Use @var{type} of Push-To-Talk device. Supported types are -@code{RIG}, @code{DTR}, @code{RTS}, @code{PARALLEL}, @code{NONE}, -overriding @acronym{PTT} type defined in the rig's backend. - -Some side effects of this command are that when type is set to -@code{DTR}, read @acronym{PTT} state comes from Hamlib frontend, not -read from the radio. When set to @code{NONE}, @acronym{PTT} state -cannot be read or set even if rig backend supports reading/setting -@acronym{PTT} status from the rig. - -@item -D -@itemx --dcd-type=@var{type} -Use @var{type} of Data Carrier Detect device. Supported types are -@code{RIG} (@acronym{CAT} command), @code{DSR}, @code{CTS}, @code{CD}, -@code{PARALLEL}, @code{NONE}. -@ifhtml -@* -@end ifhtml - -@item -s -@itemx --serial-speed=@var{baud} -Set serial speed to @var{baud} rate. Uses @strong{maximum} serial -speed from rig backend capabilities (set by @option{-m} above) as the -default. -@ifhtml -@* -@end ifhtml - -@item -c -@itemx --civaddr=@var{id} -Use @var{id} as the @acronym{CI-V} address to communicate with the -rig. Only useful for Icom radios and those using the Icom protocol. - -@strong{N.B.} The @var{id} is in decimal notation, unless prefixed by -@code{0x}, in which case it is a hexadecimal value. - -@item -t -@itemx --send-cmd-term=@var{char} -Change the termination @var{char} for text protocol when using the -@code{send_cmd} command. The default value is @code{} -(@code{0x0d}). Non @acronym{ASCII} printable characters can be -specified as an @acronym{ASCII} number, in hexadecimal format, -prepended with @code{0x}. You may pass an empty string for no -termination char. The string '@code{-1}' tells @command{rigctl} to -switch to binary protocol. See the @code{send_cmd} command for further -explanation. -@ifhtml -@* -@end ifhtml - -@item -L -@itemx --show-conf -List all config parameters for the radio defined with @option{-m} -above. -@ifhtml -@* -@end ifhtml - -@item -C -@itemx --set-conf=@var{parm}=@var{val}[,@var{parm}=@var{val},@dots{}] -Set config parameter. e.g.@: @code{stop_bits=2} - -Use @option{-L} option for a list. - -@item -l -@itemx --list -List all model numbers defined in Hamlib and exit. As of 1.2.15.1 the -list is sorted by model number. - -@strong{N.B.} In Linux the list can be scrolled back using -@kbd{@key{SHIFT}-PageUp}/ @kbd{@key{SHIFT}-PageDown}, or using the -scrollbars of a virtual terminal in X or the @command{cmd} window in -MS Windows. The output can be piped to '@command{more}' or -'@command{less}', e.g.@: '@kbd{rigctl -l | more}'. - -@item -u -@itemx --dump-caps -Dump capabilities for the radio defined with @option{-m} above and -exit. -@ifhtml -@* -@end ifhtml - -@item -o -@itemx --vfo -Set vfo mode, requiring an extra @acronym{VFO} argument in front of -each appropriate command (except @command{set_vfo}!). Otherwise, -@code{currVFO} is assumed when this option is not set and an extra VFO -argument is not used. See @command{chk_vfo} below. -@ifhtml -@* -@end ifhtml - -@item -n -@itemx --no-restore-ai -On exit @command{rigctl} restores the state of auto information (AI) -on the controlled rig. If this is not desired, for example if you are -using @command{rigctl} to turn AI mode on or off, pass this option. - -@item -i -@itemx --read-history -Read previously saved command and argument history from a file -(default '@file{$HOME/.rigctl_history}') for the current session. -Available when @command{rigctl} is built with Readline support. - -@strong{N.B.} To read a history file stored in another directory, set -the @env{RIGCTL_HIST_DIR} environment variable, e.g.@: -'@kbd{RIGCTL_HIST_DIR=$HOME/tmp rigctl -i}'. When -@env{RIGCTL_HIST_DIR} is not set, the value of @env{HOME} is used. - -@item -I -@itemx --save-history -Write current session (and previously saved session(s) if @option{-i} -option is also given) command and argument history to a file (default -'@file{$HOME/.rigctl_history}') at the end of the current session. -Complete commands with arguments are saved as a single line to be -recalled and used or edited. Available when @command{rigctl} is built -with Readline support. - -To write a history file in another directory, set the -@env{RIGCTL_HIST_DIR} environment variable, e.g.@: -'@kbd{RIGCTL_HIST_DIR=$HOME/tmp rigctl -I}'. When -@env{RIGCTL_HIST_DIR} is not set, the value of @env{HOME} is used. - -@item -v -@itemx --verbose -Set verbose mode level, cumulative i.e.@: @option{-vvvvv} sets maximum -debugging output to @file{stderr}. - -Five different levels of diagnostics can be output to @file{stderr} -and correspond to @option{-v} for @code{BUG}, @option{-vv} for -@code{ERR}, @option{-vvv} for @code{WARN}, @option{-vvvv} for -@code{VERBOSE}, or @option{-vvvvv} for @code{TRACE}. Back end authors -will use the verbose facility to print critical values useful for -testing and will often ask for this output in response to a request -for help. - -@item -Z -@itemx --debug-time-stamps -Enable time stamps on debug output. - -@item -h -@itemx --help -Show summary of these options and exit. -@ifhtml -@* -@end ifhtml - -@item -V -@itemx --version -Show version of @command{rigctl} and exit. - -@end table - -@quotation Note -Some options may not be implemented by a given backend and will return -an error. This is most likely to occur with the @option{--set-conf} -and @option{--show-conf} options. -@end quotation - -@node rigctl commands -@subsection @command{rigctl} commands -@cindex @command{rigctl} commands -@cindex commands, @command{rigctl} - -Commands can be entered either as a single char, or as a long command -name. Basically, the commands do not take a dash in front of them on -the command line, as the options do. They may be typed in when in -interactive mode or provided as argument(s) in command line interface -mode. In interactive mode commands and their arguments may be entered -on a single line: - -@example -Rig command: M LSB 2400 -@end example - -@noindent -or singly and @command{rigctl} will prompt for any needed values. - -Since most of the Hamlib operations have a ``set'' and a ``get'' -method, in general an upper case letter will be used for set methods -whereas the corresponding lower case letter refers to the get method. -Each operation also has a long name; prepend a backslash @kbd{\} to -enter a long command name. - -@quotation -Example: Use @kbd{\dump_caps} to see what this radio can do. -@end quotation - -@noindent -Be aware that the backend for the radio to be controlled, or the radio -itself may not support some commands. In that case, the operation will -fail with a Hamlib error message. - -Here is a summary of the supported commands: - -@itemize -@item -Command short name is followed by the long name which is followed by -any variable names. - -@item -Some short commands are noted as hexadecimal digits due to the -limitation of upper and lower case letters available. Use the -associated long command name instead. - -@item -While a comma is used to separate variable names in this document, -they are not part of the command syntax used by @command{rigctl}. Use -a space to separate values. - -@item -In the case of ``set'' commands the variable @var{name} is replaced by -the value in the description. - -@item -In the case of ``get'' commands the variable @var{name} is the key -name of the value returned. - -@end itemize - -@table @command -@item q -Exit @command{rigctl} in interactive mode (@kbd{q} is not case -sensitive). - -When @command{rigctl} is controlling the rig directly, will close the -rig back end and port. When @command{rigctl} is connected to -@command{rigctld} (rig model 2), the @acronym{TCP/IP} connection to -@command{rigctld} is closed and @command{rigctld} remains running, -available for another @acronym{TCP/IP} network connection. - -@item F, set_freq @var{Frequency} -Set @var{Frequency}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item f, get_freq -Get @var{Frequency}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item M, set_mode @var{Mode}, @var{Passband} -Set @var{Mode} to one of: @code{USB}, @code{LSB}, @code{CW}, -@code{CWR}, @code{RTTY}, @code{RTTYR}, @code{AM}, @code{FM}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -Set @var{Passband} frequency in Hertz, or @code{0} for the Hamlib -backend default. A value of @code{-1} may be passed which leaves the -rig passband unchanged from the current or default value for the mode -as defined by the rig. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument -instead of @var{Mode} will return a space separated list of radio -backend supported Modes. Use this to determine the supported Modes of -a given radio backend. - -@item m, get_mode -Get @var{Mode}, @var{Passband}. - -Returns Mode as a string from @command{set_mode} above and Passband -frequency in Hertz. - -@item V, set_vfo @var{VFO} -Set @var{VFO} to one of: @code{VFOA}, @code{VFOB}, @code{VFOC}, -@code{currVFO}, @code{VFO}, @code{MEM}, @code{Main}, @code{Sub}, -@code{TX}, @code{RX}. - -In @acronym{VFO} mode only a single @acronym{VFO} parameter is -required. - -@item v, get_vfo -Get current @var{VFO}. - -Returns @acronym{VFO} as a string from @command{set_vfo} above. - -@item J, set_rit @var{RIT} -Set @var{RIT}, in Hertz, can be a positive or negative value. - -A value of @code{0} resets @acronym{RIT} and @emph{should} turn -@acronym{RIT} off. If not, file a bug report against the Hamlib -backend. - -@strong{N.B.} This functionality is under transition and in the future -will need to be activated with the @command{set_func} command. - -@item j, get_rit -Get @var{RIT}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item Z, set_xit @var{XIT} -Set @var{XIT}, in Hertz, can be a positive or negative value. - -A value of @code{0} resets @acronym{XIT} and @emph{should} turn -@acronym{XIT} off. If not, file a bug report against the Hamlib -backend. - -@strong{N.B.} This functionality is under transition and in the future -will need to be activated with the @command{set_func} command. - -@item z, get_xit -Get @var{XIT}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item T, set_ptt @var{PTT} -Set @var{PTT} to one of: @code{0} (RX), @code{1} (TX), @code{2} (TX -mic), @code{3} (TX data). -@ifhtml -@* -@end ifhtml - -@item t, get_ptt -Get @var{PTT} status. -@ifhtml -@* -@end ifhtml - -@item 0x8b, get_dcd -Get @var{DCD} (squelch) status, @code{0} (Closed) or @code{1} (Open) -@ifhtml -@* -@end ifhtml - -@item R, set_rptr_shift @var{Rptr Shift} -Set @var{Rptr Shift}: @code{+}, @code{-} or something else for none. -@ifhtml -@* -@end ifhtml - -@item r, get_rptr_shift -Get @var{Rptr Shift}. Returns @code{+}, @code{-} or @code{None}. -@ifhtml -@* -@end ifhtml - -@item O, set_rptr_offs @var{Rptr Offset} -Set @var{Rptr Offset}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item o, get_rptr_offs -Get @var{Rptr Offset}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item C, set_ctcss_tone @var{CTCSS Tone} -Set @var{CTCSS Tone}, in tenths of Hertz. - -@acronym{CTCSS}, -@url{http://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System, -@dfn{Continuous Tone Coded Squelch System}}, is a method used to -reduce the annoyance of listening to other users on a shared two-way -communications radio channel by imposing a tone on the transmitted -signal. Also known as @dfn{subaudible tone} and @acronym{PL}, -@dfn{Private Line}. - -@item c, get_ctcss_tone -Get @var{CTCSS Tone}, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item D, set_dcs_code @var{DCS Code} -Set @var{DCS Code}. - -@acronym{DCS}, -@url{http://en.wikipedia.org/wiki/Digital-Coded_Squelch#DCS, -@dfn{Digital-Coded Squelch}} is a digital version of @acronym{CTCSS} -which imposes a digital code on the transmitted signal. - -@item d, get_dcs_code -Get @var{DCS Code}. -@ifhtml -@* -@end ifhtml - -@item 0x90, set_ctcss_sql @var{CTCSS Sql} -Set @var{CTCSS Sql} tone, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item 0x91, get_ctcss_sql -Get @var{CTCSS Sql} tone, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item 0x92, set_dcs_sql @var{DCS Sql} -Set @var{DCS Sql} code. -@ifhtml -@* -@end ifhtml - -@item 0x93, get_dcs_sql -Get @var{DCS Sql} code. -@ifhtml -@* -@end ifhtml - -@item I, set_split_freq @var{Tx Frequency} -Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. - -See also @command{set_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item i, get_split_freq -Get @var{TX Frequency}, in Hertz for ``split'' frequency operation. - -See also @command{get_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item X, set_split_mode @var{TX Mode}, @var{TX Passband} -Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, -@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. A value of @code{-1} may be -passed which leaves the rig passband unchanged from the current or -default value for the mode as defined by the rig. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{TX Mode} will return a space separated list of radio backend -supported TX Modes. Use this to determine the supported TX Modes of a -given radio backend. - -See also @command{set_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item x, get_split_mode -Get @var{TX Mode}, @var{TX Passband}. - -Returns TX mode as a string from @command{set_split_mode} above and TX -passband in Hz. - -See also @command{get_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item K, set_split_freq_mode @var{Tx Frequency}, @var{TX Mode}, @var{TX Passband} -Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. -Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, -@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. A value of @code{-1} may be -passed which leaves the rig passband unchanged from the current or -default value for the mode as defined by the rig. - -This is a convenience function that combines the effect of -@command{set_split_freq} and @command{set_split_mode}. It should be -used when both are required since it allows the back end to optimize -the operations. For example on many Icom rigs the current VFO must be -changed temporarily while executing these commands and that can -disrupt receive or transmit, using this function may minimize that -disruption. - -See also @command{set_split_freq} and @command{set_split_mode} above. -@ifhtml -@* -@end ifhtml - -@item k, get_split_freq_mode -Get @var{TX Frequency}, in Hertz for ``split'' frequency operation -along with The @var{TX Mode} as a string from @command{set_split_mode} -above and @var{TX Passband} in Hz. - -This is a convenience function that combines the effect of -@command{get_split_freq} and @command{get_split_mode}. It should be -used when both are required since it allows the back end to optimize -the operations. For example on many Icom rigs the current VFO must be -changed temporarily while executing these commands and that can -disrupt receive or transmit, using this function may minimize that -disruption. - -See also @command{get_split_freq} and @command{get_split_mode} above. -@ifhtml -@* -@end ifhtml - -@item S, set_split_vfo @var{Split}, @var{TX VFO} -Set @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO} -from @command{set_vfo} above. -@ifhtml -@* -@end ifhtml - -@item s, get_split_vfo -Get @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO}. -@ifhtml -@* -@end ifhtml - -@item N, set_ts @var{Tuning Step} -Set @var{Tuning Step}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item n, get_ts -Get @var{Tuning Step}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item U, set_func @var{Func}, @var{Func Status} -Set @var{Func}, @var{Func Status}. - -@var{Func} is one of: @code{FAGC}, @code{NB}, @code{COMP}, @code{VOX}, -@code{TONE}, @code{TSQL}, @code{SBKIN}, @code{FBKIN}, @code{ANF}, -@code{NR}, @code{AIP}, @code{APF}, @code{MON}, @code{MN}, @code{RF}, -@code{ARO}, @code{LOCK}, @code{MUTE}, @code{VSC}, @code{REV}, -@code{SQL}, @code{ABM}, @code{BC}, @code{MBC}, @code{RIT}, @code{AFC}, -@code{SATMODE}, @code{SCOPE}, @code{RESUME}, @code{TBURST}, -@code{TUNER}, @code{XIT}. - -Func Status argument is @code{1} for ``activate'', @code{0} for -``de-activate'', much as TRUE/FALSE definitions in the C/C++ languages -(true is non-zero and false is zero). - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Func} will return a space separated list of radio backend -supported ``set'' functions. Use this to determine the supported -functions of a given radio backend. - -@item u, get_func @var{Func} -Get @var{Func Status}. - -Returns @var{Func Status} as a non null value for the @var{Func} passed. -@var{Func} is a token from the list in @command{set_func} above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Func} will return a space separated list of radio backend -supported ``get'' functions. Use this to determine the supported -functions of a given radio backend. - -@item L, set_level @var{Level}, @var{Level Value} -Set @var{Level}, @var{Level Value}. - -@var{Level} is one of: @code{PREAMP}, @code{ATT}, @code{VOX}, @code{AF}, -@code{RF}, @code{SQL}, @code{IF}, @code{APF}, @code{NR}, @code{PBT_IN}, -@code{PBT_OUT}, @code{CWPITCH}, @code{RFPOWER}, @code{MICGAIN}, -@code{KEYSPD}, @code{NOTCHF}, @code{COMP}, @code{AGC}(@code{0}:OFF, -@code{1}:SUPERFAST, @code{2}:FAST, @code{3}:SLOW, @code{4}:USER, -@code{5}:MEDIUM, @code{6}:AUTO), @code{BKINDL}, @code{BAL}, -@code{METER}, @code{VOXGAIN}, @code{ANTIVOX}, @code{SLOPE_LOW}, -@code{SLOPE_HIGH}, @code{RAWSTR}, @code{SWR}, @code{ALC}, -@code{STRENGTH}. - -The @var{Level Value} can be a float or an integer. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Level} will return a space separated list of radio backend -supported ``set'' levels. Use this to determine the supported levels of a -given radio backend. - -@item l, get_level @var{Level} -Get @var{Level Value}. - -Returns @var{Level Value} as a float or integer for the @var{Level} -passed. @var{Level} is a token from the list in @command{set_level} -above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Level} will return a space separated list of radio backend -supported ``get'' levels. Use this to determine the supported levels of a -given radio backend. - -@item P, set_parm @var{Parm}, @var{Parm Value} -Set @var{Parm}, @var{Parm Value} - -@var{Parm} is one of: @code{ANN}, @code{APO}, @code{BACKLIGHT}, -@code{BEEP}, @code{TIME}, @code{BAT}, @code{KEYLIGHT}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Parm} will return a space separated list of radio backend -supported ``set'' parameters. Use this to determine the supported -parameters of a given radio backend. - -@item p, get_parm @var{Parm} -Get @var{Parm Value}. - -Returns @var{Parm Value} as a float or integer for the @var{Parm} -passed. @var{Parm} is a token from the list in @command{set_parm} -above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Parm} will return a space separated list of radio backend -supported ``get'' parameters. Use this to determine the supported -parameters of a given radio backend. - -@item B, set_bank @var{Bank} -Set @var{Bank}. Sets the current memory bank number. -@ifhtml -@* -@end ifhtml - -@item E, set_mem @var{Memory#} -Set @var{Memory#} channel number. -@ifhtml -@* -@end ifhtml - -@item e, get_mem -Get @var{Memory#} channel number. -@ifhtml -@* -@end ifhtml - -@item G, vfo_op @var{Mem/VFO Op} -Perform @var{Mem/VFO Op}. - -@var{Mem/VFO Op}eration is one of: @code{CPY}, @code{XCHG}, -@code{FROM_VFO}, @code{TO_VFO}, @code{MCL}, @code{UP}, @code{DOWN}, -@code{BAND_UP}, @code{BAND_DOWN}, @code{LEFT}, @code{RIGHT}, -@code{TUNE}, @code{TOGGLE}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Mem/VFO Op} will return a space separated list of radio backend -supported ``set'' Mem/VFO Ops. Use this to determine the supported Mem/VFO -Ops of a given radio backend. - -@item g, scan @var{Scan Fct}, @var{Scan Channel} -Perform @var{Scan Fct} @var{Scan Channel}. - -Scan function/channel is one of: @code{STOP}, @code{MEM}, @code{SLCT}, -@code{PRIO}, @code{PROG}, @code{DELTA}, @code{VFO}, @code{PLT}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Scan Fct} will return a space separated list of radio backend -supported Scan Functions. Use this to determine the supported Scan -Functions of a given radio backend. - -@item H, set_channel @var{Channel} -Set memory @var{Channel} data. Not implemented yet. -@ifhtml -@* -@end ifhtml - -@item h, get_channel -Get memory @var{Channel} data. Not implemented yet. -@ifhtml -@* -@end ifhtml - -@item A, set_trn @var{Transceive} -Set @var{Transceive} mode (reporting event): @code{OFF}, @code{RIG}, -@code{POLL}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Transceive} will return a space separated list of radio backend -supported Scan Transceive modes. Use this to determine the supported -Transceive modes of a given radio backend. - -@item a, get_trn -Get @var{Transceive} mode (reporting event) as in @command{set_trn} -above. -@ifhtml -@* -@end ifhtml - -@item Y, set_ant @var{Antenna} -Set @var{Antenna} number (@code{0}, @code{1}, @code{2}, @dots{}). -@ifhtml -@* -@end ifhtml - -@item y, get_ant -Get @var{Antenna} number (@code{0}, @code{1}, @code{2}, @dots{}). -@ifhtml -@* -@end ifhtml - -@item *, reset @var{Reset} -Perform rig @var{Reset}. - -@code{0} = None, @code{1} = Software reset, @code{2} = @acronym{VFO} -reset, @code{4} = Memory Clear reset, @code{8} = Master reset. Since -these values are defined as a bitmask in @file{rig.h}, it should be -possible to @code{AND} these values together to do multiple resets at -once, if the backend supports it or supports a reset action via rig -control at all. - -@item b, send_morse @var{Morse} -Send @var{Morse} symbols. -@ifhtml -@* -@end ifhtml - -@item 0x87, set_powerstat @var{Power Status} -Set power On/Off/Standby @var{Power Status}. - -@code{0} = Power Off, @code{1} = Power On, @code{2} = Power Standby. -Defined as a bitmask in @file{rig.h}. - -@item 0x88, get_powerstat -Get power On/Off/Standby @var{Power Status} as in -@command{set_powerstat} above. -@ifhtml -@* -@end ifhtml - -@item 0x89, send_dtmf @var{Digits} -Set DTMF @var{Digits}. -@ifhtml -@* -@end ifhtml - -@item 0x8a, recv_dtmf -Get DTMF @var{Digits}. -@ifhtml -@* -@end ifhtml - -@item _, get_info -Get misc information about the rig - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 1, dump_caps -Not a real rig remote command, it just dumps capabilities, i.e. what -the backend knows about this model, and what it can do. - -TODO: Ensure this is in a consistent format so it can be read into a -hash, dictionary, etc. Bug reports requested. - -@strong{N.B.} This command will produce many lines of output so be -very careful if using a fixed length array! For example, running this -command against the Dummy backend results in over 5kB of text output. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 2, power2mW @var{Power 0.0..1.0}, @var{Frequency}, @var{Mode} -Returns @var{Power mW} - -Converts a @var{Power} value in a range of @code{0.0..1.0} to -the real transmit power in milli-Watts (integer). The @var{Frequency} -and @var{Mode} also need to be provided as output power may vary -according to these values. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 4, mW2power @var{Power mW}, @var{Frequency}, @var{Mode} -Returns @var{Power 0.0..1.0} - -Converts the real transmit power in milli-Watts (integer) to a -@var{Power} value in a range of @code{[0.0..1.0]}. The -@var{Frequency} and @var{Mode} also need to be provided as output -power may vary according to these values. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item w, send_cmd @var{Cmd} -Send raw command string to rig. This is useful for testing and -troubleshooting rig commands and responses when developing a backend. - -For binary protocols enter values as @code{\0xAA\0xBB}. Expect a -@var{Reply} from the rig which will likely be a binary block or an -@acronym{ASCII} string depending on the rig's protocol (see your -radio's computer control documentation). - -The command terminator, set by the @option{--send-cmd-term} option -above, will terminate each command string sent to the radio. This -character should not be a part of the input string. -@end table - -@node rigctl readline support -@subsection @command{rigctl} Readline support -@cindex @command{rigctl} Readline support -@cindex Readline support, @command{rigctl} - -If Readline library development files are found at configure time, -@command{rigctl} will be conditonally built with Readline support for -command and argument entry. Readline command key bindings are at -their defaults as described in the -@url{http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html, -Readline manual} although @command{rigctl} sets the name @code{rigctl} -which can be used in @code{Conditional Init Constructs} in the -Readline Init File (@file{$HOME/.inputrc} by default) for custom -keybindings unique to @command{rigctl}. - -Command history is available with Readline support as described in the -@url{http://cnswww.cns.cwru.edu/php/chet/readline/history.html#SEC1, -Readline History manual}. Command and argument strings are stored as -single lines even when arguments are prompted for input individually. -Commands and arguments are not validated and are stored as typed with -values separated by a single space. - -Normally session history is not saved, however, use of either of the -@option{-i}/@option{--read-history} or -@option{-I}/@option{--save-history} options when starting -@command{rigctl} will cause any previously saved history to be read in -and/or the current and any previous session history (assuming the -@option{-i} and @option{-I} options are given together) will be -written out when @command{rigctl} is closed. Each option is mutually -exclusive, i.e. either may be given separately or in combination. -This is useful to save a set of commands and then read them later but -not write the modified history for a consistent set of test commands -in interactive mode, for example. - -History is stored in @file{$HOME/.rigctl_history} by default although -the destination directory may be changed by setting the -@env{RIGCTL_HIST_DIR} environment variable. When -@env{RIGCTL_HIST_DIR} is unset, the value of the @env{HOME} -environment variable is used instead. Only the destination directory -may be changed at this time. - -If Readline support is not found at configure time the original -internal command handler is used. Readline is not used for -@command{rigctl} commands entered on the command line regardless if -Readline support is built in or not. - -@quotation Note -Readline support is not included in the MS Windows 32 binary builds -supplied by the Hamlib Project. Running @command{rigctl} on the MS -Windows 32 platform in the @command{cmd} shell does give session -command line history, however, it is not saved to disk between -sessions. -@end quotation @node rotctl @section @command{rotctl} @cindex rotctl Identical in function to @command{rigctl}, @command{rotctl} provides a -means for testing Hamlib functions useful for rotor control and -@acronym{QRA} locator computations. As rotors have a much narrower -scope than radios, there are fewer command line options and commands -for @command{rotctl}. +means for testing Hamlib functions useful for rotator control and +@acronym{QTH} (Maidenhead gridsquare system, see +@url{https://en.wikipedia.org/wiki/Maidenhead_Locator_System, +Maidenhead Locator System}) locator computations. As rotators have a +much narrower scope than radios, there are fewer command line options +and commands for @command{rotctl}. @menu * Introduction to rotctl:: -* rotctl invocation:: -* rotctl command line options:: -* rotctl commands:: -* rotctl readline support:: +* rotctl reference:: @end menu @node Introduction to rotctl @@ -1141,7 +204,7 @@ for @command{rotctl}. @cindex @command{rotctl}, introduction to @command{rotctl} is a character based interactive program and a -command line program able to set or query a rotor's value with a +command line program able to set or query a rotator's value with a single command. @command{rotctl} is invoked from a shell command prompt with various options and additional commands. @@ -1170,10 +233,10 @@ commands after any @command{rotctl} options: @noindent Entering interactive mode allows successive commands to be entered -without exiting @command{rotctl}. Recent additions to -@command{rotctl} allow command editing and history recall through use -of the @url{ http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html, -Readline} library. +without exiting @command{rotctl}. Interactive mode allows for command +editing and history recall through the use of the @url{ +https://tiswww.case.edu/php/chet/readline/rltop.html, Readline} +library. Interactive mode is indicated by the spartan prompt: @@ -1202,16 +265,18 @@ Rotator command: An additional prompt is printed when more information is required by the command. For @kbd{M} above, @command{rotctl} prompted for the -``Direction'' and ``Speed'' values. For @kbd{p} above, @command{rotctl} -returned the ``Azimuth'' and ``Elevation'' values without further prompts. -The command prompt is returned after each command invocation. +``Direction'' and ``Speed'' values. For @kbd{p} above, +@command{rotctl} returned the ``Azimuth'' and ``Elevation'' values +without further prompts. The command prompt is returned after each +command invocation. -The above examples invoked @command{rotctl} without specifying a rotor -model. This is a feature where the Hamlib internal rotor dummy is -used instead. The dummy rotor provides a way to test Hamlib functions -with out the need for actual rotor hardware. However, to develop back -end capability for a given rotor, having the actual radio connected to -the computer is necessary for debugging. +The above examples invoked @command{rotctl} without specifying a +rotator model. This is a feature where the Hamlib internal rotator +dummy is used instead. The dummy rotator provides a way to test +Hamlib functions with out the need for actual rotator hardware. +However, to develop back end capability for a given rotator, having +the actual controller connected to the computer is necessary for +debugging. For example, to quickly set position for RotorEZ: @@ -1234,8 +299,8 @@ The returned values do not have the prompt strings associated with interactive mode as shown above. The @option{-m} option takes a numeric value that corresponds to a -given rotor back end model. The @option{-r} option takes the path to -the port device on @acronym{POSIX} and the device name on MS Windows. +given rotator back end model. The @option{-r} option takes the path to +the port device on @acronym{POSIX} or the device name on MS Windows. @quotation Note A complete list of supported radio models may be seen by use of the @@ -1243,7 +308,7 @@ A complete list of supported radio models may be seen by use of the @example @kbd{rotctl -l} - Rig # Mfg Model Version Status + Rot # Mfg Model Version Status 1 Hamlib Dummy 0.5 Beta 2 Hamlib NET rotctl 0.3 Beta 201 Hamlib EasycommI 0.3 Beta @@ -1264,396 +329,19 @@ scrollbar to the virtual terminal window (@command{cmd} window on MS Windows) or the output can be piped to '@command{more}' or '@command{less}', e.g.@: '@kbd{rotctl -l | more}' to scroll back up the list. The list is sorted numerically by model number since Hamlib -1.2.15.1. Model numbers of a manufacturer/ protocol family are -grouped together. +1.2.15.1. Model numbers of a manufacturer/protocol family are grouped +together. @end quotation -@node rotctl invocation -@subsection @command{rotctl} invocation -@cindex @command{rotctl} invocation -@cindex invocation, @command{rotctl} +@node rotctl reference +@subsection @command{rotctl} reference +@cindex @command{rotctl} reference +@cindex reference, @command{rotctl} -Here are some additional examples for invoking @command{rotctl} for -various situations. +The complete reference for @command{rotctl} can be found in the +@kbd{rotctl}(1) Unix manual page. -Start @command{rotctl} for RotorEZ using the first serial port on -Linux: - -@example -rotctl -m 401 -r /dev/ttyS0 -@end example - -@noindent -Start @command{rotctl} for RotorEZ using @code{COM2} on MS Windows: - -@example -rotctl -m 401 -r COM2 -@end example - -@noindent -Connect to a running @command{rotctld} with rotor model 2 (@code{NET rotctl}) on the -local host and specifying the @acronym{TCP} port, and querying the position: - -@example -rotctl -m 2 -r localhost:4533 \get_pos -@end example - -@node rotctl command line options -@subsection @command{rotctl} command line options -@cindex @command{rotctl} command line options -@cindex Command line options, @command{rotctl} - -@command{rotctl} accepts the following options: - -@table @option -@item -m -@itemx --model=@var{id} -Select rotator model number. See model list (use @kbd{rotctl -l}). - -@strong{N.B.} @command{rotctl} (or third party software) will use -rotor model 2 for NET rotctl (@command{rotctld}). - -@item -r -@itemx --rot-file=@var{device} -Use @var{device} as the file name of the port the rotor is connected. -Often a serial port, but could be a USB to serial adapter. Typically -@file{/dev/ttyS0} , @file{/dev/ttyS1} , @file{/dev/ttyUSB0} , etc.@: -on Linux or @file{COM1} , @file{COM2} , etc.@: on MS Windows. The -special string @kbd{uh-rig} may be given to enable micro-ham device -support. -@ifhtml -@* -@end ifhtml - -@item -s -@itemx --serial-speed=@var{baud} -Set serial speed to @var{baud} rate. Uses @strong{maximum} serial -speed from rotor backend capabilities as the default. -@ifhtml -@* -@end ifhtml - -@item -t -@itemx --send-cmd-term=@var{char} -Change the termination @var{char} for text protocol when using the -@code{send_cmd} command. The default value is @code{} -(@code{0x0d}). Non @acronym{ASCII} printable characters can be -specified as an @acronym{ASCII} number, in hexadecimal format, -prepended with @code{0x}. You may pass an empty string for no -termination char. The string '@code{-1}' tells @command{rotctl} to -switch to binary protocol. See the @code{send_cmd} command for further -explanation. -@ifhtml -@* -@end ifhtml - -@item -L -@itemx --show-conf -List all config parameters for the rotor defined with @option{-m} -above. -@ifhtml -@* -@end ifhtml - -@item -C -@itemx --set-conf=@var{parm}=@var{val}[,@var{parm}=@var{val},@dots{}] -Set config parameter. e.g.@: @code{stop_bits=2} - -Use @option{-L} option for a list. - -@item -l -@itemx --list -List all model numbers defined in Hamlib and exit. As of 1.2.15.1 the -list is sorted by model number. - -@strong{N.B.} In Linux the list can be scrolled back using -@kbd{@key{SHIFT}-PageUp}/ @kbd{@key{SHIFT}-PageDown}, or using the -scrollbars of a virtual terminal in X or the @command{cmd} window in -MS Windows. The output can be piped to '@command{more}' or -'@command{less}', e.g.@: '@kbd{rotctl -l | more}'. - -@item -u -@itemx --dump-caps -Dump capabilities for the rotor defined with @option{-m} above and -exit. -@ifhtml -@* -@end ifhtml - -@item -i -@itemx --read-history -Read previously saved command and argument history from a file -(default '@file{$HOME/.rotctl_history}') for the current session. -Available when @command{rotctl} is built with Readline support. - -@strong{N.B.} To read a history file stored in another directory, set -the @env{ROTCTL_HIST_DIR} environment variable, e.g.@: -'@kbd{ROTCTL_HIST_DIR=$HOME/tmp rotctl -i}'. When @env{ROTCTL_HIST_DIR} -is not set, the value of @env{HOME} is used. - -@item -I -@itemx --save-history -Write current session (and previously saved session(s) if @option{-i} -option is also given) command and argument history to a file (default -'@file{$HOME/.rotctl_history}') at the end of the current session. -Complete commands with arguments are saved as a single line to be -recalled and used or edited. Available when @command{rotctl} is built -with Readline support. - -To write a history file in another directory, set the -@env{ROTCTL_HIST_DIR} environment variable, e.g.@: -'@kbd{ROTCTL_HIST_DIR=$HOME/tmp rotctl -I}'. When @env{ROTCTL_HIST_DIR} -is not set, the value of @env{HOME} is used. - -@item -v -@itemx --verbose -Set verbose mode level, cumulative i.e.@: @option{-vvvvv} sets maximum -debugging output to @file{stderr}. - -Five different levels of diagnostics can be output to @file{stderr} -and correspond to @option{-v} for @code{BUG}, @option{-vv} for -@code{ERR}, @option{-vvv} for @code{WARN}, @option{-vvvv} for -@code{VERBOSE}, or @option{-vvvvv} for @code{TRACE}. Back end authors -will use the verbose facility to print critical values useful for -testing and will often ask for this output in response to a request -for help. - -@item -Z -@itemx --debug-time-stamps -Enable time stamps on debug output. - -@item -h -@itemx --help -Show summary of these options and exit. -@ifhtml -@* -@end ifhtml - -@item -V -@itemx --version -Show version of @command{rotctl} and exit. -@end table - -@quotation Note -Some options may not be implemented by a given backend and will return -an error. This is most likely to occur with the @option{--set-conf} -and @option{--show-conf} options. -@end quotation - -@node rotctl commands -@subsection @command{rotctl} commands -@cindex @command{rotctl} commands -@cindex commands, @command{rotctl} - -@xref{rigctl commands}, for command syntax. - -@strong{Rotor commands} - -Here is a summary of the supported commands: - -@table @command -@item q -Exit @command{rotctl} in interactive mode (@kbd{q} is not case -sensitive). - -When @command{rotctl} is controlling the rotor directly, will close -the rotor back end and port. When @command{rotctl} is connected to -@command{rotctld} (rotor model 2), the @acronym{TCP/IP} connection to -@command{rotctld} is closed and @command{rotctld} remains running, -available for another @acronym{TCP/IP} network connection. - -@item P, set_pos @var{Azimuth}, @var{Elevation} -Set position: @var{Azimuth} and @var{Elevation} as double precision -floating point values. -@ifhtml -@* -@end ifhtml - -@item p, get_pos -Get position: @var{Azimuth} and @var{Elevation} as double precision -floating point values. -@ifhtml -@* -@end ifhtml - -@item M, move @var{Direction}, @var{Speed} -Move the rotator in a specific direction at the given rate. - -Values are integers where @var{Direction} is defined as @code{2} = Up, -@code{4} = Down, @code{8} = Left, and @code{16} = Right. @var{Speed} -is an integer between @code{1} and @code{100}. - -@strong{N.B.} Not all backends that implement the move command use the -Speed value. At this time only the gs232a utilizes the Speed -parameter. - -@item S, stop -Stop the rotator. -@ifhtml -@* -@end ifhtml - -@item K, park -Park the antenna. -@ifhtml -@* -@end ifhtml - -@item C, set_conf @var{Token}, @var{Value} -Set a configuration parameter. It is safe to give @var{Token} a value -of @code{0} (zero). @var{Value} may be a string up to 20 characters. - -See @option{-L} output. - -@item R, reset @var{Reset} -Reset the rotator. - -Integer value of @code{1} for Reset All. - -@item _, get_info -Get misc information on the rotator. - -At the moment returns @var{Model Name}. - -@item w, send_cmd @var{Cmd} -Send raw command string to the rotator. - -@code{} (or @option{send-cmd-term}, see @option{-t} option) is -appended automatically at the end of the command for text protocols. -For binary protocols, enter values as @code{\0xAA\0xBB}. -@end table - -@strong{Locator Commands} - -These commands offer conversions of Degrees Minutes Seconds to other -formats, Maidenhead square locator conversions and distance and -azimuth conversions. - -@table @command -@item L, lonlat2loc @var{Longitude}, @var{Latitude}, @var{Loc Len 2..12} -Returns the Maidenhead locator for the given @var{Longitude} and -@var{Latitude}. - -Both are floating point values. The precision of the returned square -is controlled by @var{Loc Len} which should be an even numbered -integer value between @code{2} and @code{12}. - -For example, @kbd{L -170.000000 -85.000000 12} returns @samp{Locator: -AA55AA00AA00}. - -@item l, loc2lonlat @var{Locator} -Returns @var{Longitude} and @var{Latitude} in decimal degrees at the -approximate center of the requested grid square (despite the use of -double precision variables internally, some rounding error occurs). -West longitude is expressed as a negative value. South latitude is -expressed as a negative value. Locator can be from 2 to 12 characters -in length. - -For example, @kbd{l AA55AA00AA00} returns @samp{Longitude: -169.999983 -Latitude: -84.999991}. - -@item D, dms2dec @var{Degrees}, @var{Minutes}, @var{Seconds}, @var{S/W} -Returns @var{Dec Degrees}, a signed floating point value. - -@var{Degrees} and @var{Minutes} are integer values and @var{Seconds} -is a floating point value. @var{S/W} is a flag with @code{1} -indicating South latitude or West longitude and @code{0} North or East -(the flag is needed as computers don't recognize a signed zero even -though only the @var{Degrees} value only is typically signed in -@acronym{DMS} notation). - -@item d, dec2dms @var{Dec Degrees} -Returns @var{Degrees}, @var{Minutes}, @var{Seconds}, @var{S/W}. - -Values are as in @command{dms2dec} above. - -@item E, dmmm2dec @var{Degrees}, @var{Dec Minutes}, @var{S/W} -Returns @var{Dec Degrees}, a signed floating point value. - -@var{Degrees} is an integer value and @var{Minutes} is a floating -point value. @var{S/W} is a flag with @code{1} indicating South -latitude or West longitude and @code{0} North or East (the flag is -needed as computers don't recognize a signed zero even though only the -@var{Degrees} value only is typically signed in @acronym{DMS} -notation). - -@item e, dec2dmmm @var{Dec Deg} -Returns @var{Degrees}, @var{Minutes}, @var{S/W}. - -Values are as in @command{dmmm2dec} above. - -@item B, qrb @var{Lon 1}, @var{Lat 1}, @var{Lon 2}, @var{Lat 2} -Returns @var{Distance} and @var{Azimuth} where @var{Distance} is in km -and @var{Azimuth} is in degrees. - -All @var{Lon}/@var{Lat} values are signed floating point numbers. - -@item A, a_sp2a_lp @var{Short Path Deg} -Returns @var{Long Path Deg} or @code{-RIG_EINVAL} upon input error. - -Both are floating point values within the range @code{0.00} to -@var{360.00}. - -@item a, d_sp2d_lp @var{Short Path km} -Returns @var{Long Path km}. - -Both are floating point values. -@end table - -@node rotctl readline support -@subsection @command{rotctl} Readline support -@cindex @command{rotctl} Readline support -@cindex Readline support, @command{rotctl} - -If Readline library development files are found at configure time, -@command{rotctl} will be conditonally built with Readline support for -command and argument entry. Readline command key bindings are at -their defaults as described in the -@url{http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html, -Readline manual} although @command{rotctl} sets the name @code{rotctl} -which can be used in @code{Conditional Init Constructs} in the -Readline Init File (@file{$HOME/.inputrc} by default) for custom -keybindings unique to @command{rotctl}. - -Command history is available with Readline support as described in the -@url{http://cnswww.cns.cwru.edu/php/chet/readline/history.html#SEC1, -Readline History manual}. Command and argument strings are stored as -single lines even when arguments are prompted for input individually. -Commands and arguments are not validated and are stored as typed with -values separated by a single space. - -Normally session history is not saved, however, use of either of the -@option{-i}/@option{--read-history} or -@option{-I}/@option{--save-history} options when starting -@command{rotctl} will cause any previously saved history to be read in -and/or the current and any previous session history (assuming the -@option{-i} and @option{-I} options are given together) will be -written out when @command{rotctl} is closed. Each option is mutually -exclusive, i.e. either may be given separately or in combination. -This is useful to save a set of commands and then read them later but -not write the modified history for a consistent set of test commands -in interactive mode, for example. - -History is stored in @file{$HOME/.rotctl_history} by default although the -destination directory may be changed by setting the -@env{ROTCTL_HIST_DIR} environment variable. When -@env{ROTCTL_HIST_DIR} is unset, the value of the @env{HOME} environment -variable is used instead. Only the destination directory may be -changed at this time. - -If Readline support is not found at configure time the original -internal command handler is used. Readline is not used for -@command{rotctl} commands entered on the command line regardless if -Readline support is built in or not. - -@quotation Note -Readline support is not included in the MS Windows 32 binary builds -supplied by the Hamlib Project. Running @command{rotctl} on the MS -Windows 32 platform in the @command{cmd} shell does give session -command line history, however, it is not saved to disk between -sessions. -@end quotation @node rigctld @section @command{rigctld} @@ -1662,17 +350,14 @@ sessions. The @command{rigctld} program is a network server that accepts the familiar commands of @command{rigctl} and provides the response data over a @acronym{TCP/IP} network socket to an application. In this -manner an application can access a @command{rigctl} instance from +manner an application can access a @command{rigctld} instance from nearly anywhere (caveat, no security is currently provided by -@command{rigctl}). Applications using @command{rigctl} do not link to -Hamlib nor use its C API. +@command{rigctld}). Applications using @command{rigctld} do not link +directly to Hamlib nor use its C API. @menu * Introduction to rigctld:: -* rigctld invocation:: -* rigctld command line options:: -* rigctld commands:: -* rigctld protocol:: +* rigctld reference:: @end menu @node Introduction to rigctld @@ -1680,15 +365,6 @@ Hamlib nor use its C API. @cindex Introduction to @command{rigctld} @cindex @command{rigctld}, introduction to -Multiple radios can be controlled on different @acronym{TCP} ports by -use of multiple @command{rigctld} processes. The syntax of the -commands are the same as @command{rigctl}. It is hoped that -@command{rigctld} will be especially useful for client authors using -languages such as @url{http://www.perl.org/, Perl}, -@url{http://www.python.org/, Python}, @url{http://php.net/, PHP}, -@url{http://www.ruby-lang.org/en/, Ruby}, @url{http://www.tcl.tk/, -TCL}, and others. - @command{rigctld} communicates to a client through a @acronym{TCP} network socket using text commands shared with @command{rigctl}. The protocol is simple; commands are sent to @command{rigctld} on one line @@ -1697,10 +373,9 @@ values, one per line, when successful, otherwise, it responds with one line @samp{RPRT x}, where @samp{x} is a negative number indicating the Hamlib error code. Commands that do not return values respond with the line @samp{RPRT x}, where @samp{x} is zero when successful, -otherwise a regative number indicating the Hamlib error code. Each +otherwise a negative number indicating the Hamlib error code. Each line is terminated with a newline @code{\n} character. This protocol -is primarily for use by the @code{NET rigctl} (rig model 2) backend. -@xref{rigctld Default protocol}. +is primarily for use by the @code{NET rigctl} (radio model 2) backend. A separate Extended Response protocol extends the above behavior by echoing the received command string as a header, any returned values @@ -1708,1064 +383,23 @@ as a key: value pair, and the @samp{RPRT x} string as the end of response marker which includes the Hamlib success or failure value. Consider using this protocol for clients that will interact with @command{rigctld} directly through a @acronym{TCP} network socket. -@xref{rigctld Extended Response protocol}. -@node rigctld invocation -@subsection @command{rigctld} invocation -@cindex @command{rigctld} invocation -@cindex invocation, @command{rigctld} - -The command line invocation for @command{rigctld} is similar to -@command{rigctl} except that in POSIX environments a trailing @kbd{&} -is appended to the command string to ``background'' the -@command{rigctld} process so the shell can be used to run other -commands while @command{rigctld} continues to run. - -Here are some examples for invoking @command{rigctld}. - -Start @command{rigctld} for a Yaesu FT-920 using a USB-to-serial -adapter and backgrounding: - -@example -rigctld -m 114 -r /dev/ttyUSB1 & -@end example - -Start @command{rigctld} for a Yaesu FT-920 using a USB to serial -adapter while setting baud rate and stop bits, and backgrounding: - -@example -rigctld -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 & -@end example - -Start @command{rigctld} for an Elecraft K3 using @code{COM2} on MS -Windows: - -@example -rigctld -m 229 -r COM2 -T 127.0.0.1 -t 4532 -@end example - -@quotation Note -On MS Windows the use of the @option{-T} and @option{-t} options appear -to be necessary to set the @acronym{IP} address and @acronym{TCP} port -or else the network socket cannot be found. On @acronym{POSIX} systems -the @command{rigctld} default values will be used. -@end quotation - -Connect to the already running @command{rigctld}, and set current -frequency to 14.266 MHz with a 1 second read timeout using the default -protocol from the shell prompt: - -@example -echo "\set_freq 14266000" | nc -w 1 localhost 4532 -@end example - -Connect to a running @command{rigctld} with @command{rigctl} on the -local host: - -@example -rigctl -m2 -@end example - -@node rigctld command line options -@subsection @command{rigctld} command line options -@cindex @command{rigctld} command line options -@cindex Command line options, @command{rigctld} - -Many of the @command{rigctld} command line options are shared -with @command{rigctl} with a few additions. - -@command{rigctld} accepts the following options: - -@table @option -@item -m -@itemx --model=@var{id} -Select radio model number. See model list (use @kbd{rigctld -l}). -@ifhtml -@* -@end ifhtml - -@item -r -@itemx --rig-file=@var{device} -Use @var{device} as the file name of the port the radio is connected. -Often a serial port, but could be a USB to serial adapter. Typically -@file{/dev/ttyS0} , @file{/dev/ttyS1} , @file{/dev/ttyUSB0} , etc.@: -on Linux or @file{COM1} , @file{COM2} , etc.@: on MS Windows. The -special string @kbd{uh-rig} may be given to enable micro-ham device -support. -@ifhtml -@* -@end ifhtml - -@item -p -@itemx --ptt-file=@var{device} -Use @var{device} as the file name of the Push-To-Talk device using a -device file as described above. -@ifhtml -@* -@end ifhtml - -@item -d -@itemx --dcd-file=@var{device} -Use @var{device} as the file name of the Data Carrier Detect device -using a device file as described above. -@ifhtml -@* -@end ifhtml - -@item -P -@itemx --ptt-type=@var{type} -Use @var{type} of Push-To-Talk device. Supported types are -@code{RIG}, @code{DTR}, @code{RTS}, @code{PARALLEL}, @code{NONE}, -overriding @acronym{PTT} type defined in the rig's backend. - -Some side effects of this command are that when type is set to -@code{DTR}, read @acronym{PTT} state comes from Hamlib frontend, not -read from the radio. When set to @code{NONE}, @acronym{PTT} state -cannot be read or set even if rig backend supports reading/setting -@acronym{PTT} status from the rig. - -@item -D -@itemx --dcd-type=@var{type} -Use @var{type} of Data Carrier Detect device. Supported types are -@code{RIG} (@acronym{CAT} command), @code{DSR}, @code{CTS}, @code{CD}, -@code{PARALLEL}, @code{NONE}. -@ifhtml -@* -@end ifhtml - -@item -s -@itemx --serial-speed=@var{baud} -Set serial speed to @var{baud} rate. Uses @strong{maximum} serial -speed from rig backend capabilities (set by @option{-m} above) as the -default. -@ifhtml -@* -@end ifhtml - -@item -c -@itemx --civaddr=@var{id} -Use @var{id} as the @acronym{CI-V} address to communicate with the -rig. Only useful for Icom radios and those using the Icom protocol. - -@strong{N.B.} The @var{id} is in decimal notation, unless prefixed by -@code{0x}, in which case it is a hexadecimal value. - -@item -T -@itemx --listen-addr=@var{IPADDR} -Use @var{IPADDR} as the listening @acronym{IP} address. The default is ANY. - -@strong{N.B.} On MS Windows setting a specific @acronym{IP} address is -likely necessary. - -@item -t -@itemx --port=@var{number} -Use @var{number} as the @acronym{TCP} listening port. The default is -@code{4532}. - -@strong{N.B.} As @command{rotctld}'s default port is @code{4533}, it -is advisable to use even numbered ports for @command{rigctld}, e.g. -@code{4532}, @code{4534}, @code{4536}, etc. - -@item -L -@itemx --show-conf -List all config parameters for the radio defined with @option{-m} -above. -@ifhtml -@* -@end ifhtml - -@item -C -@itemx --set-conf=@var{parm}=@var{val}[,@var{parm}=@var{val},@dots{}] -Set config parameter. e.g.@: @code{stop_bits=2} - -Use @option{-L} option for a list. - -@item -l -@itemx --list -List all model numbers defined in Hamlib and exit. As of 1.2.15.1 the -list is sorted by model number. - -@strong{N.B.} In Linux the list can be scrolled back using -@kbd{@key{SHIFT}-PageUp}/ @kbd{@key{SHIFT}-PageDown}, or using the -scrollbars of a virtual terminal in X or the @command{cmd} window in -MS Windows. The output can be piped to '@command{more}' or -'@command{less}', e.g.@: '@kbd{rigctl -l | more}'. - -@item -u -@itemx --dump-caps -Dump capabilities for the radio defined with @option{-m} above and -exit. -@ifhtml -@* -@end ifhtml - -@item -o -@itemx --vfo -Set vfo mode, requiring an extra @acronym{VFO} argument in front of -each appropriate command (except @command{set_vfo}!). Otherwise, -@code{currVFO} is assumed when this option is not set and an extra VFO -argument is not used. See @command{chk_vfo} below. -@ifhtml -@* -@end ifhtml - -@item -v -@itemx --verbose -Set verbose mode level, cumulative i.e.@: @option{-vvvvv} sets maximum -debugging output to @file{stderr}. - -Five different levels of diagnostics can be output to @file{stderr} -and correspond to @option{-v} for @code{BUG}, @option{-vv} for -@code{ERR}, @option{-vvv} for @code{WARN}, @option{-vvvv} for -@code{VERBOSE}, or @option{-vvvvv} for @code{TRACE}. Back end authors -will use the verbose facility to print critical values useful for -testing and will often ask for this output in response to a request -for help. - -@item -Z -@itemx --debug_time_stamps -Enable time stamps on debug output. - -@item -h -@itemx --help -Show summary of these options and exit. -@ifhtml -@* -@end ifhtml - -@item -V -@itemx --version -Show version of @command{rigctl} and exit. - -@end table - -@quotation Note -Some options may not be implemented by a given backend and will return -an error. This is most likely to occur with the @option{--set-conf} -and @option{--show-conf} options. -@end quotation - -@node rigctld commands -@subsection @command{rigctld} commands -@cindex @command{rigctld} commands -@cindex commands, @command{rigctld} - -Commands can be sent over the @acronym{TCP} socket either as a single -char, or as a long command name plus the value(s) space separated on -one @code{\n} terminated line. @xref{rigctld protocol}. - -Since most of the Hamlib operations have a ``set'' and a ``get'' -method, in general an upper case letter will be used for set methods -whereas the corresponding lower case letter refers to the get method. -Each operation also has a long name; in interactive mode, prepend a -backslash @kbd{\} to enter a long command name. - -Example (Perl): - -@example -print $socket "\\dump_caps\n"; -@end example - -@noindent -to see what the radio's backend can do. - -@quotation N.B. -In Perl and many other languages a @kbd{\} will need to -be escaped with a preceding @kbd{\} so that even though two backslash -characters appear in the code, only one will be passed to -@command{rigctld}. This is a possible bug, so beware! -@end quotation - -Be aware that the backend for the radio to be controlled, or the radio -itself may not support some commands. In that case, the operation will -fail with a Hamlib error message. - -Here is a summary of the supported commands: - -@itemize -@item -Command short name is followed by the long name which is followed by -any variable names. - -@item -Some short commands are noted as hexadecimal digits due to the -limitation of upper and lower case letters available. Use the -associated long command name instead. - -@item -While a comma is used to separate variable names in this document, -they are not part of the command syntax used by @command{rigctl}. Use -a space to separate values. - -@item -In the case of ``set'' commands the variable @var{name} is replaced by -the value in the description. - -@item -In the case of ``get'' commands the variable @var{name} is the key -name of the value returned. - -@end itemize - -@table @command -@item F, set_freq @var{Frequency} -Set @var{Frequency}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item f, get_freq -Get @var{Frequency}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item M, set_mode @var{Mode}, @var{Passband} -Set @var{Mode} to one of: @code{USB}, @code{LSB}, @code{CW}, -@code{CWR}, @code{RTTY}, @code{RTTYR}, @code{AM}, @code{FM}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -Set @var{Passband} frequency in Hertz, or @code{0} for the Hamlib -backend default. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument -instead of @var{Mode} will return a space separated list of radio -backend supported Modes. Use this to determine the supported Modes of -a given radio backend. - -@item m, get_mode -Get @var{Mode}, @var{Passband}. - -Returns Mode as a string from @command{set_mode} above and Passband -frequency in Hertz. - -@item V, set_vfo @var{VFO} -Set @var{VFO} to one of: @code{VFOA}, @code{VFOB}, @code{VFOC}, -@code{currVFO}, @code{VFO}, @code{MEM}, @code{Main}, @code{Sub}, -@code{TX}, @code{RX}. - -In @acronym{VFO} mode only a single @acronym{VFO} parameter is -required. - -@item v, get_vfo -Get current @var{VFO}. - -Returns @acronym{VFO} as a string from @command{set_vfo} above. - -@item J, set_rit @var{RIT} -Set @var{RIT}, in Hertz, can be a positive or negative value. - -A value of @code{0} resets @acronym{RIT} and @emph{should} turn -@acronym{RIT} off. If not, file a bug report against the Hamlib -backend. - -@strong{N.B.} This functionality is under transition and in the future -will need to be activated with the @command{set_func} command. - -@item j, get_rit -Get @var{RIT}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item Z, set_xit @var{XIT} -Set @var{XIT}, in Hertz, can be a positive or negative value. - -A value of @code{0} resets @acronym{XIT} and @emph{should} turn -@acronym{XIT} off. If not, file a bug report against the Hamlib -backend. - -@strong{N.B.} This functionality is under transition and in the future -will need to be activated with the @command{set_func} command. - -@item z, get_xit -Get @var{XIT}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item T, set_ptt @var{PTT} -Set @var{PTT} to one of: @code{0} (RX), @code{1} (TX), @code{2} (TX -mic), @code{3} (TX data). -@ifhtml -@* -@end ifhtml - -@item t, get_ptt -Get @var{PTT} status. -@ifhtml -@* -@end ifhtml - -@item 0x8b, get_dcd -Get @var{DCD} (squelch) status, @code{0} (Closed) or @code{1} (Open) -@ifhtml -@* -@end ifhtml - -@item R, set_rptr_shift @var{Rptr Shift} -Set @var{Rptr Shift}: @code{+}, @code{-} or something else for none. -@ifhtml -@* -@end ifhtml - -@item r, get_rptr_shift -Get @var{Rptr Shift}. Returns @code{+}, @code{-} or @code{None}. -@ifhtml -@* -@end ifhtml - -@item O, set_rptr_offs @var{Rptr Offset} -Set @var{Rptr Offset}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item o, get_rptr_offs -Get @var{Rptr Offset}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item C, set_ctcss_tone @var{CTCSS Tone} -Set @var{CTCSS Tone}, in tenths of Hertz. - -@acronym{CTCSS}, -@url{http://en.wikipedia.org/wiki/Continuous_Tone-Coded_Squelch_System, -Continuous Tone Coded Squelch System}, is a method used to reduce the -annoyance of listening to other users on a shared two-way -communications radio channel by imposing a tone on the transmitted -signal. Also known as @dfn{subaudible tone} and @acronym{PL}, -@dfn{Private Line}. - -@item c, get_ctcss_tone -Get @var{CTCSS Tone}, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item D, set_dcs_code @var{DCS Code} -Set @var{DCS Code}. - -@acronym{DCS}, -@url{http://en.wikipedia.org/wiki/Digital-Coded_Squelch#DCS, -Digital-Coded Squelch} is a digital version of @acronym{CTCSS} which -imposes a digital code on the transmitted signal. - -@item d, get_dcs_code -Get @var{DCS Code}. -@ifhtml -@* -@end ifhtml - -@item 0x90, set_ctcss_sql @var{CTCSS Sql} -Set @var{CTCSS Sql} tone, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item 0x91, get_ctcss_sql -Get @var{CTCSS Sql} tone, in tenths of Hertz. -@ifhtml -@* -@end ifhtml - -@item 0x92, set_dcs_sql @var{DCS Sql} -Set @var{DCS Sql} code. -@ifhtml -@* -@end ifhtml - -@item 0x93, get_dcs_sql -Get @var{DCS Sql} code. -@ifhtml -@* -@end ifhtml - -@item I, set_split_freq @var{Tx Frequency} -Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. - -See also @command{set_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item i, get_split_freq -Get @var{TX Frequency}, in Hertz for ``split'' frequency operation. - -See also @command{get_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item X, set_split_mode @var{TX Mode}, @var{TX Passband} -Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, -@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. A value of @code{-1} may be -passed which leaves the rig passband unchanged from the current or -default value for the mode as defined by the rig. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{TX Mode} will return a space separated list of radio backend -supported TX Modes. Use this to determine the supported TX Modes of a -given radio backend. - -See also @command{set_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item x, get_split_mode -Get @var{TX Mode}, @var{TX Passband}. - -Returns TX mode as a string from @command{set_split_mode} above and TX -passband in Hz. - -See also @command{get_split_freq_mode} below. -@ifhtml -@* -@end ifhtml - -@item K, set_split_freq_mode @var{Tx Frequency}, @var{TX Mode}, @var{TX Passband} -Set @var{TX Frequency}, in Hertz for ``split'' frequency operation. -Set @var{TX Mode} to one of: @code{AM}, @code{FM}, @code{CW}, -@code{CWR}, @code{USB}, @code{LSB}, @code{RTTY}, @code{RTTYR}, -@code{WFM}, @code{AMS}, @code{PKTLSB}, @code{PKTUSB}, @code{PKTFM}, -@code{ECSSUSB}, @code{ECSSLSB}, @code{FAX}, @code{SAM}, @code{SAL}, -@code{SAH}, @code{DSB}. - -The @var{TX Passband} is the exact passband frequency in Hertz, or -@code{0} for the Hamlib backend default. A value of @code{-1} may be -passed which leaves the rig passband unchanged from the current or -default value for the mode as defined by the rig. - -This is a convenience function that combines the effect of -@command{set_split_freq} and @command{set_split_mode}. It should be -used when both are required since it allows the back end to optimize -the operations. For example on many Icom rigs the current VFO must be -changed temporarily while executing these commands and that can -disrupt receive or transmit, using this function may minimize that -disruption. - -See also @command{set_split_freq} and @command{set_split_mode} above. -@ifhtml -@* -@end ifhtml - -@item k, get_split_freq_mode -Get @var{TX Frequency}, in Hertz for ``split'' frequency operation -along with the @var{TX Mode} as a string from @command{set_split_mode} -above and @var{TX Passband} in Hz. - -This is a convenience function that combines the effect of -@command{get_split_freq} and @command{get_split_mode}. It should be -used when both are required since it allows the back end to optimize -the operations. For example on many Icom rigs the current VFO must be -changed temporarily while executing these commands and that can -disrupt receive or transmit, using this function may minimize that -disruption. - -See also @command{get_split_freq} and @command{get_split_mode} above. -@ifhtml -@* -@end ifhtml - -@item S, set_split_vfo @var{Split}, @var{TX VFO} -Set @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO} -from @command{set_vfo} above. -@ifhtml -@* -@end ifhtml - -@item s, get_split_vfo -Get @var{Split} mode, @code{0} (off) or @code{1} (on), and @var{TX VFO}. -@ifhtml -@* -@end ifhtml - -@item N, set_ts @var{Tuning Step} -Set @var{Tuning Step}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item n, get_ts -Get @var{Tuning Step}, in Hertz. -@ifhtml -@* -@end ifhtml - -@item U, set_func @var{Func}, @var{Func Status} -Set @var{Func}, @var{Func Status}. - -@var{Func} is one of: @code{FAGC}, @code{NB}, @code{COMP}, @code{VOX}, -@code{TONE}, @code{TSQL}, @code{SBKIN}, @code{FBKIN}, @code{ANF}, -@code{NR}, @code{AIP}, @code{APF}, @code{MON}, @code{MN}, @code{RF}, -@code{ARO}, @code{LOCK}, @code{MUTE}, @code{VSC}, @code{REV}, -@code{SQL}, @code{ABM}, @code{BC}, @code{MBC}, @code{RIT}, @code{AFC}, -@code{SATMODE}, @code{SCOPE}, @code{RESUME}, @code{TBURST}, -@code{TUNER}, @code{XIT}. - -Func Status argument is @code{1} for ``activate'', @code{0} for -``de-activate'', much as TRUE/FALSE definitions in the C/C++ languages -(true is non-zero and false is zero). - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Func} will return a space separated list of radio backend -supported ``set'' functions. Use this to determine the supported -functions of a given radio backend. - -@item u, get_func @var{Func} -Get @var{Func Status}. - -Returns @var{Func Status} as a non null value for the @var{Func} passed. -@var{Func} is a token from the list in @command{set_func} above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Func} will return a space separated list of radio backend -supported ``get'' functions. Use this to determine the supported -functions of a given radio backend. - -@item L, set_level @var{Level}, @var{Level Value} -Set @var{Level}, @var{Level Value}. - -@var{Level} is one of: @code{PREAMP}, @code{ATT}, @code{VOX}, @code{AF}, -@code{RF}, @code{SQL}, @code{IF}, @code{APF}, @code{NR}, @code{PBT_IN}, -@code{PBT_OUT}, @code{CWPITCH}, @code{RFPOWER}, @code{MICGAIN}, -@code{KEYSPD}, @code{NOTCHF}, @code{COMP}, @code{AGC}(@code{0}:OFF, -@code{1}:SUPERFAST, @code{2}:FAST, @code{3}:SLOW, @code{4}:USER, -@code{5}:MEDIUM, @code{6}:AUTO), @code{BKINDL}, @code{BAL}, -@code{METER}, @code{VOXGAIN}, @code{ANTIVOX}, @code{SLOPE_LOW}, -@code{SLOPE_HIGH}, @code{RAWSTR}, @code{SWR}, @code{ALC}, -@code{STRENGTH}. - -The @var{Level Value} can be a float or an integer. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Level} will return a space separated list of radio backend -supported ``set'' levels. Use this to determine the supported levels of a -given radio backend. - -@item l, get_level @var{Level} -Get @var{Level Value}. - -Returns @var{Level Value} as a float or integer for the @var{Level} -passed. @var{Level} is a token from the list in @command{set_level} -above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Level} will return a space separated list of radio backend -supported ``get'' levels. Use this to determine the supported levels of a -given radio backend. - -@item P, set_parm @var{Parm}, @var{Parm Value} -Set @var{Parm}, @var{Parm Value} - -@var{Parm} is one of: @code{ANN}, @code{APO}, @code{BACKLIGHT}, -@code{BEEP}, @code{TIME}, @code{BAT}, @code{KEYLIGHT}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Parm} will return a space separated list of radio backend -supported ``set'' parameters. Use this to determine the supported -parameters of a given radio backend. - -@item p, get_parm @var{Parm} -Get @var{Parm Value}. - -Returns @var{Parm Value} as a float or integer for the @var{Parm} -passed. @var{Parm} is a token from the list in @command{set_parm} -above. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead -of @var{Parm} will return a space separated list of radio backend -supported ``get'' parameters. Use this to determine the supported -parameters of a given radio backend. - -@item B, set_bank @var{Bank} -Set @var{Bank}. Sets the current memory bank number. -@ifhtml -@* -@end ifhtml - -@item E, set_mem @var{Memory#} -Set @var{Memory#} channel number. -@ifhtml -@* -@end ifhtml - -@item e, get_mem -Get @var{Memory#} channel number. -@ifhtml -@* -@end ifhtml - -@item G, vfo_op @var{Mem/VFO Op} -Perform @var{Mem/VFO Op}. - -@var{Mem/VFO Op}eration is one of: @code{CPY}, @code{XCHG}, -@code{FROM_VFO}, @code{TO_VFO}, @code{MCL}, @code{UP}, @code{DOWN}, -@code{BAND_UP}, @code{BAND_DOWN}, @code{LEFT}, @code{RIGHT}, -@code{TUNE}, @code{TOGGLE}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Mem/VFO Op} will return a space separated list of radio backend -supported ``set'' Mem/VFO Ops. Use this to determine the supported Mem/VFO -Ops of a given radio backend. - -@item g, scan @var{Scan Fct}, @var{Scan Channel} -Perform @var{Scan Fct} @var{Scan Channel}. - -Scan function/channel is one of: @code{STOP}, @code{MEM}, @code{SLCT}, -@code{PRIO}, @code{PROG}, @code{DELTA}, @code{VFO}, @code{PLT}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Scan Fct} will return a space separated list of radio backend -supported Scan Functions. Use this to determine the supported Scan -Functions of a given radio backend. - -@item H, set_channel @var{Channel} -Set memory @var{Channel} data. Not implemented yet. -@ifhtml -@* -@end ifhtml - -@item h, get_channel -Get memory @var{Channel} data. Not implemented yet. -@ifhtml -@* -@end ifhtml - -@item A, set_trn @var{Transceive} -Set @var{Transceive} mode (reporting event): @code{OFF}, @code{RIG}, -@code{POLL}. - -@strong{N.B.} Passing a @kbd{?} (query) as the first argument instead of -@var{Transceive} will return a space separated list of radio backend -supported Scan Transceive modes. Use this to determine the supported -Transceive modes of a given radio backend. - -@item a, get_trn -Get @var{Transceive} mode (reporting event) as in @command{set_trn} -above. -@ifhtml -@* -@end ifhtml - -@item Y, set_ant @var{Antenna} -Set @var{Antenna} number (@code{0}, @code{1}, @code{2}, @dots{}). -@ifhtml -@* -@end ifhtml - -@item y, get_ant -Get @var{Antenna} number (@code{0}, @code{1}, @code{2}, @dots{}). -@ifhtml -@* -@end ifhtml - -@item *, reset @var{Reset} -Perform rig @var{Reset}. - -@code{0} = None, @code{1} = Software reset, @code{2} = @acronym{VFO} -reset, @code{4} = Memory Clear reset, @code{8} = Master reset. Since -these values are defined as a bitmask in @file{rig.h}, it should be -possible to @code{AND} these values together to do multiple resets at -once, if the backend supports it or supports a reset action via rig -control at all. - -@item b, send_morse @var{Morse} -Send @var{Morse} symbols. -@ifhtml -@* -@end ifhtml - -@item 0x87, set_powerstat @var{Power Status} -Set power On/Off/Standby @var{Power Status}. - -@code{0} = Power Off, @code{1} = Power On, @code{2} = Power Standby. -Defined as a bitmask in @file{rig.h}. - -@item 0x88, get_powerstat -Get power On/Off/Standby @var{Power Status} as in -@command{set_powerstat} above. -@ifhtml -@* -@end ifhtml - -@item 0x89, send_dtmf @var{Digits} -Set DTMF @var{Digits}. -@ifhtml -@* -@end ifhtml - -@item 0x8a, recv_dtmf -Get DTMF @var{Digits}. -@ifhtml -@* -@end ifhtml - -@item _, get_info -Get misc information about the rig - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 1, dump_caps -Not a real rig remote command, it just dumps capabilities, i.e. what -the backend knows about this model, and what it can do. - -TODO: Ensure this is in a consistent format so it can be read into a -hash, dictionary, etc. Bug reports requested. - -@strong{N.B.} This command will produce many lines of output so be -very careful if using a fixed length array! For example, running this -command against the Dummy backend results in over 5kB of text output. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 2, power2mW @var{Power 0.0..1.0}, @var{Frequency}, @var{Mode} -Returns @var{Power mW} - -Converts a @var{Power} value in a range of @code{0.0..1.0} to -the real transmit power in milli-Watts (integer). The @var{Frequency} -and @var{Mode} also need to be provided as output power may vary -according to these values. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item 4, mW2power @var{Power mW}, @var{Frequency}, @var{Mode} -Returns @var{Power 0.0..1.0} - -Converts the real transmit power in milli-Watts (integer) to a -@var{Power} value in a range of @code{[0.0..1.0]}. The -@var{Frequency} and @var{Mode} also need to be provided as output -power may vary according to these values. - -@acronym{VFO} parameter not used in '@acronym{VFO} mode'. - -@item w, send_cmd @var{Cmd} -Send raw command string to rig. This is useful for testing and -troubleshooting rig commands and responses when developing a backend. - -For binary protocols enter values as @code{\0xAA\0xBB}. Expect a -@var{Reply} from the rig which will likely be a binary block or an -@acronym{ASCII} string depending on the rig's protocol (see your -radio's computer control documentation). - -The command terminator, set by the @option{--send-cmd-term} option -above, will terminate each command string sent to the radio. This -character should not be a part of the input string. - -@item chk_vfo -Returns @code{CHKVFO 1} (single line only) if rigctld was invoked with -the @option{-o} or @option{--vfo} option, @code{CHKVFO 0} if not. - -@end table - -@node rigctld protocol -@subsection @command{rigctld} protocol -@cindex @command{rigctld} protocol -@cindex protocol, @command{rigctld} - -Two protocols exist for communicating with @command{rigctld}. The -``Default'' protocol is primarily used internally by Hamlib so an -application that is not written to use @command{rigctld} directly via -@acronym{TCP} network sockets can still access @command{rigctld}. The -other ``Extended Response Protocol'' is intended for the more general -use case where a variety of response formats may be needed. - - -@menu -* rigctld Default protocol:: -* rigctld Extended Response protocol:: -@end menu - -@node rigctld Default protocol -@subsubsection @command{rigctld} Default protocol -@cindex @command{rigctld} Default protocol -@cindex Default protocol, @command{rigctld} - -The @command{rigctld} protocol is intentionally simple. Commands are -entered on a single line with any needed values. In Perl, for exampl, -reliable results are obtained by terminating each command string with -a newline character, @samp{\n}. - -@noindent -Example @code{set} (Perl code): - -@example -print $socket "F 14250000\n"; -print $socket "\\set_mode LSB 2400\n"; # escape leading '\' -@end example - -@noindent -A one line response will be sent as a reply to @code{set} commands, -@samp{RPRT x\n} where @samp{x} is the Hamlib error code with @samp{0} -indicating success of the command. - -@noindent -Responses from @command{rigctld} get commands are text values and -match the same tokens used in the @code{set} commands. Each value -is returned on its own line. On error the string @samp{RPRT x\n} is -returned where @samp{x} is the Hamlib error code. - -@noindent -Example @code{get} (Perl code): - -@example -print $socket "f\n"; -"14250000\n" -@end example - -@noindent -Most @code{get} functions return one to three values. A notable -exception is the @command{dump_caps} command which returns many lines -of @samp{key:value} pairs. - -This protocol is primarily used by the @code{NET rigctl} -(@command{rigctl} model 2) backend which allows applications already -written for Hamlib's C @acronym{API} to take advantage of -@command{rigctld} without the need of rewriting application code. An -application's user can select rig model 2 (@code{NET rigctl}) and then -set @option{rig_pathname} to @kbd{localhost:4532} or other network -host:port (set by the @option{-t} option above). - -@node rigctld Extended Response protocol -@subsubsection @command{rigctld} Extended Response Protocol -@cindex @command{rigctld} Extended Response Protocol -@cindex Extended Response Protocol, @command{rigctld} - -An EXPERIMENTAL Extended Response protocol has been introduced into -@command{rigctld} as of February 16, 2010. This protocol adds several -rules to the strings returned by @command{rigctld} and adds a rule for -the command syntax. - -@enumerate -@item -The command received by @command{rigctld} is echoed with its long -command name followed by the value(s) (if any) received from the -client terminated by the specified response separator as the record -line of the response. - -@item -The last line of each block is the string @samp{RPRT x\n} where -@samp{x} is the numeric return value of the Hamlib backend function -that was called by the command. - -@item -Any records consisting of data values returned by the rig backend are -prepended by a string immediately followed by a colon then a space and -then the value terminated by the response -separator. e.g. @samp{Frequency: 14250000\n} when the command was -prepended by @code{+}. - -@item -All commands received will be acknowledged by @command{rigctld} with -lines from rules 1 and 2. Lines from rule 3 are only returned when -data values must be returned to the client. - -@end enumerate - -An example response to a @command{+\set_mode} command sent from the -shell prompt (note the prepended @code{+}): - -@example -echo "+M USB 2400" | nc -w 1 localhost 4532 -set_mode: USB 2400 -RPRT 0 -@end example - -In this case the long command name and values are returned on the -first line and the second line contains the end of block marker and -the numeric rig backend return value indicating success. - -An example response to a @command{\get_mode} query: - -@example -echo "+\get_mode" | nc -w 1 localhost 4532 -get_mode: -Mode: USB -Passband: 2400 -RPRT 0 -@end example - -In this case, as no value is passed to @command{rigctld}, the first -line consists only of the long command name. The final line shows -that the command was processed successfully by the rig backend. - -Invoking the Extended Response protocol requires prepending a command -with a punctuation character. As shown in the examples above, -prepending a '@code{+} character to the command results in the -responses being separated by a newline character (@samp{\n}). Any -other punctuation character recognized by the C @code{ispunct()} -function except @code{\}, @code{?}, or @code{_} will cause that -character to become the response separator and the entire response -will be on one line. - -Separator character summary: - -@table @code -@item + -Each record of the response is appended with a newline (@samp{\n}). -@ifhtml -@* -@end ifhtml - -@item ;, |, or , -Each record of the response is appended by the given character -resulting in entire response on one line. - -Common record separators for text representations of spreadsheet data, -etc. - -@item ? -Reserved for 'help' in @command{rigctl} short command. -@ifhtml -@* -@end ifhtml - -@item _ -Reserved for @command{\get_info} in @command{rigctl} short command. -@ifhtml -@* -@end ifhtml - -@item # -Reserved for comments when reading a command file script. - -@end table - -Other punctuation characters have not been tested! Use at your own -risk. - -For example, invoking a @command{;\get_mode} query with a leading -@code{;} returns: - -@example -get_mode:;Mode: USB;Passband: 2400;RPRT 0 -@end example - -Or, using the vertical bar (pipe) character @code{|} returns: - -@example -get_mode:|Mode: USB|Passband: 2400|RPRT 0 -@end example - -And a @command{\set_mode} command prepended with a @code{|} returns: - -@example -set_mode: USB 2400|RPRT 0 -@end example - -Such a format will allow reading a response as a single event using a -preferred response separator. Other punctuation characters have not -been tested! +Multiple radios can be controlled on different @acronym{TCP} ports by +use of multiple @command{rigctld} processes each listening on a unique +@acronym{TCP} port. It is hoped that @command{rigctld} will be +especially useful for client authors using languages such as +@url{http://www.perl.org/, Perl}, @url{http://www.python.org/, +Python}, @url{http://php.net/, PHP}, +@url{http://www.ruby-lang.org/en/, Ruby}, @url{http://www.tcl.tk/, +TCL}, and others. + +@node rigctld reference +@subsection @command{rigctld} reference +@cindex @command{rigctld} reference +@cindex reference, @command{rigctld} + +The complete reference for @command{rigctld} can be found in the +@kbd{rigctld}(1) Unix manual page. @node rotctld @@ -2775,17 +409,14 @@ been tested! The @command{rotctld} program is a network server that accepts the familiar commands of @command{rotctl} and provides the response data over a @acronym{TCP/IP} network socket to an application. In this -manner an application can access a @command{rotctl} instance from +manner an application can access a @command{rotctld} instance from nearly anywhere (caveat, no security is currently provided by -@command{rotctl}). Applications using @command{rotctl} do not link to -Hamlib nor use its C API. +@command{rotctld}). Applications using @command{rotctld} do not link +directly to Hamlib nor use its C API. @menu * Introduction to rotctld:: -* rotctld invocation:: -* rotctld command line options:: -* rotctld commands:: -* rotctld protocol:: +* rotctld reference:: @end menu @node Introduction to rotctld @@ -2794,17 +425,16 @@ Hamlib nor use its C API. @cindex @command{rotctld}, introduction to @command{rotctld} communicates to a client through a @acronym{TCP} -socket using text commands shared with @command{rotctl}. The protocol -is simple, commands are sent to @command{rotctld} on one line and -@command{rotctld} responds to ``get'' commands with the requested +network socket using text commands shared with @command{rotctl}. The +protocol is simple, commands are sent to @command{rotctld} on one line +and @command{rotctld} responds to ``get'' commands with the requested values, one per line, when successful, otherwise, it responds with one line @samp{RPRT x}, where @samp{x} is a negative number indicating the -error code. Commands that do not return values respond with the line -@samp{RPRT x}, where @samp{x} is zero when successful, otherwise is a -regative number indicating the error code. Each line is terminated -with a newline @code{\n} character. This protocol is primarily for -use by the @code{NET rotctl} (rot model 2) backend. @xref{rotctld -Default protocol}. +Hamlib error code. Commands that do not return values respond with +the line @samp{RPRT x}, where @samp{x} is zero when successful, +otherwise a negative number indicating the Hamlib error code. Each +line is terminated with a newline @code{\n} character. This protocol +is primarily for use by the @code{NET rotctl} (rot model 2) backend. A separate Extended Response protocol extends the above behavior by echoing the received command string as a header, any returned values @@ -2812,577 +442,130 @@ as a key: value pair, and the @samp{RPRT x} string as the end of response marker which includes the Hamlib success or failure value. Consider using this protocol for clients that will interact with @command{rotctld} directly through a @acronym{TCP} network socket. -@xref{rotctld Extended Response protocol}. -@node rotctld invocation -@subsection @command{rotctld} invocation -@cindex @command{rotctld} invocation -@cindex invocation, @command{rotctld} +Multiple rotators can be controlled on different @acronym{TCP} ports by +use of multiple @command{rotctld} processes each listening on a unique +@acronym{TCP} port. It is hoped that @command{rotctld} will be +especially useful for client authors using languages such as +@url{http://www.perl.org/, Perl}, @url{http://www.python.org/, +Python}, @url{http://php.net/, PHP}, +@url{http://www.ruby-lang.org/en/, Ruby}, @url{http://www.tcl.tk/, +TCL}, and others. -The command line invocation for @command{rotctld} is similar to -@command{rotctl} except that in POSIX environments a trailing @kbd{&} -is appended to the command string to ``background'' the -@command{rotctld} process so the shell can be used to run other -commands while @command{rotctld} continues to run. +@node rotctld reference +@subsection @command{rotctld} reference +@cindex @command{rotctld} reference +@cindex reference, @command{rotctld} -Here are some examples for invoking @command{rotctld}. +The complete reference for @command{rotctld} can be found in the +@kbd{rotctld}(1) Unix manual page. -Start @command{rotctld} for a Ham IV rotor with the RotorEZ installed -using a USB-to-serial adapter and backgrounding: -@example -rotctld -m 401 -r /dev/ttyUSB1 & -@end example - -Start @command{rotctld} for RotorEZ using @code{COM2} on MS Windows: - -@example -rotctl -m 401 -r COM2 -T 127.0.0.1 -t 4533 -@end example - -@quotation Note -On MS Windows the use of the @option{-T} and @option{-t} options appear -to be necessary to set the @acronym{IP} address and @acronym{TCP} port -or else the network socket cannot be found. On @acronym{POSIX} systems -the @command{rotctld} default values will be used. -@end quotation - -Connect to the already running rotctld, and set position to 135.0 -degrees azimuth and 30.0 degrees elevation with a 1 second read -timeout from the shell prompt: - -@example -echo "\set_pos 135.0 30.0" | nc -w 1 localhost 4533 -@end example - -Connect to a running @command{rotctld} with @command{rotctl} on the -local host: - -@example -rotctl -m2 -@end example - -@node rotctld command line options -@subsection @command{rotctld} command line options -@cindex @command{rotctld} command line options -@cindex Command line options, @command{rotctld} - -Many of the @command{rotctld} command line options are shared -with @command{rotctl} with a few additions. - -@command{rotctld} accepts the following options: - -@table @option -@item -m -@itemx --model=@var{id} -Select rotator model number. See model list (use @kbd{rotctl -l}). - -@strong{N.B.} @command{rotctl} (or third party software) will use -rotor model 2 for NET rotctl (@command{rotctld}). - -@item -r -@itemx --rot-file=@var{device} -Use @var{device} as the file name of the port the rotor is connected. -Often a serial port, but could be a USB to serial adapter. Typically -@file{/dev/ttyS0} , @file{/dev/ttyS1} , @file{/dev/ttyUSB0} , etc.@: -on Linux or @file{COM1} , @file{COM2} , etc.@: on MS Windows. The -special string @kbd{uh-rig} may be given to enable micro-ham device -support. -@ifhtml -@* -@end ifhtml - -@item -s -@itemx --serial-speed=@var{baud} -Set serial speed to @var{baud} rate. Uses @strong{maximum} serial -speed from rotor backend capabilities as the default. -@ifhtml -@* -@end ifhtml - -@item -T -@itemx --listen-addr=@var{IPADDR} -Use @var{IPADDR} as the listening @acronym{IP} address. The default is ANY. - -@strong{N.B.} On MS Windows setting a specific @acronym{IP} address is -likely necessary. - -@item -t -@itemx --port=@var{number} -Use @var{number} as the @acronym{TCP} listening port. The default is -@code{4533}. - -@strong{N.B.} As @command{rigctld}'s default port is @code{4532}, it -is advisable to use odd numbered ports for @command{rotctld}, e.g. -@code{4533}, @code{4535}, @code{4537}, etc. - -@item -L -@itemx --show-conf -List all config parameters for the rotor defined with @option{-m} -above. -@ifhtml -@* -@end ifhtml - -@item -C -@itemx --set-conf=@var{parm}=@var{val}[,@var{parm}=@var{val},@dots{}] -Set config parameter. e.g.@: @code{stop_bits=2} - -Use @option{-L} option for a list. - -@item -l -@itemx --list -List all model numbers defined in Hamlib and exit. As of 1.2.15.1 the -list is sorted by model number. - -@strong{N.B.} In Linux the list can be scrolled back using -@kbd{@key{SHIFT}-PageUp}/ @kbd{@key{SHIFT}-PageDown}, or using the -scrollbars of a virtual terminal in X or the @command{cmd} window in -MS Windows. The output can be piped to '@command{more}' or -'@command{less}', e.g.@: '@kbd{rotctl -l | more}'. - -@item -u -@itemx --dump-caps -Dump capabilities for the rotor defined with @option{-m} above and -exit. -@ifhtml -@* -@end ifhtml - -@item -v -@itemx --verbose -Set verbose mode level, cumulative i.e.@: @option{-vvvvv} sets maximum -debugging output to @file{stderr}. - -Five different levels of diagnostics can be output to @file{stderr} -and correspond to @option{-v} for @code{BUG}, @option{-vv} for -@code{ERR}, @option{-vvv} for @code{WARN}, @option{-vvvv} for -@code{VERBOSE}, or @option{-vvvvv} for @code{TRACE}. Back end authors -will use the verbose facility to print critical values useful for -testing and will often ask for this output in response to a request -for help. - -@item -Z -@itemx --debug-time-stamps -Enable time stamps on debug output. - -@item -h -@itemx --help -Show summary of these options and exit. -@ifhtml -@* -@end ifhtml - -@item -V -@itemx --version -Show version of @command{rotctl} and exit. -@end table - -@quotation Note -Some options may not be implemented by a given backend and will return -an error. This is most likely to occur with the @option{--set-conf} -and @option{--show-conf} options. -@end quotation - -@node rotctld commands -@subsection @command{rotctld} commands -@cindex @command{rotctld} commands -@cindex commands, @command{rotctld} - -Commands can be sent over the @acronym{TCP} socket either as a single -char, or as a long command name plus the value(s) space separated on -one @code{\n} terminated line. @xref{rotctld protocol}. - -Since most of the Hamlib operations have a ``set'' and a ``get'' -method, in general an upper case letter will be used for set methods -whereas the corresponding lower case letter refers to the get method. -Each operation also has a long name; in interactive mode, prepend a -backslash @kbd{\} to enter a long command name. - -Example (Perl): - -@example -print $socket "\\dump_caps\n"; -@end example - -@noindent -to see what the rotor's backend can do. - -@quotation N.B. -In Perl and many other languages a @kbd{\} will need to -be escaped with a preceding @kbd{\} so that even though two backslash -characters appear in the code, only one will be passed to -@command{rotctld}. This is a possible bug, so beware! -@end quotation - -Be aware that the backend for the rotor to be controlled, or the rotor -itself may not support some commands. In that case, the operation will -fail with a Hamlib error message. - -@strong{Rotor commands} - -Here is a summary of the supported commands: - -@table @command -@itemize -@item -Command short name is followed by the long name which is followed by -any variable names. - -@item -While a comma is used to separate variable names in this document, -they are not part of the command syntax used by @command{rotctl}. Use -a space to separate values. - -@item -In the case of ``set'' commands the variable @var{name} is replaced by -the value in the description. - -@item -In the case of ``get'' commands the variable @var{name} is the key -name of the value returned. - -@end itemize - -@item P, set_pos @var{Azimuth}, @var{Elevation} -Set position: @var{Azimuth} and @var{Elevation} as double precision -floating point values. -@ifhtml -@* -@end ifhtml - -@item p, get_pos -Get position: @var{Azimuth} and @var{Elevation} as double precision -floating point values. -@ifhtml -@* -@end ifhtml - -@item M, move @var{Direction}, @var{Speed} -Move the rotator in a specific direction at the given rate. - -Values are integers where @var{Direction} is defined as @code{2} = Up, -@code{4} = Down, @code{8} = Left, and @code{16} = Right. @var{Speed} -is an integer between @code{1} and @code{100}. - -@strong{N.B.} Not all backends that implement the move command use the -Speed value. At this time only the gs232a utilizes the Speed -parameter. - -@item S, stop -Stop the rotator. -@ifhtml -@* -@end ifhtml - -@item K, park -Park the antenna. -@ifhtml -@* -@end ifhtml - -@item C, set_conf @var{Token}, @var{Value} -Set a configuration parameter. It is safe to give @var{Token} a value -of @code{0} (zero). @var{Value} may be a string up to 20 characters. - -See @option{-L} output. - -@item R, reset @var{Reset} -Reset the rotator. - -Integer value of @code{1} for Reset All. - -@item _, get_info -Get misc information on the rotator. - -At the moment returns @var{Model Name}. - -@item w, send_cmd @var{Cmd} -Send raw command string to the rotator. - -@code{} (or @option{send-cmd-term}, see @option{-t} option) is -appended automatically at the end of the command for text protocols. -For binary protocols, enter values as @code{\0xAA\0xBB}. -@end table - -@strong{Locator Commands} - -These commands offer conversions of Degrees Minutes Seconds to other -formats, Maidenhead square locator conversions and distance and -azimuth conversions. - -@table @command -@item L, lonlat2loc @var{Longitude}, @var{Latitude}, @var{Loc Len 2..12} -Returns the Maidenhead locator for the given @var{Longitude} and -@var{Latitude}. - -Both are floating point values. The precision of the returned square -is controlled by @var{Loc Len} which should be an even numbered -integer value between @code{2} and @code{12}. - -For example, @kbd{+L -170.000000 -85.000000 12\n} returns -@samp{Locator: AA55AA00AA00\n}. - -@item l, loc2lonlat @var{Locator} -Returns @var{Longitude} and @var{Latitude} in decimal degrees at the -approximate center of the requested grid square (despite the use of -double precision variables internally, some rounding error occurs). -West longitude is expressed as a negative value. South latitude is -expressed as a negative value. Locator can be from 2 to 12 characters -in length. - -For example, @kbd{+l AA55AA00AA00} returns @samp{Longitude: --169.999983\nLatitude: -84.999991\n}. - -@item D, dms2dec @var{Degrees}, @var{Minutes}, @var{Seconds}, @var{S/W} -Returns @var{Dec Degrees}, a signed floating point value. - -@var{Degrees} and @var{Minutes} are integer values and @var{Seconds} -is a floating point value. @var{S/W} is a flag with @code{1} -indicating South latitude or West longitude and @code{0} North or East -(the flag is needed as computers don't recognize a signed zero even -though only the @var{Degrees} value only is typically signed in -@acronym{DMS} notation). - -@item d, dec2dms @var{Dec Degrees} -Returns @var{Degrees}, @var{Minutes}, @var{Seconds}, @var{S/W}. - -Values are as in @command{dms2dec} above. - -@item E, dmmm2dec @var{Degrees}, @var{Dec Minutes}, @var{S/W} -Returns @var{Dec Degrees}, a signed floating point value. - -@var{Degrees} is an integer value and @var{Minutes} is a floating -point value. @var{S/W} is a flag with @code{1} indicating South -latitude or West longitude and @code{0} North or East (the flag is -needed as computers don't recognize a signed zero even though only the -@var{Degrees} value only is typically signed in @acronym{DMS} -notation). - -@item e, dec2dmmm @var{Dec Deg} -Returns @var{Degrees}, @var{Minutes}, @var{S/W}. - -Values are as in @command{dmmm2dec} above. - -@item B, qrb @var{Lon 1}, @var{Lat 1}, @var{Lon 2}, @var{Lat 2} -Returns @var{Distance} and @var{Azimuth} where @var{Distance} is in km -and @var{Azimuth} is in degrees. - -All @var{Lon}/@var{Lat} values are signed floating point numbers. - -@item A, a_sp2a_lp @var{Short Path Deg} -Returns @var{Long Path Deg} or @code{-RIG_EINVAL} upon input error. - -Both are floating point values within the range @code{0.00} to -@var{360.00}. - -@item a, d_sp2d_lp @var{Short Path km} -Returns @var{Long Path km}. - -Both are floating point values. -@end table - - -@node rotctld protocol -@subsection @command{rotctld} protocol -@cindex @command{rotctld} protocol -@cindex protocol, @command{rotctld} - -Two protocols exist for communicating with @command{rotctld}. The -``Default'' protocol is primarily used internally by Hamlib so an -application that is not written to use @command{rotctld} directly via -@acronym{TCP} network sockets can still access @command{rotctld}. The -other ``Extended Response Protocol'' is intended for the more general -use case where a variety of response formats may be needed. +@node rigmem +@section @command{rigmem} +@cindex rigmem +@command{rigmem} may be used to backup and restore memory of radio +transceivers and receivers. @menu -* rotctld Default protocol:: -* rotctld Extended Response protocol:: +* Introduction to rigmem:: +* rigmem reference:: @end menu -@node rotctld Default protocol -@subsubsection @command{rotctld} Default protocol -@cindex @command{rotctld} Default protocol -@cindex Default protocol, @command{rotctld} +@node Introduction to rigmem +@subsection Introduction to @command{rigmem} +@cindex Introduction to @command{rigmem} +@cindex @command{rigmem}, introduction to -The @command{rotctld} protocol is intentionally simple. Commands are -entered on a single line with any needed values. In Perl, for exampl, -reliable results are obtained by terminating each command string with -a newline character, @samp{\n}. +Backup and restore memory of radio transceivers and receivers. +@command{rigmem} accepts @samp{command}s from the command line only. -@noindent -Example @code{set} (Perl code): +@node rigmem reference +@subsection @command{rigmem} reference +@cindex @command{rigmem} reference +@cindex reference, @command{rigmem} -@example -print $socket "P 135 10\n"; -print $socket "\\set_pos 135 10\n"; # escape leading '\' -@end example +The complete reference for @command{rigmem} can be found in the +@kbd{rigmem}(1) Unix manual page. -@noindent -A one line response will be sent as a reply to @code{set} commands, -@samp{RPRT x\n} where @samp{x} is the Hamlib error code with @samp{0} -indicating success of the command. +@node rigsmtr +@section @command{rigsmtr} +@cindex rigsmtr -@noindent -Responses from @command{rotctld} get commands are text values and -match the same tokens used in the @code{set} commands. Each value -is returned on its own line. On error the string @samp{RPRT x\n} is -returned where @samp{x} is the Hamlib error code. +@command{rigsmtr} uses Hamlib to control a radio to measure S-Meter +value versus antenna azimuth. -@noindent -Example @code{get} (Perl code): +@menu +* Introduction to rigsmtr:: +* rigsmtr reference:: +@end menu -@example -print $socket "p\n"; -"135" -"10" -@end example +@node Introduction to rigsmtr +@subsection Introduction to @command{rigsmtr} +@cindex Introduction to @command{rigsmtr} +@cindex @command{rigsmtr}, introduction to -@noindent -Most @code{get} functions return one to four values. A notable -exception is the @command{dump_caps} command which returns many lines -of @samp{key:value} pairs. +@command{rigsmtr} rotates the antenna from minimum azimuth to maximum +azimuth. Every second, or time_step if specified in seconds, it +retrieves the signal strength. Azimuth in degrees and the +corresponding S-Meter level in dB relative to S9 are then printed on +stdout. -This protocol is primarily used by the @code{NET rotctl} -(@command{rotctl} model 2) backend which allows applications already -written for Hamlib's C @acronym{API} to take advantage of -@command{rotctld} without the need of rewriting application code. An -application's user can select rotor model 2 (@code{NET rotctl}) and then -set @option{rig_pathname} to @kbd{localhost:4533} or other network -host:port (set by the @option{-t} option above). +To work correctly, @command{rigsmtr} needs a radio that could measure +S-Meter and a Hamlib backend that is able to retrieve it, connected to +a Hamlib supported rotator. -@node rotctld Extended Response protocol -@subsubsection @command{rotctld} Extended Response Protocol -@cindex @command{rotctld} Extended Response Protocol -@cindex Extended Response Protocol, @command{rotctld} +@node rigsmtr reference +@subsection @command{rigsmtr} reference +@cindex @command{rigsmtr} reference +@cindex reference, @command{rigsmtr} -An EXPERIMENTAL Extended Response protocol has been introduced into -@command{rotctld} as of February 10, 2010. This protocol adds several -rules to the strings returned by @command{rotctld} and adds a rule for -the command syntax. +The complete reference for @command{rigsmtr} can be found in the +@kbd{rigsmtr}(1) Unix manual page. -@enumerate -@item -The command received by @command{rotctld} is echoed with its long -command name followed by the value(s) (if any) received from the -client terminated by the specified response separator as the record -line of the response. +@node rigswr +@section @command{rigswr} +@cindex rigswr -@item -The last line of each block is the string @samp{RPRT x\n} where -@samp{x} is the numeric return value of the Hamlib backend function -that was called by the command. +@command{rigswr} may be used to measure VSWR vs frequency. -@item -Any records consisting of data values returned by the rotor backend are -prepended by a string immediately followed by a colon then a space and -then the value terminated by the response -separator. e.g. @samp{Azimuth: 90.000000\n} when the command was -prepended by @code{+}. +@menu +* Introduction to rigswr:: +* rigswr reference:: +@end menu -@item -All commands received will be acknowledged by @command{rotctld} with -lines from rules 1 and 2. Lines from rule 3 are only returned when -data values must be returned to the client. +@node Introduction to rigswr +@subsection Introduction to @command{rigswr} +@cindex Introduction to @command{rigswr} +@cindex @command{rigswr}, introduction to -@end enumerate +@command{rigswr} uses Hamlib to control a radio to measure +@acronym{VSWR} (Voltage Standing Wave Ratio) over a frequency range. +It scans frequencies from @var{start_freq} to @var{stop_freq} with an +optional increment of @var{freq_step} (default step is 100 kHz). All +values must be entered as an integer in Hertz (cycles per second). -An example response to a @command{+P} command sent from the -shell prompt (note the prepended @code{+}): +@quotation Note +@command{rigswr} assumes that @var{start_freq} is less than or equal +to @var{stop_freq}. If it is greater, @command{rigswr} will exit +without doing anything. +@end quotation -@example -echo "+P 90 45" | nc -w 1 localhost 4533 -set_pos: 90 45 -RPRT 0 -@end example +For each frequency, @command{rigswr} transmits at 25% of total POWER +during 0.5 second in CW mode and reads @acronym{VSWR}. -In this case the long command name and values are returned on the -first line and the second line contains the end of block marker and -the numeric rotor backend return value indicating success. +Frequency and the corresponding @acronym{VSWR} are then printed on +@file{stdout}. -An example response to a @command{+\get_pos} query: +To work correctly, @command{rigswr} needs a radio that can measure +@acronym{VSWR} and a Hamlib backend that supports reading +@acronym{VSWR} from the radio. -@example -echo "+\get_pos" | nc -w 1 localhost 4533 -get_pos: -Azimuth: 90.000000 -Elevation: 45.000000 -RPRT 0 -@end example +@node rigswr reference +@subsection @command{rigswr} reference +@cindex @command{rigswr} reference +@cindex reference, @command{rigswr} -In this case, as no value is passed to @command{rotctld}, the first -line consists only of the long command name. The final line shows -that the command was processed successfully by the rig backend. - -Invoking the Extended Response protocol requires prepending a command -with a punctuation character. As shown in the examples above, -prepending a '@code{+} character to the command results in the -responses being separated by a newline character (@samp{\n}). Any -other punctuation character recognized by the C @code{ispunct()} -function except @code{\}, @code{?}, or @code{_} will cause that -character to become the response separator and the entire response -will be on one line. - -Separator character summary: - -@table @code -@item + -Each record of the response is appended with a newline (@samp{\n}). -@ifhtml -@* -@end ifhtml - -@item ;, |, or , -Each record of the response is appended by the given character -resulting in entire response on one line. - -Common record separators for text representations of spreadsheet data, -etc. - -@item ? -Reserved for 'help' in @command{rotctl} short command. -@ifhtml -@* -@end ifhtml - -@item _ -Reserved for @command{\get_info} in @command{rotctl} short command. -@ifhtml -@* -@end ifhtml - -@item # -Reserved for comments when reading a command file script. - -@end table - -Other punctuation characters have not been tested! Use at your own -risk. - -For example, invoking a @command{;\get_pos} query with a leading -@code{;} returns: - -@example -get_pos:;Azimuth: 90.000000;Elevation: 45.000000;RPRT 0 -@end example - -Or, using the vertical bar (pipe) character @code{|} returns: - -@example -get_pos:|Azimuth: 90.000000|Elevation: 45.000000|RPRT 0 -@end example - -And a @command{\set_pos} command prepended with a @code{|} returns: - -@example -set_pos: 135 22.5|RPRT 0 -@end example - -Such a format will allow reading a response as a single event using a -preferred response separator. Other punctuation characters have not -been tested! - -All commands with the exception of @command{\set_conf} have been -tested with the Extended Response protocol and the included -@file{testrotctld.pl} script. +The complete reference for @command{rigswr} can be found in the +@kbd{rigswr}(1) Unix manual page. diff --git a/dummy/flrig.c b/dummy/flrig.c index a96c96426..b067c5f5d 100644 --- a/dummy/flrig.c +++ b/dummy/flrig.c @@ -96,6 +96,8 @@ struct flrig_priv_data { freq_t curr_freqB; pbwidth_t curr_widthA; pbwidth_t curr_widthB; + int has_get_modeA; /* True if this function is available */ + int has_get_bwA; /* True if this function is available */ }; const struct rig_caps flrig_caps = { @@ -104,9 +106,9 @@ const struct rig_caps flrig_caps = { .mfg_name = "FLRig", .version = BACKEND_VER, .copyright = "LGPL", - .status = RIG_STATUS_BETA, + .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, - .targetable_vfo = RIG_TARGETABLE_FREQ, + .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, .ptt_type = RIG_PTT_RIG, .port_type = RIG_PORT_NETWORK, .write_delay = 0, @@ -166,33 +168,31 @@ const struct rig_caps flrig_caps = { // Structure for mapping flrig dynmamic modes to hamlib modes // flrig displays modes as the rig displays them -// hamlib displays modes in generic form -#define MAXMODELEN 8 struct s_modeMap { int mode_hamlib; - char mode_flrig[MAXMODELEN]; + char *mode_flrig; }; // FLRig will provide us the modes for the selected rig // We will then put them in this struct static struct s_modeMap modeMap[]= { - {RIG_MODE_USB,""}, - {RIG_MODE_LSB,""}, - {RIG_MODE_PKTUSB,""}, - {RIG_MODE_PKTLSB,""}, - {RIG_MODE_PKTUSB,""}, - {RIG_MODE_PKTLSB,""}, - {RIG_MODE_AM,""}, - {RIG_MODE_FM,""}, - {RIG_MODE_FMN,""}, - {RIG_MODE_WFM,""}, - {RIG_MODE_CW,""}, - {RIG_MODE_CW,""}, - {RIG_MODE_CWR,""}, - {RIG_MODE_CWR,""}, - {RIG_MODE_RTTY,""}, - {RIG_MODE_RTTYR,""}, - {0,""} + {RIG_MODE_USB,NULL}, + {RIG_MODE_LSB,NULL}, + {RIG_MODE_PKTUSB,NULL}, + {RIG_MODE_PKTLSB,NULL}, + {RIG_MODE_PKTUSB,NULL}, + {RIG_MODE_PKTLSB,NULL}, + {RIG_MODE_AM,NULL}, + {RIG_MODE_FM,NULL}, + {RIG_MODE_FMN,NULL}, + {RIG_MODE_WFM,NULL}, + {RIG_MODE_CW,NULL}, + {RIG_MODE_CW,NULL}, + {RIG_MODE_CWR,NULL}, + {RIG_MODE_CWR,NULL}, + {RIG_MODE_RTTY,NULL}, + {RIG_MODE_RTTYR,NULL}, + {0,NULL} }; /* @@ -219,25 +219,6 @@ static int check_vfo(vfo_t vfo) return TRUE; } -/* - * vfo_curr - * Assumes rig!=NULL - */ -static int vfo_curr(RIG *rig, vfo_t vfo) -{ - int retval = 0; - vfo_t vfocurr; - struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv; - - // get the current VFO from flrig in case user changed it - if ((retval = flrig_get_vfo(rig, &vfocurr)) != RIG_OK) { - return retval; - } - priv->curr_vfo = vfocurr; - retval = (vfo == vfocurr); - return retval; -} - /* Rather than use some huge XML library we only need a few things * So we'll hand craft them * xml_build takes a value and return an xml string for FLRig @@ -337,6 +318,10 @@ static char *xml_parse(char *xml, char *value, int value_len) if (value != NULL) { xml_parse2(next, value, value_len); } + if (strstr(value,"faultString")) { + rig_debug(RIG_DEBUG_ERR, "%s error:\n%s\n", __FUNCTION__, value); + value[0]=0; /* truncate to give empty response */ + } return value; } @@ -352,7 +337,7 @@ static int read_transaction(RIG *rig, char *xml, int xml_len) rig_debug(RIG_DEBUG_TRACE, "%s\n", __FUNCTION__); struct rig_state *rs = &rig->state; - rs->rigport.timeout = 4000; // 3 second read string timeout + rs->rigport.timeout = 1000; // 2 second read string timeout int retry=5; char *delims="\n"; @@ -360,7 +345,7 @@ static int read_transaction(RIG *rig, char *xml, int xml_len) do { char tmp_buf[MAXXMLLEN]; // plenty big for expected flrig responses int len = read_string(&rs->rigport, tmp_buf, sizeof(tmp_buf), delims, strlen(delims)); - rig_debug(RIG_DEBUG_WARN,"%s: string='%s'",__FUNCTION__,tmp_buf); + rig_debug(RIG_DEBUG_WARN,"%s: string='%s'",__FUNCTION__,tmp_buf); if (len > 0) retry = 3; if (len <= 0) { rig_debug(RIG_DEBUG_ERR,"%s: read_string error=%d\n",__FUNCTION__,len); @@ -373,8 +358,8 @@ static int read_transaction(RIG *rig, char *xml, int xml_len) } if (strstr(xml,terminator)) { rig_debug(RIG_DEBUG_VERBOSE,"%s: got %s\n",__FUNCTION__,terminator); - // Testing slowing down 3 of commands per second - usleep(2*1000); + // Slow down just a bit -- not sure this is needed anymore but not a big deal here + usleep(2*1000); retval = RIG_OK; } else { @@ -395,11 +380,11 @@ static int write_transaction(RIG *rig, char *xml, int xml_len) char xmltmp[MAXXMLLEN]; struct rig_state *rs = &rig->state; - + // This shouldn't ever happen...but just in case // We need to avoid and empty write as rigctld replies with blank line if (xml_len == 0) { - rig_debug(RIG_DEBUG_ERR,"%s: len==0??\n",__FUNCTION__); + rig_debug(RIG_DEBUG_ERR,"%s: len==0??\n",__FUNCTION__); } while(try-- >= 0 && retval != RIG_OK) { @@ -476,9 +461,11 @@ static char * modeMapGetFLRig(unsigned int modeHamlib) static unsigned int modeMapGetHamlib(const char *modeFLRig) { int i; + char modeFLRigCheck[64]; + snprintf(modeFLRigCheck,sizeof(modeFLRigCheck),"|%.32s|",modeFLRig); rig_debug(RIG_DEBUG_VERBOSE,"%s: get hamlib mode from %s\n",__FUNCTION__,modeFLRig); for(i=0; modeMap[i].mode_hamlib!=0; ++i) { - if (streq(modeMap[i].mode_flrig,modeFLRig)) { + if (strstr(modeMap[i].mode_flrig,modeFLRigCheck)) { rig_debug(RIG_DEBUG_VERBOSE,"%s: got hamlib mode %s\n",__FUNCTION__,rig_strrmode(modeMap[i].mode_hamlib)); return modeMap[i].mode_hamlib; } @@ -495,10 +482,26 @@ static unsigned int modeMapGetHamlib(const char *modeFLRig) static void modeMapAdd(unsigned int *modes,int mode_hamlib,char *mode_flrig) { int i; + rig_debug(RIG_DEBUG_VERBOSE,"%s:mode_flrig=%s\n",__FUNCTION__,mode_flrig); + int len1 = strlen(mode_flrig)+3; /* bytes needed for allocating */ for(i=0; modeMap[i].mode_hamlib!=0; ++i) { if (modeMap[i].mode_hamlib==mode_hamlib) { *modes |= modeMap[i].mode_hamlib; - strncpy(modeMap[i].mode_flrig,mode_flrig,sizeof(modeMap[i].mode_flrig)); + /* we will pipe delimit all the entries for easier matching */ + /* all entries will have pipe symbol on both sides */ + if (modeMap[i].mode_flrig == NULL) { + modeMap[i].mode_flrig = calloc(1,len1); + if (modeMap[i].mode_flrig == NULL) { + rig_debug(RIG_DEBUG_ERR,"%s: error allocating memory for modeMap\n",__FUNCTION__); + return; + } + } + int len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */ + modeMap[i].mode_flrig = realloc(modeMap[i].mode_flrig,strlen(modeMap[i].mode_flrig)+len1); + if (strlen(modeMap[i].mode_flrig)==0) modeMap[i].mode_flrig[0]='|'; + strncat(modeMap[i].mode_flrig,mode_flrig,len1+len2); + strncat(modeMap[i].mode_flrig,"|",len1+len2); + rig_debug(RIG_DEBUG_VERBOSE,"%s: Adding mode=%s at %d, index=%d, result=%s\n",__FUNCTION__,mode_flrig, mode_hamlib, i, modeMap[i].mode_flrig); return; } } @@ -527,6 +530,31 @@ static int flrig_open(RIG *rig) { strncpy(priv->info,value,sizeof(priv->info)); rig_debug(RIG_DEBUG_VERBOSE,"Transceiver=%s\n", value); + /* see if get_modeA is available */ + pxml = xml_build("rig.get_modeA", NULL, xml, sizeof(xml)); + retval = write_transaction(rig, pxml, strlen(pxml)); + read_transaction(rig, xml, sizeof(xml)); + xml_parse(xml, value, sizeof(value)); + if (strlen(value)>0) { /* must have it since we got an answer */ + priv->has_get_modeA = 1; + rig_debug(RIG_DEBUG_VERBOSE,"%s: getmodeA is available=%s\n", __FUNCTION__, value); + } + else { + rig_debug(RIG_DEBUG_VERBOSE,"%s: getmodeA is not available\n",__FUNCTION__); + } + /* see if get_bwA is available */ + pxml = xml_build("rig.get_bwA", NULL, xml, sizeof(xml)); + retval = write_transaction(rig, pxml, strlen(pxml)); + read_transaction(rig, xml, sizeof(xml)); + xml_parse(xml, value, sizeof(value)); + if (strlen(value)>0) { /* must have it since we got an answer */ + priv->has_get_bwA = 1; + rig_debug(RIG_DEBUG_VERBOSE,"%s: get_bwA is available=%s\n", __FUNCTION__, value); + } + else { + rig_debug(RIG_DEBUG_VERBOSE,"%s: get_bwA is not available\n",__FUNCTION__); + } + pxml = xml_build("rig.get_AB", value, xml, sizeof(xml)); retval = write_transaction(rig, pxml, strlen(pxml)); read_transaction(rig, xml, sizeof(xml)); @@ -605,6 +633,7 @@ static int flrig_open(RIG *rig) { else if (streq(p,"RTTY-L")) modeMapAdd(&modes,RIG_MODE_RTTYR,p); else if (streq(p,"RTTY(U)")) modeMapAdd(&modes,RIG_MODE_RTTY,p); else if (streq(p,"RTTY(R")) modeMapAdd(&modes,RIG_MODE_RTTYR,p); + else if (streq(p,"DIG")) modeMapAdd(&modes,RIG_MODE_PKTUSB,p); else rig_debug(RIG_DEBUG_ERR,"%s: Unknown mode for this rig='%s'\n",__FUNCTION__,p); } rig->state.mode_list = modes; @@ -657,7 +686,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } if (vfo == RIG_VFO_CURR) { - vfo = priv->curr_vfo; + vfo = priv->curr_vfo; rig_debug(RIG_DEBUG_VERBOSE, "%s: get_freq2 vfo=%s\n", __FUNCTION__, rig_strvfo(vfo)); } @@ -723,7 +752,7 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } if (vfo == RIG_VFO_CURR) { - vfo = priv->curr_vfo; + vfo = priv->curr_vfo; } else if (vfo == RIG_VFO_TX && priv->split) { vfo = RIG_VFO_B; // if split always TX on VFOB @@ -856,7 +885,7 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t wid // save some VFO swapping .. may replace with VFO specific calls that won't cause VFO change if (vfo==RIG_VFO_A && mode==priv->curr_modeA) return RIG_OK; if (vfo==RIG_VFO_B && mode==priv->curr_modeB) return RIG_OK; - retval = flrig_set_mode(rig,RIG_VFO_B,mode,width); + retval = flrig_set_mode(rig,vfo,mode,width); rig_debug(RIG_DEBUG_TRACE, "%s: set mode=%s\n",__FUNCTION__,rig_strrmode(mode)); return retval; } @@ -878,7 +907,7 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (priv->ptt) return RIG_OK; if (vfo == RIG_VFO_CURR) { - vfo = priv->curr_vfo; + vfo = priv->curr_vfo; } if (check_vfo(vfo) == FALSE) { @@ -886,21 +915,16 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) __FUNCTION__, rig_strvfo(vfo)); return -RIG_EINVAL; } - // - // Don't touch mode or width if PTT=true - ptt_t ptt; - retval = flrig_get_ptt(rig,RIG_VFO_A,&ptt); - if (ptt) { - priv->ptt = 1; - rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); - return RIG_OK; // just return OK and ignore this + if (priv->ptt) { + rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); + return RIG_OK; // just return OK and ignore this } // Switch to VFOB if appropriate since we can't set mode directly // MDB int vfoSwitched = 0; rig_debug(RIG_DEBUG_WARN,"%s: curr_vfo = %s\n",__FUNCTION__,rig_strvfo(priv->curr_vfo)); - if (vfo == RIG_VFO_B && priv->curr_vfo != RIG_VFO_B) { + if (!priv->has_get_bwA && vfo == RIG_VFO_B && priv->curr_vfo != RIG_VFO_B) { vfoSwitched = 1; rig_debug(RIG_DEBUG_WARN,"%s: switch to VFOB = %d\n",__FUNCTION__,vfoSwitched); } @@ -919,7 +943,17 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) char cmd_buf[MAXCMDLEN]; sprintf(cmd_buf, "%s", ttmode); char xml[MAXXMLLEN]; - char *pxml = xml_build("rig.set_mode", cmd_buf, xml, sizeof(xml)); + char *pxml=NULL; + if (!priv->has_get_modeA) { + pxml = xml_build("rig.set_mode", cmd_buf, xml, sizeof(xml)); + } + else { + char *cmd="rig.set_modeA"; + if (vfo==RIG_VFO_B) { + cmd="rig.set_modeB"; + } + pxml = xml_build(cmd, cmd_buf, xml, sizeof(xml)); + } retval = write_transaction(rig, pxml, strlen(pxml)); if (retval < 0) { @@ -930,15 +964,25 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) read_transaction(rig, xml, sizeof(xml)); rig_debug(RIG_DEBUG_VERBOSE, "%s: response=%s\n", __FUNCTION__,xml); - // Need to update the available bandwidths for this mode - if (width > 0) { + // Determine if we need to update the bandwidth + int needBW=0; + if (vfo == RIG_VFO_A) needBW = priv->curr_widthA != width; + else if (vfo == RIG_VFO_B) needBW = priv->curr_widthB != width; + else rig_debug(RIG_DEBUG_ERR,"%s: needBW unknown vfo=%s\n",__FUNCTION__,rig_strvfo(vfo)); + // Need to update the bandwidth + if (width > 0 && needBW) { sprintf(cmd_buf, "%ld", width); + // if we're not on VFOB but asking for VFOB still have to switch VFOS + if (!vfoSwitched && vfo==RIG_VFO_B) flrig_set_vfo(rig,RIG_VFO_B); + if (!vfoSwitched && vfo==RIG_VFO_A) flrig_set_vfo(rig,RIG_VFO_A); pxml = xml_build("rig.set_bandwidth", cmd_buf, xml, sizeof(xml)); retval = write_transaction(rig, pxml, strlen(pxml)); if (retval < 0) { return retval; } read_transaction(rig, xml, sizeof(xml)); + if (!vfoSwitched && vfo==RIG_VFO_B) flrig_set_vfo(rig,RIG_VFO_A); + if (!vfoSwitched && vfo==RIG_VFO_A) flrig_set_vfo(rig,RIG_VFO_B); } // Return to VFOA if needed @@ -984,29 +1028,26 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) vfo_t curr_vfo = priv->curr_vfo; if (vfo == RIG_VFO_CURR) { - vfo = priv->curr_vfo; + vfo = priv->curr_vfo; } rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __FUNCTION__, rig_strvfo(vfo)); - // - // Don't touch mode or width if PTT=true - ptt_t ptt; - retval = flrig_get_ptt(rig,RIG_VFO_A,&ptt); - if (ptt) { - priv->ptt = 1; - if (vfo == RIG_VFO_A) *mode = priv->curr_modeA; - else *mode = priv->curr_modeB; - rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); - return RIG_OK; // just return OK and ignore this + if (priv->ptt) { + if (vfo == RIG_VFO_A) *mode = priv->curr_modeA; + else *mode = priv->curr_modeB; + rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); + return RIG_OK; // just return OK and ignore this } // Switch to VFOB if appropriate int vfoSwitched=0; - if (vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B) { + rig_debug(RIG_DEBUG_ERR,"%s has_get_modeA=%d\n",__FUNCTION__,priv->has_get_modeA); + if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B) { vfoSwitched = 1; } if (vfoSwitched) { + rig_debug(RIG_DEBUG_VERBOSE,"%s switch to VFOB=%d\n",__FUNCTION__,priv->has_get_modeA); retval = flrig_set_vfo(rig, RIG_VFO_B); if (retval < 0) { return retval; @@ -1014,7 +1055,16 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } char xml[MAXXMLLEN]; - char *pxml = xml_build("rig.get_mode", NULL, xml, sizeof(xml)); + char *cmdp="rig.get_mode"; /* default to old way */ + if (priv->has_get_modeA) { /* change to new way if we can */ + /* calling this way reduces VFO swapping */ + /* we get the cached value in flrig */ + /* vfo B may not be getting polled though in FLRig */ + /* so we may not be 100% accurate if op is twiddling knobs */ + cmdp = "rig.get_modeA"; + if (vfo==RIG_VFO_B) cmdp = "rig.get_modeB"; + } + char *pxml = xml_build(cmdp, NULL, xml, sizeof(xml)); retval = write_transaction(rig, pxml, strlen(pxml)); if (retval < 0) { return retval; @@ -1037,8 +1087,17 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } - // Get the bandwidth - pxml = xml_build("rig.get_bw", NULL, xml, sizeof(xml)); + /* Get the bandwidth */ + cmdp="rig.get_bw"; /* default to old way */ + if (priv->has_get_bwA) { /* change to new way if we can */ + /* calling this way reduces VFO swapping */ + /* we get the cached value in flrig */ + /* vfo B may not be getting polled though in FLRig */ + /* so we may not be 100% accurate if op is twiddling knobs */ + cmdp = "rig.get_bwA"; + if (vfo==RIG_VFO_B) cmdp = "rig.get_bwB"; + } + pxml = xml_build(cmdp, NULL, xml, sizeof(xml)); retval = write_transaction(rig, pxml, strlen(pxml)); if (retval < 0) { return retval; @@ -1100,10 +1159,6 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo) vfo = priv->curr_vfo; } - // Force PTT off - // Why were we turning off PTT here? - // flrig_set_ptt(rig,RIG_VFO_A,0); - char value[MAXCMDLEN]; char xml[MAXXMLLEN]; sprintf(value, "%s", @@ -1114,11 +1169,23 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo) if (retval < 0) { return retval; } - //usleep(50*1000); // temporary sleep until flrig is fixed priv->curr_vfo = vfo; rs->tx_vfo = RIG_VFO_B; // always VFOB read_transaction(rig, xml, sizeof(xml)); + /* for some rigs FLRig turns off split when VFOA is selected */ + /* so if we are in split and asked for A we have to turn split back on */ + if (priv->split && vfo==RIG_VFO_A) { + char xml[MAXXMLLEN]; + char value[MAXCMDLEN]; + sprintf(value, "%d", priv->split); + char *pxml = xml_build("rig.set_split", value, xml, sizeof(xml)); + retval = write_transaction(rig, pxml, strlen(pxml)); + if (retval < 0) { + return retval; + } + read_transaction(rig, xml, sizeof(xml)); // get response but don't care + } return RIG_OK; } @@ -1193,6 +1260,11 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) __FUNCTION__, rig_strvfo(vfo)); return -RIG_EINVAL; } + // we always split on VFOB so if no change just return + freq_t qtx_freq; + retval = flrig_get_freq(rig, RIG_VFO_B, &qtx_freq); + if (retval != RIG_OK) return retval; + if (tx_freq == qtx_freq) return RIG_OK; char xml[MAXXMLLEN]; char value[MAXCMDLEN]; @@ -1218,7 +1290,11 @@ static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) { rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __FUNCTION__, rig_strvfo(vfo)); + + struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv; + int retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq); + priv->curr_freqB = *tx_freq; return retval; } @@ -1238,21 +1314,15 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX) { tx_vfo = RIG_VFO_B; } - - - // Don't touch split if PTT=true - ptt_t ptt; - retval = flrig_get_ptt(rig,RIG_VFO_A,&ptt); - if (ptt) { - priv->ptt = 1; - rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); - return RIG_OK; // just return OK and ignore this - } - - /* for flrig we have to be on VFOA when we set split for VFOB Tx */ - /* we can keep the rig on VFOA since we can set freq by VFO now */ - if (!vfo_curr(rig, RIG_VFO_A)) { - flrig_set_vfo(rig, RIG_VFO_A); + vfo_t qtx_vfo; + split_t qsplit; + retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo); + if (retval != RIG_OK) return retval; + if (split == qsplit) return RIG_OK; + if (priv->ptt) { + priv->ptt = 1; + rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); + return RIG_OK; // just return OK and ignore this } char xml[MAXXMLLEN]; @@ -1264,7 +1334,7 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) return retval; } priv->split = split; - + read_transaction(rig, xml, sizeof(xml)); // get response but don't care return RIG_OK; @@ -1316,25 +1386,22 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, rmode_t m if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX) return -RIG_ENTARGET; - - // Don't touch split if PTT=true - ptt_t ptt; - retval = flrig_get_ptt(rig,RIG_VFO_A,&ptt); - if (ptt) { - priv->ptt = 1; - rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); - return RIG_OK; // just return OK and ignore this + if (priv->ptt) { + rig_debug(RIG_DEBUG_ERR,"%s call not made as PTT=1\n",__FUNCTION__); + return RIG_OK; // just return OK and ignore this } - // assume split is on B - // swap to VFOB to prevent lots of vfo swapping while seting up VFOB - flrig_set_vfo(rig,RIG_VFO_B); retval = flrig_set_freq (rig, RIG_VFO_B, freq); if (retval != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s flrig_set_freq failed\n", __FUNCTION__); return retval; } // Make VFOB mode match VFOA mode, keep VFOB width + rmode_t qmode; + pbwidth_t qwidth; + retval = flrig_get_mode(rig,RIG_VFO_B,&qmode,&qwidth); + if (retval != RIG_OK) return retval; + if (qmode == priv->curr_modeA) return RIG_OK; retval = flrig_set_mode(rig,RIG_VFO_B,priv->curr_modeA,width); if (retval != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s flrig_set_mode failed\n", __FUNCTION__); diff --git a/dummy/flrig.h b/dummy/flrig.h index db8d02bfe..10ede864a 100644 --- a/dummy/flrig.h +++ b/dummy/flrig.h @@ -28,7 +28,7 @@ #include #endif -#define BACKEND_VER "1.0" +#define BACKEND_VER "1.5" #define EOM "\r" #define TRUE 1 diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 0e09d7c15..de7de5e1d 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -68,11 +68,11 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf) ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); if (ret < 0) return ret; - - if (memcmp(buf, NETRIGCTL_RET, strlen(NETRIGCTL_RET))==0) + if (strncmp(buf, NETRIGCTL_RET, strlen(NETRIGCTL_RET))==0) { return atoi(buf+strlen(NETRIGCTL_RET)); + } - return RIG_OK; + return ret; } diff --git a/elad/Android.mk b/elad/Android.mk new file mode 100644 index 000000000..603ab9151 --- /dev/null +++ b/elad/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := elad.c fdm_duo.c +LOCAL_MODULE := elad + +LOCAL_CFLAGS := -DHAVE_CONFIG_H +LOCAL_C_INCLUDES := android include src +LOCAL_LDLIBS := -lhamlib -Lobj/local/armeabi + +include $(BUILD_STATIC_LIBRARY) diff --git a/elad/Makefile.am b/elad/Makefile.am new file mode 100644 index 000000000..857e892a0 --- /dev/null +++ b/elad/Makefile.am @@ -0,0 +1,6 @@ +ELADSRC = elad.c elad.h fdm_duo.c + +noinst_LTLIBRARIES = libhamlib-elad.la +libhamlib_elad_la_SOURCES = $(ELADSRC) + +EXTRA_DIST = Android.mk diff --git a/elad/elad.c b/elad/elad.c new file mode 100644 index 000000000..79db0c9be --- /dev/null +++ b/elad/elad.c @@ -0,0 +1,3357 @@ +/* + * Hamlib ELAD backend - main file + * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (C) 2009,2010 Alessandro Zummo + * Copyright (C) 2009,2010,2011,2012,2013 by Nate Bargmann, n0nb@n0nb.us + * Copyright (C) 2018 by Giovanni Franza, info@hb9eik.ch + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include +#include + +#include "hamlib/rig.h" +#include "network.h" +#include "serial.h" +#include "misc.h" +#include "register.h" +#include "cal.h" + +#include "elad.h" + +#ifndef max +#define max(a,b) (((a) (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +struct elad_id { + rig_model_t model; + int id; +}; + +struct elad_id_string { + rig_model_t model; + const char *id; +}; + +#define UNKNOWN_ID -1 + +/* + * Identification number as returned by "ID;" + * Please, if the model number of your rig is listed as UNKNOWN_ID, + * send the value to for inclusion. Thanks --SF + * + * TODO: sort this list with most frequent rigs first. + */ +static const struct elad_id elad_id_list[] = { + { RIG_MODEL_ELAD_FDM_DUO, 1 }, + { RIG_MODEL_NONE, UNKNOWN_ID }, /* end marker */ +}; + +/* XXX numeric ids have been tested only with the TS-450 */ +static const struct elad_id_string elad_id_string_list[] = { + { RIG_MODEL_ELAD_FDM_DUO, "001" }, + { RIG_MODEL_NONE, NULL }, /* end marker */ +}; + +rmode_t elad_mode_table[ELAD_MODE_TABLE_MAX] = { + [0] = RIG_MODE_NONE, + [1] = RIG_MODE_LSB, + [2] = RIG_MODE_USB, + [3] = RIG_MODE_CW, + [4] = RIG_MODE_FM, + [5] = RIG_MODE_AM, + [6] = RIG_MODE_RTTY, + [7] = RIG_MODE_CWR, + [8] = RIG_MODE_NONE, /* TUNE mode */ + [9] = RIG_MODE_RTTYR +}; + +/* + * 38 CTCSS sub-audible tones + */ +const tone_t elad38_ctcss_list[] = { + 670, 719, 744, 770, 797, 825, 854, 885, 915, 948, + 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318, + 1365, 1413, 1462, 1514, 1567, 1622, 1679, 1738, 1799, 1862, + 1928, 2035, 2107, 2181, 2257, 2336, 2418, 2503, + 0, +}; + + +/* + * 42 CTCSS sub-audible tones + */ +const tone_t elad42_ctcss_list[] = { + 670, 693, 719, 744, 770, 797, 825, 854, 885, 915, 948, + 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318, + 1365, 1413, 1462, 1514, 1567, 1622, 1679, 1738, 1799, 1862, + 1928, 2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541, + 0, +}; + + +/* Token definitions for .cfgparams in rig_caps + * + * See enum rig_conf_e and struct confparams in rig.h + */ +const struct confparams elad_cfg_params[] = { + { TOK_FINE, "fine", "Fine", "Fine step mode", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_VOICE, "voice", "Voice", "Voice recall", + NULL, RIG_CONF_BUTTON, { } }, + { TOK_XIT, "xit", "XIT", "XIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_RIT, "rit", "RIT", "RIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { RIG_CONF_END, NULL, } +}; + + +/** + * elad_transaction + * Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL + * + * Parameters: + * cmdstr: Command to be sent to the rig. cmdstr can also be NULL, + * indicating that only a reply is needed (nothing will be sent). + * data: Buffer for reply string. Can be NULL, indicating that no reply + * is needed and will return with RIG_OK after command was sent. + * datasize: Size of buffer. It is the caller's responsibily to provide + * a large enough buffer for all possible replies for a command. + * + * returns: + * RIG_OK - if no error occurred. + * RIG_EIO - if an I/O error occured while sending/receiving data. + * RIG_ETIMEOUT - if timeout expires without any characters received. + * RIG_REJECTED - if a negative acknowledge was received or command not + * recognized by rig. + */ +int elad_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize) +{ + char buffer[ELAD_MAX_BUF_LEN]; /* use our own buffer since + verification may need a longer + buffer than the user supplied one */ + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || (!cmdstr && !datasize) || (datasize && !data)) + return -RIG_EINVAL; + + struct elad_priv_data * priv = rig->state.priv; + struct elad_priv_caps *caps = elad_caps(rig); + struct rig_state *rs; + int retval; + char cmdtrm[2]; /* Default Command/Reply termination char */ + char *cmd; + int len; + int retry_read = 0; + + rs = &rig->state; + rs->hold_decode = 1; + + /* Emulators don't need any post_write_delay */ + if (priv->is_emulation) rs->rigport.post_write_delay = 0; + + cmdtrm[0] = caps->cmdtrm; + cmdtrm[1] = '\0'; + + transaction_write: + + if (cmdstr) + { + rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr); + + len = strlen(cmdstr); + + cmd = malloc(len + 2); + if (cmd == NULL) { + retval = -RIG_ENOMEM; + goto transaction_quit; + } + + memcpy(cmd, cmdstr, len); + + /* XXX the if is temporary, until all invocations are fixed */ + if (cmdstr[len - 1] != ';' && cmdstr[len - 1] != '\r') { + cmd[len] = caps->cmdtrm; + len++; + } + + /* flush anything in the read buffer before command is sent */ + if (rs->rigport.type.rig == RIG_PORT_NETWORK || rs->rigport.type.rig == RIG_PORT_UDP_NETWORK) { + network_flush(&rs->rigport); + } else { + serial_flush(&rs->rigport); + } + + retval = write_block(&rs->rigport, cmd, len); + + free(cmd); + + if (retval != RIG_OK) + goto transaction_quit; + } + + if (!datasize) { + rig->state.hold_decode = 0; + + /* no reply expected so we need to write a command that always + gives a reply so we can read any error replies from the actual + command being sent without blocking */ + if (RIG_OK != (retval = write_block (&rs->rigport, priv->verify_cmd + , strlen (priv->verify_cmd)))) { + goto transaction_quit; + } + } + + transaction_read: + /* allow one extra byte for terminator we don't return */ + len = min (datasize ? datasize + 1 : strlen (priv->verify_cmd) + 13, ELAD_MAX_BUF_LEN); + retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm)); + if (retval < 0) { + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + goto transaction_quit; + } + + /* Check that command termination is correct */ + if (strchr(cmdtrm, buffer[strlen(buffer)-1])==NULL) { + rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, buffer); + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + retval = -RIG_EPROTO; + goto transaction_quit; + } + + if (strlen(buffer) == 2) { + switch (buffer[0]) { + case 'N': + /* Command recognised by rig but invalid data entered. */ + if (cmdstr) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: NegAck for '%s'\n", __func__, cmdstr); + } + retval = -RIG_ENAVAIL; + goto transaction_quit; + case 'O': + /* Too many characters sent without a carriage return */ + if (cmdstr) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: Overflow for '%s'\n", __func__, cmdstr); + } + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + retval = -RIG_EPROTO; + goto transaction_quit; + case 'E': + /* Communication error */ + if (cmdstr) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: Communication error for '%s'\n", __func__, cmdstr); + } + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + retval = -RIG_EIO; + goto transaction_quit; + case '?': + /* Command not understood by rig or rig busy */ + if (cmdstr) + { + rig_debug(RIG_DEBUG_ERR, "%s: Unknown command or rig busy '%s'\n", __func__, cmdstr); + } + if (retry_read++ < rs->rigport.retry) + { + rig_debug(RIG_DEBUG_ERR, "%s: Retrying shortly\n", __func__); + usleep (rig->caps->timeout * 1000); + goto transaction_read; + } + retval = -RIG_ERJCTED; + goto transaction_quit; + } + } + + /* + * Check that we received the correct reply. The first two characters + * should be the same as command. Because the Elecraft XG3 uses + * single character commands we only check the first character in + * that case. + */ + if (datasize) + { + if (cmdstr && (buffer[0] != cmdstr[0] || (cmdstr[1] && buffer[1] != cmdstr[1]))) + { + /* + * TODO: When RIG_TRN is enabled, we can pass the string to + * the decoder for callback. That way we don't ignore any + * commands. + */ + rig_debug(RIG_DEBUG_ERR, "%s: Wrong reply %c%c for command %c%c\n", + __func__, buffer[0], buffer[1], cmdstr[0], cmdstr[1]); + + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + + retval = -RIG_EPROTO; + goto transaction_quit; + } + + if (retval > 0) + { + /* move the result excluding the command terminator into the + caller buffer */ + len = min (datasize, retval) - 1; + strncpy (data, buffer, len); + data[len] = '\0'; + } + } + else + { + if (priv->verify_cmd[0] != buffer[0] + || (priv->verify_cmd[1] && priv->verify_cmd[1] != buffer[1])) + { + /* + * TODO: When RIG_TRN is enabled, we can pass the string to + * the decoder for callback. That way we don't ignore any + * commands. + */ + rig_debug(RIG_DEBUG_ERR, "%s: WRONG reply %c%c for command verification %c%c (datasize=%d)\n", + __func__, buffer[0], buffer[1] + , priv->verify_cmd[0], priv->verify_cmd[1], datasize); + + if (retry_read++ < rs->rigport.retry) + goto transaction_write; + + retval = -RIG_EPROTO; + goto transaction_quit; + } + } + retval = RIG_OK; + + transaction_quit: + + rs->hold_decode = 0; + return retval; +} + + +/** + * elad_safe_transaction + * A wrapper for elad_transaction to check returned data against + * expected length, + * + * Parameters: + * cmd Same as elad_transaction() cmdstr + * buf Same as kenwwod_transaction() data + * buf_size Same as elad_transaction() datasize + * expected Value of expected string length + * + * Returns: + * RIG_OK - if no error occured. + * RIG_EPROTO if returned string and expected are not equal + * Error from elad_transaction() if any + * + */ +int elad_safe_transaction(RIG *rig, const char *cmd, char *buf, + size_t buf_size, size_t expected) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !cmd) + return -RIG_EINVAL; + + int err; + int retry = 0; + + if (expected == 0) + buf_size = 0; + + do + { + err = elad_transaction(rig, cmd, buf, buf_size); + if (err != RIG_OK) /* return immediately on error as any + retries handled at lower level */ + return err; + + size_t length = strlen (buf); + if (length != expected) /* worth retrying as some rigs + occasionally send short results */ + { + rig_debug(RIG_DEBUG_ERR, "%s: wrong answer; len for cmd %s: " + "expected = %d, got %d\n", + __func__, cmd, expected, length); + err = -RIG_EPROTO; + usleep (rig->caps->timeout * 1000); + } + } while (err != RIG_OK && ++retry < rig->state.rigport.retry); + + return err; +} + +rmode_t elad2rmode(unsigned char mode, const rmode_t mode_table[]) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (mode >= ELAD_MODE_TABLE_MAX) + return RIG_MODE_NONE; + return mode_table[mode]; +} + +char rmode2elad(rmode_t mode, const rmode_t mode_table[]) +{ + int i; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (mode != RIG_MODE_NONE) + { + for(i = 0; i < ELAD_MODE_TABLE_MAX; i++) { + if (mode_table[i] == mode) + return i; + } + } + return -1; +} + +int elad_init(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv; + struct elad_priv_caps *caps = elad_caps(rig); + + priv = malloc(sizeof(struct elad_priv_data)); + if (priv == NULL) + return -RIG_ENOMEM; + + memset(priv, 0x00, sizeof(struct elad_priv_data)); + strcpy (priv->verify_cmd, RIG_MODEL_XG3 == rig->caps->rig_model ? ";" : "ID;"); + priv->split = RIG_SPLIT_OFF; + priv->trn_state = -1; + priv->curr_mode = 0; + rig->state.priv = priv; + + /* default mode_table */ + if (caps->mode_table == NULL) + caps->mode_table = elad_mode_table; + + /* default if_len */ + if (caps->if_len == 0) + caps->if_len = 37; + + rig_debug(RIG_DEBUG_TRACE, "%s: if_len = %d\n", __func__, caps->if_len); + + return RIG_OK; +} + +int elad_cleanup(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + free(rig->state.priv); + rig->state.priv = NULL; + + return RIG_OK; +} + +int elad_open(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + int err, i; + char *idptr; + char id[ELAD_MAX_BUF_LEN]; + + if (RIG_MODEL_TS590S == rig->caps->rig_model) + { + /* we need the firmware version for these rigs to deal with f/w defects */ + static char fw_version[7]; + + err = elad_transaction (rig, "FV", fw_version, sizeof (fw_version)); + if (RIG_OK != err) + { + rig_debug (RIG_DEBUG_ERR, "%s: cannot get f/w version\n", __func__); + return err; + } + /* store the data after the "FV" which should be a f/w version + string of the form n.n e.g. 1.07 */ + priv->fw_rev = &fw_version[2]; + char * dot_pos = strchr (fw_version, '.'); + if (dot_pos) + { + priv->fw_rev_uint = atoi (&fw_version[2]) * 100 + atoi (dot_pos + 1); + } + else + { + rig_debug (RIG_DEBUG_ERR, "%s: cannot get f/w version\n", __func__); + return -RIG_EPROTO; + } + rig_debug (RIG_DEBUG_TRACE, "%s: found f/w version %s\n", __func__, priv->fw_rev); + } + + /* get id in buffer, will be null terminated */ + err = elad_get_id(rig, id); + if (RIG_MODEL_XG3 != rig->caps->rig_model && -RIG_ETIMEOUT == err) + { + /* Some Kenwood emulations have no ID command response :( + * Try an FA command to see is anyone is listening */ + char buffer[ELAD_MAX_BUF_LEN]; + err = elad_transaction (rig, "FA", buffer, sizeof (buffer)); + if (RIG_OK != err) + { + rig_debug (RIG_DEBUG_ERR, "%s: no response from rig\n", __func__); + return err; + } + /* here we know there is something that responds to FA but not + to ID so use FA as the command verification command */ + strcpy (priv->verify_cmd, "FA;"); + strcpy (id, "ID019"); /* fake a TS-2000 */ + } + else + { + if (err != RIG_OK) { + rig_debug(RIG_DEBUG_ERR, "%s: cannot get identification\n", __func__); + return err; + } + } + + /* id is something like 'IDXXX' or 'ID XXX' */ + if (strlen(id) < 5) { + rig_debug(RIG_DEBUG_ERR, "%s: unknown id type (%s)\n", __func__, id); + return -RIG_EPROTO; + } + + if (!strcmp ("IDID900", id) /* DDUtil in TS-2000 mode */ + || !strcmp ("ID900", id) /* PowerSDR after ZZID; command */ + || !strcmp ("ID904", id) /* SmartSDR Flex-6700 */ + || !strcmp ("ID905", id) /* PowerSDR Flex-6500 */ + || !strcmp ("ID906", id) /* PowerSDR Flex-6700R */ + || !strcmp ("ID907", id) /* PowerSDR Flex-6300 */ + || !strcmp ("ID908", id) /* PowerSDR Flex-6400 */ + || !strcmp ("ID909", id) /* PowerSDR Flex-6600 */ + ) + { + priv->is_emulation = 1; /* Emulations don't have SAT mode */ + strcpy (id, "ID019"); /* fake it */ + } + + /* check for a white space and skip it */ + idptr = &id[2]; + if (*idptr == ' ') + idptr++; + + /* compare id string */ + for (i = 0; elad_id_string_list[i].model != RIG_MODEL_NONE; i++) { + if (strcmp(elad_id_string_list[i].id, idptr) != 0) + continue; + + /* found matching id, verify driver */ + rig_debug(RIG_DEBUG_TRACE, "%s: found match %s\n", + __func__, elad_id_string_list[i].id); + + if (elad_id_string_list[i].model == rig->caps->rig_model) { + /* get current AI state so it can be restored */ + elad_get_trn (rig, &priv->trn_state); /* ignore errors */ + /* Currently we cannot cope with AI mode so turn it off in + case last client left it on */ + elad_set_trn(rig, RIG_TRN_OFF); /* ignore status in case + it's not supported */ + return RIG_OK; + } + + /* driver mismatch */ + rig_debug(RIG_DEBUG_ERR, + "%s: wrong driver selected (%d instead of %d)\n", + __func__, rig->caps->rig_model, + elad_id_string_list[i].model); + + return -RIG_EINVAL; + } + + rig_debug(RIG_DEBUG_ERR, "%s: your rig (%s) is unknown\n", + __func__, id); + + return -RIG_EPROTO; +} + + +int elad_close(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + if (!rig) return -RIG_EINVAL; + struct elad_priv_data *priv = rig->state.priv; + if (!no_restore_ai && priv->trn_state >= 0) + { + /* restore AI state */ + elad_set_trn (rig, priv->trn_state); /* ignore status in case + it's not supported */ + } + return RIG_OK; +} + + +/* ID + * Reads transceiver ID number + * + * caller must give a buffer of ELAD_MAX_BUF_LEN size + * + */ +int elad_get_id(RIG *rig, char *buf) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + return elad_transaction(rig, "ID", buf, ELAD_MAX_BUF_LEN); +} + + +/* IF + * Retrieves the transceiver status + * + */ +static int elad_get_if(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_caps *caps = elad_caps(rig); + + return elad_safe_transaction(rig, "IF", priv->info, + ELAD_MAX_BUF_LEN, caps->if_len); +} + + +/* FN FR FT + * Sets the RX/TX VFO or M.CH mode of the transceiver, does not set split + * VFO, but leaves it unchanged if in split VFO mode. + * + */ +int elad_set_vfo(RIG *rig, vfo_t vfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + + /* Emulations do not need to set VFO since VFOB is a copy of VFOA + * except for frequency. And we can change freq without changing VFOS + * This prevents a 1.8 second delay in PowerSDR when switching VFOs + * We'll do this once if curr_mode has not been set yet + */ + if (priv->is_emulation && priv->curr_mode > 0) return RIG_OK; + + char cmdbuf[6]; + int retval; + char vfo_function; + + switch (vfo) { + case RIG_VFO_A: + vfo_function = '0'; + break; + + case RIG_VFO_B: + vfo_function = '1'; + break; + + case RIG_VFO_MEM: + vfo_function = '2'; + break; + + case RIG_VFO_CURR: + return RIG_OK; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + + //if rig=ts2000 then check Satellite mode status + if(rig->caps->rig_model == RIG_MODEL_TS2000 && !priv->is_emulation) { + char retbuf[20]; + rig_debug(RIG_DEBUG_VERBOSE, "Checking Satellite mode status\n"); + snprintf(cmdbuf, sizeof (cmdbuf), "SA"); + + retval = elad_transaction(rig, cmdbuf, retbuf, 20); + if (retval != RIG_OK) + return retval; + + rig_debug(RIG_DEBUG_VERBOSE, "Satellite mode status %s\n",retbuf); + //Satellite mode ON + if(retbuf[2]=='1') { + //SAT mode doesn't allow FR command (cannot select VFO) + //selecting VFO is useless in SAT MODE + return RIG_OK; + } + } + + snprintf(cmdbuf, sizeof (cmdbuf), "FR%c", vfo_function); + + if (rig->caps->rig_model == RIG_MODEL_TS50 + || rig->caps->rig_model == RIG_MODEL_TS940) + { + cmdbuf[1] = 'N'; + } + + /* set RX VFO */ + retval = elad_transaction(rig, cmdbuf, NULL, 0); + if (retval != RIG_OK) + return retval; + + /* if FN command then there's no FT or FR */ + /* If split mode on, the don't change TxVFO */ + if ('N' == cmdbuf[1] || priv->split != RIG_SPLIT_OFF) + return RIG_OK; + + /* set TX VFO */ + cmdbuf[1] = 'T'; + return elad_transaction(rig, cmdbuf, NULL, 0); +} + + +/* CB + * Sets the operating VFO, does not set split + * VFO, but leaves it unchanged if in split VFO mode. + * + */ +int elad_set_vfo_main_sub(RIG *rig, vfo_t vfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char cmdbuf[6]; + char vfo_function; + + switch (vfo) { + case RIG_VFO_MAIN: + vfo_function = '0'; + break; + + case RIG_VFO_SUB: + vfo_function = '1'; + break; + + case RIG_VFO_CURR: + return RIG_OK; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + + snprintf(cmdbuf, sizeof (cmdbuf), "CB%c", vfo_function); + return elad_transaction(rig, cmdbuf, NULL, 0); +} + + +/* CB + * Gets the operating VFO + * + */ +int elad_get_vfo_main_sub(RIG *rig, vfo_t * vfo) +{ + char buf[4]; + int rc; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !vfo) + return -RIG_EINVAL; + + if (RIG_OK == (rc = elad_safe_transaction(rig, "CB", buf, sizeof (buf), 3))) + { + *vfo = buf[2] == '1' ? RIG_VFO_SUB : RIG_VFO_MAIN; + } + return rc; +} + + +/* FR FT TB + * Sets the split RX/TX VFO or M.CH mode of the transceiver. + * + */ +int elad_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + char cmdbuf[6]; + int retval; + unsigned char vfo_function; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + if (split) + { + // Rx MAIN/Tx SUB is the only split method + retval = elad_set_vfo_main_sub (rig, RIG_VFO_MAIN); + if (retval != RIG_OK) return retval; + } + snprintf(cmdbuf, sizeof (cmdbuf), "TB%c", RIG_SPLIT_ON == split ? '1' : '0'); + return elad_transaction(rig, cmdbuf, NULL, 0); + } + + if(vfo != RIG_VFO_CURR) { + switch (vfo) { + case RIG_VFO_A: vfo_function = '0'; break; + case RIG_VFO_B: vfo_function = '1'; break; + case RIG_VFO_MEM: vfo_function = '2'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + /* set RX VFO */ + snprintf(cmdbuf, sizeof (cmdbuf), "FR%c", vfo_function); + retval = elad_transaction(rig, cmdbuf, NULL, 0); + if (retval != RIG_OK) + return retval; + } + + /* Split off means Rx and Tx are the same */ + if (split == RIG_SPLIT_OFF) { + txvfo = vfo; + if (txvfo == RIG_VFO_CURR) { + retval = rig_get_vfo(rig, &txvfo); + if (retval != RIG_OK) + return retval; + } + } + + switch (txvfo) { + case RIG_VFO_VFO: + case RIG_VFO_A: vfo_function = '0'; break; + case RIG_VFO_B: vfo_function = '1'; break; + case RIG_VFO_MEM: vfo_function = '2'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, txvfo); + return -RIG_EINVAL; + } + if (RIG_MODEL_K2 == rig->caps->rig_model + || RIG_MODEL_K3 == rig->caps->rig_model) { + /* do not attempt redundant split change commands on Elecraft as + they impact output power when transmitting */ + if (RIG_OK == (retval = elad_safe_transaction (rig, "FT", cmdbuf, sizeof (cmdbuf), 3))) + { + if (cmdbuf[2] == vfo_function) return RIG_OK; + } + } + /* set TX VFO */ + snprintf(cmdbuf, sizeof (cmdbuf), "FT%c", vfo_function); + retval = elad_transaction(rig, cmdbuf, NULL, 0); + if (retval != RIG_OK) + return retval; + + /* Remember whether split is on, for elad_set_vfo */ + priv->split = split; + + return RIG_OK; +} + + +/* SP + * Sets the split mode of the transceivers that have the FN command. + * + */ +int elad_set_split(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + char cmdbuf[6]; + int retval; + + snprintf(cmdbuf, sizeof (cmdbuf), "SP%c", RIG_SPLIT_ON == split ? '1' : '0'); + retval = elad_transaction(rig, cmdbuf, NULL, 0); + if (retval != RIG_OK) + return retval; + + /* Remember whether split is on, for elad_set_vfo */ + priv->split = split; + + return RIG_OK; +} + + +/* IF TB + * Gets split VFO status from elad_get_if() + * + */ +int elad_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !split || !txvfo) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + int retval; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char buf[4]; + if (RIG_OK == (retval = elad_safe_transaction (rig, "TB", buf, sizeof (buf), 3))) + { + if ('1' == buf[2]) + { + *split = RIG_SPLIT_ON; + *txvfo = RIG_VFO_SUB; + } + else + { + *split = RIG_SPLIT_OFF; + *txvfo = RIG_VFO_MAIN; + } + } + return retval; + } + + retval = elad_get_if(rig); + if (retval != RIG_OK) + return retval; + + switch (priv->info[32]) { + case '0': + *split = RIG_SPLIT_OFF; + break; + + case '1': + *split = RIG_SPLIT_ON; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported split %c\n", + __func__, priv->info[32]); + return -RIG_EPROTO; + } + + /* Remember whether split is on, for elad_set_vfo */ + priv->split = *split; + + /* find where is the txvfo.. */ + /* Elecraft info[30] does not track split VFO when transmitting */ + int transmitting = '1' == priv->info[28] + && RIG_MODEL_K2 != rig->caps->rig_model + && RIG_MODEL_K3 != rig->caps->rig_model; + switch (priv->info[30]) + { + case '0': + *txvfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + break; + + case '1': + *txvfo = (*split && !transmitting) ? RIG_VFO_A : RIG_VFO_B; + break; + + case '2': + *txvfo = RIG_VFO_MEM; /* SPLIT MEM operation doesn't involve VFO A or VFO B */ + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %c\n", + __func__, priv->info[30]); + return -RIG_EPROTO; + } + + return RIG_OK; +} + + +/* + * elad_get_vfo_if using byte 31 of the IF information field + * + * Specifically this needs to return the RX VFO, the IF command tells + * us the TX VFO in split TX mode when transmitting so we need to swap + * results sometimes. + */ +int elad_get_vfo_if(RIG *rig, vfo_t *vfo) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !vfo) + return -RIG_EINVAL; + + int retval; + struct elad_priv_data *priv = rig->state.priv; + + retval = elad_get_if(rig); + if (retval != RIG_OK) + return retval; + + /* Elecraft info[30] does not track split VFO when transmitting */ + int split_and_transmitting = + '1' == priv->info[28] /* transmitting */ + && '1' == priv->info[32] /* split */ + && RIG_MODEL_K2 != rig->caps->rig_model + && RIG_MODEL_K3 != rig->caps->rig_model; + switch (priv->info[30]) + { + case '0': + *vfo = split_and_transmitting ? RIG_VFO_B : RIG_VFO_A; + break; + + case '1': + *vfo = split_and_transmitting ? RIG_VFO_A : RIG_VFO_B; + break; + + case '2': + *vfo = RIG_VFO_MEM; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %c\n", + __func__, priv->info[30]); + return -RIG_EPROTO; + } + return RIG_OK; +} + + +/* + * elad_set_freq + */ +int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char freqbuf[16]; + unsigned char vfo_letter = '\0'; + vfo_t tvfo; + int err; + + tvfo = (vfo==RIG_VFO_CURR || vfo==RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + + if (RIG_VFO_CURR == tvfo) { + /* fetch from rig */ + err = rig_get_vfo (rig, &tvfo); + if (RIG_OK != err) return err; + } + + switch (tvfo) { + case RIG_VFO_A: + case RIG_VFO_MAIN: + vfo_letter = 'A'; + break; + case RIG_VFO_B: + case RIG_VFO_SUB: + vfo_letter = 'B'; + break; + case RIG_VFO_C: + vfo_letter = 'C'; + break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(freqbuf, sizeof (freqbuf), "F%c%011"PRIll, vfo_letter, (int64_t)freq); + + err = elad_transaction(rig, freqbuf, NULL, 0); + + struct elad_priv_data * priv = rig->state.priv; + if (RIG_OK == err && RIG_MODEL_TS590S == rig->caps->rig_model && priv->fw_rev_uint <= 107 && ('A' == vfo_letter || 'B' == vfo_letter)) + { + /* TS590s f/w rev 1.07 or earlier has a defect that means + frequency set on TX VFO in split mode may not be set + correctly. + + The symptom of the defect is either TX on the wrong + frequency (i.e. TX on a frequency different from that + showing on the TX VFO) or no output. + + We use an IF command to find out if we have just set + the "back" VFO when the rig is in split mode. If we + have; we then read the other VFO and set it to what we + read - a null transaction that fixes the defect. */ + + err = elad_get_if(rig); + if (RIG_OK != err) + { + return err; + } + + if ('1' == priv->info[32] && priv->info[30] != ('A' == vfo_letter ? '0' : '1')) + { + /* split mode and setting "back" VFO */ + + /* set other VFO to whatever it is at currently */ + err = elad_safe_transaction (rig, 'A' == vfo_letter ? "FB" : "FA", freqbuf, 16, 13); + if (RIG_OK != err) + { + return err; + } + err = elad_transaction (rig, freqbuf, NULL, 0); + } + } + + return err; +} + +int elad_get_freq_if(RIG *rig, vfo_t vfo, freq_t *freq) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !freq) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + char freqbuf[50]; + int retval; + + retval = elad_get_if(rig); + if (retval != RIG_OK) + return retval; + + memcpy(freqbuf, priv->info, 15); + freqbuf[14] = '\0'; + sscanf(freqbuf + 2, "%"SCNfreq, freq); + + return RIG_OK; +} + +/* + * elad_get_freq + */ +int elad_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !freq) + return -RIG_EINVAL; + + char freqbuf[50]; + char cmdbuf[4]; + int retval; + unsigned char vfo_letter = '\0'; + vfo_t tvfo; + + tvfo = (vfo == RIG_VFO_CURR || vfo==RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + + if (RIG_VFO_CURR == tvfo) { + /* fetch from rig */ + retval = rig_get_vfo (rig, &tvfo); + if (RIG_OK != retval) return retval; + } + + /* memory frequency cannot be read with an Fx command, use IF */ + if (tvfo == RIG_VFO_MEM) { + + return elad_get_freq_if(rig, vfo, freq); + } + + switch (tvfo) { + case RIG_VFO_A: + case RIG_VFO_MAIN: + vfo_letter = 'A'; + break; + case RIG_VFO_B: + case RIG_VFO_SUB: + vfo_letter = 'B'; + break; + case RIG_VFO_C: + vfo_letter = 'C'; + break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + + snprintf(cmdbuf, sizeof (cmdbuf), "F%c", vfo_letter); + + retval = elad_safe_transaction(rig, cmdbuf, freqbuf, 50, 13); + if (retval != RIG_OK) + return retval; + + sscanf(freqbuf+2, "%"SCNfreq, freq); + + return RIG_OK; +} + +int elad_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !rit) + return -RIG_EINVAL; + + int retval; + char buf[6]; + struct elad_priv_data *priv = rig->state.priv; + + retval = elad_get_if(rig); + if (retval != RIG_OK) + return retval; + + memcpy(buf, &priv->info[18], 5); + + buf[5] = '\0'; + *rit = atoi(buf); + + return RIG_OK; +} + +/* + * rit can only move up/down by 10 Hz, so we use a loop... + */ +int elad_set_rit(RIG * rig, vfo_t vfo, shortfreq_t rit) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char buf[4]; + int retval, i; + + if (rit == 0) + return elad_transaction(rig, "RC", NULL, 0); + + snprintf(buf, sizeof (buf), "R%c", (rit > 0) ? 'U' : 'D'); + + retval = elad_transaction(rig, "RC", NULL, 0); + if (retval != RIG_OK) + return retval; + + for (i = 0; i < labs(lrint(rit/10)); i++) + retval = elad_transaction(rig, buf, NULL, 0); + + return retval; +} + +/* + * rit and xit are the same + */ +int elad_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *rit) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !rit) + return -RIG_EINVAL; + + return elad_get_rit(rig, vfo, rit); +} + +int elad_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + return elad_set_rit(rig, vfo, rit); +} + +int elad_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + return elad_transaction(rig, scan == RIG_SCAN_STOP ? "SC00" : "SC01", NULL, 0); + } + else + { + return elad_transaction(rig, scan == RIG_SCAN_STOP ? "SC0" : "SC1", NULL, 0); + } +} + +/* + * 000 No select + * 002 FM Wide + * 003 FM Narrow + * 005 AM + * 007 SSB + * 009 CW + * 010 CW NARROW + */ + +/* XXX revise */ +static int elad_set_filter(RIG *rig, pbwidth_t width) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char *cmd; + + if (width <= Hz(250)) + cmd = "FL010009"; + else if(width <= Hz(500)) + cmd = "FL009009"; + else if(width <= kHz(2.7)) + cmd = "FL007007"; + else if(width <= kHz(6)) + cmd = "FL005005"; + else + cmd = "FL002002"; + + return elad_transaction(rig, cmd, NULL, 0); +} + +/* + * elad_set_mode + */ +int elad_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_caps *caps = elad_caps(rig); + char buf[6]; + char kmode; + int err; + char data_mode = '0'; + + if (RIG_MODEL_TS590S == rig->caps->rig_model + || RIG_MODEL_TS590SG == rig->caps->rig_model) + { + /* supports DATA sub modes */ + switch (mode) + { + case RIG_MODE_PKTUSB: + data_mode = '1'; + mode = RIG_MODE_USB; + break; + + case RIG_MODE_PKTLSB: + data_mode = '1'; + mode = RIG_MODE_LSB; + break; + + case RIG_MODE_PKTFM: + data_mode = '1'; + mode = RIG_MODE_FM; + break; + + default: break; + } + } + + if (priv->is_emulation || rig->caps->rig_model == RIG_MODEL_HPSDR) + { + /* emulations like PowerSDR and SmartSDR normally hijack the + RTTY modes for SSB-DATA AFSK modes */ + if (RIG_MODE_PKTLSB == mode) mode = RIG_MODE_RTTY; + if (RIG_MODE_PKTUSB == mode) mode = RIG_MODE_RTTYR; + } + + kmode = rmode2elad(mode, caps->mode_table); + if (kmode < 0 ) { + rig_debug(RIG_DEBUG_WARN, "%s: unsupported mode '%s'\n", + __func__, rig_strrmode(mode)); + return -RIG_EINVAL; + } + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + /* The TS990s has targetable read mode but can only set the mode + of the current VFO :( So we need to toggle the operating VFO + to set the "back" VFO mode. This is done here rather than not + setting caps.targetable_vfo to not include + RIG_TARGETABLE_MODE since the toggle is not required for + reading the mode. */ + char c; + vfo_t curr_vfo; + err = elad_get_vfo_main_sub (rig, &curr_vfo); + if (err != RIG_OK) return err; + if (kmode <= 9) + { + c = '0' + kmode; + } + else + { + c = 'A' + kmode - 10; + } + if (vfo != RIG_VFO_CURR && vfo != curr_vfo) + { + err = elad_set_vfo_main_sub (rig, vfo); + if (err != RIG_OK) return err; + } + snprintf(buf, sizeof (buf), "OM0%c", c); /* target vfo is ignored */ + int err = elad_transaction(rig, buf, NULL, 0); + if (vfo != RIG_VFO_CURR && vfo != curr_vfo) + { + int err2 = elad_set_vfo_main_sub (rig, curr_vfo); + if (RIG_OK == err && err2 != RIG_OK) return err2; + } + } + else + { + snprintf(buf, sizeof (buf), "MD%c", '0' + kmode); + err = elad_transaction(rig, buf, NULL, 0); + } + if (err != RIG_OK) return err; + + if (RIG_MODEL_TS590S == rig->caps->rig_model + || RIG_MODEL_TS590SG == rig->caps->rig_model) + { + if (!(RIG_MODE_CW == mode + || RIG_MODE_CWR == mode + || RIG_MODE_AM == mode + || RIG_MODE_RTTY == mode + || RIG_MODE_RTTYR == mode)) + { + /* supports DATA sub modes - see above */ + snprintf (buf, sizeof (buf), "DA%c", data_mode); + err = elad_transaction (rig, buf, NULL, 0); + if (err != RIG_OK) return err; + } + } + + if (RIG_PASSBAND_NOCHANGE == width) return RIG_OK; + if (rig->caps->rig_model == RIG_MODEL_TS450S + || rig->caps->rig_model == RIG_MODEL_TS690S + || rig->caps->rig_model == RIG_MODEL_TS850 + || rig->caps->rig_model == RIG_MODEL_TS950SDX) { + + if (RIG_PASSBAND_NORMAL == width) + width = rig_passband_normal(rig, mode); + err = elad_set_filter(rig, width); + /* non fatal */ + } + + return RIG_OK; +} + +static int elad_get_filter(RIG *rig, pbwidth_t *width) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !width) + return -RIG_EINVAL; + + int err, f, f1, f2; + char buf[10]; + + err = elad_safe_transaction(rig, "FL", buf, sizeof(buf), 8); + if (err != RIG_OK) + return err; + + f2 = atoi(&buf[5]); + + buf[5] = '\0'; + f1 = atoi(&buf[2]); + + if (f2 > f1) + f = f2; + else + f = f1; + + switch (f) { + case 2: + *width = kHz(12); + break; + case 3: + case 5: + *width = kHz(6); + break; + case 7: + *width = kHz(2.7); + break; + case 9: + *width = Hz(500); + break; + case 10: + *width = Hz(250); + break; + } + + return RIG_OK; +} + +/* + * elad_get_mode + */ +int elad_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !mode || !width) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + struct elad_priv_caps *caps = elad_caps(rig); + char cmd[4]; + char modebuf[10]; + int offs; + int retval; + + /* for emulation do not read mode from VFOB as it is copy of VFOA */ + /* we avoid the VFO swapping most of the time this way */ + /* only need to get it if it has to be initialized */ + if (priv->curr_mode > 0 && priv->is_emulation && vfo == RIG_VFO_B) { + return priv->curr_mode; + } + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + if (RIG_OK != (retval = elad_get_vfo_main_sub (rig, &vfo))) + { + return retval; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(cmd, sizeof (cmd), "OM%c", c); + offs = 3; + } + else + { + snprintf(cmd, sizeof (cmd), "MD"); + offs = 2; + } + + retval = elad_safe_transaction(rig, cmd, modebuf, 6, offs + 1); + if (retval != RIG_OK) + return retval; + + int kmode; + if (modebuf[offs] <= '9') + { + kmode = modebuf[offs] - '0'; + } + else + { + kmode = modebuf[offs] - 'A' + 10; + } + *mode = elad2rmode(kmode, caps->mode_table); + if (priv->is_emulation || rig->caps->rig_model == RIG_MODEL_HPSDR) + { + /* emulations like PowerSDR and SmartSDR normally hijack the + RTTY modes for SSB-DATA AFSK modes */ + if (RIG_MODE_RTTY == *mode) *mode = RIG_MODE_PKTLSB; + if (RIG_MODE_RTTYR == *mode) *mode = RIG_MODE_PKTUSB; + } + + if (RIG_MODEL_TS590S == rig->caps->rig_model + || RIG_MODEL_TS590SG == rig->caps->rig_model) + { + /* supports DATA sub-modes */ + retval = elad_safe_transaction (rig, "DA", modebuf, 6, 3); + if (retval != RIG_OK) + { + return retval; + } + if ('1' == modebuf[2]) + { + switch (*mode) + { + case RIG_MODE_USB: *mode = RIG_MODE_PKTUSB; break; + case RIG_MODE_LSB: *mode = RIG_MODE_PKTLSB; break; + case RIG_MODE_FM: *mode = RIG_MODE_PKTFM; break; + default: break; + } + } + } + + /* XXX ? */ + *width = rig_passband_normal(rig, *mode); + + return RIG_OK; +} + +/* This is used when the radio does not support MD; for mode reading */ +int elad_get_mode_if(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !mode || !width) + return -RIG_EINVAL; + + int err; + struct elad_priv_caps *caps = elad_caps(rig); + struct elad_priv_data *priv = rig->state.priv; + + err = elad_get_if(rig); + if (err != RIG_OK) + return err; + + *mode = elad2rmode(priv->info[29] - '0', caps->mode_table); + + *width = rig_passband_normal(rig, *mode); + + if (rig->caps->rig_model == RIG_MODEL_TS450S + || rig->caps->rig_model == RIG_MODEL_TS690S + || rig->caps->rig_model == RIG_MODEL_TS850 + || rig->caps->rig_model == RIG_MODEL_TS950SDX) { + + err = elad_get_filter(rig, width); + /* non fatal */ + } + + return RIG_OK; +} + +int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char levelbuf[16]; + int i, elad_val; + + if (RIG_LEVEL_IS_FLOAT(level)) + elad_val = val.f * 255; + else + elad_val = val.i; + + switch (level) { + case RIG_LEVEL_RFPOWER: + /* + * Best estimate: 1.0 corresponds to 100W + * Anything better must be done in rig-specific files. + */ + if (RIG_LEVEL_IS_FLOAT(level)) elad_val = val.f * 100; + snprintf(levelbuf, sizeof (levelbuf), "PC%03d", elad_val); + break; + + case RIG_LEVEL_AF: + snprintf(levelbuf, sizeof (levelbuf), "AG%03d", elad_val); + break; + + case RIG_LEVEL_RF: + /* XXX check level range */ + snprintf(levelbuf, sizeof (levelbuf), "RG%03d", elad_val); + break; + + case RIG_LEVEL_SQL: + snprintf(levelbuf, sizeof (levelbuf), "SQ%03d", elad_val); + break; + + case RIG_LEVEL_AGC: + if (elad_val > 3) + elad_val = 3; /* 0.. 255 */ + snprintf(levelbuf, sizeof (levelbuf), "GT%03d", 84*elad_val); + break; + + case RIG_LEVEL_ATT: + /* set the attenuator if a correct value is entered */ + if (val.i == 0) + snprintf(levelbuf, sizeof (levelbuf), "RA00"); + else { + for (i=0; istate.attenuator[i]; i++) { + if (val.i == rig->state.attenuator[i]) + { + snprintf(levelbuf, sizeof (levelbuf), "RA%02d", i+1); + break; + } + } + if (val.i != rig->state.attenuator[i]) + return -RIG_EINVAL; + } + break; + + case RIG_LEVEL_PREAMP: + /* set the preamp if a correct value is entered */ + if (val.i == 0) + snprintf(levelbuf, sizeof (levelbuf), "PA0"); + else { + for (i=0; istate.preamp[i]; i++) { + if (val.i == rig->state.preamp[i]) + { + snprintf(levelbuf, sizeof (levelbuf), "PA%01d", i+1); + break; + } + } + if (val.i != rig->state.preamp[i]) + return -RIG_EINVAL; + } + break; + + case RIG_LEVEL_SLOPE_HIGH: + if(val.i>20 || val.i < 0) + return -RIG_EINVAL; + snprintf(levelbuf, sizeof (levelbuf), "SH%02d",(val.i)); + break; + + case RIG_LEVEL_SLOPE_LOW: + if(val.i>20 || val.i < 0) + return -RIG_EINVAL; + snprintf(levelbuf, sizeof (levelbuf), "SL%02d",(val.i)); + break; + + case RIG_LEVEL_CWPITCH: + if(val.i > 1000 || val.i < 400) + return -RIG_EINVAL; + snprintf(levelbuf, sizeof (levelbuf), "PT%02d", (val.i / 50) - 8); + break; + + case RIG_LEVEL_KEYSPD: + if(val.i > 50 || val.i < 5) + return -RIG_EINVAL; + snprintf(levelbuf, sizeof (levelbuf), "KS%03d", val.i); + break; + + default: + rig_debug(RIG_DEBUG_ERR, "Unsupported set_level %d", level); + return -RIG_EINVAL; + } + + return elad_transaction(rig, levelbuf, NULL, 0); +} + +int get_elad_level(RIG *rig, const char *cmd, float *f) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !cmd || !f) + return -RIG_EINVAL; + + char lvlbuf[10]; + int retval; + int lvl; + int len = strlen (cmd); + + retval = elad_safe_transaction(rig, cmd, lvlbuf, 10, len + 3); + if (retval != RIG_OK) + return retval; + + /* 000..255 */ + sscanf(lvlbuf + len, "%d", &lvl); + *f = lvl / 255.0; + return RIG_OK; +}; + + +/* + * elad_get_level + */ +int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !val) + return -RIG_EINVAL; + + char lvlbuf[ELAD_MAX_BUF_LEN]; + char *cmd; + int retval; + int lvl; + int i, ret, agclevel, len; + + switch (level) { + case RIG_LEVEL_RAWSTR: + if (RIG_MODEL_TS590S == rig->caps->rig_model || RIG_MODEL_TS590SG == rig->caps->rig_model) { + cmd = "SM0"; + len= 3; + } + else { + cmd = "SM"; + len = 2; + } + retval = elad_safe_transaction(rig, cmd, lvlbuf, 10, len+4); + if (retval != RIG_OK) + return retval; + + /* XXX atoi ? */ + sscanf(lvlbuf+len, "%d", &val->i); /* rawstr */ + break; + + case RIG_LEVEL_STRENGTH: + if (RIG_MODEL_TS590S == rig->caps->rig_model || RIG_MODEL_TS590SG == rig->caps->rig_model) { + cmd = "SM0"; + len = 3; + } + else { + cmd = "SM"; + len = 2; + } + retval = elad_safe_transaction(rig, cmd, lvlbuf, 10, len+4); + if (retval != RIG_OK) + return retval; + + sscanf(lvlbuf+len, "%d", &val->i); /* rawstr */ + + if (rig->caps->str_cal.size) + val->i = (int) rig_raw2val(val->i, &rig->caps->str_cal); + else + val->i = (val->i * 4) - 54; + break; + + case RIG_LEVEL_ATT: + retval = elad_safe_transaction(rig, "RA", lvlbuf, 50, 6); + if (retval != RIG_OK) + return retval; + + sscanf(lvlbuf+2, "%d", &lvl); + if (lvl == 0) { + val->i = 0; + } else { + for (i=0; istate.attenuator[i] == 0) { + rig_debug(RIG_DEBUG_ERR, "%s: " + "unexpected att level %d\n", + __func__, lvl); + return -RIG_EPROTO; + } + } + if (i != lvl) + return -RIG_EINTERNAL; + val->i = rig->state.attenuator[i-1]; + } + break; + + case RIG_LEVEL_PREAMP: + retval = elad_safe_transaction(rig, "PA", lvlbuf, 50, 3); + if (retval != RIG_OK) + return retval; + + if (lvlbuf[2] == '0') + val->i = 0; + else if (isdigit((int)lvlbuf[2])) { + lvl = lvlbuf[2]-'0'; + for (i=0; istate.preamp[i] == 0) { + rig_debug(RIG_DEBUG_ERR,"%s: " + "unexpected preamp level %d\n", + __func__, lvl); + return -RIG_EPROTO; + } + } + if (i != lvl) + return -RIG_EINTERNAL; + val->i = rig->state.preamp[i-1]; + } else { + rig_debug(RIG_DEBUG_ERR,"%s: " + "unexpected preamp char '%c'\n", + __func__, lvlbuf[2]); + return -RIG_EPROTO; + } + break; + + case RIG_LEVEL_RFPOWER: + /* + * an answer "PC100" means 100 Watt + * which is val=1.0 on most rigs, but + * get_elad_level maps 0...255 onto 0.0 ... 1.0 + */ + ret = get_elad_level(rig, "PC", &val->f); + val->f = val->f * (255.0/100.0); + return ret; + + case RIG_LEVEL_AF: + return get_elad_level(rig, "AG", &val->f); + + case RIG_LEVEL_RF: + return get_elad_level(rig, "RG", &val->f); + + case RIG_LEVEL_SQL: + return get_elad_level(rig, "SQ", &val->f); + + case RIG_LEVEL_MICGAIN: + return get_elad_level(rig, "MG", &val->f); + + case RIG_LEVEL_AGC: + ret = get_elad_level(rig, "GT", &val->f); + agclevel = 255 * val->f; + if (agclevel == 0) val->i = 0; + else if (agclevel < 85) val->i = 1; + else if (agclevel < 170) val->i = 2; + else if (agclevel <= 255) val->i = 3; + return ret; + + case RIG_LEVEL_SLOPE_LOW: + retval = elad_transaction (rig, "SL", lvlbuf, sizeof (lvlbuf)); + if (retval != RIG_OK) + return retval; + val->i=atoi(&lvlbuf[2]); + break; + + case RIG_LEVEL_SLOPE_HIGH: + retval = elad_transaction (rig, "SH", lvlbuf, sizeof (lvlbuf)); + if (retval != RIG_OK) + return retval; + val->i=atoi(&lvlbuf[2]); + break; + + case RIG_LEVEL_CWPITCH: + retval = elad_safe_transaction(rig, "PT", lvlbuf, 50, 4); + if (retval != RIG_OK) + return retval; + + sscanf(lvlbuf+2, "%d", &val->i); + val->i = (val->i * 1000) + 1000; /* 00 - 08 */ + break; + + case RIG_LEVEL_KEYSPD: + retval = elad_safe_transaction(rig, "KS", lvlbuf, 50, 5); + if (retval != RIG_OK) + return retval; + + sscanf(lvlbuf+2, "%d", &val->i); + break; + + case RIG_LEVEL_IF: + case RIG_LEVEL_APF: + case RIG_LEVEL_NR: + case RIG_LEVEL_PBT_IN: + case RIG_LEVEL_PBT_OUT: + case RIG_LEVEL_NOTCHF: + case RIG_LEVEL_COMP: + case RIG_LEVEL_BKINDL: + case RIG_LEVEL_BALANCE: + return -RIG_ENIMPL; + + default: + rig_debug(RIG_DEBUG_ERR, "Unsupported get_level %d", level); + return -RIG_EINVAL; + } + + return RIG_OK; +} + +int elad_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char buf[6]; /* longest cmd is GTxxx */ + + switch (func) { + case RIG_FUNC_NB: + snprintf(buf, sizeof (buf), "NB%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_ABM: + snprintf(buf, sizeof (buf), "AM%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_COMP: + snprintf(buf, sizeof (buf), "PR%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_TONE: + snprintf(buf, sizeof (buf), "TO%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_TSQL: + snprintf(buf, sizeof (buf), "CT%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_VOX: + snprintf(buf, sizeof (buf), "VX%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_FAGC: + snprintf(buf, sizeof (buf), "GT00%c", (status == 0) ? '4' : '2'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_NR: + snprintf(buf, sizeof (buf), "NR%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_BC: + snprintf(buf, sizeof (buf), "BC%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_ANF: + snprintf(buf, sizeof (buf), "NT%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_LOCK: + snprintf(buf, sizeof (buf), "LK%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_AIP: + snprintf(buf, sizeof (buf), "MX%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_RIT: + snprintf(buf, sizeof (buf), "RT%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case RIG_FUNC_XIT: + snprintf(buf, sizeof (buf), "XT%c", (status == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + default: + rig_debug(RIG_DEBUG_ERR, "Unsupported set_func %#x", func); + return -RIG_EINVAL; + } + + return -RIG_EINVAL; +} + +/* + * works for any 'format 1' command + * answer is always 4 bytes: two byte command id, status and terminator + */ +int get_elad_func(RIG *rig, const char *cmd, int *status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !cmd || !status) + return -RIG_EINVAL; + + int retval; + char buf[10]; + + retval = elad_safe_transaction(rig, cmd, buf, 10, 3); + if (retval != RIG_OK) + return retval; + + *status = buf[2] == '0' ? 0 : 1; + + return RIG_OK; +}; + +/* + * elad_get_func + */ +int elad_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !status) + return -RIG_EINVAL; + + char fctbuf[20]; + int retval; + + switch (func) { + case RIG_FUNC_FAGC: + retval = elad_safe_transaction(rig, "GT", fctbuf, 20, 5); + if (retval != RIG_OK) + return retval; + + *status = fctbuf[4] != '4' ? 1 : 0; + return RIG_OK; + + case RIG_FUNC_NB: + return get_elad_func(rig, "NB", status); + + case RIG_FUNC_ABM: + return get_elad_func(rig, "AM", status); + + case RIG_FUNC_COMP: + return get_elad_func(rig, "PR", status); + + case RIG_FUNC_TONE: + return get_elad_func(rig, "TO", status); + + case RIG_FUNC_TSQL: + return get_elad_func(rig, "CT", status); + + case RIG_FUNC_VOX: + return get_elad_func(rig, "VX", status); + + case RIG_FUNC_NR: + return get_elad_func(rig, "NR", status); + + /* FIXME on TS2000 */ + case RIG_FUNC_BC: + return get_elad_func(rig, "BC", status); + + case RIG_FUNC_ANF: + return get_elad_func(rig, "NT", status); + + case RIG_FUNC_LOCK: + return get_elad_func(rig, "LK", status); + + case RIG_FUNC_AIP: + return get_elad_func(rig, "MX", status); + + default: + rig_debug(RIG_DEBUG_ERR, "Unsupported get_func %#x", func); + return -RIG_EINVAL; + } + + return -RIG_EINVAL; +} + +/* + * elad_set_ctcss_tone + * Assumes rig->caps->ctcss_list != NULL + * + * Warning! This is untested stuff! May work at least on TS-870S + * Please owners report to me , thanks. --SF + */ +int elad_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + const struct rig_caps *caps; + char tonebuf[16]; + int i; + + caps = rig->caps; + +/* TODO: replace 200 by something like RIGTONEMAX */ + for (i = 0; caps->ctcss_list[i] != 0 && i<200; i++) { + if (caps->ctcss_list[i] == tone) + break; + } + if (caps->ctcss_list[i] != tone) + return -RIG_EINVAL; + +/* TODO: replace menu no 57 by a define */ + snprintf(tonebuf, sizeof (tonebuf), "EX%03d%04d", 57, i+1); + + return elad_transaction(rig, tonebuf, NULL, 0); +} + +int elad_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + const struct rig_caps *caps = rig->caps; + char buf[6]; + int i; + + /* XXX 40 is a fixed constant */ + for (i = 0; caps->ctcss_list[i] != 0 && i < 40; i++) { + if (tone == caps->ctcss_list[i]) + break; + } + + if (tone != caps->ctcss_list[i]) + return -RIG_EINVAL; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + int err; + if (RIG_OK != (err = elad_get_vfo_main_sub (rig, &vfo))) + { + return err; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(buf, sizeof (buf), "TN%c%02d", c, i + 1); + } + else + { + snprintf(buf, sizeof (buf), "TN%02d", i + 1); + } + + return elad_transaction(rig, buf, NULL, 0); +} + +/* + * elad_get_ctcss_tone + * Assumes rig->state.priv != NULL + */ +int elad_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !tone) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + const struct rig_caps *caps; + char tonebuf[3]; + int i, retval; + unsigned int tone_idx; + + caps = rig->caps; + + if (RIG_MODEL_TS990S == caps->rig_model) + { + char cmd[4]; + char buf[6]; + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + if (RIG_OK != (retval = elad_get_vfo_main_sub (rig, &vfo))) + { + return retval; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(cmd, sizeof (cmd), "TN%c", c); + retval = elad_safe_transaction (rig, cmd, buf, sizeof (buf), 5); + memcpy (tonebuf, &buf[3], 2); + } + else + { + retval = elad_get_if(rig); + memcpy(tonebuf, &priv->info[34], 2); + } + + if (retval != RIG_OK) + return retval; + + tonebuf[2] = '\0'; + tone_idx = atoi(tonebuf); + + if (tone_idx == 0) { + rig_debug(RIG_DEBUG_ERR, "%s: CTCSS tone is zero (%s)\n", + __func__, tonebuf); + return -RIG_EPROTO; + } + + /* check this tone exists. That's better than nothing. */ + for (i = 0; ictcss_list[i] == 0) { + rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04d)\n", + __func__, tone_idx); + return -RIG_EPROTO; + } + } + *tone = caps->ctcss_list[tone_idx-1]; + + return RIG_OK; +} + +int elad_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + const struct rig_caps *caps = rig->caps; + char buf[6]; + int i; + + for (i = 0; caps->ctcss_list[i] != 0 && i < 40; i++) { + if (tone == caps->ctcss_list[i]) + break; + } + + if (tone != caps->ctcss_list[i]) + return -RIG_EINVAL; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + int err; + if (RIG_OK != (err = elad_get_vfo_main_sub (rig, &vfo))) + { + return err; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(buf, sizeof (buf), "CN%c%02d", c, i + 1); + } + else + { + snprintf(buf, sizeof (buf), "CN%02d", i + 1); + } + return elad_transaction(rig, buf, NULL, 0); +} + +int elad_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !tone) + return -RIG_EINVAL; + + const struct rig_caps *caps; + char cmd[4]; + char tonebuf[6]; + int offs; + int i, retval; + unsigned int tone_idx; + + caps = rig->caps; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + if (RIG_OK != (retval = elad_get_vfo_main_sub (rig, &vfo))) + { + return retval; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf(cmd, sizeof (cmd), "CN%c", c); + offs = 3; + } + else + { + snprintf(cmd, sizeof (cmd), "CT"); + offs = 2; + } + + retval = elad_safe_transaction(rig, cmd, tonebuf, 6, offs + 2); + if (retval != RIG_OK) + return retval; + + tone_idx = atoi(tonebuf + offs); + + if (tone_idx == 0) { + rig_debug(RIG_DEBUG_ERR, "%s: CTCSS is zero (%s)\n", + __func__, tonebuf); + return -RIG_EPROTO; + } + + /* check this tone exists. That's better than nothing. */ + for (i = 0; ictcss_list[i] == 0) { + rig_debug(RIG_DEBUG_ERR, "%s: CTCSS NG (%04d)\n", + __func__, tone_idx); + return -RIG_EPROTO; + } + } + *tone = caps->ctcss_list[tone_idx-1]; + + return RIG_OK; +} + + +/* + * set the aerial/antenna to use + */ +int elad_set_ant(RIG * rig, vfo_t vfo, ant_t ant) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char cmd[8]; + char a; + + switch (ant) { + case RIG_ANT_1: a = '1'; break; + case RIG_ANT_2: a = '2'; break; + case RIG_ANT_3: a = '3'; break; + case RIG_ANT_4: a = '4'; break; + default: + return -RIG_EINVAL; + } + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + int err; + if (RIG_OK != (err = elad_get_vfo_main_sub (rig, &vfo))) + { + return err; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf (cmd, sizeof (cmd), "AN0%c%c99", c, a); + } + else + { + snprintf (cmd, sizeof (cmd), "AN%c", a); + } + + return elad_transaction(rig, cmd, NULL, 0); +} + +int elad_set_ant_no_ack(RIG * rig, vfo_t vfo, ant_t ant) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + const char *cmd; + + switch (ant) { + case RIG_ANT_1: + cmd = "AN1"; + break; + case RIG_ANT_2: + cmd = "AN2"; + break; + case RIG_ANT_3: + cmd = "AN3"; + break; + case RIG_ANT_4: + cmd = "AN4"; + break; + default: + return -RIG_EINVAL; + } + + return elad_transaction(rig, cmd, NULL, 0); +} + +/* + * get the aerial/antenna in use + */ +int elad_get_ant (RIG *rig, vfo_t vfo, ant_t *ant) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !ant) + return -RIG_EINVAL; + + char ackbuf[8]; + int offs; + int retval; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + retval = elad_safe_transaction(rig, "AN0", ackbuf, sizeof (ackbuf), 7); + offs = 4; + } + else + { + retval = elad_safe_transaction(rig, "AN", ackbuf, sizeof (ackbuf), 3); + offs = 2; + } + if (retval != RIG_OK) + return retval; + + if (ackbuf[offs] < '1' || ackbuf[offs] > '9') + return -RIG_EPROTO; + + *ant = RIG_ANT_N(ackbuf[offs]-'1'); + + /* XXX check that the returned antenna is valid for the current rig */ + + return RIG_OK; +} + +/* + * elad_get_ptt + */ +int elad_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !ptt) + return -RIG_EINVAL; + + struct elad_priv_data *priv = rig->state.priv; + int retval; + + retval = elad_get_if(rig); + if (retval != RIG_OK) + return retval; + + *ptt = priv->info[28] == '0' ? RIG_PTT_OFF : RIG_PTT_ON; + + return RIG_OK; +} + +int elad_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + const char *ptt_cmd; + char busybuf[10]; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + switch (ptt) { + case RIG_PTT_ON: ptt_cmd = "TX"; break; + case RIG_PTT_ON_MIC: ptt_cmd = "TX0"; break; + case RIG_PTT_ON_DATA: ptt_cmd = "TX1"; break; + case RIG_PTT_OFF: ptt_cmd = "RX"; break; + default: return -RIG_EINVAL; + } + return elad_transaction(rig, ptt_cmd, busybuf, 4); +} + +int elad_set_ptt_safe(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + char busybuf[10]; + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + int err; + ptt_t current_ptt; + + err = elad_get_ptt(rig, vfo, ¤t_ptt); + if (err != RIG_OK) + return err; + + if (current_ptt == ptt) + return RIG_OK; + + return elad_transaction(rig, + (ptt == RIG_PTT_ON) ? "TX" : "RX", busybuf, 4); +} + + +/* + * elad_get_dcd + */ +int elad_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !dcd) + return -RIG_EINVAL; + + char busybuf[10]; + int retval; + + retval = elad_safe_transaction(rig, "BY", busybuf, 10, 3); + if (retval != RIG_OK) + return retval; + + int offs = 2; + if (RIG_MODEL_TS990S == rig->caps->rig_model && RIG_VFO_SUB == vfo) + { + offs = 3; + } + *dcd = (busybuf[offs] == '1') ? RIG_DCD_ON : RIG_DCD_OFF; + + return RIG_OK; +} + +/* + * elad_set_trn + */ +int elad_set_trn(RIG *rig, int trn) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + return elad_transaction(rig, (trn == RIG_TRN_RIG) ? "AI2" : "AI0", NULL, 0); + } + else + { + return elad_transaction(rig, (trn == RIG_TRN_RIG) ? "AI1" : "AI0", NULL, 0); + } +} + +/* + * elad_get_trn + */ +int elad_get_trn(RIG *rig, int *trn) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !trn) + return -RIG_EINVAL; + + /* these rigs only have AI[0|1] set commands and no AI query */ + if (rig->caps->rig_model == RIG_MODEL_TS450S + || rig->caps->rig_model == RIG_MODEL_TS690S + || rig->caps->rig_model == RIG_MODEL_TS790 + || rig->caps->rig_model == RIG_MODEL_TS850 + || rig->caps->rig_model == RIG_MODEL_TS950SDX) { + return -RIG_ENAVAIL; + } + + char trnbuf[6]; + int retval; + + retval = elad_safe_transaction(rig, "AI", trnbuf, 6, 3); + if (retval != RIG_OK) + return retval; + + *trn = trnbuf[2] != '0' ? RIG_TRN_RIG : RIG_TRN_OFF; + + return RIG_OK; +} + +/* + * elad_set_powerstat + */ +int elad_set_powerstat(RIG *rig, powerstat_t status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + return elad_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); +} + +/* + * elad_get_powerstat + */ +int elad_get_powerstat(RIG *rig, powerstat_t *status) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !status) + return -RIG_EINVAL; + + char pwrbuf[6]; + int retval; + + retval = elad_safe_transaction(rig, "PS", pwrbuf, 6, 3); + if (retval != RIG_OK) + return retval; + + *status = pwrbuf[2] == '0' ? RIG_POWER_OFF : RIG_POWER_ON; + + return RIG_OK; +} + +/* + * elad_reset + */ +int elad_reset(RIG *rig, reset_t reset) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char rstbuf[6]; + char rst; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + switch (reset) + { + case RIG_RESET_SOFT: rst = '4'; break; + case RIG_RESET_VFO: rst = '3'; break; + case RIG_RESET_MCALL: rst = '2'; break; + case RIG_RESET_MASTER: rst = '5'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported reset %d\n", + __func__, reset); + return -RIG_EINVAL; + } + } + else + { + switch(reset) { + case RIG_RESET_VFO: rst = '1'; break; + case RIG_RESET_MASTER: rst = '2'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported reset %d\n", + __func__, reset); + return -RIG_EINVAL; + } + } + snprintf(rstbuf, sizeof (rstbuf), "SR%c", rst); + + /* this command has no answer */ + return elad_transaction(rig, rstbuf, NULL, 0); +} + +/* + * elad_send_morse + */ +int elad_send_morse(RIG *rig, vfo_t vfo, const char *msg) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !msg) + return -RIG_EINVAL; + + char morsebuf[40], m2[30]; + int msg_len, buff_len, retval, i; + const char *p; + + p = msg; + msg_len = strlen(msg); + + while(msg_len > 0) { + /* + * Check with "KY" if char buffer is available. + * if not, sleep. + */ + for (;;) { + retval = elad_transaction(rig, "KY;", m2, 4); + if (retval != RIG_OK) + return retval; + /* + * If answer is "KY0;", there is space in buffer and we can proceed. + * If answer is "KY1;", we have to wait a while + * If answer is something else, return with error to prevent infinite loops + */ + if (!strncmp(m2,"KY0", 3)) break; + if (!strncmp(m2,"KY1", 3)) usleep(500000); else return -RIG_EINVAL; + } + buff_len = msg_len > 24 ? 24 : msg_len; + + strncpy(m2, p, 24); + m2[24] = '\0'; + + /* + * Make the total message segments 28 characters + * in length because some Kenwoods demand it. + * 0x20 fills in the message end. + * Some rigs don't need the fill + */ + switch(rig->caps->rig_model) { + case RIG_MODEL_K3: // probably a lot more rigs need to go here + snprintf(morsebuf, sizeof (morsebuf), "KY %s", m2); + break; + default: + /* the command must consist of 28 bytes 0x20 padded */ + snprintf(morsebuf, sizeof (morsebuf), "KY %-24s", m2); + for(i = strlen(morsebuf) - 1;i > 0 && morsebuf[i] == ' '; --i) { + morsebuf[i]=0x20; + } + } + retval = elad_transaction(rig, morsebuf, NULL, 0); + if (retval != RIG_OK) + return retval; + + msg_len -= buff_len; + p += buff_len; + } + + return RIG_OK; +} + +/* + * elad_vfo_op + */ +int elad_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + switch(op) { + case RIG_OP_UP: + return elad_transaction(rig, "UP", NULL, 0); + + case RIG_OP_DOWN: + return elad_transaction(rig, "DN", NULL, 0); + + case RIG_OP_BAND_UP: + return elad_transaction(rig, "BU", NULL, 0); + + case RIG_OP_BAND_DOWN: + return elad_transaction(rig, "BD", NULL, 0); + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported op %#x\n", + __func__, op); + return -RIG_EINVAL; + } +} + +/* + * elad_set_mem + */ +int elad_set_mem(RIG *rig, vfo_t vfo, int ch) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char buf[7]; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + int err; + if (RIG_OK != (err = elad_get_vfo_main_sub (rig, &vfo))) + { + return err; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf (buf, sizeof (buf), "MN%c%03d", c, ch); + } + else + { + /* + * "MCbmm;" + * where b is the bank number, mm the memory number. + * b can be a space + */ + snprintf(buf, sizeof (buf), "MC %02d", ch); + } + return elad_transaction(rig, buf, NULL, 0); +} + +/* + * elad_get_mem + */ +int elad_get_mem(RIG *rig, vfo_t vfo, int *ch) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !ch) + return -RIG_EINVAL; + + char cmd[4]; + char membuf[10]; + int offs; + int retval; + + if (RIG_MODEL_TS990S == rig->caps->rig_model) + { + char c; + + if (RIG_VFO_CURR == vfo || RIG_VFO_VFO == vfo) + { + if (RIG_OK != (retval = elad_get_vfo_main_sub (rig, &vfo))) + { + return retval; + } + } + switch (vfo) + { + case RIG_VFO_MAIN: c = '0'; break; + case RIG_VFO_SUB: c = '1'; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %d\n", __func__, vfo); + return -RIG_EINVAL; + } + snprintf (cmd, sizeof (cmd), "MN%c", c); + offs = 3; + } + else + { + /* + * "MCbmm;" + * where b is the bank number, mm the memory number. + * b can be a space + */ + snprintf (cmd, sizeof (cmd), "MC"); + offs = 2; + } + retval = elad_safe_transaction(rig, cmd, membuf, sizeof (membuf), 3 + offs); + if (retval != RIG_OK) + return retval; + + *ch = atoi(membuf + offs); + + return RIG_OK; +} + +int elad_get_mem_if(RIG *rig, vfo_t vfo, int *ch) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !ch) + return -RIG_EINVAL; + + int err; + char buf[4]; + struct elad_priv_data *priv = rig->state.priv; + + err = elad_get_if(rig); + if (err != RIG_OK) + return err; + + memcpy(buf, &priv->info[26], 2); + buf[2] = '\0'; + + *ch = atoi(buf); + + return RIG_OK; +} + +int elad_get_channel(RIG *rig, channel_t *chan) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !chan) + return -RIG_EINVAL; + + int err; + char buf[26]; + char cmd[8]; + struct elad_priv_caps *caps = elad_caps(rig); + + /* put channel num in the command string */ + char bank = ' '; + if (rig->caps->rig_model == RIG_MODEL_TS940) + { + bank = '0' + chan->bank_num; + } + snprintf(cmd, sizeof (cmd), "MR0%c%02d", bank, chan->channel_num); + + err = elad_safe_transaction(rig, cmd, buf, 26, 23); + if (err != RIG_OK) + return err; + + memset(chan, 0x00, sizeof(channel_t)); + + chan->vfo = RIG_VFO_VFO; + + /* MR0 1700005890000510 ; + * MRsbccfffffffffffMLTtt ; + */ + + /* parse from right to left */ + + /* XXX based on the available documentation, there is no command + * to read out the filters of a given memory channel. The rig, however, + * stores this information. + */ + + if (buf[19] == '0' || buf[19] == ' ') + chan->ctcss_tone = 0; + else { + buf[22] = '\0'; + if (rig->caps->ctcss_list) + chan->ctcss_tone = rig->caps->ctcss_list[atoi(&buf[20])]; + } + + /* memory lockout */ + if (buf[18] == '1') + chan->flags |= RIG_CHFLAG_SKIP; + + chan->mode = elad2rmode(buf[17] - '0', caps->mode_table); + + buf[17] = '\0'; + chan->freq = atoi(&buf[6]); + + if (chan->freq == RIG_FREQ_NONE) + return -RIG_ENAVAIL; + + buf[6] = '\0'; + chan->channel_num = atoi(&buf[4]); + + if (buf[3] >= '0' && buf[3] <= '9') + { + chan->bank_num = buf[3] - '0'; + } + + /* split freq */ + cmd[2] = '1'; + err = elad_safe_transaction(rig, cmd, buf, 26, 23); + if (err != RIG_OK) + return err; + + chan->tx_mode = elad2rmode(buf[17] - '0', caps->mode_table); + + buf[17] = '\0'; + chan->tx_freq = atoi(&buf[6]); + + if (chan->freq == chan->tx_freq) { + chan->tx_freq = RIG_FREQ_NONE; + chan->tx_mode = RIG_MODE_NONE; + chan->split = RIG_SPLIT_OFF; + } else + chan->split = RIG_SPLIT_ON; + + return RIG_OK; +} + +int elad_set_channel(RIG *rig, const channel_t *chan) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !chan) + return -RIG_EINVAL; + + char buf[128]; + char mode, tx_mode = 0; + int err; + int tone = 0; + + struct elad_priv_caps *caps = elad_caps(rig); + + mode = rmode2elad(chan->mode, caps->mode_table); + if (mode < 0 ) { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%s'\n", + __func__, rig_strrmode(chan->mode)); + return -RIG_EINVAL; + } + + if (chan->split == RIG_SPLIT_ON) { + tx_mode = rmode2elad(chan->tx_mode, caps->mode_table); + if (tx_mode < 0 ) { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%s'\n", + __func__, rig_strrmode(chan->tx_mode)); + return -RIG_EINVAL; + } + + } + + /* find tone */ + if (chan->ctcss_tone) { + + for (tone = 0; rig->caps->ctcss_list[tone] != 0; tone++) { + if (chan->ctcss_tone == rig->caps->ctcss_list[tone]) + break; + } + + if (chan->ctcss_tone != rig->caps->ctcss_list[tone]) + tone = 0; + } + + char bank = ' '; + if (rig->caps->rig_model == RIG_MODEL_TS940) + { + bank = '0' + chan->bank_num; + } + + snprintf(buf, sizeof (buf), "MW0%c%02d%011"PRIll"%c%c%c%02d ", /* note the space at + the end */ + bank, + chan->channel_num, + (int64_t)chan->freq, + '0' + mode, + (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', + chan->ctcss_tone ? '1' : '0', + chan->ctcss_tone ? (tone + 1) : 0); + + err = elad_transaction(rig, buf, NULL, 0); + if (err != RIG_OK) + return err; + + snprintf(buf, sizeof (buf), "MW1%c%02d%011"PRIll"%c%c%c%02d ", + bank, + chan->channel_num, + (int64_t)(chan->split == RIG_SPLIT_ON ? chan->tx_freq : 0), + (chan->split == RIG_SPLIT_ON) ? ('0' + tx_mode) : '0', + (chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0', + chan->ctcss_tone ? '1' : '0', + chan->ctcss_tone ? (tone + 1) : 0); + + return elad_transaction(rig, buf, NULL, 0); +} + +int elad_set_ext_parm(RIG *rig, token_t token, value_t val) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return -RIG_EINVAL; + + char buf[4]; + + switch (token) { + case TOK_VOICE: + return elad_transaction(rig, "VR", NULL, 0); + + case TOK_FINE: + snprintf(buf, sizeof (buf), "FS%c", (val.i == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case TOK_XIT: + snprintf(buf, sizeof (buf), "XT%c", (val.i == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + + case TOK_RIT: + snprintf(buf, sizeof (buf), "RT%c", (val.i == 0) ? '0' : '1'); + return elad_transaction(rig, buf, NULL, 0); + } + + return -RIG_EINVAL; +} + +int elad_get_ext_parm(RIG *rig, token_t token, value_t *val) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig || !val) + return -RIG_EINVAL; + + int err; + struct elad_priv_data *priv = rig->state.priv; + + switch (token) { + case TOK_FINE: + return get_elad_func(rig, "FS", &val->i); + + case TOK_XIT: + err = elad_get_if(rig); + if (err != RIG_OK) + return err; + + val->i = (priv->info[24] == '1') ? 1 : 0; + return RIG_OK; + + case TOK_RIT: + err = elad_get_if(rig); + if (err != RIG_OK) + return err; + + val->i = (priv->info[23] == '1') ? 1 : 0; + return RIG_OK; + } + + return -RIG_ENIMPL; +} + +/* + * elad_get_info + * supposed to work only for TS2000... + */ +const char* elad_get_info(RIG *rig) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rig) + return "*rig == NULL"; + + char firmbuf[10]; + int retval; + + retval = elad_safe_transaction(rig, "TY", firmbuf, 10, 5); + if (retval != RIG_OK) + return NULL; + + switch (firmbuf[4]) { + case '0': return "Firmware: Overseas type"; + case '1': return "Firmware: Japanese 100W type"; + case '2': return "Firmware: Japanese 20W type"; + default: return "Firmware: unknown"; + } +} + +#define IDBUFSZ 16 + +/* + * proberigs_elad + * + * Notes: + * There's only one rig possible per port. + * + * rig_model_t probeallrigs_elad(port_t *port, rig_probe_func_t cfunc, rig_ptr_t data) + */ +DECLARE_PROBERIG_BACKEND(elad) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + char idbuf[IDBUFSZ]; + int id_len=-1, i, k_id; + int retval=-1; + int rates[] = { 115200, 57600, 38400, 19200, 9600, 4800, 1200, 0 }; /* possible baud rates */ + int rates_idx; + + if (!port) + return RIG_MODEL_NONE; + + if (port->type.rig != RIG_PORT_SERIAL) + return RIG_MODEL_NONE; + + port->write_delay = port->post_write_delay = 0; + port->parm.serial.stop_bits = 2; + port->retry = 1; + + /* + * try for all different baud rates + */ + for (rates_idx = 0; rates[rates_idx]; rates_idx++) { + port->parm.serial.rate = rates[rates_idx]; + port->timeout = 2*1000/rates[rates_idx] + 50; + + retval = serial_open(port); + if (retval != RIG_OK) + return RIG_MODEL_NONE; + + retval = write_block(port, "ID;", 3); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2); + close(port->fd); + + if (retval != RIG_OK || id_len < 0) + continue; + } + + if (retval != RIG_OK || id_len < 0 || !strcmp(idbuf, "ID;")) + return RIG_MODEL_NONE; + + /* + * reply should be something like 'IDxxx;' + */ + if (id_len != 5 && id_len != 6) { + idbuf[7] = '\0'; + rig_debug(RIG_DEBUG_VERBOSE, "probe_elad: protocol error, " + " expected %d, received %d: %s\n", + 6, id_len, idbuf); + return RIG_MODEL_NONE; + } + + + /* first, try ID string */ + for (i=0; elad_id_string_list[i].model != RIG_MODEL_NONE; i++) { + if (!strncmp(elad_id_string_list[i].id, idbuf+2, 16)) { + rig_debug(RIG_DEBUG_VERBOSE, "probe_elad: " + "found %s\n", idbuf+2); + if (cfunc) + (*cfunc)(port, elad_id_string_list[i].model, data); + return elad_id_string_list[i].model; + } + } + + /* then, try ID numbers */ + + k_id = atoi(idbuf+2); + + /* + * Elecraft K2 returns same ID as TS570 + */ + if (k_id == 17) { + retval = serial_open(port); + if (retval != RIG_OK) + return RIG_MODEL_NONE; + retval = write_block(port, "K2;", 3); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2); + close(port->fd); + if (retval != RIG_OK) + return RIG_MODEL_NONE; + /* + * reply should be something like 'K2n;' + */ + if (id_len == 4 || !strcmp(idbuf, "K2")) { + rig_debug(RIG_DEBUG_VERBOSE, "probe_elad: found K2\n"); + if (cfunc) + (*cfunc)(port, RIG_MODEL_K2, data); + return RIG_MODEL_K2; + } + } + + for (i=0; elad_id_list[i].model != RIG_MODEL_NONE; i++) { + if (elad_id_list[i].id == k_id) { + rig_debug(RIG_DEBUG_VERBOSE, "probe_elad: " + "found %03d\n", k_id); + if (cfunc) + (*cfunc)(port, elad_id_list[i].model, data); + return elad_id_list[i].model; + } + } + /* + * not found in known table.... + * update elad_id_list[]! + */ + rig_debug(RIG_DEBUG_WARN, "probe_elad: found unknown device " + "with ID %03d, please report to Hamlib " + "developers.\n", k_id); + + rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay=%d\n", __func__, port->post_write_delay); + return RIG_MODEL_NONE; +} + + +/* + * initrigs_elad is called by rig_backend_load + */ +DECLARE_INITRIG_BACKEND(elad) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + +// rig_debug(RIG_DEBUG_VERBOSE, "elad: _init called\n"); + + rig_register(&fdm_duo_caps); + + return RIG_OK; +} diff --git a/elad/elad.h b/elad/elad.h new file mode 100644 index 000000000..673f64dfc --- /dev/null +++ b/elad/elad.h @@ -0,0 +1,174 @@ +/* + * Hamlib ELAD backend - main header + * Copyright (c) 2000-2011 by Stephane Fillod + * Copyright (C) 2009,2010 Alessandro Zummo + * Copyright (C) 2009,2010,2011,2012,2013 by Nate Bargmann, n0nb@n0nb.us + * Copyright (C) 2018 by Giovanni Franza, info@hb9eik.ch + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _ELAD_H +#define _ELAD_H 1 + +#include +#include "token.h" + +#define BACKEND_VER "1.0" + +#define EOM_KEN ';' +#define EOM_TH '\r' + +#define ELAD_MODE_TABLE_MAX 24 +#define ELAD_MAX_BUF_LEN 128 /* max answer len, arbitrary */ + + +/* Tokens for Parameters common to multiple rigs. + * Use token # >= 1 or <= 100. Defined here so they will be + * available in Kenwood name space. + */ +#define TOK_VOICE TOKEN_BACKEND(1) +#define TOK_FINE TOKEN_BACKEND(2) +#define TOK_XIT TOKEN_BACKEND(3) +#define TOK_RIT TOKEN_BACKEND(4) + +/* Token structure assigned to .cfgparams in rig_caps */ +extern const struct confparams elad_cfg_params[]; + + +/* + * modes in use by the "MD" command + */ +#define MD_NONE '0' +#define MD_LSB '1' +#define MD_USB '2' +#define MD_CW '3' +#define MD_FM '4' +#define MD_AM '5' +#define MD_FSK '6' +#define MD_CWR '7' +#define MD_FSKR '9' + +struct elad_priv_caps { + char cmdtrm; /* Command termination chars (ken=';' or th='\r') */ + int if_len; /* length of IF; answer excluding ';' terminator */ + rmode_t *mode_table; +}; + +struct elad_priv_data { + char info[ELAD_MAX_BUF_LEN]; + split_t split; /* current split state */ + int k2_ext_lvl; /* Initial K2 extension level */ + int k3_ext_lvl; /* Initial K3 extension level */ + int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */ + char *fw_rev; /* firmware revision level */ + int trn_state; /* AI state discovered at startup */ + unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */ + char verify_cmd[4]; /* command used to verify set commands */ + int is_emulation; /* flag for TS-2000 emulations */ + void * data; /* model specific data */ + rmode_t curr_mode; /* used for is_emulation to avoid get_mode on VFOB */ +}; + + +#define elad_caps(rig) ((struct elad_priv_caps *)(rig)->caps->priv) + + +extern rmode_t elad_mode_table[ELAD_MODE_TABLE_MAX]; + +extern const tone_t elad38_ctcss_list[]; +extern const tone_t elad42_ctcss_list[]; + +int elad_transaction(RIG *rig, const char *cmd, char *data, size_t data_len); +int elad_safe_transaction(RIG *rig, const char *cmd, char *buf, + size_t buf_size, size_t expected); + +rmode_t elad2rmode(unsigned char mode, const rmode_t mode_table[]); +char rmode2elad(rmode_t mode, const rmode_t mode_table[]); + +int elad_init(RIG *rig); +int elad_cleanup(RIG *rig); +int elad_open(RIG *rig); +int elad_close(RIG *rig); + +int elad_set_vfo(RIG *rig, vfo_t vfo); +int elad_set_vfo_main_sub(RIG *rig, vfo_t vfo); +int elad_get_vfo_if(RIG *rig, vfo_t *vfo); +int elad_get_vfo_main_sub(RIG *rig, vfo_t *vfo); +int elad_set_split(RIG *rig, vfo_t vfo , split_t split, vfo_t txvfo); +int elad_set_split_vfo(RIG *rig, vfo_t vfo , split_t split, vfo_t txvfo); +int elad_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo); + +int elad_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +int elad_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +int elad_get_freq_if(RIG *rig, vfo_t vfo, freq_t *freq); +int elad_set_rit(RIG * rig, vfo_t vfo, shortfreq_t rit); +int elad_get_rit(RIG *rig, vfo_t vfo, shortfreq_t * rit); +int elad_set_xit(RIG * rig, vfo_t vfo, shortfreq_t rit); +int elad_get_xit(RIG *rig, vfo_t vfo, shortfreq_t * rit); +int elad_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +int elad_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +int elad_get_mode_if(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +int elad_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); +int elad_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +int elad_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); +int elad_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); +int elad_set_ext_parm(RIG *rig, token_t token, value_t val); +int elad_get_ext_parm(RIG *rig, token_t token, value_t *val); +int elad_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); +int elad_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone); +int elad_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone); +int elad_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); +int elad_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone); +int elad_set_powerstat(RIG *rig, powerstat_t status); +int elad_get_powerstat(RIG *rig, powerstat_t *status); +int elad_reset(RIG *rig, reset_t reset); +int elad_send_morse(RIG *rig, vfo_t vfo, const char *msg); +int elad_set_ant (RIG * rig, vfo_t vfo, ant_t ant); +int elad_set_ant_no_ack(RIG * rig, vfo_t vfo, ant_t ant); +int elad_get_ant (RIG * rig, vfo_t vfo, ant_t * ant); +int elad_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +int elad_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +int elad_set_ptt_safe(RIG *rig, vfo_t vfo, ptt_t ptt); +int elad_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); +int elad_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); +int elad_set_mem(RIG *rig, vfo_t vfo, int ch); +int elad_get_mem(RIG *rig, vfo_t vfo, int *ch); +int elad_get_mem_if(RIG *rig, vfo_t vfo, int *ch); +int elad_get_channel(RIG *rig, channel_t *chan); +int elad_set_channel(RIG *rig, const channel_t *chan); +int elad_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch); +const char * elad_get_info(RIG *rig); +int elad_get_id(RIG *rig, char *buf); + +int elad_set_trn(RIG *rig, int trn); +int elad_get_trn(RIG *rig, int *trn); + +/* only use if returned string has length 6, e.g. 'SQ011;' */ +int get_elad_level(RIG *rig, const char *cmd, float *f); +int get_elad_func(RIG *rig, const char *cmd, int *status); + +extern const struct rig_caps fdm_duo_caps; + +/* use when not interested in the answer, but want to check its len */ +static int inline elad_simple_transaction(RIG *rig, const char *cmd, size_t expected) +{ + struct elad_priv_data *priv = rig->state.priv; + return elad_safe_transaction(rig, cmd, priv->info, ELAD_MAX_BUF_LEN, expected); +} + +#endif /* _ELAD_H */ diff --git a/elad/fdm_duo.c b/elad/fdm_duo.c new file mode 100644 index 000000000..645b4834c --- /dev/null +++ b/elad/fdm_duo.c @@ -0,0 +1,421 @@ +/* + * Hamlib ELAD backend - FDM_DUO description + * Copyright (c) 2000-2004 by Stephane Fillod and Juergen Rinas + * Copyright (c) 2018 by Giovanni Franza HB9EIK + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include "idx_builtin.h" +#include "elad.h" + +#define FDM_DUO_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_RTTYR) +#define FDM_DUO_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY) +#define FDM_DUO_AM_TX_MODES RIG_MODE_AM +#define FDM_DUO_VFO (RIG_VFO_A|RIG_VFO_B) + +#define FDM_DUO_LEVEL_ALL (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC) +#define FDM_DUO_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_NR|RIG_FUNC_NR|RIG_FUNC_BC) + + +/* + * elad_fdm_duo_get_info + * Assumes rig!=NULL + */ +static const char * +elad_fdm_duo_get_info (RIG * rig) +{ + char firmbuf[50]; + int retval; + + retval = elad_transaction (rig, "TY", firmbuf, sizeof (firmbuf)); + if (retval != RIG_OK) + return NULL; + size_t firm_len = strlen (firmbuf); + if (firm_len != 5) + { + rig_debug (RIG_DEBUG_ERR, "elad_get_info: wrong answer len=%d\n", firm_len); + return NULL; + } + switch (firmbuf[4]) + { + case '0': + return "FDM-DUOHX (200W)"; + case '1': + return "FDM-DUOSAT (100W + AT)"; + case '2': + return "Japanese 50W type"; + case '3': + return "Japanese 20W type"; + default: + return "Firmware: unknown"; + } +} + + +/* + * elad_fdm_duo_set_level + * Assumes rig!=NULL + * + * set levels of most functions + * + * WARNING: the commands differ slightly from the general versions in elad.c + * e.g.: "SQ"=>"SQ0" , "AG"=>"AG0" + */ +int +elad_fdm_duo_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val) +{ + char levelbuf[16]; + int elad_val; + + switch (level) + { + case RIG_LEVEL_RFPOWER: + elad_val = val.f * 100; /* level for FDM_DUOSAT is from 0.. 100W in SSB */ + sprintf (levelbuf, "PC%03d", elad_val); + break; + + case RIG_LEVEL_AF: + elad_val = val.f * 255; /* possible values for FDM_DUO are 000.. 255 */ + sprintf (levelbuf, "AG0%03d", elad_val); + break; + + case RIG_LEVEL_RF: + elad_val = val.f * 100; /* possible values for FDM_DUO are 000.. 100 */ + sprintf (levelbuf, "RG%03d", elad_val); + break; + + case RIG_LEVEL_SQL: + elad_val = val.f * 255; /* possible values for FDM_DUO are 000.. 255 */ + sprintf (levelbuf, "SQ0%03d", elad_val); + break; + + case RIG_LEVEL_AGC: /* possible values for FDM_DUO 000(=off), 001(=fast), 002(=slow) */ + /* hamlib argument is int, possible values rig.h:enum agc_level_e */ + switch (val.i) + { + case RIG_AGC_OFF: + elad_val = 0; + break; + case RIG_AGC_FAST: + elad_val = 1; + break; + case RIG_AGC_SLOW: + elad_val = 2; + break; + default: + rig_debug (RIG_DEBUG_ERR, "Unsupported agc value"); + return -RIG_EINVAL; + }; + sprintf (levelbuf, "GT%03d", elad_val); + break; + + default: + rig_debug (RIG_DEBUG_ERR, "Unsupported set_level %d", level); + return -RIG_EINVAL; + } + + return elad_transaction(rig, levelbuf, NULL, 0); +} + + +/* + * elad_get_level + * Assumes rig!=NULL, val!=NULL + */ +int +elad_fdm_duo_get_level (RIG * rig, vfo_t vfo, setting_t level, value_t * val) +{ + char ackbuf[50]; + size_t ack_len; + int levelint; + int retval; + + switch (level) + { + case RIG_LEVEL_RFPOWER: + retval = elad_transaction (rig, "PC", ackbuf, sizeof (ackbuf)); + if (RIG_OK != retval) + return retval; + ack_len = strlen (ackbuf); + if (5 != ack_len) + return -RIG_EPROTO; + if (1 != sscanf (&ackbuf[2], "%d", &levelint)) + return -RIG_EPROTO; + val->f = (float) levelint / 100.; + return RIG_OK; + + case RIG_LEVEL_AF: + retval = elad_transaction (rig, "AG0", ackbuf, sizeof (ackbuf)); + if (RIG_OK != retval) + return retval; + ack_len = strlen (ackbuf); + if (6 != ack_len) + return -RIG_EPROTO; + if (1 != sscanf (&ackbuf[3], "%d", &levelint)) + return -RIG_EPROTO; + val->f = (float) levelint / 255.; + return RIG_OK; + + case RIG_LEVEL_RF: + retval = elad_transaction (rig, "RG", ackbuf, sizeof (ackbuf)); + if (RIG_OK != retval) + return retval; + ack_len = strlen (ackbuf); + if (5 != ack_len) + return -RIG_EPROTO; + if (1 != sscanf (&ackbuf[2], "%d", &levelint)) + return -RIG_EPROTO; + val->f = (float) levelint / 100.; + return RIG_OK; + + case RIG_LEVEL_SQL: + retval = elad_transaction (rig, "SQ0", ackbuf, sizeof (ackbuf)); + if (RIG_OK != retval) + return retval; + ack_len = strlen (ackbuf); + if (6 != ack_len) + return -RIG_EPROTO; + if (1 != sscanf (&ackbuf[3], "%d", &levelint)) + return -RIG_EPROTO; + val->f = (float) levelint / 255.; + return RIG_OK; + + case RIG_LEVEL_AGC: + retval = elad_transaction (rig, "GT", ackbuf, sizeof (ackbuf)); + if (RIG_OK != retval) + return retval; + ack_len = strlen (ackbuf); + if (5 != ack_len) + return -RIG_EPROTO; + switch (ackbuf[4]) + { + case '0': + val->i = RIG_AGC_OFF; + break; + case '1': + val->i = RIG_AGC_FAST; + break; + case '2': + val->i = RIG_AGC_SLOW; + break; + default: + return -RIG_EPROTO; + } + return RIG_OK; + + case RIG_LEVEL_MICGAIN: + case RIG_LEVEL_PREAMP: + case RIG_LEVEL_IF: + case RIG_LEVEL_APF: + case RIG_LEVEL_NR: + case RIG_LEVEL_PBT_IN: + case RIG_LEVEL_PBT_OUT: + case RIG_LEVEL_CWPITCH: + case RIG_LEVEL_KEYSPD: + case RIG_LEVEL_NOTCHF: + case RIG_LEVEL_COMP: + case RIG_LEVEL_BKINDL: + case RIG_LEVEL_BALANCE: + return -RIG_ENIMPL; + + default: + rig_debug (RIG_DEBUG_ERR, "Unsupported get_level %d", level); + return -RIG_EINVAL; + } + + return RIG_OK; /* never reached */ +} + +static struct elad_priv_caps fdm_duo_priv_caps = { + .cmdtrm = EOM_KEN, +}; + + +/* + * fdm_duo rig capabilities. + * Notice that some rigs share the same functions. + * Also this struct is READONLY! + */ +const struct rig_caps fdm_duo_caps = { + .rig_model = RIG_MODEL_ELAD_FDM_DUO, + .model_name = "FDM-DUO", + .mfg_name = "ELAD", + .version = BACKEND_VER ".5", + .copyright = "LGPL", + .status = RIG_STATUS_UNTESTED, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG_MICDATA, + .dcd_type = RIG_DCD_RIG, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 4800, + .serial_rate_max = 115200, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 200, + .retry = 10, + .preamp = {12, RIG_DBLST_END,}, + .attenuator = {12, RIG_DBLST_END,}, + .max_rit = kHz (9.99), + .max_xit = kHz (9.99), + .max_ifshift = Hz (0), + .targetable_vfo = RIG_TARGETABLE_FREQ, + .transceive = RIG_TRN_RIG, + + + .rx_range_list1 = { + {kHz(100), Hz(59999999), FDM_DUO_ALL_MODES, -1, -1, FDM_DUO_VFO}, + RIG_FRNG_END, + }, /*!< Receive frequency range list for ITU region 1 */ + .tx_range_list1 = { + {kHz(1810), kHz(1850), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, /* 100W class */ + {kHz(1810), kHz(1850), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, /* 25W class */ + {kHz(3500), kHz(3800), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(3500), kHz(3800), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(7), kHz(7200), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(7), kHz(7200), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(10100), kHz(10150), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(10100), kHz(10150), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(14), kHz(14350), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(14), kHz(14350), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(18068), kHz(18168), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(18068), kHz(18168), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(21), kHz(21450), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(21), kHz(21450), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(24890), kHz(24990), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(24890), kHz(24990), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(28), kHz(29700), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(28), kHz(29700), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(50), kHz(52000), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(50), kHz(52000), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + RIG_FRNG_END, + }, /*!< Transmit frequency range list for ITU region 1 */ + .rx_range_list2 = { + {kHz(100), Hz(59999999), FDM_DUO_ALL_MODES, -1, -1, FDM_DUO_VFO}, + RIG_FRNG_END, + }, /*!< Receive frequency range list for ITU region 2 */ + .tx_range_list2 = { + {kHz(1800), MHz(2) - 1, FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, /* 100W class */ + {kHz(1800), MHz(2) - 1, FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, /* 25W class */ + {kHz(3500), MHz(4) - 1, FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(3500), MHz(4) - 1, FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(5250), kHz(5450), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(5250), kHz(5450), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(7), kHz(7300), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(7), kHz(7300), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(10100), kHz(10150), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(10100), kHz(10150), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(14), kHz(14350), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(14), kHz(14350), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(18068), kHz(18168), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(18068), kHz(18168), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(21), kHz(21450), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(21), kHz(21450), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {kHz(24890), kHz(24990), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {kHz(24890), kHz(24990), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(28), kHz(29700), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(28), kHz(29700), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + {MHz(50), kHz(52000), FDM_DUO_OTHER_TX_MODES, 5000, 100000, FDM_DUO_VFO}, + {MHz(50), kHz(52000), FDM_DUO_AM_TX_MODES, 5000, 25000, FDM_DUO_VFO}, + RIG_FRNG_END, + }, /*!< Transmit frequency range list for ITU region 2 */ + .tuning_steps = { + {FDM_DUO_ALL_MODES,kHz(1)}, + {FDM_DUO_ALL_MODES,Hz(2500)}, + {FDM_DUO_ALL_MODES,kHz(5)}, + {FDM_DUO_ALL_MODES,Hz(6250)}, + {FDM_DUO_ALL_MODES,kHz(10)}, + {FDM_DUO_ALL_MODES,Hz(12500)}, + {FDM_DUO_ALL_MODES,kHz(15)}, + {FDM_DUO_ALL_MODES,kHz(20)}, + {FDM_DUO_ALL_MODES,kHz(25)}, + {FDM_DUO_ALL_MODES,kHz(30)}, + {FDM_DUO_ALL_MODES,kHz(100)}, + {FDM_DUO_ALL_MODES,kHz(500)}, + {FDM_DUO_ALL_MODES,MHz(1)}, + {FDM_DUO_ALL_MODES,0}, /* any tuning step */ + RIG_TS_END, + }, + /* mode/filter list, remember: order matters! */ + .filters = { + {RIG_MODE_SSB, kHz(2.4)}, + {RIG_MODE_CW, Hz(200)}, + {RIG_MODE_RTTY, Hz(500)}, + {RIG_MODE_AM, kHz(9)}, + {RIG_MODE_FM, kHz(14)}, + RIG_FLT_END, + }, + .priv = (void *) &fdm_duo_priv_caps, + .rig_init = elad_init, + .rig_cleanup = elad_cleanup, + .set_freq = elad_set_freq, + .get_freq = elad_get_freq, + .set_rit = elad_set_rit, /* FIXME should this switch to rit mode or just set the frequency? */ + .get_rit = elad_get_rit, + .set_xit = elad_set_xit, /* FIXME should this switch to xit mode or just set the frequency? */ + .get_xit = elad_get_xit, + .set_mode = elad_set_mode, + .get_mode = elad_get_mode, + .set_vfo = elad_set_vfo, + .get_vfo = elad_get_vfo_if, + .set_split_vfo = elad_set_split_vfo, + .get_split_vfo = elad_get_split_vfo_if, + .get_ptt = elad_get_ptt, + .set_ptt = elad_set_ptt, + .get_dcd = elad_get_dcd, + .set_powerstat = elad_set_powerstat, + .get_powerstat = elad_get_powerstat, + .get_info = elad_fdm_duo_get_info, + .reset = elad_reset, + .set_ant = elad_set_ant, + .get_ant = elad_get_ant, + .scan = elad_scan, /* not working, invalid arguments using rigctl; elad_scan does only support on/off and not tone and CTCSS scan */ + .has_set_level = FDM_DUO_LEVEL_ALL, + .has_get_level = FDM_DUO_LEVEL_ALL, + .set_level = elad_fdm_duo_set_level, + .get_level = elad_fdm_duo_get_level, + .has_get_func = FDM_DUO_FUNC_ALL, + .has_set_func = FDM_DUO_FUNC_ALL, + .set_func = elad_set_func, + .get_func = elad_get_func, +}; + + +/* + * my notes: + * format with: indent --line-length 200 fdm_duo.c + * + * for the FDM_DUO the function NR and BC have tree state: NR0,1,2 and BC0,1,2 + * this cannot be send through the on/off logic of set_function! + */ + + +/* + * Function definitions below + */ diff --git a/icmarine/icm802.c b/icmarine/icm802.c index 56b914ea8..391c11f34 100644 --- a/icmarine/icm802.c +++ b/icmarine/icm802.c @@ -58,9 +58,9 @@ const struct rig_caps icm802_caps = { .rig_model = RIG_MODEL_IC_M802, .model_name = "IC-M802", .mfg_name = "Icom", -.version = BACKEND_VER, +.version = BACKEND_VER".1", .copyright = "LGPL", -.status = RIG_STATUS_UNTESTED, +.status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_RIG, diff --git a/icmarine/icmarine.c b/icmarine/icmarine.c index 0d20d3a15..969265df7 100644 --- a/icmarine/icmarine.c +++ b/icmarine/icmarine.c @@ -220,14 +220,14 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param, char *res int cmd_len = 0; unsigned csum = 0; + rig_debug(RIG_DEBUG_TRACE, "%s: cmd='%s', param=%s\n",__FUNCTION__,cmd,param); + rs = &rig->state; priv = (struct icmarine_priv_data *)rs->priv; serial_flush(&rs->rigport); /* command formating */ - cmdbuf[BUFSZ]='\0'; - cmd_len = snprintf(cmdbuf, BUFSZ, "$PICOA,%02u,%02u,%s", CONTROLLER_ID, priv->remote_id, @@ -258,8 +258,6 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param, char *res if (retval < OFFSET_CMD+5) return -RIG_EPROTO; - respbuf[retval] = 0; - /* check response */ if (memcmp(respbuf, "$PICOA,", strlen("$PICOA,"))) return -RIG_EPROTO; @@ -274,20 +272,22 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param, char *res return -RIG_ERJCTED; } - /* So this is a query */ - retval = read_string(&rs->rigport, respbuf, BUFSZ, LF, strlen(LF)); - if (retval < 0) - return retval; - - /* strip *checksum and CR/LF from string */ - respbuf[retval-5] = 0; - - p = strchr(respbuf+OFFSET_CMD, ','); + /* strip from *checksum and after */ + char *strip = strrchr(respbuf,'*'); + if (strip) { + *strip = 0; + } + else { + rig_debug(RIG_DEBUG_ERR, "%s: checksum not in response? response='%s'\n",__FUNCTION__,respbuf); + return -RIG_EPROTO; + } + p = strrchr(respbuf, ','); if (p) strncpy(response, p+1, BUFSZ); else return -RIG_EPROTO; + rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __FUNCTION__,response); return RIG_OK; } @@ -297,6 +297,8 @@ int icmarine_set_freq(RIG *rig, vfo_t vfo, freq_t freq) char freqbuf[BUFSZ]; struct icmarine_priv_data *priv; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + priv = (struct icmarine_priv_data*)rig->state.priv; sprintf(freqbuf, "%.6f", freq/MHz(1)); @@ -318,6 +320,8 @@ int icmarine_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) char freqbuf[BUFSZ] = ""; double d; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + retval = icmarine_transaction (rig, CMD_RXFREQ, NULL, freqbuf); if (retval != RIG_OK) return retval; @@ -325,8 +329,10 @@ int icmarine_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) if (freqbuf[0] == '\0') { *freq = 0; } else { - if (sscanf(freqbuf, "%lf", &d) != 1) + if (sscanf(freqbuf, "%lf", &d) != 1) { + rig_debug(RIG_DEBUG_ERR,"%s: sscanf('%s') failed\n",__FUNCTION__,freqbuf); return -RIG_EPROTO; + } *freq = (freq_t)(d*MHz(1)); } @@ -338,6 +344,8 @@ int icmarine_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq) { char freqbuf[BUFSZ]; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + sprintf(freqbuf, "%.6f", freq/MHz(1)); return icmarine_transaction (rig, CMD_TXFREQ, freqbuf, NULL); @@ -349,6 +357,8 @@ int icmarine_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq) char freqbuf[BUFSZ] = ""; double d; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + retval = icmarine_transaction (rig, CMD_TXFREQ, NULL, freqbuf); if (retval != RIG_OK) return retval; @@ -369,8 +379,9 @@ int icmarine_set_split_vfo(RIG *rig, vfo_t rx_vfo, split_t split, vfo_t tx_vfo) { struct icmarine_priv_data *priv; - priv = (struct icmarine_priv_data *)rig->state.priv; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + priv = (struct icmarine_priv_data *)rig->state.priv; /* when disabling split mode */ if (RIG_SPLIT_ON == priv->split && @@ -390,6 +401,8 @@ int icmarine_get_split_vfo(RIG *rig, vfo_t rx_vfo, split_t *split, vfo_t *tx_vfo { struct icmarine_priv_data *priv; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + priv = (struct icmarine_priv_data *)rig->state.priv; *split = priv->split; @@ -403,6 +416,8 @@ int icmarine_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { const char *pmode; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + switch (mode) { case RIG_MODE_CW: pmode = MD_CW; break; case RIG_MODE_USB: pmode = MD_USB; break; @@ -424,11 +439,12 @@ int icmarine_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int retval; char modebuf[BUFSZ]; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + retval = icmarine_transaction (rig, CMD_MODE, NULL, modebuf); if (retval != RIG_OK) return retval; - if (!memcmp(modebuf, MD_LSB, strlen(MD_LSB))) *mode = RIG_MODE_LSB; else if (!memcmp(modebuf, MD_USB, strlen(MD_USB))) @@ -453,8 +469,15 @@ int icmarine_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) */ int icmarine_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { - return icmarine_transaction (rig, CMD_PTT, + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + + int retval = icmarine_transaction (rig, CMD_PTT, ptt == RIG_PTT_ON ? "TX" : "RX", NULL); + if (retval != RIG_OK) { + rig_debug(RIG_DEBUG_ERR, "%s: transaction failed\n",__FUNCTION__); + return retval; + } + return RIG_OK; } int icmarine_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) @@ -462,17 +485,23 @@ int icmarine_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) char pttbuf[BUFSZ]; int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + retval = icmarine_transaction (rig, CMD_PTT, NULL, pttbuf); - if (retval != RIG_OK) + if (retval != RIG_OK) { + rig_debug(RIG_DEBUG_ERR, "%s: transaction failed\n",__FUNCTION__); return retval; + } - if (!strcmp(pttbuf, "TX")) + if (strncmp(pttbuf, "TX",2)==0) *ptt = RIG_PTT_ON; - else if (!strcmp(pttbuf, "RX")) + else if (strncmp(pttbuf, "RX",2)==0) *ptt = RIG_PTT_OFF; - else + else { + rig_debug(RIG_DEBUG_ERR, "%s: invalid pttbuf='%s'\n",__FUNCTION__,pttbuf); retval = -RIG_EPROTO; + } return retval; } @@ -482,6 +511,8 @@ int icmarine_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) char dcdbuf[BUFSZ]; int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + retval = icmarine_transaction (rig, CMD_SQLS, NULL, dcdbuf); if (retval != RIG_OK) @@ -499,6 +530,8 @@ int icmarine_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) int icmarine_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + if (RIG_OP_TUNE != op && RIG_OP_NONE != op) return -RIG_EINVAL; @@ -510,6 +543,8 @@ int icmarine_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + switch(func) { case RIG_FUNC_NB: retval = icmarine_transaction (rig, CMD_NB, status ? "ON":"OFF", NULL); @@ -527,6 +562,8 @@ int icmarine_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) char funcbuf[BUFSZ]; int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + switch(func) { case RIG_FUNC_NB: retval = icmarine_transaction (rig, CMD_NB, NULL, funcbuf); @@ -547,6 +584,8 @@ int icmarine_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) char lvlbuf[BUFSZ]; int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + switch(level) { case RIG_LEVEL_AF: sprintf(lvlbuf, "%u", (unsigned)(val.f * 255)); @@ -580,6 +619,8 @@ int icmarine_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) char lvlbuf[BUFSZ]; int retval; + rig_debug(RIG_DEBUG_TRACE, "%s:\n",__FUNCTION__); + switch(level) { case RIG_LEVEL_RAWSTR: retval = icmarine_transaction (rig, CMD_SMETER, NULL, lvlbuf); diff --git a/icmarine/icmarine.h b/icmarine/icmarine.h index dd002a4d1..ca097eea8 100644 --- a/icmarine/icmarine.h +++ b/icmarine/icmarine.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "0.1" +#define BACKEND_VER "0.2" struct icmarine_priv_caps { unsigned char default_remote_id; /* the remote default equipment's ID */ diff --git a/icom/ic7300.c b/icom/ic7300.c index 0f3020252..e68ad16e4 100644 --- a/icom/ic7300.c +++ b/icom/ic7300.c @@ -46,7 +46,7 @@ #define IC7300_OTHER_TX_MODES (RIG_MODE_FM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR) #define IC7300_AM_TX_MODES (RIG_MODE_AM|RIG_MODE_PKTAM) -#define IC7300_FUNCS (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_ANF|RIG_FUNC_LOCK|RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_SCOPE) +#define IC7300_FUNCS (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_ANF|RIG_FUNC_LOCK|RIG_FUNC_RIT|RIG_FUNC_XIT|RIG_FUNC_SCOPE|RIG_FUNC_TUNER) #define IC7300_LEVELS (RIG_LEVEL_PREAMP|RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_COMP|RIG_LEVEL_BKINDL|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_CWPITCH|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_NOTCHF|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_VOXGAIN|RIG_LEVEL_ANTIVOX|RIG_LEVEL_VOXDELAY|RIG_LEVEL_SWR|RIG_LEVEL_ALC) @@ -379,7 +379,17 @@ int ic7300_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } *status = ackbuf[2]; break; - + + case RIG_FUNC_TUNER: + retval = icom_transaction (rig, 0x1C, 0x01, NULL, 0, ackbuf, &ack_len); + if (ack_len == 3) + { + *status = ackbuf[2]; // 0x01 = enabled, 0x00 = disabled, 0x02 = tuning in progress + } else { + return RIG_BUSERROR; + } + break; + default: return icom_get_func(rig, vfo, func, status); } @@ -405,6 +415,16 @@ int ic7300_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) case RIG_FUNC_XIT: ts_buf[0] = status; return icom_transaction (rig, 0x21, 0x02, ts_buf, 1, ackbuf, &ack_len); + + case RIG_FUNC_TUNER: + if(status==0 || status==1 || status==2) + { // 0=off, 1 = on, 2 = begin tuning + ts_buf[0] = status; + return icom_transaction (rig, 0x1C, 0x01, ts_buf, 1, ackbuf, &ack_len); + } else { + return -1; // perhaps some other reply would be more informative + } + default: return icom_set_func(rig, vfo, func, status); } diff --git a/icom/optoscan.c b/icom/optoscan.c index a6e8a4ff4..2ba8c027c 100644 --- a/icom/optoscan.c +++ b/icom/optoscan.c @@ -735,7 +735,7 @@ static int optoscan_wait_timer(RIG *rig, pltstate_t *state) gettimeofday(&(state->timer_current), NULL); - usec_diff = abs((state->timer_current.tv_usec) - + usec_diff = (int)labs((state->timer_current.tv_usec) - (state->timer_start.tv_usec)); if (usec_diff < settle_usec) { @@ -744,4 +744,3 @@ static int optoscan_wait_timer(RIG *rig, pltstate_t *state) return RIG_OK; } - diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 6fe3e6fea..df76d5161 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -455,7 +455,9 @@ typedef enum { RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */ RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */ RIG_DCD_PARALLEL, /*!< DCD status from parallel port pin */ - RIG_DCD_CM108 /*!< DCD status from CM108 vol dn pin */ + RIG_DCD_CM108, /*!< DCD status from CM108 vol dn pin */ + RIG_DCD_GPIO, /*!< DCD status from GPIO pin */ + RIG_DCD_GPION, /*!< DCD status from inverted GPIO pin */ } dcd_type_t; @@ -595,7 +597,7 @@ enum rig_conf_e { }; -#define RIG_COMBO_MAX 8 +#define RIG_COMBO_MAX 16 /** * \brief Configuration parameter structure. @@ -1634,6 +1636,8 @@ struct rig_state { int transmit; /*!< rig should be transmitting i.e. hard wired PTT asserted - used by rigs that don't do CAT while in Tx */ + freq_t lo_freq; /*!< Local oscillator frequency of any + transverter */ }; diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index 81e8a291e..673202977 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -105,6 +105,7 @@ #define RIG_MODEL_FT1200 RIG_MAKE_MODEL(RIG_YAESU, 34) #define RIG_MODEL_FT991 RIG_MAKE_MODEL(RIG_YAESU, 35) #define RIG_MODEL_FT891 RIG_MAKE_MODEL(RIG_YAESU, 36) +#define RIG_MODEL_FTDX3000 RIG_MAKE_MODEL(RIG_YAESU, 37) /* @@ -590,6 +591,13 @@ #define RIG_BACKEND_BARRETT "barrett" #define RIG_MODEL_BARRETT_2050 RIG_MAKE_MODEL(RIG_BARRETT, 1) +/* + * Elad + */ +#define RIG_ELAD 33 +#define RIG_BACKEND_ELAD "elad" +#define RIG_MODEL_ELAD_FDM_DUO RIG_MAKE_MODEL(RIG_ELAD, 1) + /* * TODO: diff --git a/include/hamlib/rotlist.h b/include/hamlib/rotlist.h index a8b943626..9afdf0ac8 100644 --- a/include/hamlib/rotlist.h +++ b/include/hamlib/rotlist.h @@ -350,6 +350,18 @@ #define ROT_MODEL_PROSISTEL ROT_MAKE_MODEL(ROT_PROSISTEL, 1) +/** + * \def ROT_MODEL_MEADE + * \brief A macro that returns the model number of the MEADE backend. + * + * The MEADE backen can be used with Meade telescope rotators like + * DS-2000 + */ +#define ROT_MEADE 18 +#define ROT_BACKEND_MEADE "meade" +#define ROT_MODEL_MEADE ROT_MAKE_MODEL(ROT_MEADE, 1) + + /** * \typedef typedef int rot_model_t * \brief Convenience type definition for rotator model. diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index cf19b9ffa..ccd0e4d97 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -219,6 +219,9 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasiz rs = &rig->state; rs->hold_decode = 1; + /* Emulators don't need any post_write_delay */ + if (priv->is_emulation) rs->rigport.post_write_delay = 0; + cmdtrm[0] = caps->cmdtrm; cmdtrm[1] = '\0'; @@ -497,6 +500,7 @@ int kenwood_init(RIG *rig) strcpy (priv->verify_cmd, RIG_MODEL_XG3 == rig->caps->rig_model ? ";" : "ID;"); priv->split = RIG_SPLIT_OFF; priv->trn_state = -1; + priv->curr_mode = 0; rig->state.priv = priv; /* default mode_table */ @@ -714,6 +718,14 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) return -RIG_EINVAL; struct kenwood_priv_data *priv = rig->state.priv; + + /* Emulations do not need to set VFO since VFOB is a copy of VFOA + * except for frequency. And we can change freq without changing VFOS + * This prevents a 1.8 second delay in PowerSDR when switching VFOs + * We'll do this once if curr_mode has not been set yet + */ + if (priv->is_emulation && priv->curr_mode > 0) return RIG_OK; + char cmdbuf[6]; int retval; char vfo_function; @@ -1416,7 +1428,7 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } } - if (priv->is_emulation) + if (priv->is_emulation || rig->caps->rig_model == RIG_MODEL_HPSDR) { /* emulations like PowerSDR and SmartSDR normally hijack the RTTY modes for SSB-DATA AFSK modes */ @@ -1565,6 +1577,12 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int offs; int retval; + /* for emulation do not read mode from VFOB as it is copy of VFOA */ + /* we avoid the VFO swapping most of the time this way */ + /* only need to get it if it has to be initialized */ + if (priv->curr_mode > 0 && priv->is_emulation && vfo == RIG_VFO_B) { + return priv->curr_mode; + } if (RIG_MODEL_TS990S == rig->caps->rig_model) { char c; @@ -1607,7 +1625,7 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) kmode = modebuf[offs] - 'A' + 10; } *mode = kenwood2rmode(kmode, caps->mode_table); - if (priv->is_emulation) + if (priv->is_emulation || rig->caps->rig_model == RIG_MODEL_HPSDR) { /* emulations like PowerSDR and SmartSDR normally hijack the RTTY modes for SSB-DATA AFSK modes */ @@ -1709,7 +1727,8 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) break; case RIG_LEVEL_SQL: - snprintf(levelbuf, sizeof (levelbuf), "SQ%03d", kenwood_val); + /* Default to RX#0 */ + snprintf(levelbuf, sizeof (levelbuf), "SQ0%03d", kenwood_val); break; case RIG_LEVEL_AGC: @@ -1818,26 +1837,43 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_EINVAL; char lvlbuf[KENWOOD_MAX_BUF_LEN]; + char *cmd; int retval; int lvl; - int i, ret, agclevel; + int i, ret, agclevel, len; switch (level) { case RIG_LEVEL_RAWSTR: - retval = kenwood_safe_transaction(rig, "SM", lvlbuf, 10, 6); + if (RIG_MODEL_TS590S == rig->caps->rig_model || RIG_MODEL_TS590SG == rig->caps->rig_model) { + cmd = "SM0"; + len= 3; + } + else { + cmd = "SM"; + len = 2; + } + retval = kenwood_safe_transaction(rig, cmd, lvlbuf, 10, len+4); if (retval != RIG_OK) return retval; /* XXX atoi ? */ - sscanf(lvlbuf+2, "%d", &val->i); /* rawstr */ + sscanf(lvlbuf+len, "%d", &val->i); /* rawstr */ break; case RIG_LEVEL_STRENGTH: - retval = kenwood_safe_transaction(rig, "SM", lvlbuf, 10, 6); + if (RIG_MODEL_TS590S == rig->caps->rig_model || RIG_MODEL_TS590SG == rig->caps->rig_model) { + cmd = "SM0"; + len = 3; + } + else { + cmd = "SM"; + len = 2; + } + retval = kenwood_safe_transaction(rig, cmd, lvlbuf, 10, len+4); if (retval != RIG_OK) return retval; - sscanf(lvlbuf+2, "%d", &val->i); /* rawstr */ + sscanf(lvlbuf+len, "%d", &val->i); /* rawstr */ if (rig->caps->str_cal.size) val->i = (int) rig_raw2val(val->i, &rig->caps->str_cal); @@ -3352,6 +3388,7 @@ DECLARE_PROBERIG_BACKEND(kenwood) "with ID %03d, please report to Hamlib " "developers.\n", k_id); + rig_debug(RIG_DEBUG_TRACE, "%s: post_write_delay=%d\n", __func__, port->post_write_delay); return RIG_MODEL_NONE; } diff --git a/kenwood/kenwood.h b/kenwood/kenwood.h index 4e8bb85d7..6f7677c6f 100644 --- a/kenwood/kenwood.h +++ b/kenwood/kenwood.h @@ -27,7 +27,7 @@ #include #include "token.h" -#define BACKEND_VER "0.9" +#define BACKEND_VER "1.0" #define EOM_KEN ';' #define EOM_TH '\r' @@ -80,6 +80,7 @@ struct kenwood_priv_data { char verify_cmd[4]; /* command used to verify set commands */ int is_emulation; /* flag for TS-2000 emulations */ void * data; /* model specific data */ + rmode_t curr_mode; /* used for is_emulation to avoid get_mode on VFOB */ }; diff --git a/kenwood/pihpsdr.c b/kenwood/pihpsdr.c index 1e945059b..e431e6110 100644 --- a/kenwood/pihpsdr.c +++ b/kenwood/pihpsdr.c @@ -656,7 +656,8 @@ int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) switch (level) { case RIG_LEVEL_RFPOWER: - /* XXX check level range */ + /* level is float between 0.0 and 1.0, maps to 0 ... 100 */ + kenwood_val = val.f * 100; sprintf(levelbuf, "PC%03d", kenwood_val); break; diff --git a/kenwood/thd72.c b/kenwood/thd72.c index 13e3f09fc..8bfea64c7 100644 --- a/kenwood/thd72.c +++ b/kenwood/thd72.c @@ -657,14 +657,14 @@ static int thd72_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } break; case RIG_LEVEL_VOXGAIN: - retval = thd72_get_menu_item(rig, 8, '9', &l); + retval = thd72_get_menu_item(rig, 8, 9, &l); if (retval != RIG_OK) return retval; /* FIXME - if VOX is off, what do we return */ val->f = l / 9.0; break; case RIG_LEVEL_VOXDELAY: - retval = thd72_get_menu_item(rig, 9, '7', &l); + retval = thd72_get_menu_item(rig, 9, 7, &l); if (retval != RIG_OK) return retval; /* FIXME - if VOX is off, what do we return */ @@ -683,7 +683,7 @@ static int thd72_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) val->f = thd72sqlevel[l]; break; case RIG_LEVEL_BALANCE: - retval = thd72_get_menu_item(rig, 13, '4', &l); + retval = thd72_get_menu_item(rig, 13, 4, &l); if (retval != RIG_OK) return retval; /* FIXME - is balance 0.0 .. 1.0 or -1.0 .. 1.0? */ @@ -782,7 +782,7 @@ static int thd72_get_parm(RIG *rig, setting_t parm, value_t *val) switch (parm) { case RIG_PARM_APO: - retval = thd72_get_menu_item(rig, 3, '3', &l); + retval = thd72_get_menu_item(rig, 3, 3, &l); if (retval != RIG_OK) return retval; val->i = thd72apo[l]; diff --git a/kenwood/ts2000.c b/kenwood/ts2000.c index 4f21e360e..04c71f7d1 100644 --- a/kenwood/ts2000.c +++ b/kenwood/ts2000.c @@ -126,7 +126,7 @@ const struct rig_caps ts2000_caps = { .mfg_name = "Kenwood", .version = BACKEND_VER ".4", .copyright = "LGPL", -.status = RIG_STATUS_BETA, +.status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_RIG, diff --git a/kenwood/ts590.c b/kenwood/ts590.c index 207b81e8e..a113d1e58 100644 --- a/kenwood/ts590.c +++ b/kenwood/ts590.c @@ -41,7 +41,7 @@ const char* ts590_get_info(RIG *rig); #define TS590_LEVEL_ALL (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|\ RIG_LEVEL_CWPITCH|RIG_LEVEL_METER|RIG_LEVEL_SWR|RIG_LEVEL_ALC|\ - RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_STRENGTH|RIG_LEVEL_KEYSPD) + RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_RAWSTR|RIG_LEVEL_STRENGTH|RIG_LEVEL_KEYSPD) #define TS590_FUNC_ALL (RIG_FUNC_LOCK|RIG_FUNC_AIP|RIG_FUNC_TONE|\ RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_NR|RIG_FUNC_NR|RIG_FUNC_BC) @@ -60,6 +60,19 @@ const char* ts590_get_info(RIG *rig); .flags=RIG_CHFLAG_SKIP \ } +#define TS590_STR_CAL {9, {\ + { 0, -60},\ + { 3, -48},\ + { 6, -36},\ + { 9, -24},\ + {12, -12},\ + {15, 0},\ + {20, 20},\ + {25, 40},\ + {30, 60}}\ + } + + static struct kenwood_priv_caps ts590_priv_caps = { .cmdtrm = EOM_KEN, }; @@ -187,6 +200,7 @@ const struct rig_caps ts590_caps = { {RIG_MODE_FM, kHz(12)}, RIG_FLT_END, }, + .str_cal = TS590_STR_CAL, .priv = (void *) &ts590_priv_caps, .rig_init = kenwood_init, .rig_cleanup = kenwood_cleanup, @@ -354,6 +368,7 @@ const struct rig_caps ts590sg_caps = { {RIG_MODE_FM, kHz(12)}, RIG_FLT_END, }, + .str_cal = TS590_STR_CAL, .priv = (void *) &ts590_priv_caps, .rig_init = kenwood_init, .rig_cleanup = kenwood_cleanup, diff --git a/kit/funcube.c b/kit/funcube.c index c44a8588d..9fc1adb9d 100644 --- a/kit/funcube.c +++ b/kit/funcube.c @@ -174,12 +174,12 @@ const struct rig_caps funcubeplus_caps = { .has_get_level = RIG_LEVEL_ATT | RIG_LEVEL_PREAMP | RIG_LEVEL_RF, // RIG_LEVEL_ATT: Mixer gain on/off // RIG_LEVEL_PREAMP: LNA gain on/off // RIG_LEVEL_RF 0..1 : IF gain 0 .. 59 dB - - + + .has_set_level = RIG_LEVEL_ATT | RIG_LEVEL_PREAMP | RIG_LEVEL_RF, // RIG_LEVEL_ATT: Mixer gain on/off // RIG_LEVEL_PREAMP: LNA gain on/off // RIG_LEVEL_RF 0..1 : IF gain 0 .. 59 dB - // so values have to be mapped + // so values have to be mapped .has_get_parm = RIG_PARM_NONE, .has_set_parm = RIG_PARM_NONE, .level_gran = {}, @@ -700,8 +700,8 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) libusb_device_handle *udh = rig->state.rigport.handle; int ret; int actual_length; - unsigned char au8BufOut[64]; // endpoint size - unsigned char au8BufIn[64]; // endpoint size + unsigned char au8BufOut[64] = { 0 }; // endpoint size + unsigned char au8BufIn[64] = { 0 }; // endpoint size switch (level) { case RIG_LEVEL_PREAMP: @@ -719,7 +719,7 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) if( au8BufOut[1] > 59 ) au8BufOut[1]= 59; break; - + default: rig_debug(RIG_DEBUG_ERR, "%s: Unsupported level %d\n", __func__, level); @@ -761,8 +761,8 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) libusb_device_handle *udh = rig->state.rigport.handle; int ret; int actual_length; - unsigned char au8BufOut[64]; // endpoint size - unsigned char au8BufIn[64]; // endpoint size + unsigned char au8BufOut[64] = { 0 }; // endpoint size + unsigned char au8BufIn[64] = { 0 }; // endpoint size switch (level) { case RIG_LEVEL_ATT: @@ -773,7 +773,7 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_RF: au8BufOut[0] = REQUEST_GET_IF_GAIN; - break; + break; default: rig_debug(RIG_DEBUG_ERR, "%s: Unsupported level %d\n", __func__, level); return -RIG_EINVAL; @@ -809,7 +809,7 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) switch (level) { case RIG_LEVEL_PREAMP: case RIG_LEVEL_ATT: - val->i = au8BufIn[2] &0x01; + val->i = au8BufIn[2] &0x01; break; case RIG_LEVEL_RF: diff --git a/meade/Android.mk b/meade/Android.mk new file mode 100644 index 000000000..2cb4e71b3 --- /dev/null +++ b/meade/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := meade.c +LOCAL_MODULE := meade + +LOCAL_CFLAGS := -DHAVE_CONFIG_H +LOCAL_C_INCLUDES := android include src +LOCAL_LDLIBS := -lhamlib -Lobj/local/armeabi + +include $(BUILD_STATIC_LIBRARY) \ No newline at end of file diff --git a/meade/Makefile.am b/meade/Makefile.am new file mode 100644 index 000000000..67ffc2bb0 --- /dev/null +++ b/meade/Makefile.am @@ -0,0 +1,6 @@ +MEADESRC = meade.c meade.h + +noinst_LTLIBRARIES = libhamlib-meade.la +libhamlib_meade_la_SOURCES = $(MEADESRC) + +EXTRA_DIST = README.md Android.mk \ No newline at end of file diff --git a/meade/README.md b/meade/README.md new file mode 100644 index 000000000..6544c4c0a --- /dev/null +++ b/meade/README.md @@ -0,0 +1,45 @@ +# Meade Telescope Rotator Module + +This module interfaces Meade telescope rotator via the LX200 serial protocol. + +These rotators can easily be modified to carry antennas instead of telescopes. + +## Usage + +1. Set the telescope manually to show to north with 0 degree elevation +1. Connect the Autosar and the serial cable with the telescope and control PC +1. Turn on telescope rotator +1. Press `Speed` on the Autosar to accept "Don't look into the sun" warning +1. Press `Mode` a couple of times until the Autosar display shows `Object` +1. Start `rigctl` or `rigctld` with the arguments `-m 1801 -s ` + +Have Fun. + +### Hints + +1. The rotator has no lock on 360 degree azimuth. For example, if you go form 359 degree to 002 degree, it will go the short way. That means it is possible to make several rotations in the same directions. Please have a kind look on your cables and don't use the rotator unattended! +2. If a new position gets sent to the rotor while it is in movement, it moves immediately to the new position, but stores the old one and moves again to the old one after the new position is reached. To avoid this, a `Stop all movement` command gets executed if a position update reaches the rotator while in movement. That can cause a choppy movement when going to a new position which is far away. + +## LX200 Protocol + +[2003 Protocol Verison](https://www.meade.com/support/LX200CommandSet.pdf) +[2010 Protocol Verison](https://www.meade.com/support/TelescopeProtocol_2010-10.pdf) + +## Current Status + +The current status is ALPHA. It is tested with Meade DS-2000 with Autosar 494 (2003 Firmware) and Meade 506 i2c to RS232 interface cable, tested under Linux with rotctl and gpredict. + +### What works good: + +* `set_position` works for azimuth and elevation (0-360,0-90 degree), high frequent update (<2s) can cause sometimes unexpected behavior. +* `get_position` works mostly fine, sometime the elevation gets not read properly +* `init`, `cleanup`, `get_info` work as expected +* `open` sends all setup commands needed for now +* `close` stops all movement of the rotor +* `meade_stop` stops fine +* `park`, `reset` move the rotor to home position (north, elevation 0) + +### What works with some problems: + +* `move` works fine for elevation, but for azimuth it will sometimes move in the wrong direction caused by the short way movement. + diff --git a/meade/meade.c b/meade/meade.c new file mode 100644 index 000000000..d82d3cf46 --- /dev/null +++ b/meade/meade.c @@ -0,0 +1,407 @@ +/* + * Hamlib Meade telescope rotor backend - main file + * Copyright (c) 2018 by Andreas Mueller (DC1MIL) + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include +#include +#include + +#include +#include + +#include "serial.h" +#include "misc.h" +#include "register.h" + +#include "meade.h" + +struct meade_priv_data { + azimuth_t az; + elevation_t el; + + struct timeval tv; /* time last az/el update */ + azimuth_t target_az; + elevation_t target_el; +}; + +/** + * Command list: + * See https://www.meade.com/support/LX200CommandSet.pdf + * and https://www.meade.com/support/TelescopeProtocol_2010-10.pdf for newer + * Firmware Versions + * + * Not the full set of available commands is used, the list here shows + * only the commands of the telescope used by hamlib + * + * All used Commands are supportet by Meade Telescopes with LX-200 protocol + * (e.g. DS-2000 with Autostar) and should also work with the LX16 and + * LX200GPS. + * Tested only with DS-2000 and AutoStar 494 together with Meade 506 i2c to + * Serial cable. But should also work with other AutoStars and the regular + * Serial Cable. + * + * | Command | Atribute | Return value | Description | + * -------------------------------------------------------------------- + * | :Me# | - | - | Moves telescope east | + * | :Mn# | - | - | Moves telescope north | + * | :Ms# | - | - | Moves telescope south | + * | :Mw# | - | - | Moves telescope west | + * | :AL# | - | - | Set to Land mode | + * | :Sz DDD*MM# | D,M | 1' == OK | Set Target azimuth | + * | :SasDD*MM# | s,D,M | 1' == OK | Set Target elevation | + * | :Mw# | - | - | Moves telescope west | + * | :Q# | - | - | Halt all slewing | + * | :SoDD# | D | '1' == OK | Set minimal elevation | + * | :ShDD# | D | '1' == OK | Set maximal elevation | + * | :MA# | - | '0' == OK | GoTo Target | + * | :D# | - | 0x7F == YES | Check if active movement | + * + */ + +/** + * meade_transaction + * + * cmdstr - Command to be sent to the rig. + * data - Buffer for reply string. Can be NULL, indicating that no reply is + * is needed, but answer will still be read. + * data_len - in: Size of buffer. It is the caller's responsibily to provide + * a large enough buffer for all possible replies for a command. + * + * returns: + * RIG_OK - if no error occurred. + * RIG_EIO - if an I/O error occurred while sending/receiving data. + * RIG_ETIMEOUT - if timeout expires without any characters received. + */ +static int meade_transaction (ROT *rot, const char *cmdstr, + char *data, size_t *data_len, size_t expected_return_length) +{ + struct rot_state *rs; + int return_value; + int retry_read = 0; + + rs = &rot->state; + + while(1) { + serial_flush(&rs->rotport); + + if (cmdstr) { + return_value = write_block(&rs->rotport, cmdstr, strlen(cmdstr)); + if (return_value != RIG_OK) { + return return_value; + } + } + + /* Not all commands will send a return value, so use data = NULL if no + return value is expected, Strings end with '#' */ + if (data != NULL) { + memset(data,0,BUFSIZE); + *data_len = read_string(&rs->rotport, data, expected_return_length + 1, "\n", strlen("\n")); + if (*data_len < 0) { + if (retry_read++ >= rot->state.rotport.retry) { + return RIG_ETIMEOUT; + } + } + else { + return RIG_OK; + } + } + else { + return RIG_OK; + } + } +} + +/* + * Initialization + */ +static int meade_init(ROT *rot) +{ + struct meade_priv_data *priv; + + priv = (struct meade_priv_data*) + malloc(sizeof(struct meade_priv_data)); + + if (!priv) + return -RIG_ENOMEM; + rot->state.priv = (void*)priv; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rot->state.rotport.type.rig = RIG_PORT_SERIAL; + + priv->az = priv->el = 0; + + priv->target_az = priv->target_el = 0; + + return RIG_OK; +} + +/* + * Cleanup + */ +static int meade_cleanup(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (rot->state.priv) + free(rot->state.priv); + + rot->state.priv = NULL; + + return RIG_OK; +} + +/* + * Opens the Port and sets all needed parametes for operation + */ +static int meade_open(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + /* Set Telescope to Land alignment mode to deactivate sloping */ + /* Allow 0-90 Degree Elevation */ + return meade_transaction(rot, ":AL#:So00#:Sh90#" , NULL, 0, 0); +} + +/* + * Closes the port and stops all movement + */ +static int meade_close(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + /* Stop all Movement */ + return meade_transaction(rot, ":Q#" , NULL, 0, 0); +} + +/* + * Sets the target position and starts movement + * + * az: Target azimuth + * el: Target elevation + */ +static int meade_set_position(ROT *rot, azimuth_t az, elevation_t el) +{ + struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; + char cmd_str[BUFSIZE]; + char return_str[BUFSIZE]; + size_t return_str_size; + float az_degrees, az_minutes, el_degrees, el_minutes; + + rig_debug(RIG_DEBUG_VERBOSE,"%s called: %.2f %.2f\n", __func__, + az, el); + + az_degrees = floor(az); + az_minutes = (az - az_degrees) * 60; + el_degrees = floor(el); + el_minutes = (el - el_degrees) * 60; + + /* Check if there is an active movement, if yes, stop it if + new target is more than 5 Degrees away from old target + if not, don't accept new target*/ + meade_transaction(rot, ":D#", return_str, &return_str_size, 1); + if(return_str_size > 0 && return_str[0] == 0x7F) { + if(fabsf(az - priv->target_az) > 5 || fabsf(el - priv->target_el) > 5) + meade_transaction(rot, ":Q#", NULL, 0, 0); + else + return RIG_OK; + } + + priv->target_az = az; + priv->target_el = el; + + num_sprintf(cmd_str, ":Sz %03.0f*%02.0f#:Sa+%02.0f*%02.0f#:MA#", + az_degrees, az_minutes, el_degrees, el_minutes); + + meade_transaction(rot, cmd_str, return_str, &return_str_size, 3); + /* '1' == Azimuth accepted '1' == Elevation accepted '0' == No error */ + if(return_str_size > 0 && strstr(return_str , "110") != NULL) + return RIG_OK; + else + return RIG_EINVAL; +} + +/* + * Get position of rotor, simulating slow rotation + */ +static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el) +{ + char return_str[BUFSIZE]; + size_t return_str_size; + int az_degree, az_minutes, el_degree, el_minutes; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + meade_transaction(rot, ":GZ#:GA#", return_str, &return_str_size, 14); + if(return_str_size > 13 && return_str[return_str_size-1] == '#') { /* '#' == EOS */ + az_degree = strtol(return_str, NULL, 10); + az_minutes = strtol(return_str + 4, NULL, 10); + el_degree = strtol(return_str + 8, NULL, 10); + el_minutes = strtol(return_str + 11, NULL, 10); + *az = dmmm2dec(az_degree, az_minutes, 0); + *el = dmmm2dec(el_degree, el_minutes, 0); + return RIG_OK; + } + else { + return RIG_EINVAL; + } +} + +/* + * Stops all movement + */ +static int meade_stop(ROT *rot) +{ + struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; + azimuth_t az; + elevation_t el; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + meade_transaction(rot, ":Q#", NULL, 0, 0); + meade_get_position(rot, &az, &el); + + priv->target_az = priv->az = az; + priv->target_el = priv->el = el; + + return RIG_OK; +} + +/* + * Moves to Home Position + */ +static int meade_park(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + /* Assume home is 0,0 */ + meade_set_position(rot, 0, 0); + + return RIG_OK; +} + +/* + * Reset: Nothing to do exept parking + */ +static int meade_reset(ROT *rot, rot_reset_t reset) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + meade_park(rot); + + return RIG_OK; +} + +/* + * Movement to direction + */ +static int meade_move(ROT *rot, int direction, int speed) +{ + struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: Direction = %d, Speed = %d\n", __func__, direction, speed); + + switch(direction) { + case ROT_MOVE_UP: + return meade_set_position(rot, priv->target_az, 90); + + case ROT_MOVE_DOWN: + return meade_set_position(rot, priv->target_az, 0); + + case ROT_MOVE_CCW: + return meade_set_position(rot, -180, priv->target_el); + + case ROT_MOVE_CW: + return meade_set_position(rot, 180, priv->target_el); + + default: + return -RIG_EINVAL; + } + + return RIG_OK; +} + +static const char *meade_get_info(ROT *rot) +{ + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + return "Meade telescope rotator with LX200 protocol."; +} + +/* + * Meade telescope rotator capabilities. + */ + +const struct rot_caps meade_caps = { + .rot_model = ROT_MODEL_MEADE, + .model_name = "LX200", + .mfg_name = "Meade", + .version = "0.1", + .copyright = "LGPL", + .status = RIG_STATUS_ALPHA, + .rot_type = ROT_TYPE_AZEL, + + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 9600, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 200, + .timeout = 400, + .retry = 5, + + .min_az = 0., + .max_az = 360., + .min_el = 0., + .max_el = 90., + + .priv = NULL, /* priv */ + + .rot_init = meade_init, + .rot_cleanup = meade_cleanup, + .rot_open = meade_open, + .rot_close = meade_close, + + .set_position = meade_set_position, + .get_position = meade_get_position, + .park = meade_park, + .stop = meade_stop, + .reset = meade_reset, + .move = meade_move, + + .get_info = meade_get_info, +}; + +DECLARE_INITROT_BACKEND(meade) +{ + rig_debug(RIG_DEBUG_VERBOSE, "meade: _init called\n"); + + rot_register(&meade_caps); + + return RIG_OK; +} diff --git a/meade/meade.h b/meade/meade.h new file mode 100644 index 000000000..855f531a5 --- /dev/null +++ b/meade/meade.h @@ -0,0 +1,31 @@ +/* + * Hamlib Meade telescope rotor backend - main header + * Copyright (c) 2018 by Andreas Mueller (DC1MIL) + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _MEADE_H +#define _MEADE_H 1 + +#define BUFSIZE 128 +#define CR "\r" +#define LF "\x0a" + +extern const struct rot_caps meade_caps; + +#endif /* _MEADE_H */ diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 0f7ef5d51..b62041da0 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,2 +1,2 @@ -EXTRA_DIST = README.scripts build-win32.sh README.build-win32 \ - build-VB.NET.sh README.build-VB.NET +EXTRA_DIST = README.scripts build-w32.sh build-w64.sh README.build-Windows \ + build-VB.NET.sh README.build-VB.NET astylerc diff --git a/scripts/README.build-Windows b/scripts/README.build-Windows new file mode 100644 index 000000000..f3dc95da4 --- /dev/null +++ b/scripts/README.build-Windows @@ -0,0 +1,94 @@ + +This file is a HOWTO for the cross-compiling of Windows 32 and 64 bit +binary DLLs built from a tarball generated by 'make dist' in a Git +checkout. The resulting DLLs are built with a cdecl interface compatible +with MS VC++. + + +Prerequisites +============= + +In these steps the release or daily snapshot tarball is unpacked in ~/builds +for the Windows build and all operations are done from there unless +otherwise noted. + +Under Linux you need at least the mingw-w64 package to cross-compile it, zip +to create the archive, the tofrodos or dos2unix package installed to convert +to DOS text format, and Wine plus the free MVC++Toolkit available from: + +http://uploading.com/files/HNH73WB3/VCToolkitSetup%28v1.01%29%282004.07.06%29.zip.html + +to create the Windows .LIB file (unzip and then install it with Wine in the +usual way). + +On Debian Jesse the mingw-w64 package works and is being used to build +the daily Windows 32/64 snapshots and releases. + +Finally, the Windows version of libusb 1.0 must be available for the USB backends +to be built. Download the latest libusb-1.0 from: + +https://sourceforge.net/projects/libusb/files/libusb-1.0/ + +and unzip the archive in ~/builds + +Any version of libusb from 1.0.20 is known to work. + +Several variables may need to be set differently at the top of the script file +depending on your system. + +The script now relies on a pair of environment variables to locate the needed +libusb files. + +The script generates HTML documents for the included .EXE files using groff +to convert the nroff formatted man pages. On Debian and derivatives, the groff +package is likely already installed. + + +Build for Windows 32/64, cross-compile on Linux: +================================================ + +Extract the Hamlib tarball into ~/builds (if you prefer another directory +be sure to edit the BUILD_DIR variable in the build-w[32|64].sh script): + + $ tar xvfz ~/Downloads/hamlib-3.3~git-???????-20180527.tar.gz + +Invoke the build-w[32|64].sh script (it requires a Bash shell) with the +name of the directory/Hamlib version to build (you need not cd into the hamlib +directory, although it won't hurt. The build-w[32|64].sh script uses absolute +paths): + + $ build-w32.sh hamlib-3.3~git + +or: + + $ build-w64.sh hamlib-3.3~git + + +Release Info +============ + +The structure of the archive is: + +$ tree -d +. +|-- bin +|-- doc +|-- include +| `-- hamlib +|-- lib + |-- gcc + `-- msvc + +8 directories + +The bin/ directory is where the executables and DLL files are placed. Header +files are under include/Hamlib/ and compiler specific files are under lib/*. +HTML documents for the .EXE programs are in doc/ while text documents +(READMEs and such) are in the main archive directory. The doc/ directory +also contains the generated HTML texinfo manual. The embedded +README.w[32|64]-bin.txt file generated by the build-w[32|64].sh script +describes setting the PATH environment variable in Windows 2000, Windows XP, +and Windows 7. + + +73, Nate, N0NB diff --git a/scripts/README.build-win32 b/scripts/README.build-win32 deleted file mode 100644 index f0ed232e5..000000000 --- a/scripts/README.build-win32 +++ /dev/null @@ -1,98 +0,0 @@ - -This file is a HOWTO for the cross-compiling of Windows 32 bit binary DLLs -built from a tarball generated by 'make dist' in a Git checkout. The -resulting DLLs are built with a cdecl interface compatible with MS VC++. - - -Prerequisites -============= - -In these steps the release or daily snapshot tarball is unpacked in ~/builds -for the Windows 32 build and all operations are done from there unless -otherwise noted. - -Under Linux you need at least the mingw32 package to cross-compile it (although -mingw-w64-i696 is being used to build the daily snapshots) zip to create -the archive, the tofrodos or dos2unix package installed to convert to DOS -text format, and Wine plus the free MVC++Toolkit available from: - -http://uploading.com/files/HNH73WB3/VCToolkitSetup%28v1.01%29%282004.07.06%29.zip.html - -to create the Windows 32 .LIB file (unzip and then install it with Wine in the -usual way). - -NB: Debian Squeeze and later users will need at least the mingw32-runtime -3.15 package as the 3.13 package is broken. You can manually install the -Ubuntu version from: - -http://packages.ubuntu.com/maverick/devel/mingw32-runtime - -On Debian Jesse the mingw-w64-i686 pacakge works and is being used to build -the daily Windows 32 snapshots. - -Finally, the Windows 32 version of libusb must be available for the USB backends -to be built. Download the latest libusb-win32-bin-1.2.4.0.zip from: - -https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/ - -and unzip the archive in ~/builds/libusb-win32-bin-1.2.4.0 - -Any version of libusb from 1.2.3.0 is known to work. - -Several variables may need to be set differently at the top of the script file -depending on your system. - -The script now relies on a pair of environment variables to locate the needed -libusb files and the third party pkg-config utility is no longer used for -libusb. - -The script generates PDF documents for the included .EXE files using the -groff and ps2pdf utilities to convert the nroff formatted man pages. On -Debian and derivatives, installing the groff and ghostscript packages will -provide them. - - -Build for Windows 32, cross-compile on Linux: -============================================= - -Extract the Hamlib tarball into ~/builds (if you prefer another directory -be sure to edit the BUILD_DIR variable in the build-win32.sh script): - - $ tar xvfz ~/Downloads/hamlib-3.0~git-???????-20121007.tar.gz - -Invoke the build-win32.sh script (it requires a Bash shell) with the name of -the directory/Hamlib version to build (you need not cd into the hamlib -directory, although it won't hurt. The build-win32 script uses absolute -paths): - - $ build-win32.sh hamlib-3.0~git - - -Release Info -============ - -The structure of the archive is: - -$ tree -d -. -|-- bin -|-- doc -|-- include -| `-- hamlib -|-- lib -| |-- gcc -| `-- msvc -`-- pdf - -8 directories - -The bin directory is where the executables and DLL files are placed. Header -files are under include/Hamlib and compiler specific files are under lib/*. -PDF documents for the .EXE programs are in pdf/ while text documents -(READMEs and such) are in the main archive directory. The doc/ directory -contains the generated HTML manual. The embedded README.win32-bin file -generated by the build-win32.sh script describes setting the PATH -environment variable in Windows 2000, Windows XP, and Windows 7. - - -73, Nate, N0NB diff --git a/scripts/README.scripts b/scripts/README.scripts index 80b3defcd..5b6eb8a72 100644 --- a/scripts/README.scripts +++ b/scripts/README.scripts @@ -1,11 +1,13 @@ The scripts/ directory will contain helper scripts for building Hamlib -binary releases for Win32 and possibly other target platforms. EAch -script should be accompanied by a companion README file with information -on the script and build requirements. +binary releases for Microsoft Windows 32 and 64 bit architectures and +possibly other target platforms. Each script should be accompanied by +a companion README file with information on the script and build +requirements. Scripts: -build-win32.sh for building Win32 DLLs and EXEs for use with MS VC++. +build-w32.sh and build-w64.sh for building Microsoft Windows 32 and 64 bit +DLLs and EXEs for use with MS VC++. build-VB.NET.sh for building Win32 DLLs and EXEs for use with MS VB.NET 2002 Framework 1.1 diff --git a/scripts/build-w32.sh b/scripts/build-w32.sh new file mode 100644 index 000000000..92ead58ed --- /dev/null +++ b/scripts/build-w32.sh @@ -0,0 +1,232 @@ +#!/bin/bash + +# Builds Hamlib 3.x W32 binary distribution. + +# A script to build a set of W32 binary DLLs from a Hamlib tarball. +# This script assumes that the Hamlib tarball has been extracted to the +# directory specified in $BUILD_DIR and that libusb-1.x.y has also +# been extracted to $BUILD_DIR. The MS VC++ Toolkit must also be installed +# and working with Wine. +# +# See README.build-win32 for complete details. + + +# Set this to a desired directory +BUILD_DIR=~/builds + +# Set this to LibUSB archive extracted in $BUILD_DIR +LIBUSB_VER=libusb-1.0.20 + +# uncomment the correct HOST_ARCH= line for your minGW installation +HOST_ARCH=i686-w64-mingw32 + +# Set to the strip name for your version of minGW +HOST_ARCH_STRIP=i686-w64-mingw32-strip + +# Error return codes. See /usr/include/sysexits.h +EX_USAGE=64 +EX_NOINPUT=66 + + +# Pass name of Hamlib archive extracted in $BUILD_DIR +if [ $# -ne 1 ]; then + echo -e "\nUsage: `basename $0` hamlib-version\n" + echo -e "See README.build-win32 for more information.\n" + exit ${EX_USAGE} +fi + +# Make sure the Hamlib archive is where we expect +if [ -d ${BUILD_DIR}/$1 ]; then + echo -e "\nBuilding W32 binaries in ${BUILD_DIR}/$1\n\n" + cd ${BUILD_DIR}/$1 +else + echo -e "\nBuild directory, ${BUILD_DIR}/$1 not found!\nCheck path for $1 or correct the version number.\n" + exit ${EX_NOINPUT} +fi + +RELEASE=`/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[3\./ {print $2;exit}' ./configure.ac` +HL_FILENAME=hamlib-w32-${RELEASE} +INST_DIR=`pwd`/mingw32-inst +ZIP_DIR=`pwd`/${HL_FILENAME} +LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER} + + +# Create W32 specific README.w32-bin file +cat > README.w32-bin < Radio model 120, or Yaesu FT-817 (use 'rigctl -l' for a list) + -r -> Radio device, in this case COM1 + -v -> Verbosity level. For testing four or five v characters are required. + Five 'v's set a debug level of TRACE which generates a lot of screen + output showing communication to the radio and values of important + variables. These traces are vital information for Hamlib rig backend + development. + +To run rigctl or rotctl open a cmd window (Start|Run|enter 'cmd' in the +dialog). If text scrolls off the screen, you can scroll back with the mouse. +To copy output text into a mailer or editor (I recommend Notepad++, a free +editor also licensed under the GPL), highlight the text as a rectangle in the +cmd window, press (or right-click the window icon in the upper left +corner and select Edit, then Copy), and paste it into your editor with Ctl-V +(or Edit|Paste from the typical GUI menu). + +All feedback is welcome to the mail address below. + + +Uninstall +========= + +To uninstall, simply delete the Hamlib directory. You may wish to edit the +PATH as above to remove the Hamlib bin path, if desired. + + +Information for w32 Programmers +================================= + +There is a .LIB import library for MS-VC++ in lib/msvc. Simply #include + (add directory to include path), include the .LIB in your +project and you are done. Note: MS-VC++ cannot compile all the Hamlib code, but +the API defined by rig.h has been made MSVC friendly :-) + +As the source code for the library DLLs is licensed under the LGPL, your +program is not considered a "derivative work" when using the published Hamlib +API and normal linking to the front-end library, and may be of a license of +your choosing. The published Hamlib API may be found at: + +http://hamlib.sourceforge.net/manuals/3.0.1/index.html + + +Thank You! +========== + +Patches, feedback, and contributions are welcome. + +Please report problems or success to hamlib-developer@lists.sourceforge.net + +Cheers, +Stephane Fillod - F8CFE +Nate Bargmann - N0NB +http://www.hamlib.org + +END_OF_README + + +# Configure and build hamlib for mingw32, with libusb-win32 + +./configure --host=${HOST_ARCH} \ + --prefix=${INST_DIR} \ + --without-cxx-binding \ + --disable-static \ + CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \ + LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW32/dll" + + +make install + +mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc +cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-2.def; todos ${ZIP_DIR}/lib/msvc/libhamlib-2.def +cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.; todos ${ZIP_DIR}/include/hamlib/*.h +cp -a doc/Hamlib_design.png ${ZIP_DIR}/doc +cp -a doc/hamlib.html ${ZIP_DIR}/doc + +# C++ binding is useless on w32 because of ABI +rm ${ZIP_DIR}/include/hamlib/{rig,rot}class.h + +for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README README.betatester README.w32-bin THANKS ; do \ + cp -a ${f} ${ZIP_DIR}/${f}.txt ; todos ${ZIP_DIR}/${f}.txt ; done + +# Generate HTML documents from nroff formatted man files +for f in doc/man1/*.1 doc/man7/*.7; do \ + /usr/bin/groff -mandoc -Thtml >${f}.html ${f} + cp -a ${f}.html ${ZIP_DIR}/doc/. ; done + +cd ${BUILD_DIR}/$1 + +# Copy build files into specific locations for Zip file +cp -a ${INST_DIR}/bin/{rigctld.exe,rigctl.exe,rigmem.exe,rigsmtr.exe,rigswr.exe,rotctld.exe,rotctl.exe} ${ZIP_DIR}/bin/. +cp -a ${INST_DIR}/bin/libhamlib-?.dll ${ZIP_DIR}/bin/. +cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/. + +# NB: Strip Hamlib DLLs and EXEs +${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll + +# Copy needed third party DLLs +cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/. +cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW32/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll + +# Required for MinGW with GCC 4.9 +cp -a /usr/lib/gcc/i686-w64-mingw32/4.9-posix/libgcc_s_sjlj-1.dll ${ZIP_DIR}/bin/libgcc_s_sjlj-1.dll + +## Need VC++ free toolkit installed (default Wine directory installation shown) +( cd ${ZIP_DIR}/lib/msvc/ && wine ~/.wine/drive_c/Program\ Files/Microsoft\ Visual\ C++\ Toolkit\ 2003/bin/link.exe /lib /machine:i386 /def:libhamlib-2.def ) + +/usr/bin/zip -r ${HL_FILENAME}.zip `basename ${ZIP_DIR}` diff --git a/scripts/build-win32.sh b/scripts/build-w64.sh similarity index 70% rename from scripts/build-win32.sh rename to scripts/build-w64.sh index 7f52e3b6c..e4838f8eb 100644 --- a/scripts/build-win32.sh +++ b/scripts/build-w64.sh @@ -1,29 +1,29 @@ #!/bin/bash -# Builds Hamlib 3.x Win32 binary distribution. +# Builds Hamlib 3.x W64 binary distribution. -# A script to build a set of Win32 binary DLLs from a Hamlib tarball. +# A script to build a set of W64 binary DLLs from a Hamlib tarball. # This script assumes that the Hamlib tarball has been extracted to the # directory specified in $BUILD_DIR and that libusb-win32-bin-1.x.y.z has also # been extracted to $BUILD_DIR. The MS VC++Toolkit must also be installed # and working with Wine. # -# See README.build-win32 for complete details. +# Requires libusb-1.0 to be accessible for USB backends to be built. + +# See README.build-w64 for complete details. # Set this to a desired directory BUILD_DIR=~/builds # Set this to LibUSB archive extracted in $BUILD_DIR -LIBUSB_VER=libusb-win32-bin-1.2.4.0 +LIBUSB_VER=libusb-1.0.20 # uncomment the correct HOST_ARCH= line for your minGW installation -# HOST_ARCH=i586-mingw32msvc -HOST_ARCH=i686-w64-mingw32 +HOST_ARCH=x86_64-w64-mingw32 # Set to the strip name for your version of minGW -# HOST_ARCH_STRIP=i586-mingw32msvc-strip -HOST_ARCH_STRIP=i686-w64-mingw32-strip +HOST_ARCH_STRIP=x86_64-w64-mingw32-strip # Error return codes. See /usr/include/sysexits.h EX_USAGE=64 @@ -33,43 +33,46 @@ EX_NOINPUT=66 # Pass name of Hamlib archive extracted in $BUILD_DIR if [ $# -ne 1 ]; then echo -e "\nUsage: `basename $0` hamlib-version\n" - echo -e "See README.build-win32 for more information.\n" - exit $EX_USAGE + echo -e "See README.build-w64 for more information.\n" + exit ${EX_USAGE} fi # Make sure the Hamlib archive is where we expect if [ -d ${BUILD_DIR}/$1 ]; then - echo -e "\nBuilding Win32 binaries in ${BUILD_DIR}/$1\n\n" + echo -e "\nBuilding w64 binaries in ${BUILD_DIR}/$1\n\n" cd ${BUILD_DIR}/$1 else echo -e "\nBuild directory, ${BUILD_DIR}/$1 not found!\nCheck path for $1 or correct the version number.\n" exit $EX_NOINPUT fi -RELEASE=`/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[3\./ {print $2}' ./configure.ac` -INST_DIR=`pwd`/mingw-inst -ZIP_DIR=`pwd`/hamlib-win32-${RELEASE} -LIBUSB_WIN32_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER} +RELEASE=`/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[3\./ {print $2;exit}' ./configure.ac` +HL_FILENAME=hamlib-w64-${RELEASE} +INST_DIR=`pwd`/mingw64-inst +ZIP_DIR=`pwd`/${HL_FILENAME} +LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER} -# Create Win32 specific README.win32_bin file -cat > README.win32-bin < README.w64-bin < (add directory to include path), include the .LIB in your -project and you are done. Note: MS-VC++ cannot compile all the Hamlib code, -but the API defined by rig.h has been made MSVC friendly :-) - As the source code for the library DLLs is licensed under the LGPL, your program is not considered a "derivative work" when using the published Hamlib API and normal linking to the front-end library, and may be of a license of your choosing. The published Hamlib API may be found at: -http://sourceforge.net/apps/mediawiki/hamlib/index.php?title=Documentation +http://hamlib.sourceforge.net/manuals/1.2.15/index.html + +(The 3.0 API is unchanged although new documentation will be forthcoming.) Thank You! @@ -180,36 +180,34 @@ http://www.hamlib.org END_OF_README -# Configure and build hamlib for mingw32, with libusb-win32 +# Configure and build hamlib for x86_64-w64-mingw32, with libusb-1.0 ./configure --host=${HOST_ARCH} \ - --prefix=`pwd`/mingw-inst \ + --prefix=${INST_DIR} \ --without-cxx-binding \ --disable-static \ - CPPFLAGS="-I${LIBUSB_WIN32_BIN_PATH}/include" \ - LDFLAGS="-L${LIBUSB_WIN32_BIN_PATH}/lib/gcc" + CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \ + LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW64/dll" make install -mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/pdf ${ZIP_DIR}/doc +mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc ${ZIP_DIR}/lib/msvc # ${ZIP_DIR}/pdf cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-2.def; todos ${ZIP_DIR}/lib/msvc/libhamlib-2.def cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.; todos ${ZIP_DIR}/include/hamlib/*.h cp -a doc/Hamlib_design.png ${ZIP_DIR}/doc cp -a doc/hamlib.html ${ZIP_DIR}/doc -# C++ binding is useless on win32 because of ABI +# C++ binding is useless on w64 because of ABI rm ${ZIP_DIR}/include/hamlib/{rig,rot}class.h -for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README README.betatester README.win32-bin THANKS ; do \ +for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README README.betatester README.w64-bin THANKS ; do \ cp -a ${f} ${ZIP_DIR}/${f}.txt ; todos ${ZIP_DIR}/${f}.txt ; done -# Generate PDF documents from nroff formatted man files -cd tests - -for f in rigmem.1 rigsmtr.1 rigswr.1; do \ - groff -mandoc >${f}.ps ${f} ; ps2pdf ${f}.ps ; rm ${f}.ps ; \ - cp -a ${f}.pdf ${ZIP_DIR}/pdf/. ; done +# Generate HTML documents from nroff formatted man files +for f in doc/man1/*.1 doc/man7/*.7; do \ + /usr/bin/groff -mandoc -Thtml >${f}.html ${f} + cp -a ${f}.html ${ZIP_DIR}/doc/. ; done cd ${BUILD_DIR}/$1 @@ -222,14 +220,13 @@ cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/. ${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll # Copy needed third party DLLs -cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/. -cp -a ${LIBUSB_WIN32_BIN_PATH}/bin/x86/libusb0_x86.dll ${ZIP_DIR}/bin/libusb0.dll +cp -a /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/. +cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW64/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll -# Required for MinGW with GCC 4.8 -cp -a /usr/lib/gcc/i686-w64-mingw32/4.8/libgcc_s_sjlj-1.dll ${ZIP_DIR}/bin/libgcc_s_sjlj-1.dll +# Required for MinGW with GCC 4.9 +cp -a /usr/lib/gcc/x86_64-w64-mingw32/4.9-posix/libgcc_s_seh-1.dll ${ZIP_DIR}/bin/libgcc_s_seh-1.dll -# Need VC++ free toolkit installed (default Wine directory installation shown) -( cd ${ZIP_DIR}/lib/msvc/ && wine ~/.wine/drive_c/Program\ Files/Microsoft\ Visual\ C++\ Toolkit\ 2003/bin/link.exe /lib /machine:i386 /def:libhamlib-2.def ) - -zip -r hamlib-win32-${RELEASE}.zip `basename ${ZIP_DIR}` +## Need VC++ free toolkit installed (default Wine directory installation shown) +( cd ${ZIP_DIR}/lib/msvc/ && wine ~/.wine/drive_c/Program\ Files/Microsoft\ Visual\ C++\ Toolkit\ 2003/bin/link.exe /lib /machine:amd64 /def:libhamlib-2.def ) +zip -r ${HL_FILENAME}.zip `basename ${ZIP_DIR}` diff --git a/src/cm108.c b/src/cm108.c index 22530194e..9c184d9b3 100644 --- a/src/cm108.c +++ b/src/cm108.c @@ -115,7 +115,8 @@ int cm108_open(hamlib_port_t *port) && ((hiddevinfo.product >= 0x0008 && hiddevinfo.product <= 0x000f) || hiddevinfo.product == 0x0012 - || hiddevinfo.product == 0x013a)) + || hiddevinfo.product == 0x013a + || hiddevinfo.product == 0x013c)) // SSS1621/23 || (hiddevinfo.vendor == 0x0c76 && (hiddevinfo.product == 0x1605 diff --git a/src/conf.c b/src/conf.c index 551e54fa5..b38f6c365 100644 --- a/src/conf.c +++ b/src/conf.c @@ -91,7 +91,7 @@ static const struct confparams frontend_cfg_params[] = { TOK_PTT_TYPE, "ptt_type", "PTT type", "Push-To-Talk interface type override", - "RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DTR", "RTS", "Parallel", "CM108", "None", NULL }} } + "RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DTR", "RTS", "Parallel", "CM108", "GPIO", "GPION", "None", NULL }} } }, { TOK_PTT_PATHNAME, "ptt_pathname", "PTT path name", @@ -106,13 +106,18 @@ static const struct confparams frontend_cfg_params[] = { TOK_DCD_TYPE, "dcd_type", "DCD type", "Data Carrier Detect (or squelch) interface type override", - "RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DSR", "CTS", "CD", "Parallel", "CM108", "None", NULL }} } + "RIG", RIG_CONF_COMBO, { .c = {{ "RIG", "DSR", "CTS", "CD", "Parallel", "CM108", "GPIO", "GPION", "None", NULL }} } }, { TOK_DCD_PATHNAME, "dcd_pathname", "DCD path name", "Path name to the device file of the Data Carrier Detect (or squelch)", "/dev/rig", RIG_CONF_STRING, }, + { + TOK_LO_FREQ, "lo_freq", "LO Frequency", + "Frequency to add to the VFO frequency for use with a transverter", + "0", RIG_CONF_NUMERIC, { .n = {0.0, 1e9, .1}} + }, { RIG_CONF_END, NULL, } }; @@ -422,6 +427,14 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) { rs->pttport.type.ptt = RIG_PTT_CM108; } + else if (!strcmp(val, "GPIO")) + { + rs->pttport.type.ptt = RIG_PTT_GPIO; + } + else if (!strcmp(val, "GPION")) + { + rs->pttport.type.ptt = RIG_PTT_GPION; + } else if (!strcmp(val, "None")) { rs->pttport.type.ptt = RIG_PTT_NONE; @@ -471,6 +484,14 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) { rs->dcdport.type.dcd = RIG_DCD_CM108; } + else if (!strcmp(val, "GPIO")) + { + rs->dcdport.type.dcd = RIG_DCD_GPIO; + } + else if (!strcmp(val, "GPION")) + { + rs->dcdport.type.dcd = RIG_DCD_GPION; + } else if (!strcmp(val, "None")) { rs->dcdport.type.dcd = RIG_DCD_NONE; @@ -494,6 +515,9 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) case TOK_POLL_INTERVAL: rs->poll_interval = atof(val); break; + case TOK_LO_FREQ: + rs->lo_freq = atof(val); + break; default: @@ -720,6 +744,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val) s = "CM108"; break; + case RIG_PTT_GPIO: + s = "GPIO"; + break; + + case RIG_PTT_GPION: + s = "GPION"; + break; + case RIG_PTT_NONE: s = "None"; break; @@ -766,6 +798,14 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val) s = "CM108"; break; + case RIG_DCD_GPIO: + s = "GPIO"; + break; + + case RIG_DCD_GPION: + s = "GPION"; + break; + case RIG_DCD_NONE: s = "None"; break; diff --git a/src/gpio.c b/src/gpio.c index 269305e1a..05755e8d7 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -29,7 +29,7 @@ #include "gpio.h" -int gpio_open(hamlib_port_t *port, int on_value) +int gpio_open(hamlib_port_t *port, int output, int on_value) { char pathname[FILPATHLEN*2]; FILE *fexp, *fdir; @@ -69,14 +69,16 @@ int gpio_open(hamlib_port_t *port, int on_value) return -RIG_EIO; } - fprintf(fdir, "out\n"); + char *dir = output ? "out" : "in"; + rig_debug(RIG_DEBUG_VERBOSE, "Setting direction of GPIO%s to %s\n", port->pathname, dir); + fprintf(fdir, "%s\n", dir); fclose(fdir); snprintf(pathname, sizeof(pathname), "/sys/class/gpio/gpio%s/value", port->pathname); - fd = open(pathname, O_WRONLY); + fd = open(pathname, O_RDWR); if (fd < 0) { @@ -127,10 +129,36 @@ int gpio_ptt_get(hamlib_port_t *port, ptt_t *pttx) { if (port->parm.gpio.value) { - return RIG_PTT_ON; + *pttx = RIG_PTT_ON; } else { - return RIG_PTT_OFF; + *pttx = RIG_PTT_OFF; } + return RIG_OK; } + +int gpio_dcd_get(hamlib_port_t *port, dcd_t *dcdx) +{ + char val; + int port_value; + + lseek(port->fd, 0, SEEK_SET); + if (read(port->fd, &val, sizeof(val)) <= 0) + { + return -RIG_EIO; + } + rig_debug(RIG_DEBUG_VERBOSE, "DCD GPIO pin value: %c\n", val); + + port_value = val - '0'; + + if (port_value == port->parm.gpio.on_value) + { + *dcdx = RIG_DCD_ON; + } else + { + *dcdx = RIG_DCD_OFF; + } + return RIG_OK; +} + diff --git a/src/gpio.h b/src/gpio.h index c72a2b53f..d53054bf2 100644 --- a/src/gpio.h +++ b/src/gpio.h @@ -28,10 +28,11 @@ __BEGIN_DECLS /* Hamlib internal use, see rig.c */ -int gpio_open(hamlib_port_t *p, int on_value); +int gpio_open(hamlib_port_t *p, int output, int on_value); int gpio_close(hamlib_port_t *p); int gpio_ptt_set(hamlib_port_t *p, ptt_t pttx); int gpio_ptt_get(hamlib_port_t *p, ptt_t *pttx); +int gpio_dcd_get(hamlib_port_t *p, dcd_t *dcdx); __END_DECLS diff --git a/src/iofunc.c b/src/iofunc.c index 8cd0966a9..432375cae 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -692,6 +692,8 @@ int HAMLIB_API read_string(hamlib_port_t *p, /* Store the time of the read loop start */ gettimeofday(&start_time, NULL); + rxbuffer[0] = 0; /* ensure string is terminated */ + while (total_count < rxmax - 1) { tv = tv_timeout; /* select may have updated it */ diff --git a/src/microham.c b/src/microham.c index b440a6d35..631104fd4 100644 --- a/src/microham.c +++ b/src/microham.c @@ -78,8 +78,10 @@ #define PATH_MAX 256 #endif +#if !(defined(WIN32) || !defined(HAVE_GLOB_H)) static char uh_device_path[PATH_MAX]; // use PATH_MAX since udev names can be VERY long! +#endif static int uh_device_fd = -1; static int uh_is_initialized = 0; @@ -106,14 +108,18 @@ static pthread_t readthread; #define freelock() #endif +#if defined(HAVE_SELECT) // // time of last heartbeat. Updated by heartbeat() // static time_t lastbeat = 0; +#endif + +#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) static time_t starttime; #define TIME ((int) (time(NULL) - starttime)) - +#endif // // close all sockets and mark them free @@ -205,9 +211,12 @@ static void close_microham() * number begins with MK, M2, CK, DK, D2, 2R, 2P or UR. Then, open the serial * line with correct serial speed etc. and put a valid fd into uh_device_fd. */ -static void finddevices() -{ -} +/* Commenting out the following dummy function to quell the warning from + * MinGW's GCC of a defined but not used function. + */ +/* static void finddevices() */ +/* { */ +/* } */ #else @@ -381,6 +390,7 @@ static void finddevices() #endif +#if defined(HAVE_SELECT) // // parse a frame received from the keyer // This is called from the "device reading" thread @@ -500,8 +510,10 @@ static void parseFrame(unsigned char *frame) } } } +#endif /* HAVE_SELECT */ +#if defined(HAVE_SELECT) // // Send radio bytes to microHam device // @@ -548,6 +560,7 @@ static void writeRadio(unsigned char *bytes, int len) freelock(); } +#endif /* HAVE_SELECT */ // @@ -585,6 +598,7 @@ static void writeFlags() } +#if defined(HAVE_SELECT) // // Send bytes to the WinKeyer within microHam device // @@ -639,6 +653,7 @@ static void writeWkey(unsigned char *bytes, int len) freelock(); } +#endif /* HAVE_SELECT */ // @@ -701,6 +716,7 @@ static void writeControl(unsigned char *data, int len) } +#if defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) // // send a heartbeat and record time // The "last heartbeat" time is recorded in a global variable @@ -716,8 +732,10 @@ static void heartbeat() writeControl(seq, 2); lastbeat = time(NULL); } +#endif /* defined(HAVE_PTHREAD) && defined(HAVE_SOCKETPAIR) && defined(HAVE_SELECT) */ +#if defined(HAVE_SELECT) // // This thread reads from the microHam device and puts data on the sockets // it also issues periodic heartbeat messages @@ -725,7 +743,6 @@ static void heartbeat() // static void *read_device(void *p) { -#if defined(HAVE_SELECT) unsigned char frame[4]; int framepos = 0; int ret; @@ -862,9 +879,9 @@ static void *read_device(void *p) } } -#endif - return NULL; +// return NULL; } +#endif /* diff --git a/src/network.c b/src/network.c index 0bacd7c01..143f59c4f 100644 --- a/src/network.c +++ b/src/network.c @@ -241,7 +241,7 @@ int network_open(hamlib_port_t *rp, int default_port) { break; } - char msg[555]; + char msg[1024]; snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname); handle_error(RIG_DEBUG_WARN, msg); diff --git a/src/register.c b/src/register.c index 226268b0d..88f99f045 100644 --- a/src/register.c +++ b/src/register.c @@ -87,6 +87,7 @@ DEFINE_INITRIG_BACKEND(prm80); DEFINE_INITRIG_BACKEND(adat); DEFINE_INITRIG_BACKEND(dorji); DEFINE_INITRIG_BACKEND(barrett); +DEFINE_INITRIG_BACKEND(elad); #ifdef HAVE_WINRADIO DEFINE_INITRIG_BACKEND(winradio); @@ -139,6 +140,7 @@ static struct { RIG_ADAT, RIG_BACKEND_ADAT, RIG_FUNCNAM(adat) }, { RIG_DORJI, RIG_BACKEND_DORJI, RIG_FUNCNAMA(dorji) }, { RIG_BARRETT, RIG_BACKEND_BARRETT, RIG_FUNCNAMA(barrett) }, + { RIG_ELAD, RIG_BACKEND_ELAD, RIG_FUNCNAMA(elad) }, { 0, NULL }, /* end */ }; diff --git a/src/rig.c b/src/rig.c index 5e0b483d0..c7c4ae36f 100644 --- a/src/rig.c +++ b/src/rig.c @@ -406,6 +406,7 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model) rs->poll_interval = 500; /* should it be a parameter to rig_init ? --SF */ rs->itu_region = RIG_ITU_REGION2; + rs->lo_freq = 0; switch (rs->itu_region) { @@ -688,7 +689,7 @@ int HAMLIB_API rig_open(RIG *rig) break; case RIG_PTT_GPIO: - rs->pttport.fd = gpio_open(&rs->pttport, 1); + rs->pttport.fd = gpio_open(&rs->pttport, 1, 1); if (rs->pttport.fd < 0) { @@ -706,7 +707,7 @@ int HAMLIB_API rig_open(RIG *rig) break; case RIG_PTT_GPION: - rs->pttport.fd = gpio_open(&rs->pttport, 0); + rs->pttport.fd = gpio_open(&rs->pttport, 1, 0); if (rs->pttport.fd < 0) { @@ -780,6 +781,34 @@ int HAMLIB_API rig_open(RIG *rig) break; + case RIG_DCD_GPIO: + rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 1); + + if (rs->dcdport.fd < 0) + { + rig_debug(RIG_DEBUG_ERR, + "%s: cannot open DCD device \"%s\"\n", + __func__, + rs->dcdport.pathname); + status = -RIG_EIO; + } + + break; + + case RIG_DCD_GPION: + rs->dcdport.fd = gpio_open(&rs->dcdport, 0, 0); + + if (rs->dcdport.fd < 0) + { + rig_debug(RIG_DEBUG_ERR, + "%s: cannot open DCD device \"%s\"\n", + __func__, + rs->dcdport.pathname); + status = -RIG_EIO; + } + + break; + default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported DCD type %d\n", @@ -969,6 +998,10 @@ int HAMLIB_API rig_close(RIG *rig) port_close(&rs->dcdport, RIG_PORT_PARALLEL); break; + case RIG_DCD_GPIO: + case RIG_DCD_GPION: + port_close(&rs->dcdport, RIG_PORT_GPIO); + default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported DCD type %d\n", @@ -1060,6 +1093,11 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } caps = rig->caps; + if (rig->state.lo_freq != 0.0) + { + freq -= rig->state.lo_freq; + } + if (rig->state.vfo_comp != 0.0) { @@ -1191,7 +1229,10 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { rig->state.current_freq = *freq; } - + if (rig->state.lo_freq != 0.0) + { + *freq += rig->state.lo_freq; + } return retcode; } @@ -2036,6 +2077,10 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) case RIG_DCD_PARALLEL: return par_dcd_get(&rig->state.dcdport, dcd); + case RIG_DCD_GPIO: + case RIG_DCD_GPION: + return gpio_dcd_get(&rig->state.dcdport, dcd); + case RIG_DCD_NONE: return -RIG_ENAVAIL; /* not available */ diff --git a/src/rot_reg.c b/src/rot_reg.c index d6bae5ca5..7d04acf7b 100644 --- a/src/rot_reg.c +++ b/src/rot_reg.c @@ -81,7 +81,7 @@ DEFINE_INITROT_BACKEND(celestron); DEFINE_INITROT_BACKEND(ether6); DEFINE_INITROT_BACKEND(cnctrk); DEFINE_INITROT_BACKEND(prosistel); - +DEFINE_INITROT_BACKEND(meade); /** * \def ROT_BACKEND_LIST @@ -118,6 +118,7 @@ static struct { ROT_ETHER6, ROT_BACKEND_ETHER6, ROT_FUNCNAMA(ether6) }, { ROT_CNCTRK, ROT_BACKEND_CNCTRK, ROT_FUNCNAMA(cnctrk) }, { ROT_PROSISTEL, ROT_BACKEND_PROSISTEL, ROT_FUNCNAMA(prosistel) }, + { ROT_MEADE, ROT_BACKEND_MEADE, ROT_FUNCNAMA(meade) }, { 0, NULL }, /* end */ }; diff --git a/src/token.h b/src/token.h index 18f93df49..585ff5d37 100644 --- a/src/token.h +++ b/src/token.h @@ -96,6 +96,8 @@ #define TOK_VFO_COMP TOKEN_FRONTEND(110) /** \brief rig: polling interval (units?) */ #define TOK_POLL_INTERVAL TOKEN_FRONTEND(111) +/** \brief rig: lo frequency of any transverters */ +#define TOK_LO_FREQ TOKEN_FRONTEND(112) /** \brief rig: International Telecommunications Union region no. */ #define TOK_ITU_REGION TOKEN_FRONTEND(120) /* diff --git a/tests/rigctl.c b/tests/rigctl.c index 4f98e2bd9..c79b4628d 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -121,8 +121,6 @@ static struct option long_options[] = /* variable for readline support */ #ifdef HAVE_LIBREADLINE static const int have_rl = 1; -#else /* no readline */ -static const int have_rl = 0; #endif @@ -143,6 +141,7 @@ int main(int argc, char *argv[]) int verbose = 0; int show_conf = 0; int dump_caps_opt = 0; + #ifdef HAVE_READLINE_HISTORY int rd_hist = 0; int sv_hist = 0; @@ -150,7 +149,8 @@ int main(int argc, char *argv[]) const char hist_file[] = "/.rigctl_history"; char *hist_path = NULL; struct stat hist_dir_stat; -#endif +#endif /* HAVE_READLINE_HISTORY */ + const char *rig_file = NULL, *ptt_file = NULL, *dcd_file = NULL; ptt_type_t ptt_type = RIG_PTT_NONE; dcd_type_t dcd_type = RIG_DCD_NONE; @@ -301,6 +301,14 @@ int main(int argc, char *argv[]) { dcd_type = RIG_DCD_CM108; } + else if (!strcmp(optarg, "GPIO")) + { + dcd_type = RIG_DCD_GPIO; + } + else if (!strcmp(optarg, "GPION")) + { + dcd_type = RIG_DCD_GPION; + } else if (!strcmp(optarg, "NONE")) { dcd_type = RIG_DCD_NONE; @@ -381,7 +389,7 @@ int main(int argc, char *argv[]) case 'I': sv_hist++; break; -#endif +#endif /* HAVE_READLINE_HISTORY */ case 'v': verbose++; @@ -562,7 +570,7 @@ int main(int argc, char *argv[]) } } -#endif +#endif /* HAVE_READLINE_HISTORY */ } #endif /* HAVE_LIBREADLINE */ @@ -600,11 +608,11 @@ int main(int argc, char *argv[]) hist_path = (char *)NULL; } -#endif +#endif /* HAVE_READLINE_HISTORY */ } -#endif - rig_close(my_rig); /* close port */ +#endif /* HAVE_LIBREADLINE */ + rig_close(my_rig); /* close port */ rig_cleanup(my_rig); /* if you care about memory */ return exitcode; diff --git a/tests/rotctl.c b/tests/rotctl.c index 0474d0cb0..0d79f562a 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -109,8 +109,6 @@ static struct option long_options[] = /* variable for readline support */ #ifdef HAVE_LIBREADLINE static const int have_rl = 1; -#else /* no readline */ -static const int have_rl = 0; #endif @@ -131,6 +129,7 @@ int main(int argc, char *argv[]) int verbose = 0; int show_conf = 0; int dump_caps_opt = 0; + #ifdef HAVE_READLINE_HISTORY int rd_hist = 0; int sv_hist = 0; @@ -138,7 +137,8 @@ int main(int argc, char *argv[]) const char hist_file[] = "/.rotctl_history"; char *hist_path = NULL; struct stat hist_dir_stat; -#endif +#endif /* HAVE_READLINE_HISTORY */ + const char *rot_file = NULL; int serial_rate = 0; char conf_parms[MAXCONFLEN] = ""; @@ -240,7 +240,7 @@ int main(int argc, char *argv[]) case 'I': sv_hist++; break; -#endif +#endif /* HAVE_READLINE_HISTORY */ case 'v': verbose++; @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) } } -#endif +#endif /* HAVE_READLINE_HISTORY */ } #endif /* HAVE_LIBREADLINE */ @@ -433,11 +433,11 @@ int main(int argc, char *argv[]) hist_path = (char *)NULL; } -#endif +#endif /* HAVE_READLINE_HISTORY */ } -#endif - rot_close(my_rot); /* close port */ +#endif /* HAVE_LIBREADLINE */ + rot_close(my_rot); /* close port */ rot_cleanup(my_rot); /* if you care about memory */ return exitcode; diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index d9c9b56a7..aab130006 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1007,9 +1007,9 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc) #endif /* The starting position of the source string is the first - * character past the initial '\'. + * character past the initial '\'. */ - snprintf(cmd_name, sizeof(cmd_name), parsed_input[0] + 1); + snprintf(cmd_name, sizeof(cmd_name), "%s", parsed_input[0] + 1); /* Sanity check as valid multiple character commands consist of * alpha-numeric characters and the underscore ('_') character. @@ -1603,7 +1603,7 @@ void list_models() rot_load_all_backends(); - printf(" Rig # Mfg Model Version Status\n"); + printf(" Rot # Mfg Model Version Status\n"); status = rot_list_foreach(hash_model_list, NULL); if (status != RIG_OK) diff --git a/yaesu/ft100.c b/yaesu/ft100.c index f53d6a6a0..e7829c1b1 100644 --- a/yaesu/ft100.c +++ b/yaesu/ft100.c @@ -55,7 +55,7 @@ static int ft100_send_priv_cmd(RIG *rig, unsigned char ci); /* kc2ivl - what works on a ft100 as of 02/27/2002 */ /* ptt on/off */ -/* set mode AM,CW,USB,LSB,FM use RTTY for DIG mode */ +/* set mode AM,CW,USB,LSB,FM use PKTUSB for DIG mode*/ /* set split on/off */ /* set repeater +, - splx */ /* set frequency of current vfo */ @@ -140,11 +140,11 @@ static const tone_t ft100_dcs_list[] = { 662, 664, 703, 712, 723, 731, 732, 734, 743, 754, \ 0, }; -#define FT100_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM) +#define FT100_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_PKTUSB|RIG_MODE_FM) #define FT100_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB) #define FT100_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM) -#define FT100_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM) +#define FT100_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_PKTUSB|RIG_MODE_FM) #define FT100_AM_TX_MODES (RIG_MODE_AM) #define FT100_GET_RIG_LEVELS (RIG_LEVEL_RAWSTR|RIG_LEVEL_RFPOWER|\ RIG_LEVEL_SWR|RIG_LEVEL_ALC|RIG_LEVEL_MICGAIN|RIG_LEVEL_SQL) @@ -259,9 +259,9 @@ const struct rig_caps ft100_caps = { }, .filters = { - {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY, kHz(2.4)}, - {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY, Hz(300)}, - {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY, Hz(500)}, + {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTUSB, kHz(2.4)}, + {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTUSB, Hz(300)}, + {RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTUSB, Hz(500)}, {RIG_MODE_AM|RIG_MODE_FM, kHz(6)}, {RIG_MODE_WFM, kHz(230)}, RIG_FLT_END, @@ -519,7 +519,7 @@ int ft100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { case RIG_MODE_FM: cmd_index = FT100_NATIVE_CAT_SET_MODE_FM; break; - case RIG_MODE_RTTY: + case RIG_MODE_PKTUSB: cmd_index = FT100_NATIVE_CAT_SET_MODE_DIG; break; case RIG_MODE_WFM: @@ -608,7 +608,7 @@ int ft100_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { *mode = RIG_MODE_AM; break; case 0x05: - *mode = RIG_MODE_RTTY; + *mode = RIG_MODE_PKTUSB; break; case 0x06: *mode = RIG_MODE_FM; diff --git a/yaesu/ft5000.c b/yaesu/ft5000.c index e04ae0284..e7ab71026 100644 --- a/yaesu/ft5000.c +++ b/yaesu/ft5000.c @@ -50,9 +50,9 @@ const struct rig_caps ftdx5000_caps = { .rig_model = RIG_MODEL_FTDX5000, .model_name = "FT-DX5000", .mfg_name = "Yaesu", - .version = NEWCAT_VER, + .version = NEWCAT_VER ".1", .copyright = "LGPL", - .status = RIG_STATUS_ALPHA, + .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_NONE, @@ -207,3 +207,173 @@ const struct rig_caps ftdx5000_caps = { .get_channel = newcat_get_channel, }; + +/* + * ft3000 rig capabilities. + * Largely compatible with the ft5000 + * Found one exception where ft3000 does not have TARGETABLE_MODE + * Also this struct is READONLY! + * + */ + +const struct rig_caps ftdx3000_caps = { + .rig_model = RIG_MODEL_FTDX3000, + .model_name = "FT-DX3000", + .mfg_name = "Yaesu", + .version = NEWCAT_VER ".1", + .copyright = "LGPL", + .status = RIG_STATUS_STABLE, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG, + .dcd_type = RIG_DCD_NONE, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 4800, /* Default rate per manual */ + .serial_rate_max = 38400, + .serial_data_bits = 8, + .serial_stop_bits = 1, /* Assumed since manual makes no mention */ + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_HARDWARE, + .write_delay = FTDX5000_WRITE_DELAY, + .post_write_delay = FTDX5000_POST_WRITE_DELAY, + .timeout = 2000, + .retry = 3, + .has_get_func = FTDX5000_FUNCS, + .has_set_func = FTDX5000_FUNCS, + .has_get_level = FTDX5000_LEVELS, + .has_set_level = RIG_LEVEL_SET(FTDX5000_LEVELS), + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + .level_gran = { + [LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } }, + [LVL_CWPITCH] = { .min = { .i = 300 }, .max = { .i = 1050 }, .step = { .i = 50 } }, + }, + .ctcss_list = common_ctcss_list, + .dcs_list = NULL, + .preamp = { 10, 20, RIG_DBLST_END, }, /* TBC */ + .attenuator = { 6, 12, 18, RIG_DBLST_END, }, + .max_rit = Hz(9999), + .max_xit = Hz(9999), + .max_ifshift = Hz(1000), + .vfo_ops = FTDX5000_VFO_OPS, + .targetable_vfo = RIG_TARGETABLE_FREQ, + .transceive = RIG_TRN_OFF, /* May enable later as the 5000 has an Auto Info command */ + .bank_qty = 0, + .chan_desc_sz = 0, + .str_cal = FTDX5000_STR_CAL, + .chan_list = { + { 1, 99, RIG_MTYPE_MEM, NEWCAT_MEM_CAP }, + { 100, 117, RIG_MTYPE_EDGE, NEWCAT_MEM_CAP }, /* two by two */ + RIG_CHAN_END, + }, + + .rx_range_list1 = { + /* General coverage + ham, ANT_5 is RX only antenna */ + {kHz(30), MHz(60), FTDX5000_ALL_RX_MODES, -1, -1, FTDX5000_VFO_ALL, FTDX5000_TX_ANTS|RIG_ANT_5}, + RIG_FRNG_END, + }, + + .tx_range_list1 = { + FRQ_RNG_HF(1, FTDX5000_OTHER_TX_MODES, W(5), W(200), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), + FRQ_RNG_HF(1, FTDX5000_AM_TX_MODES, W(2), W(75), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), /* AM class */ + FRQ_RNG_6m(1, FTDX5000_OTHER_TX_MODES, W(5), W(200), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), + FRQ_RNG_6m(1, FTDX5000_AM_TX_MODES, W(2), W(75), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), /* AM class */ + + RIG_FRNG_END, + }, + + .rx_range_list2 = { + {kHz(30), MHz(60), FTDX5000_ALL_RX_MODES, -1, -1, FTDX5000_VFO_ALL, FTDX5000_TX_ANTS|RIG_ANT_5}, + RIG_FRNG_END, + }, + + .tx_range_list2 = { + FRQ_RNG_HF(2, FTDX5000_OTHER_TX_MODES, W(5), W(200), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), + FRQ_RNG_HF(2, FTDX5000_AM_TX_MODES, W(2), W(75), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), /* AM class */ + FRQ_RNG_6m(2, FTDX5000_OTHER_TX_MODES, W(5), W(200), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), + FRQ_RNG_6m(2, FTDX5000_AM_TX_MODES, W(2), W(75), FTDX5000_VFO_ALL, FTDX5000_TX_ANTS), /* AM class */ + + RIG_FRNG_END, + }, + + .tuning_steps = { + {FTDX5000_SSB_CW_RX_MODES, Hz(10)}, /* Normal */ + {FTDX5000_SSB_CW_RX_MODES, Hz(100)}, /* Fast */ + + {FTDX5000_AM_RX_MODES, Hz(100)}, /* Normal */ + {FTDX5000_AM_RX_MODES, kHz(1)}, /* Fast */ + + {FTDX5000_FM_RX_MODES, Hz(100)}, /* Normal */ + {FTDX5000_FM_RX_MODES, kHz(1)}, /* Fast */ + + RIG_TS_END, + + }, + + /* mode/filter list, .remember = order matters! */ + .filters = { + {FTDX5000_CW_RTTY_PKT_RX_MODES, Hz(1800)}, /* Normal CW, RTTY, PKT/USER */ + {FTDX5000_CW_RTTY_PKT_RX_MODES, Hz(500)}, /* Narrow CW, RTTY, PKT/USER */ + {FTDX5000_CW_RTTY_PKT_RX_MODES, Hz(2400)}, /* Wide CW, RTTY, PKT/USER */ + {RIG_MODE_SSB, Hz(2400)}, /* Normal SSB */ + {RIG_MODE_SSB, Hz(1800)}, /* Narrow SSB */ + {RIG_MODE_SSB, Hz(3000)}, /* Wide SSB */ + {RIG_MODE_AM, Hz(9000)}, /* Normal AM */ + {RIG_MODE_AM, Hz(6000)}, /* Narrow AM */ + {FTDX5000_FM_RX_MODES, Hz(15000)}, /* Normal FM */ + {FTDX5000_FM_RX_MODES, Hz(8000)}, /* Narrow FM */ + + RIG_FLT_END, + }, + + .priv = NULL, + + .rig_init = newcat_init, + .rig_cleanup = newcat_cleanup, + .rig_open = newcat_open, /* port opened */ + .rig_close = newcat_close, /* port closed */ + + .cfgparams = newcat_cfg_params, + .set_conf = newcat_set_conf, + .get_conf = newcat_get_conf, + .set_freq = newcat_set_freq, + .get_freq = newcat_get_freq, + .set_mode = newcat_set_mode, + .get_mode = newcat_get_mode, + .set_vfo = newcat_set_vfo, + .get_vfo = newcat_get_vfo, + .set_ptt = newcat_set_ptt, + .get_ptt = newcat_get_ptt, + .set_split_vfo = newcat_set_split_vfo, + .get_split_vfo = newcat_get_split_vfo, + .set_rit = newcat_set_rit, + .get_rit = newcat_get_rit, + .set_xit = newcat_set_xit, + .get_xit = newcat_get_xit, + .set_ant = newcat_set_ant, + .get_ant = newcat_get_ant, + .get_func = newcat_get_func, + .set_func = newcat_set_func, + .get_level = newcat_get_level, + .set_level = newcat_set_level, + .get_mem = newcat_get_mem, + .set_mem = newcat_set_mem, + .vfo_op = newcat_vfo_op, + .get_info = newcat_get_info, + .power2mW = newcat_power2mW, + .mW2power = newcat_mW2power, + .set_rptr_shift = newcat_set_rptr_shift, + .get_rptr_shift = newcat_get_rptr_shift, + .set_ctcss_tone = newcat_set_ctcss_tone, + .get_ctcss_tone = newcat_get_ctcss_tone, + .set_ctcss_sql = newcat_set_ctcss_sql, + .get_ctcss_sql = newcat_get_ctcss_sql, + .set_powerstat = newcat_set_powerstat, + .get_powerstat = newcat_get_powerstat, + .get_ts = newcat_get_ts, + .set_ts = newcat_set_ts, + .set_trn = newcat_set_trn, + .get_trn = newcat_get_trn, + .set_channel = newcat_set_channel, + .get_channel = newcat_get_channel, + +}; diff --git a/yaesu/ft817.c b/yaesu/ft817.c index e3cf62cc4..8b236b68d 100644 --- a/yaesu/ft817.c +++ b/yaesu/ft817.c @@ -177,7 +177,7 @@ const struct rig_caps ft817_caps = { .write_delay = FT817_WRITE_DELAY, .post_write_delay = FT817_POST_WRITE_DELAY, .timeout = FT817_TIMEOUT, - .retry = 3, + .retry = 5, .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL, .has_get_level = RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER, @@ -456,17 +456,27 @@ int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; int n; + freq_t f1 = 0, f2 = 0; + int retries = rig->state.rigport.retry + 1; // +1 because, because 2 steps are needed even in best scenario if (vfo != RIG_VFO_CURR) return -RIG_ENTARGET; - if (check_cache_timeout(&p->fm_status_tv)) - if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0) - return n; + while ((f1 == 0 || f1 != f2) && retries-- > 0) { + if (check_cache_timeout(&p->fm_status_tv)) + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0) + return n; + f1 = f2; + f2 = from_bcd_be(p->fm_status, 8); + } - *freq = from_bcd_be(p->fm_status, 8) * 10; + if (retries >= 0) { + *freq = f1 * 10; + return RIG_OK; + } else { + return -RIG_EIO; + } - return RIG_OK; } int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) @@ -842,6 +852,8 @@ int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { int index, n; + ptt_t ptt_response = -1; + int retries = rig->state.rigport.retry; if (vfo != RIG_VFO_CURR) return -RIG_ENTARGET; @@ -859,15 +871,32 @@ int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) return -RIG_EINVAL; } - n = ft817_send_cmd(rig, index); - rig_force_cache_timeout( - &((struct ft817_priv_data *)rig->state.priv)->tx_status_tv); + do { + n = ft817_send_cmd(rig, index); - if (n < 0 && n != -RIG_ERJCTED) - return n; + rig_force_cache_timeout( + &((struct ft817_priv_data *)rig->state.priv)->tx_status_tv); + + if (n < 0 && n != -RIG_ERJCTED) + return n; + + if (ft817_get_ptt(rig, vfo, &ptt_response) != RIG_OK) { + ptt_response = -1; + } + + if (ptt_response != ptt) { + usleep(1000l * FT817_RETRY_DELAY); // Wait before next try. Helps with slower rigs cloning FT817 protocol (e.g. MCHF) + } + + } while (ptt_response != ptt && retries-- > 0); + + if (retries >=0) { + return RIG_OK; + } else { + return -RIG_EIO; + } - return RIG_OK; } int ft817_set_func (RIG *rig, vfo_t vfo, setting_t func, int status) diff --git a/yaesu/ft817.h b/yaesu/ft817.h index 78aad0ba9..4bccf4c9f 100644 --- a/yaesu/ft817.h +++ b/yaesu/ft817.h @@ -50,7 +50,14 @@ /* * Read timeout. */ -#define FT817_TIMEOUT 1000 +#define FT817_TIMEOUT 3000 + +/* + * Return from TX to RX may have a delay. If status is not changed + * on the first attempt, wait this amount of milliseconds before + * each next next attempts. + */ +#define FT817_RETRY_DELAY 100 /* * The time the TX, RX and FREQ/MODE status are cached (in millisec). diff --git a/yaesu/ft900.c b/yaesu/ft900.c index 5328080df..2175be2e9 100644 --- a/yaesu/ft900.c +++ b/yaesu/ft900.c @@ -1,4 +1,4 @@ -/* + /* * hamlib - (C) Frank Singleton 2000 (javabear at users.sourceforge.net) * * ft900.c - (C) Frank Singleton 2000 (javabear at users.sourceforge.net) @@ -37,6 +37,7 @@ #include "bandplan.h" #include "serial.h" #include "misc.h" +#include "cal.h" #include "yaesu.h" #include "ft900.h" @@ -138,7 +139,8 @@ struct ft900_priv_data { unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ yaesu_cmd_set_t pcs[FT900_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[FT900_ALL_DATA_LENGTH]; /* returned data--max value, some are less */ - unsigned char current_mem; /* private memory channel number */ + unsigned char current_mem; /* private memory channel number */ + int ptt; /* ptt status needed for meter reading */ }; /* @@ -151,9 +153,9 @@ const struct rig_caps ft900_caps = { .rig_model = RIG_MODEL_FT900, .model_name = "FT-900", .mfg_name = "Yaesu", - .version = "0.1", + .version = "0.2", .copyright = "LGPL", - .status = RIG_STATUS_UNTESTED, + .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, .ptt_type = RIG_PTT_RIG, .dcd_type = RIG_DCD_NONE, @@ -903,9 +905,11 @@ static int ft900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { switch (ptt) { case RIG_PTT_OFF: cmd_index = FT900_NATIVE_PTT_OFF; + priv->ptt = 0; break; case RIG_PTT_ON: cmd_index = FT900_NATIVE_PTT_ON; + priv->ptt = 1; break; default: return -RIG_EINVAL; /* wrong PTT state! */ @@ -961,6 +965,7 @@ static int ft900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { default: /* Oops! */ return -RIG_EINVAL; /* Invalid PTT bit?! */ } + priv->ptt = *ptt; return RIG_OK; } @@ -1297,13 +1302,11 @@ static int ft900_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { * is life when mapping non-linear S-meters to a linear scale. * */ - if (*p > 160) { - val->i = 60; - } else if (*p <= 72) { - val->i = ((72 - *p) / 1.3333) * -1; - } else { - val->i = ((*p - 72) / 1.4667); + cal_table_t cal=FT900_STR_CAL_SMETER; + if (priv->ptt) { + cal = (cal_table_t)FT900_STR_CAL_POWER; } + val->i = (int)rig_raw2val(*p,&cal); rig_debug(RIG_DEBUG_TRACE, "%s: calculated level = %i\n", __func__, val->i); diff --git a/yaesu/ft900.h b/yaesu/ft900.h index b424c7163..0c84f3b06 100644 --- a/yaesu/ft900.h +++ b/yaesu/ft900.h @@ -71,7 +71,7 @@ #define FT900_PACING_INTERVAL 5 #define FT900_PACING_DEFAULT_VALUE 0 -#define FT900_WRITE_DELAY 50 +#define FT900_WRITE_DELAY 5 /* Delay sequential fast writes */ @@ -315,6 +315,25 @@ typedef enum ft900_native_cmd_e ft900_native_cmd_t; #define P3 1 #define P4 0 +/* + * Two calibration sets for the smeter/power readings + */ + +#define FT900_STR_CAL_SMETER { 3, \ + { \ + { 0, -54 }, /* S0 */ \ + {0x44, 0 }, /* S9 */ \ + {0x9d, 60 }, /* +60dB */ \ + } } + +#define FT900_STR_CAL_POWER { 5, \ + { \ + { 0, 0 }, /* 0W */ \ + {0x44, 10 }, /* 10W */ \ + {0x69, 25 }, /* 25W */ \ + {0x92, 50 }, /* 50W */ \ + {0xCE, 100 }, /* 100W */ \ + } } /* * API local implementation diff --git a/yaesu/ft991.c b/yaesu/ft991.c index deaebbb22..7b052df22 100644 --- a/yaesu/ft991.c +++ b/yaesu/ft991.c @@ -289,7 +289,7 @@ int ft991_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_wi * ------------------------------------------------------------------ * Returns RIG_OK on success or an error code on failure * - * Comments: Passs band is not set here nor does it make sense as the + * Comments: Pass band is not set here nor does it make sense as the * FT991 cannot receive on VFO B. The FT991 cannot set * VFO B mode directly so we'll just set A and swap A * into B but we must preserve the VFO A mode and VFO B @@ -333,7 +333,7 @@ int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_widt { return err; } - strncat (restore_commands, priv->ret_data, NEWCAT_DATA_LEN-1); + strncpy(restore_commands, priv->ret_data, NEWCAT_DATA_LEN); /* Change mode on VFOA */ if (RIG_OK != (err = newcat_set_mode (rig, RIG_VFO_A, tx_mode, RIG_PASSBAND_NOCHANGE))) diff --git a/yaesu/newcat.c b/yaesu/newcat.c index b6fc85be2..cfee052ac 100644 --- a/yaesu/newcat.c +++ b/yaesu/newcat.c @@ -59,6 +59,7 @@ static const char cat_term = ';'; /* Yaesu command terminator */ typedef enum nc_rigid_e { NC_RIGID_NONE = 0, NC_RIGID_FT450 = 241, + NC_RIGID_FT450D = 244, NC_RIGID_FT950 = 310, NC_RIGID_FT891 = 135, NC_RIGID_FT991 = 135, @@ -340,6 +341,8 @@ int newcat_open(RIG *rig) { last client left it on */ newcat_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's not supported */ + /* Initialize rig_id in case any subsequent commands need it */ + (void)newcat_get_rigid(rig); return RIG_OK; } @@ -2018,8 +2021,10 @@ int newcat_set_level(RIG * rig, vfo_t vfo, setting_t level, value_t val) case RIG_LEVEL_RFPOWER: if (!newcat_valid_command(rig, "PC")) return -RIG_ENAVAIL; - scale = (newcat_is_rig(rig, RIG_MODEL_FT950)) ? 100 : 255; - scale = (newcat_is_rig(rig, RIG_MODEL_FT1200)) ? 100 : scale; + scale = (newcat_is_rig(rig, RIG_MODEL_FT450)) && + (newcat_get_rigid(rig) == NC_RIGID_FT450D) ? 100. : 255.; + scale = newcat_is_rig(rig, RIG_MODEL_FT950) ? 100. : scale ; + scale = newcat_is_rig(rig, RIG_MODEL_FT1200) ? 100. : scale ; fpf = newcat_scale_float(scale, val.f); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PC%03d%c", fpf, cat_term); break; @@ -2449,6 +2454,12 @@ int newcat_get_level(RIG * rig, vfo_t vfo, setting_t level, value_t * val) switch (level) { case RIG_LEVEL_RFPOWER: + scale = (newcat_is_rig(rig, RIG_MODEL_FT450)) && + (newcat_get_rigid(rig) == NC_RIGID_FT450D) ? 100. : 255.; + scale = newcat_is_rig(rig, RIG_MODEL_FT950) ? 100. : scale ; + scale = newcat_is_rig(rig, RIG_MODEL_FT1200) ? 100. : scale ; + val->f = (float)atoi(retlvl)/scale; + break; case RIG_LEVEL_VOXGAIN: case RIG_LEVEL_COMP: case RIG_LEVEL_ANTIVOX: diff --git a/yaesu/yaesu.c b/yaesu/yaesu.c index 7ffea3d07..ffb173148 100644 --- a/yaesu/yaesu.c +++ b/yaesu/yaesu.c @@ -96,6 +96,7 @@ DECLARE_INITRIG_BACKEND(yaesu) rig_register(&ft1000mpmkv_caps); rig_register(&ft1000mpmkvfld_caps); rig_register(&ft2000_caps); + rig_register(&ftdx3000_caps); rig_register(&ftdx5000_caps); rig_register(&ft9000_caps); rig_register(&frg100_caps); diff --git a/yaesu/yaesu.h b/yaesu/yaesu.h index 4c540837e..2125ab1c8 100644 --- a/yaesu/yaesu.h +++ b/yaesu/yaesu.h @@ -69,6 +69,7 @@ extern const struct rig_caps ft1000mpmkv_caps; extern const struct rig_caps ft1000mpmkvfld_caps; extern const struct rig_caps ft1000d_caps; extern const struct rig_caps ft2000_caps; +extern const struct rig_caps ftdx3000_caps; extern const struct rig_caps ftdx5000_caps; extern const struct rig_caps ft9000_caps; extern const struct rig_caps frg100_caps;