Re: [Hamlib-developer] Hamlib vs Python
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Black M. <mdb...@ya...> - 2024-10-27 14:13:33
|
I made an issue for improving the python API -- it is lacking in many functions. But it will be quite a while before I have chance to improve this... You can subscribe to this issue and you'll get notification when updates are done to fix that....could be many months...no promises.... https://github.com/Hamlib/Hamlib/issues/1624 But rigctld can provide all the information. Here's an example to get frequency and split status import socket # Hamlib rigctld configuration HOST = 'localhost' # Change to the IP of the machine running rigctld if needed PORT = 4532 # Default port for rigctld def send_command(command): """Sends a command to rigctld and returns the response.""" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) s.sendall(command.encode() + b'\n') response = s.recv(1024).decode().strip() return response def get_frequency(): """Gets the frequency from rigctld.""" return send_command('f') def get_mode(): """Gets the mode from rigctld.""" return send_command('m') def get_split_status(): """Gets the split status from rigctld and parses the response.""" response = send_command('s') parts = response.split() if len(parts) == 2: split_on = parts[0] # Split on/off status transmit_vfo = parts[1] # Transmit VFO else: split_on = "Unknown" transmit_vfo = "Unknown" return split_on, transmit_vfo # Fetch and display frequency, mode, and split status frequency = get_frequency() mode = get_mode() split_on, transmit_vfo = get_split_status() print(f"Frequency: {frequency} Hz") print(f"Mode: {mode}") print(f"Split Status: {'On' if split_on == '1' else 'Off'}") print(f"Transmit VFO: {transmit_vfo}") Mike W9MDB |