-
Notifications
You must be signed in to change notification settings - Fork 32
Hamlib rotator support #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
It works for me, but there's a few open ends:
Comments, feedback? |
src/qrb.c
Outdated
|
||
if (pfx_index != my.countrynr && 0 == get_qrb(&range, &bearing)) { | ||
|
||
pthread_mutex_lock(&tlf_rot_mutex); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/qrb.c
Outdated
|
||
if (pfx_index != my.countrynr && 0 == get_qrb(&range, &bearing)) { | ||
|
||
pthread_mutex_lock(&tlf_rot_mutex); |
There was a problem hiding this comment.
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?
Can you please check, where the delete of test/test_rules.c comes from? |
Sorry, I should have pushed this to a different branch... |
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 |
8408dfa
to
46afb1a
Compare
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 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. |
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.
Fwiw, I've been using this version of the rotator support in the last contests and for some casual operation. The |
strncpy(my_rot->state.rotport.pathname, rotportname, | ||
TLFFILPATHLEN - 1); | ||
|
||
my_rot->state.rotport.parm.serial.rate = serial_rate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retcode = rot_open(my_rot); | ||
|
||
if (retcode != RIG_OK) { | ||
TLF_LOG_WARN("rot_open: %s", rigerror(retcode)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the main GUI is not initialized TLF_LOG_WARN will not work correctly. Please use show_rigerror() instead (see init_tlf_rig()).
Btw, in newer hamlib version rigerror() does return the accumulated error messages as far, not the error message for the last error (see discussion in last weeks on hamlib mailing list). If needed use tlf_rigerror() instead which respects the different implementations for the problem.
pthread_mutex_unlock(&tlf_rot_mutex); | ||
|
||
if (retcode != RIG_OK) { | ||
TLF_LOG_WARN("Rotator get position error: %s", rigerror(retcode)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above wrt rigerror()
pthread_mutex_unlock(&tlf_rot_mutex); | ||
|
||
if (retcode != RIG_OK) { | ||
TLF_LOG_WARN("Problem with setting rotator position: %s", rigerror(retcode)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
pthread_mutex_unlock(&tlf_rot_mutex); | ||
|
||
if (retcode != RIG_OK) { | ||
TLF_LOG_WARN("Rotator stop error: %s", rigerror(retcode)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again see above
Sorry, for late comment - was afk for some time. |
This adds Hamlib rotator support to tlf. When a call or prefix is entered, pressing Ctrl-D rotates the antenna to the calculated bearing.