Skip to content

Commit

Permalink
Add sending CW via rigctld.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbridak committed May 21, 2024
1 parent 7844711 commit 1ce9ea6
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 35 deletions.
78 changes: 66 additions & 12 deletions fdlogger/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,95 +1215,149 @@ def sendf1(self):
self.infoline.setText(f"Sending {self.process_macro(self.F1.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F1.text()
self.cw.sendcw(f"{self.process_macro(self.F1.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F1.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F1.toolTip())} ")

def sendf2(self):
"""send f2"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F2.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F2.text()
self.cw.sendcw(f"{self.process_macro(self.F2.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F2.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F2.toolTip())} ")

def sendf3(self):
"""send f3"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F3.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F3.text()
self.cw.sendcw(f"{self.process_macro(self.F3.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F3.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F3.toolTip())} ")

def sendf4(self):
"""send f4"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F4.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F4.text()
self.cw.sendcw(f"{self.process_macro(self.F4.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F4.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F4.toolTip())} ")

def sendf5(self):
"""send f5"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F5.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F5.text()
self.cw.sendcw(f"{self.process_macro(self.F5.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F5.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F5.toolTip())} ")

def sendf6(self):
"""send f6"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F6.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F6.text()
self.cw.sendcw(f"{self.process_macro(self.F6.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F6.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F6.toolTip())} ")

def sendf7(self):
"""send f7"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F7.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F7.text()
self.cw.sendcw(f"{self.process_macro(self.F7.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F7.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F7.toolTip())} ")

def sendf8(self):
"""send f8"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F8.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F8.text()
self.cw.sendcw(f"{self.process_macro(self.F8.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F8.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F8.toolTip())} ")

def sendf9(self):
"""send f9"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F9.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F9.text()
self.cw.sendcw(f"{self.process_macro(self.F9.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(f"{self.process_macro(self.F9.toolTip())} ")
else:
self.cw.sendcw(f"{self.process_macro(self.F9.toolTip())} ")

def sendf10(self):
"""send f10"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F10.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F10.text()
self.cw.sendcw(f"{self.process_macro(self.F10.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(
f"{self.process_macro(self.F10.toolTip())} "
)
else:
self.cw.sendcw(f"{self.process_macro(self.F10.toolTip())} ")

def sendf11(self):
"""send f11"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F11.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F11.text()
self.cw.sendcw(f"{self.process_macro(self.F11.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(
f"{self.process_macro(self.F11.toolTip())} "
)
else:
self.cw.sendcw(f"{self.process_macro(self.F11.toolTip())} ")

def sendf12(self):
"""send f12"""
if self.cw is not None:
self.infoline.setText(f"Sending {self.process_macro(self.F12.toolTip())}")
if self.preference.get("send_n1mm_packets"):
self.n1mm.radio_info["FunctionKeyCaption"] = self.F12.text()
self.cw.sendcw(f"{self.process_macro(self.F12.toolTip())} ")
if self.cw.servertype == 3:
if self.cat_control is not None:
self.cat_control.sendcw(
f"{self.process_macro(self.F12.toolTip())} "
)
else:
self.cw.sendcw(f"{self.process_macro(self.F12.toolTip())} ")

def clearinputs(self):
"""clear text entry fields"""
Expand Down
59 changes: 36 additions & 23 deletions fdlogger/data/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -520,48 +520,48 @@ color: rgb(211, 215, 207);</string>
<string>CW</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>CW_Address:</string>
<string>CW_Port:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="cwip_field">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>CW_Port:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<string>localhost</string>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="usecwdaemon_radioButton">
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="cwport_field">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
</property>
<property name="text">
<string>cwdaemon</string>
<string>6789</string>
</property>
</widget>
</item>
Expand All @@ -578,45 +578,58 @@ color: rgb(211, 215, 207);</string>
</property>
</widget>
</item>
<item row="2" column="2" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="radioButton_5">
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="usecwdaemon_radioButton">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>None</string>
<string>cwdaemon</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="cwport_field">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="inputMethodHints">
<set>Qt::ImhDigitsOnly</set>
<property name="text">
<string>CW_Address:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="3" alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="radioButton_5">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>6789</string>
<string>None</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="cwip_field">
<item row="2" column="2">
<widget class="QRadioButton" name="usecat4cw_radioButton">
<property name="font">
<font>
<family>JetBrains Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>localhost</string>
<string>CAT</string>
</property>
</widget>
</item>
Expand Down
29 changes: 29 additions & 0 deletions fdlogger/lib/cat_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CAT interface abstraction"""

import logging
import socket
import xmlrpc.client
Expand Down Expand Up @@ -64,6 +65,34 @@ def __initialize_rigctrld(self):
self.online = False
self.logger.debug("%s", exception)

def sendcw(self, texttosend):
"""..."""
self.logger.debug(f"{texttosend=} {self.interface=}")
if self.interface == "flrig":
...
return
if self.interface == "rigctld":
self.sendcwrigctl(texttosend)

def sendcwrigctl(self, texttosend):
"""..."""
if self.rigctrlsocket:
try:
self.online = True
self.rigctrlsocket.send(bytes(f"b{texttosend}\n", "utf-8"))
_ = self.rigctrlsocket.recv(1024).decode().strip()
return True
except socket.error as exception:
self.online = False
self.logger.debug("setvfo_rigctld: %s", f"{exception}")
self.rigctrlsocket = None
return False
self.__initialize_rigctrld()
return False

def sendcwxmlrpc(self, texttosend):
"""..."""

def get_vfo(self) -> str:
"""Poll the radio for current vfo using the interface"""
vfo = ""
Expand Down
5 changes: 5 additions & 0 deletions fdlogger/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def setup(self):
self.usepywinkeyer_radioButton.setChecked(
bool(self.preference.get("cwtype") == 2)
)
self.usecat4cw_radioButton.setChecked(
bool(self.preference.get("cwtype") == 3)
)
self.connect_to_server.setChecked(bool(self.preference.get("useserver")))
self.multicast_group.setText(
str(self.preference.get("multicast_group", ""))
Expand Down Expand Up @@ -110,6 +113,8 @@ def save_changes(self):
self.preference["cwtype"] = 1
if self.usepywinkeyer_radioButton.isChecked():
self.preference["cwtype"] = 2
if self.usecat4cw_radioButton.isChecked():
self.preference["cwtype"] = 3
self.preference["useserver"] = self.connect_to_server.isChecked()
self.preference["multicast_group"] = self.multicast_group.text()
self.preference["multicast_port"] = self.multicast_port.text()
Expand Down

0 comments on commit 1ce9ea6

Please sign in to comment.