Skip to content

Hamlib rotator support - #455

Merged
dl1jbe merged 1 commit into
Tlf:masterfrom
df7cb:rotator
Nov 17, 2025
Merged

dl1jbe merged 1 commit into
Tlf:masterfrom
df7cb:rotator

Conversation

@df7cb

@df7cb df7cb commented Jan 12, 2025

Copy link
Copy Markdown
Contributor

This adds Hamlib rotator support to tlf. When a call or prefix is entered, pressing Ctrl-D rotates the antenna to the calculated bearing.

@df7cb

df7cb commented Jan 12, 2025

Copy link
Copy Markdown
Contributor Author

It works for me, but there's a few open ends:

  • hitting ESC should probably stop the rotator as well
  • so far, Ctrl-D works in the call input field only, but at least the exchange input should be covered as well
  • is Ctrl-D ("direction") the best key? Ctrl-R ("rotate") and Ctrl-Q (QTC) are already taken

Comments, feedback?

Comment thread src/main.c Outdated
Comment thread src/qrb.c Outdated

if (pfx_index != my.countrynr && 0 == get_qrb(&range, &bearing)) {

pthread_mutex_lock(&tlf_rot_mutex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a mutex for rot?
rig controls are called from both threads (main + background), but rot looks to be called from main only.

another question: does rot_set_position() just send a message to the rotator and doesn't wait for it to actually reach to requested position?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need the mutex now, but I would think it's safer to include it. New code might violate the assumption.

set_position just starts the rotation. You wouldn't want the rest of the program to halt for a minute while the antenna is turning...

Thanks for the review, will fix the variable init later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do hamlib guarantee that you can call functions for rig control and rotator control at the same time?
Otherwise (as set_position comes back immediately) why not use tlf_rig_mutex for both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rig control and rotator control are talking to different devices, so calling functions at the same time is not a problem.

We could use the same mutex, but... this feels wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw the next step would be to read out the bearing and show it in the UI (I get reminded about this every time I'm using the station from remote), there the mutex might already be required.

Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/qrb.c Outdated

if (pfx_index != my.countrynr && 0 == get_qrb(&range, &bearing)) {

pthread_mutex_lock(&tlf_rot_mutex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do hamlib guarantee that you can call functions for rig control and rotator control at the same time?
Otherwise (as set_position comes back immediately) why not use tlf_rig_mutex for both?

Comment thread src/qrb.c
Comment thread tlf.1.in
@dl1jbe

dl1jbe commented Apr 28, 2025

Copy link
Copy Markdown
Member

Can you please check, where the delete of test/test_rules.c comes from?

@df7cb

df7cb commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

Sorry, I should have pushed this to a different branch...

@df7cb

df7cb commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

I think this is good to go - these are the changes I've been using over the past weeks.

If people agree, I'll do the final polishing and push a rebased version.

@dl1jbe

dl1jbe commented Apr 29, 2025

Copy link
Copy Markdown
Member

I think this is good to go - these are the changes I've been using over the past weeks.

If people agree, I'll do the final polishing and push a rebased version.

Looks mostly good. But can you please have a look at the failing tests? Thanks

@df7cb
df7cb force-pushed the rotator branch 3 times, most recently from 8408dfa to 46afb1a Compare August 29, 2025 19:52
@df7cb

df7cb commented Aug 29, 2025

Copy link
Copy Markdown
Contributor Author

Sorry that it took so long, I always pick this up shortly before a contest, and after a weekend on the air, time is running out to actually submit it. Now I started a bit earlier...

I added the ability to rotate to the long-path direction. Since I was never really happy with Ctrl-D, keys are ^ (short-path) and & (long-path).

Since tests were not happy with hamlib code being in qrb.c, I moved the rotator interface to where the rig interface is living. sendqrg.c doesn't really fit (did it ever fit the rig interface?), but now similar code is in a similar place.

Tests are passing now. I think I addressed all concerns, IMHO the code is good to go now.

@df7cb
df7cb marked this pull request as ready for review August 29, 2025 20:57
@df7cb

df7cb commented Sep 23, 2025

Copy link
Copy Markdown
Contributor Author

Fwiw, I've been using this version of the rotator support in the last contests and for some casual operation. The ^ and & operations (short/long path) worked flawlessly.

Comment thread src/sendqrg.c Outdated
Comment thread src/sendqrg.c Outdated
Comment thread src/sendqrg.c Outdated
Comment thread src/sendqrg.c Outdated
Comment thread src/sendqrg.c Outdated
@dl1jbe

dl1jbe commented Sep 26, 2025

Copy link
Copy Markdown
Member

Sorry, for late comment - was afk for some time.

@df7cb

df7cb commented Nov 2, 2025

Copy link
Copy Markdown
Contributor Author

I finally found the time to do the updates. Sorry for being so slow...

@dl1jbe

dl1jbe commented Nov 7, 2025

Copy link
Copy Markdown
Member

Time is sparse atm. Hope to find time to look into it in coming week. Sorry.

Comment thread test/data.c Outdated

/*-------------------------------------rigctl-------------------------------*/
char rotconf[80];
#ifdef HAVE_LIBHAMLIB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hamlib is mandatory, please drop both checks. It just hasn't been cleaned up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated,

Comment thread src/parse_logcfg.c Outdated
#endif

{"RIGPORT", CFG_STRING_NOCHOMP(rigportname)},
{"ROTPORT", CFG_STRING_NOCHOMP(rotportname)},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CFG_STRING_NOCHOMP is used for RIGPORT due to some backwards compatibility (I'll revisit this, see below). Please use plain (chomping) CFG_STRING.

parse_logcfg.h:

// FIXME: remove NOCHOMPs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, and updated the test file for the new (better) value.

Comment thread src/main.c Outdated
{"import", 'i', 0, 0, "Import Cabrillo file to Tlf format"},
{"no-cluster", 'n', 0, 0, "Start without cluster hookup" },
{"no-rig", 'r', 0, 0, "Start without radio control" },
{"no-rotator", 'R', 0, 0, "Start without radio control" },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes. Fixed.

@dl1jbe

dl1jbe commented Nov 10, 2025

Copy link
Copy Markdown
Member

At the moment I see only one point to think about:

if (pfx->dxcc_ctynr == my.countrynr)
        return; /* rotating to own country does not make much sense */

It may make sense for large countries, but how to find the correct direction by program?
The operator may know the correct direction - are there always manual controls or do we need to provide some solution from TLFs side?

@df7cb

df7cb commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor Author

I just pushed a new version addressing @zcsahok's comments, thanks for the review!

It may make sense for large countries, but how to find the correct direction by program? The operator may know the correct direction - are there always manual controls or do we need to provide some solution from TLFs side?

My next idea was to add "rotate 30° left/right buttons" (for example on [ and ] or < and >), but TBH I'd want the current patch committed first because it's kind of the minimum version of the feature we can then build on.

Other future ideas might be:

  • show current heading (near the TRX frequency)
  • check if MYQRA is already used to compute the beam heading and if not, fix that MYQRA is already used
  • rotate to locator from exchange field

@dl1jbe

dl1jbe commented Nov 11, 2025

Copy link
Copy Markdown
Member

My next idea was to add "rotate 30° left/right buttons" (for example on [ and ] or < and >), but TBH I'd want the current patch committed first because it's kind of the minimum version of the feature we can then build on.

The sounds reasonable.

As a side note: I fear that it will be difficult to find a lot of unused single key codes for additional rotator commands. As it probably will not be used very often a two key combination with a common first key may be appropriate (like '.' for filtering the multi infos).

Other future ideas might be:
* show current heading (near the TRX frequency)
* check if MYQRA is already used to compute the beam heading and if not, fix that
* rotate to locator from exchange field

At least the first point will be very useful.

This adds rotator support. Configuration is done exactly like rig
support with ROTATOR_CONTROL, ROTMODEL, ROTSPEED and ROTPORT.

Two new keybindings are introduced: ^ (think "arrow") rotates towards
the country of the current call, and & (the key right of ^ on US
keyboards) rotates to the long-path direction. If the current call is
from the own country, no rotation is done.
@df7cb

df7cb commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

Rebased.

@dl1jbe
dl1jbe merged commit e3b7cb8 into Tlf:master Nov 17, 2025
2 checks passed
@dl1jbe

dl1jbe commented Nov 17, 2025

Copy link
Copy Markdown
Member

Thanks for the work Christoph

@df7cb

df7cb commented Nov 17, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews!

@df7cb
df7cb deleted the rotator branch November 17, 2025 21:20
zcsahok pushed a commit to zcsahok/tlf that referenced this pull request Jul 31, 2026
This adds rotator support. Configuration is done exactly like rig
support with ROTATOR_CONTROL, ROTMODEL, ROTSPEED and ROTPORT.

Two new keybindings are introduced: ^ (think "arrow") rotates towards
the country of the current call, and & (the key right of ^ on US
keyboards) rotates to the long-path direction. If the current call is
from the own country, no rotation is done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants