Skip to content
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

Use Hamlib for PTT control #19

Open
tmiw opened this issue Apr 26, 2022 · 0 comments
Open

Use Hamlib for PTT control #19

tmiw opened this issue Apr 26, 2022 · 0 comments

Comments

@tmiw
Copy link
Collaborator

tmiw commented Apr 26, 2022

The current codebase has an IRadio interface as well as classes for each major radio manufacturer (e.g. RadioKenwood, RadioIcom, etc.) Eventually we'd like to remove those and replace them with a HamlibRadio class that interfaces with the Hamlib library for CAT/PTT control. This can be done by doing the following:

  1. Create a Hamlib project in the solution to store the wrapper C# interface. This wrapper provides a modern interface to Hamlib and hides the various required P/Invoke calls and marshalling.
  2. Build 32 and 64 bit versions of Hamlib using MinGW (Hamlib unfortunately doesn't like being compiled by Visual Studio). Example of required command in the Hamlib source tree to set this up: ./configure --host=i686-w64-mingw32 --disable-static
  3. For future use, also build a .dylib for macOS. ./configure from above doesn't need --host here but we should make this a universal ARM/Intel binary. This example from the FreeDV project on how to build a universal version of Hamlib is useful.
  4. Update the Hamlib project/Paclink solution to store the DLLs created in (2) and (3) and copy them to the final build location for packaging by the installer. The copying to the final build location would only be needed for Windows and (future) Mac builds as Linux can use whatever the user's distro provides for the hamlib package.
  5. Update the wrapper classes so that they can figure out which version of the DLL or .dylib to load. Useful documentation from Microsoft on how to accomplish that is here.
  6. Update the Paclink project to properly display the radios available from Hamlib when the user needs to select one for CAT control, as well as create RadioHamlib when attempting a connection to the gateway.

Advantages of going with Hamlib instead of our own code:

  1. Much wider support for radios overall. In addition, adding additional radios would be a simple matter of rebuilding the DLLs and .dylib.
  2. We're able to take advantage of much more extensive testing of more radios done by users from a wide variety of ham radio related projects.

Disadvantages:

  1. Needing to use P/Invoke adds some complexity. If we were able to build Hamlib in Visual Studio, it may be possible to build a C++ .NET assembly using both managed and unmanaged code to hide that complexity.
  2. Possible licensing issues. Hamlib is LGPL, so we'll need to look at that closely to make sure there are no issues.
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

No branches or pull requests

1 participant