This found tons of errors in rig_debug statements
So this patch cleans up all the files that were producing warnings or errors
This should fix a few segfaults when running with debug turned on
Before altering the serial port settings, make a copy of the settings
and track it by the fd. On serial port close, restore the original
settings for that port.
On Mac OS the Prolific PL2032 kernel driver locks up if closing without
first restoring the options. When this happens, further usage of the port
is impossible until computer is rebooted, which cannot even be done
without a hard power-off.
With this fix, a clean close make sure we can re-open the port again.
* Change magic numbers in icom_set|get_ctcss|dcs_sql|code functions to
constants defined in src/tones.h
* fix a minor bug in icom_get_dcs_code (now ignoring polarity instead of
reporting invalid DCS code when sending reverse pol. DCS code)
* introduce DCS codes to IC-R8600 rig backend
73,
Ekki, DF4OR
I have an potential initial release of a backend for iOptron alt-az mounts.
I have tested it and it appears to work well both from the command line and
driven by Gpredict with my iEQ45Pro. I ran the source through astyle and I
think that it's OK. Compiling and testing was done under Unbuntu 18.
Bob KD8CGH
On Debian Buster gcc ((Debian 8.2.0-8) 8.2.0) was throwing the following
warning:
CC network.lo
../../hamlib/src/network.c: In function ‘network_open’:
../../hamlib/src/network.c:245:46: warning: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 139 [-Wformat-truncation=]
snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname);
^~
../../hamlib/src/network.c:245:9: note: ‘snprintf’ output between 44 and 555 bytes into a destination of size 150
snprintf(msg,sizeof(msg),"connect to %s failed, (trying next interface)",rp->pathname);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Raising the size of the msg buffer to 1024 quelled the warning.
* Added new rotor module (18) for Meade telescope rotors
* Implemented all needed rotor functions
* Added README.md
* Tested with DS-2000 Rotor with Autostar 494 and 506 serial cable
* Tested on Linux (Debian) with rotctl and gpredict
I tried to control my "FUNcube Dongle Pro" SDR with Hamlib. At first it
worked fine, but when I tried to correct the frequency divergence with
the vfo_comp parameter, I found a bug in the software.
Example:
$ ./rigctl -m 2513 -C vfo_comp=0.01
Rig command: F 100000000
Rig command: f
Frequency: 102010000
The correction must toke place when setting the frequency and when it
is read back. But one time the correction must work in on direction,
the other time quite opposite.
I found the code in the file rig.c and could see, that both times the
same calculation is used.
The simplest way to correct this is to go to the “rig_get_freq(“
subroutine and change it in the line 1188 from “+=” to “-=” , even that
is mathematically not correct.
Result:
$ ./rigctl -m 2513 -C vfo_comp=0.01
Rig command: F 100000000
Rig command: f
Frequency: 99990000
$ ./rigctl -m 2513 -C vfo_comp=0.000022
Rig command: F 100000000
Rig command: f
Frequency: 99999999
You can see, that the result is quite good for small divergences of
some ppm, but there is still an error for bigger divergences. So I
changed the line 1188 to the form I hope it is the mathematically
correct one:
*freq = (freq_t)(*freq/(1.0+(double)rig->state.vfo_comp));
Result:
$ ./rigctl -m 2513 -C vfo_comp=0.01
Rig command: F 100000000
Rig command: f
Frequency: 100000000
$ ./rigctl -m 2513 -C vfo_comp=0.000022
Rig command: F 100000000
Rig command: f
Frequency: 100000000
Now the result looks good for small and for bigger divergences.
Best regards
Dieter Röver (DK6OV)
Hi,
I had trouble with CTS serial port squelch (on microHAM USB Interface III).
It seems there is a bug in the hamlib code and I think the similar thing
should be done as has been done for the pttport, i.e. if the dcdport is
the same as the rigport, do not reopen it. Otherwise the serial port will
be reset to its default and it will key the radio PTT forever (because
the RTS line is reset on the port reopen). Patch attached
73! Jaroslav, OK2JRQ
This flag can be used by back ends that need to take special action
while the rig is transmitting e.g. the FT-747GX and similar that do
not process CAT commands while transmitting.
The flag is also used as a default answer to rig_get_ptt if nothing
better is available.
Deal with inaccurate CAT query for Rx/Tx on the Yaesu FT-847
This rig doesn't set the Rx/Tx status flag when PTT is asserted via
the PTT pin on the rear PACKET socket so we need to override which we
can do if we known we have asserted PTT via rig_set_ptt().
Adjust style and fix set PTT defects
Fix a warning from a declaration of a deleted function definition
When the PTT serial port is not the control port the intention is to
free the port when PTT is reset so that other applications can share
it. This logic was faulty with attempts to call port functions on an
unopened port when repeatedly calling the rig_set_ptt API.
Thanks to Christoph van Wullen, DL1YCF, for finding and analyzing this
defect.
When using separate serial port for PTT via RTS pr DTR it is
convienent to close the port when the PTT line is not asserted. This
allows other applications to share the PTT serial port.
This has been achieved by ensuring that file descriptor for the port
is set to -1 when the port is closed, this then allows the invalid FD
to be used as a PTT surrogate for the rig_get_ptt API when the port is
only being used for PTT.
This patch changes rig_list_foreach such that the called function may
call rig_unregister without having to access freed memory. This avoids
a valgrind MemCheck and makes it possible to clean up teh rig_list
database.
This change allows the set_mode functions to leave the rig passband
unchanged if required. For the few rigs that do not have explcit
passband width control either current state is read and rewritten or a
"normal" width is chosen e.g. select a normal width when there is a
choice like CW and CW-NARROW.
CAT protocols that don't allow direct addressing of VFOs require that
the "other" VFO be queried or set via a select then get/set then
select back to original or swap then get/set then swap again. When
both frequncy and mode need to be set the sequences can be optimized
if a single funciton is avaiable.
This enhancement adds those single functions rig_set_split_freq_mode()
and rig_get_split_freq_mode() with a default impelementation that
calls the individual rig_{get,set}_split_{freq,mode}() functions. Back
ends can choose to implement an optimized version which is used
instead of the default if present.
Using these functions when an optimized implementation is available
allows the TX VFO's frequency and mode to be set in a single operation
with only one VFO exchange or selection either side of the
operation. Many CAT protocols are very efficient when getting or
setting both frequency and mode and some even combine the two in a
single command.
The letters 'K' and 'k' are used for the rigctl short command name for
these functions.
Some distributions--Debian and Alpine tested--put libusb.h under the
libusb-1.0 directory. Test for its presence and if found define
HAVE_LIBUSB_1_0_LIBUSB_H. Also test for HAVE_LIBUSB or
HAVE_LIBUSB_1_0_LIBUSB_H and conditionally include the correct header
file in the sources.
As Hamlib now restores the rig auto information state (AI) on exit
there is now a need to disable that functionality so that rigctl can
be used to set/reset AI mode on the rig explicitly.
A new public API function 'rig_no_restore_ai()' is also added that
allows any client to disable this auto AI restore functionality if
required. Most clients should do nothing as restoring AI state is a
good thing.
This means that rigctl & rigctld now work with default arguments on a
modern Windows machine with dual stack and localhost being [::1] as
the first interface returned by getaddrinfo().
Try all the interfaces return by DNS lookups to establish a connection
or listening port. Handle Windows network errors correctly so that
meaningful messages are printed.
The rigctl program now accepts IPv6 numeric addresses in the portname
field like [<addr>}:<port> for example the IPv6 loopback on port 4531
would be [::1]:4531.
The previous commit introduced a regression that masks any error
return from opening the serial port used for PTT when that port is
different from the CAT serial port.
Before this change only the line used for PTT was being lowered on
open. It is necessary for platforms other than Windows to avoid
issues with other uses of the line not used for PTT such as interfaces
that wire-or RTS and DTR together or use it for CW or FSK keying. This
is because platforms other than Windows raise both DTR and RTS on
serial port opening.
Also changed code that opens CAT port to lower RTS or DTR if it is
used for PTT. In this case there is no need to lower the other line of
DTR or RTS as there is already a config parameter to control it
(dtr_state or rts_state). This change is necessary to maintain current
functionality.
The serial port line control functions take a boolean argument not a
ptt_t argument. Changed usage in rig_open() to use a explicit zero
instead of RIG_PTT_OFF value which only coincidentally happens to be
zero.
Buffer size is now an input parameter only as the return data length
is implicit since a null terminated C string is returned. Better
precondition checks are impelmented.
Many APIs emulate direct VFO addressing by using caps->set_vfo() or
caps->vfo_op(..., RIG_OP_TOGGLE) to simulate direct addressing of a
non-current VFO. The mirrored function call to revert back to the
original current VFO was not checking for errors. This is not
unreasonable but it turns out that some rigs can arbitarily fail doing
VFO changes or swaps (e.g. Yaesu FT-450).
I have added checks to these calls but only fail with the error if the
API call being wrapped does not fail itself. This allows the mirroring
VFO operation to be completed, if possible, even if the wrapped
function could not be completed, hence as before, making every effort
not to change the rig state unnecessarily.
The read_string() function was changed to return a -RIG_ETIMEOUT error
when timing out after having read some characters. This caused a back
end to fail because it was using a read_string() with an invalid stop
character and relying on the timed out read_string() to fetch the
data. This patch reverts to the prior behavior of returning a null
terminated buffer and read bytes count if at least one byte has been
read.
Fix bytes read count accumulation in Windows serial I/O.
read_string from communications port doesn't handle timeout on
anything but the first character read.
Honour VMIN tty parameter correctly.
When a serial control line (DTR or RTS) is used for PTT control the
rig_open() function clears the PTT control line after opening the
port. This is necessary on Linux because opening the port sets them
both as part of the normal RS-232 protocol. The lines were not being
cleared when the PTT port was the same port as the CAT control port.
I have a problem with the CM119A GPIO. The PTT line of the DMK
Engineering URI was not activated by the hamlib when using fldigi or
rigctl.
I fiddled with the source code and managed to edit the code in cm108.c
to get the PTT-line activate on my URI-box.
A successful rigctl command is:
rigctl -p /dev/hidraw0 -C ptt_pathname=/dev/hidraw0,ptt_type=CM108,ptt_bitnum=2
Attached is the modified source code file and a patch in 'git diff'
format.
The version of origin is 1.2.15.3.
73 de Veijo OH3NFC
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
The Icom IC-7100 back end added this enum instead of using the extant
RIG_PTT_RIG enum. Also the rig_get_ptt() implementation didn't handle
it and errored out.
Note: RIG_PTT_SERIAL_CAT was added in commit
e9ee671149 - N0NB
MinGW was issuing the following warning:
CC rig.lo
rig.c: In function 'rig_init':
rig.c:330:36: warning: assignment makes integer from pointer without a cast [enabled by default]
rs->rigport.parm.cm108.ptt_bitnum = DEFAULT_CM108_PTT_BITNUM;
^
The constant DEFAULT_CM108_PTT_BITNUM was being defined as a string on
non-linux platforms. Now defined to an integer on these platforms. The
actual value may need to be corrected at some point in the future when
CM108 support is completed for those platforms.
Clean up various left over commented lines from dlopen to single
libhamlib transition. Remove unneeded configure variables.
Correct minor inconsistencies in Makefile.am files.
Define a new variable, READLINE_LIBS, so that only programs that offer
Readline support are linked against it.
Fix various compilation warnings and errors in test files revealed with
'make check' on MinGW.
Define rig and rotor backends to (mostly) be built in alphabetical
order.
From Martin, CT1IQI:
"Several programs under Linux rely on Hamlib for control. I wanted to
try WSJT-X (digital modes like JT65) and found that my new IC-7100 was
not yet supported, also after having compiled the current git version of
Hamlib and having compiled WSJT-X against that.
So I added a IC-7100 by taking the ic-7200 and 7420 rig files as
example, be it without going (yet) through all of the very many commands
the ic-7100 supports.
This produced the situation where there was communication, e.g. setting
and reading frequencies, but the PTT control did not work. I debugged
that to actually the lack of a PTT mode in Hamlib that uses serial and
CAT at the same time; currently PTT per 'serial' seems equivalent to
toggling certain RS232 pins but not to any serial command level. So I
added a RIG_PTT_SERIAL_CAT mode for PTT control. Now the wsjt-x program
works nicely with the ic-7100 and controls both frequency and PTT via
the single USB cable."
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Add the rig and rotor backends to the list of dependencies for
libhamlib.la so that updating a given backend will force libhamlib.la to
be relinked as well. Thanks to Bill Sommerville, G4WJS, for reporting
this.
Removed obsolete references and variables related to LTDL.
With the new registration code set the HAVE_WINRADIO preprocessor
conditional if the winradio backend is to be built and test this
conditional in src/register.c whether to build winradio support.
rig_open was giving RIG_DEBUG_ERR messsages if PTT or DCD
port was unavailable but the function was not returning an
error status.
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Hi,
patch attached to enable the above which was partially coded but not
quite working.
73
Bill
G4WJS.
>From 9dab3a250dfad7203772df91aadf79d38c108f04 Mon Sep 17 00:00:00 2001
From: Bill Somerville <bill@classdesign.com>
Date: Fri, 6 Sep 2013 01:13:34 +0100
Subject: [PATCH] Fix using same serail port for PTT and CAT
src/rig.c was coded to allow the same serial port for PTT and
CAT but them tried to open the port twice. I have added code
to share the file descriptor in this situation.
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Moved all backend *.h files into the SOURCES primary as Automake
documentation states all source file types should be listed. This
causes Automake to include *.h files in rebuild rules for the targets.
Removed the '-DIN_HAMLIB' assignment from the CFLAGS primary in each
backend and assigned it to AM_CPPFLAGS in configure.ac. The effect is
the same and it simplifies the backend Makefile.am files.
Removed all commented lines.
Use the system gettaddrinfo function when possible as before. Tested on
GNU, Cygwin, MinGW on Linux, and MinGW on Windows. Under MinGW the
replacement getaddrinfo is used. Perhaps this is an area for
investigation to be certain MinGW really doesn't supply getaddrinfo.
This reverts some of the patches from Remi Chateauneu in commit
60019c9. This fixes build issues encountered building the Windows
binary daily snapshots.
Enabled static library build by default at configure time.
Fixed pthread library linking for the ars backend on MinGW.
Trying to run the pthread enabled binaries on W2k resulted in an error
dialog with the text, "The procedure entry point freeaddrinfo could not be
located in ws2_32.dll". A Microsoft support page
(http://support.microsoft.com/kb/955045) hints that when 'ws2tcpip.h' is
included that 'wspiapi.h' should be included as well. Since MinGw
includes both files, this patch corrects the runtime error on W2k
Summary from Lada:
On Win7, good testing command is:
C:\hamlib> rigctl -vvvvv -m 214 -r COM1 -s 4800 -C data_bits=8 -C
stop_bits=2 -C serial_handshake=Hardware -C timeout=1000
Behavior of this command differs on COM port. On hardware ports
(onboard, PCI NetMos, all probably 16550-compatible) rigctl freeze in
data write. It is correct, no hardware handshake is estabilished. On
FT232 USB port initialization failed by timeout. I think it is not
correct but this is not subject of this e-mail.
Looked into hamlib source and found, that timeout argument is no
longer handled. SetCommTimeouts takes timeout from c_cc[VTIME] which
is not filled.
Signed-off-by: Ladislav Vaiz <spam@nagano.cz>
Android makefile fragments are distributed as extra distribution files
by the GNU build system but are otherwise ignored. The Android build
support is independent and does not rely on the GNU build system.
See android/README.android for more info.
Signed-off-by: Nate Bargmann <n0nb@n0nb.us>