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

@mbridak trying to fix flrig just a bit. #213

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions not1mm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,16 @@ def change_to_band_and_mode(self, band: int, mode: str) -> None:
-------
Nothing
"""

if mode in ["CW", "SSB", "RTTY"]:
freq = fakefreq(str(band), mode)
self.change_freq(freq)
vfo = float(freq)
vfo = int(vfo * 1000)
if mode == "CW":
mode = self.rig_control.last_cw_mode
if mode == "RTTY":
mode = self.rig_control.last_data_mode
self.change_mode(mode, intended_freq=vfo)

def quit_app(self) -> None:
Expand Down Expand Up @@ -3315,10 +3320,9 @@ def change_mode(self, mode: str, intended_freq=None) -> None:
-------
None
"""

if mode in ("CW", "CW-U", "CW-L", "CWR"):
if self.rig_control and self.rig_control.online:
self.rig_control.set_mode("CW")
self.rig_control.set_mode(self.rig_control.last_cw_mode)
if self.pref.get("cwtype") == 3 and self.rig_control is not None:
if self.rig_control.interface == "flrig":
self.cwspeed_spinbox_changed()
Expand All @@ -3332,9 +3336,18 @@ def change_mode(self, mode: str, intended_freq=None) -> None:
self.clearinputs()
self.read_cw_macros()
return
if mode == "RTTY":
if mode in (
"DIGI-U",
"DIGI-L",
"RTTY",
"RTTY-R",
"LSB-D",
"USB-D",
"AM-D",
"FM-D",
):
if self.rig_control and self.rig_control.online:
self.rig_control.set_mode("RTTY")
self.rig_control.set_mode(self.rig_control.last_data_mode)
else:
self.radio_state["mode"] = "RTTY"
self.setmode("RTTY")
Expand Down Expand Up @@ -3548,6 +3561,7 @@ def poll_radio(self, the_dict):
Passing in a dictionary object with the
vfo freq, mode, bandwidth, and online state of the radio.
"""
logger.debug(f"{the_dict=}")
self.set_radio_icon(0)
info_dirty = False
vfo = the_dict.get("vfoa", "")
Expand Down Expand Up @@ -3645,7 +3659,7 @@ def edit_cw_macros(self) -> None:
-------
None
"""
if self.radio_state.get("mode") == "CW":
if self.radio_state.get("mode") in ("CW", "CW-L", "CW-R", "CWR"):
macro_file = "cwmacros.txt"
elif self.radio_state.get("mode") in (
"RTTY",
Expand All @@ -3659,6 +3673,7 @@ def edit_cw_macros(self) -> None:
"RTTYR",
"PKTLSB",
"PKTUSB",
"FSK",
):
macro_file = "rttymacros.txt"
else:
Expand Down Expand Up @@ -3687,7 +3702,11 @@ def read_cw_macros(self) -> None:
temp directory this is running from... In theory.
"""

if self.radio_state.get("mode") == "CW":
if self.radio_state.get("mode") in (
"CW",
"CW-L",
"CW-R",
):
macro_file = "cwmacros.txt"
elif self.radio_state.get("mode") in (
"RTTY",
Expand Down
27 changes: 19 additions & 8 deletions not1mm/lib/cat_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def __init__(self, interface: str, host: str, port: int) -> None:
self.__initialize_rigctrld()
elif self.interface == "fake":
self.online = True
logger.debug("Using Fake Rig")
return

def __initialize_rigctrld(self):
Expand Down Expand Up @@ -223,7 +224,9 @@ def __getvfo_flrig(self) -> str:
"""Poll the radio using flrig"""
try:
self.online = True
return self.server.rig.get_vfo()
vfo_value = self.server.rig.get_vfo()
logger.debug(f"{vfo_value=}")
return vfo_value
except (
ConnectionRefusedError,
xmlrpc.client.Fault,
Expand All @@ -232,7 +235,7 @@ def __getvfo_flrig(self) -> str:
http.client.ResponseNotReady,
) as exception:
self.online = False
logger.debug("getvfo_flrig: %s", f"{exception}")
logger.debug(f"{exception=}")
return ""

def __getvfo_rigctld(self) -> str:
Expand All @@ -244,7 +247,7 @@ def __getvfo_rigctld(self) -> str:
return self.__get_serial_string().strip()
except socket.error as exception:
self.online = False
logger.debug("getvfo_rigctld: %s", f"{exception}")
logger.debug(f"{exception=}")
self.rigctrlsocket = None
return ""

Expand All @@ -268,7 +271,9 @@ def __getmode_flrig(self) -> str:
# 7300 ['LSB', 'USB', 'AM', 'FM', 'CW', 'CW-R', 'RTTY', 'RTTY-R', 'LSB-D', 'USB-D', 'AM-D', 'FM-D']
try:
self.online = True
return self.server.rig.get_mode()
mode_value = self.server.rig.get_mode()
logger.debug(f"{mode_value=}")
return mode_value
except (
ConnectionRefusedError,
xmlrpc.client.Fault,
Expand All @@ -282,7 +287,7 @@ def __getmode_flrig(self) -> str:

def __getmode_rigctld(self) -> str:
"""Returns mode vai rigctld"""
# QMX 'AM CW USB LSB RTTY FM CWR RTTYR'
# QMX 'DIGI-U DIGI-L CW-U CW-L' or 'LSB', 'USB', 'CW', 'FM', 'AM', 'FSK'
# 7300 'AM CW USB LSB RTTY FM CWR RTTYR PKTLSB PKTUSB FM-D AM-D'
if self.rigctrlsocket:
try:
Expand Down Expand Up @@ -316,6 +321,7 @@ def __getbw_flrig(self):
try:
self.online = True
bandwidth = self.server.rig.get_bw()
logger.debug(f"{bandwidth=}")
return bandwidth[0]
except (
ConnectionRefusedError,
Expand Down Expand Up @@ -438,7 +444,9 @@ def __get_mode_list_flrig(self):
"""Returns list of modes supported by the radio"""
try:
self.online = True
return self.server.rig.get_modes()
mode_list = self.server.rig.get_modes()
logger.debug(f"{mode_list=}")
return mode_list
except (
ConnectionRefusedError,
xmlrpc.client.Fault,
Expand Down Expand Up @@ -529,7 +537,10 @@ def __setmode_flrig(self, mode: str) -> bool:
"""Sets the radios mode"""
try:
self.online = True
return self.server.rig.set_mode(mode)
logger.debug(f"{mode=}")
set_mode_result = self.server.rig.set_mode(mode)
logger.debug(f"self.server.rig.setmode(mode) = {set_mode_result}")
return set_mode_result
except (
ConnectionRefusedError,
xmlrpc.client.Fault,
Expand All @@ -538,7 +549,7 @@ def __setmode_flrig(self, mode: str) -> bool:
http.client.ResponseNotReady,
) as exception:
self.online = False
logger.debug("setmode_flrig: %s", f"{exception}")
logger.debug(f"{exception=}")
return False

def __setmode_rigctld(self, mode: str) -> bool:
Expand Down
24 changes: 24 additions & 0 deletions not1mm/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ class Radio(QObject):
host = None
port = None
modes = ""
cw_list = ["CW", "CW-L", "CW-U", "CWR"]
rtty_list = [
"RTTY",
"DIGI-L",
"PKTLSB",
"LSB-D",
]
last_data_mode = "RTTY"
last_cw_mode = "CW"
last_ph_mode = "SSB"

def __init__(self, interface: str, host: str, port: int) -> None:
super().__init__()
Expand All @@ -49,6 +58,15 @@ def run(self):
self.cat = CAT(self.interface, self.host, self.port)
self.online = self.cat.online
self.modes = self.cat.get_mode_list()
for pos_cw in self.cw_list:
if pos_cw in self.modes:
self.last_cw_mode = pos_cw
break
for pos_rtty in self.rtty_list:
if pos_rtty in self.modes:
self.last_data_mode = pos_rtty
break

except ConnectionResetError:
...
while not self.time_to_quit:
Expand Down Expand Up @@ -97,6 +115,7 @@ def store_last_data_mode(self, the_mode: str = ""):
"USB-D",
"AM-D",
"FM-D",
"FSK",
"DIGI-U",
"DIGI-L",
"RTTYR",
Expand All @@ -106,6 +125,11 @@ def store_last_data_mode(self, the_mode: str = ""):
if the_mode in datamodes:
self.last_data_mode = the_mode

cwmodes = ["CW", "CW-L", "CW-U", "CWR"]

if the_mode in cwmodes:
self.last_cw_mode = the_mode

def sendcw(self, texttosend):
"""..."""
logger.debug(f"Send CW: {texttosend}")
Expand Down
Loading