10 Feb 2006 18:16
Re: Rig list from Python
Martin, AA6E <martin.ewing <at> gmail.com>
2006-02-10 17:16:09 GMT
2006-02-10 17:16:09 GMT
Hi, Hamish,
Glad to see there are at least two of us interested in Python apps. I
am just getting started with Python hamlib too. I haven't figured out
the 'foreach' function, but I don't think it's necessary. You may say
it's a hack, but I think it's a neat use of Python. Here's my little
program:
import Hamlib
def isRIG_MODEL(s):
return s.startswith("RIG_MODEL")
rig_models = filter(isRIG_MODEL, dir(Hamlib))
rig_codes = map(lambda x: Hamlib.__dict__[x], rig_models)
for i in range(len(rig_models)):
print rig_models[i], rig_codes[i]
This gets you a complete list of the magic rig codes, and you can use
it to check the capabilities -- which are still a mystery to me!
Basically, Hamlib's own symbol dictionary has all the information you
want.
73 Martin AA6E
On 2/10/06, Hamish Moffatt <hamish <at> cloud.net.au> wrote:
> Hi,
>
> I'm new to using Hamlib. I want to use it in a Python application.
> I'm running on Debian and we have a working python2.3-hamlib3 package
> (thanks Joop).
>
> Firstly I want to get a list of all the supported rigs so I can present
> it to the user. Looking at the API documentation, the riglist.h page
> says there is a function called foreach_opened_rig(), although it looks
> like that is not right.
>
> The riglist.h source says there is a rig_list_foreach function which
> takes a pointer to a function to call. However I don't think this is
> usable from Python? I can't make Python happy with the definition of my
> callback.
>
> There is a nasty hack in that I can get a list of all the RIG_MODEL_*
> constants defined at runtime (using dir(Hamlib)) but then I don't know
> how to get details about each one, like a user-presentable name.
>
> Suggestions would be most welcome.
>
> thanks,
> Hamish
> --
> Hamish Moffatt VK3SB <hamish <at> debian.org> <hamish <at> cloud.net.au>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Hamlib-developer mailing list
> Hamlib-developer <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hamlib-developer
>
--
martin.ewing <at> gmail.com
http://blog.aa6e.net
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
RSS Feed