Raw NIF surface over the Hamlib C API (via the hlx_* C shim and a Rustler
crate at native/hamlib_nif).
This is the low-level binding — prefer Hamlib.Rig for a managed,
process-owned interface. Every function here corresponds 1:1 to a shim call.
Return shapes
Operations that don't return data →
:ok | {:error, {code, reason}}get_freq/1→{:ok, hz} | {:error, {code, reason}}get_mode/1→{:ok, {mode_string, passband_hz}} | {:error, …}get_ptt/1→{:ok, boolean} | {:error, …}
code is the integer Hamlib error (negative), reason its text. A handle is
an opaque resource from init/1; the BEAM frees the underlying rig when the
handle is garbage-collected (close + cleanup), even on owner crash.
Lifecycle
{:ok, h} = Hamlib.Nif.init(model) # allocate (no I/O)
:ok = Hamlib.Nif.set_conf(h, "rig_pathname", path)
:ok = Hamlib.Nif.set_conf(h, "serial_speed", "19200")
:ok = Hamlib.Nif.open(h) # opens the port
...
:ok = Hamlib.Nif.close(h)
Summary
Types
{hamlib_error_code, reason_string}.
Functions
Close the rig port (rig stays initialized; reopenable).
Get frequency in Hz from the current VFO.
Get current {mode_string, passband_hz}.
Get PTT state as a boolean.
Allocate + initialize a rig for a Hamlib model number. No port I/O.
Open the configured rig port.
Set a Hamlib config token by name (e.g. "rig_pathname", "serial_speed", "ptt_type").
Set Hamlib's global debug verbosity (0 = silent … 5 = trace).
Set frequency in Hz on the current VFO.
Set mode by string + passband Hz (0 = rig's normal width).
Set PTT: true = transmit, false = receive.
Hamlib library version string.
Types
Functions
Close the rig port (rig stays initialized; reopenable).
Get frequency in Hz from the current VFO.
Get current {mode_string, passband_hz}.
Get PTT state as a boolean.
Allocate + initialize a rig for a Hamlib model number. No port I/O.
Open the configured rig port.
Set a Hamlib config token by name (e.g. "rig_pathname", "serial_speed", "ptt_type").
@spec set_debug(0..5) :: :ok
Set Hamlib's global debug verbosity (0 = silent … 5 = trace).
Set frequency in Hz on the current VFO.
Set mode by string + passband Hz (0 = rig's normal width).
Set PTT: true = transmit, false = receive.
@spec version() :: String.t()
Hamlib library version string.