Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e8a0846f7 | ||
|
|
fb888a2e08 |
@@ -1,3 +1,18 @@
|
||||
Quisk Version 4.2.40 November 2024
|
||||
===================================
|
||||
Python 3.13 eliminated the telnetlib module, so I wrote a replacement. I fixed a bug in window sizing.
|
||||
If you use the Dx Cluster feature, please report any problems. Dx Cluster used to use the telnetlib module
|
||||
but is now new code.
|
||||
|
||||
I updated the install to Python 3.13. Please report any problems with Python 3.13.
|
||||
|
||||
Quisk Version 4.2.39 October 2024
|
||||
==================================
|
||||
I added an optional Hardware method PollGuiControl(self). If you define this in your Hardware file,
|
||||
the GUI thread will call it frequently. It can be used to set PTT from your hardware.
|
||||
|
||||
I am trying to work around a wxPython quirk that causes mouse wheel tuning to fail. Please test.
|
||||
|
||||
Quisk Version 4.2.38 September 2024
|
||||
====================================
|
||||
This is a bugfix release. I fixed a bug in the Hamlib serial port when using a physical TTY instead
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
#Quisk version 4.2.38
|
||||
#Quisk version 4.2.40
|
||||
from .quisk import main
|
||||
|
||||
+87
-39
@@ -1,9 +1,9 @@
|
||||
from __future__ import absolute_import
|
||||
# This code was contributed by Christof, DJ4CM. Many Thanks!!
|
||||
# Modified November 2024 by N2ADR to remove deprecated telnetlib module.
|
||||
|
||||
import threading
|
||||
import socket
|
||||
import time
|
||||
import telnetlib
|
||||
import quisk_conf_defaults as conf
|
||||
|
||||
class DxEntry:
|
||||
@@ -81,61 +81,109 @@ class DxEntry:
|
||||
|
||||
class DxCluster(threading.Thread):
|
||||
def __init__(self):
|
||||
self.do_init = 1
|
||||
self.error = 'Starting'
|
||||
self.dxSpots = []
|
||||
threading.Thread.__init__(self)
|
||||
self.doQuit = threading.Event()
|
||||
self.dxSpots = []
|
||||
self.doQuit.clear()
|
||||
self.dxLock = threading.Lock()
|
||||
self.addr = conf.dxClHost + ':' + str(conf.dxClPort)
|
||||
self.msg_no_spots = "No DX Cluster data from " + self.addr
|
||||
self.msg_one_spot = '1 DX spot received from ' + self.addr
|
||||
self.msg_spots = ' DX spots received from ' + self.addr
|
||||
|
||||
def run(self):
|
||||
self.telnetInit()
|
||||
self.telnetConnect()
|
||||
if self.error:
|
||||
self.sock.close()
|
||||
return
|
||||
while not self.doQuit.isSet():
|
||||
try:
|
||||
self.telnetRead()
|
||||
by = self.sock.recv(1024)
|
||||
except TimeoutError:
|
||||
continue
|
||||
except:
|
||||
self.tn.close()
|
||||
time.sleep(20)
|
||||
by = b''
|
||||
if by:
|
||||
with self.dxLock:
|
||||
self.bytes += by
|
||||
else:
|
||||
self.sock.close()
|
||||
self.error = "Restarting " + self.addr
|
||||
time.sleep(2)
|
||||
if not self.doQuit.isSet():
|
||||
self.telnetConnect()
|
||||
self.tn.close()
|
||||
|
||||
def setListener (self, listener):
|
||||
self.listener = listener
|
||||
if self.error:
|
||||
self.sock.close()
|
||||
return
|
||||
self.sock.close()
|
||||
|
||||
def telnetInit(self):
|
||||
self.tn = telnetlib.Telnet()
|
||||
|
||||
def telnetConnect(self):
|
||||
self.bytes = bytearray(0)
|
||||
self.error = 'Starting'
|
||||
self.sock = socket.socket()
|
||||
self.sock.settimeout(20)
|
||||
try:
|
||||
self.sock.connect( (conf.dxClHost, conf.dxClPort) )
|
||||
except:
|
||||
self.error = "Failed to connect to " + self.addr
|
||||
return
|
||||
self.sock.settimeout(1)
|
||||
for i in range(10):
|
||||
try:
|
||||
self.tn.open(conf.dxClHost, conf.dxClPort, 10)
|
||||
self.tn.read_until(b"login:", 10)
|
||||
self.tn.write(conf.user_call_sign.encode('utf-8', errors='ignore') + b"\n") # user_call_sign may be Unicode
|
||||
break
|
||||
self.bytes += self.sock.recv(1024)
|
||||
except:
|
||||
time.sleep(0.5)
|
||||
pass
|
||||
if b"login:" in self.bytes:
|
||||
break
|
||||
else:
|
||||
self.error = 'No "login:" prompt from ' + self.addr
|
||||
return
|
||||
self.sock.sendall(conf.user_call_sign.encode('utf-8', errors='ignore') + b"\r\n")
|
||||
if conf.dxClPassword:
|
||||
self.tn.read_until(b"Password: ")
|
||||
self.tn.write(conf.dxClPassword.encode('utf-8', errors='ignore') + b"\n")
|
||||
for i in range(10):
|
||||
try:
|
||||
self.bytes += self.sock.recv(1024)
|
||||
except:
|
||||
pass
|
||||
if b"Password:" in self.bytes:
|
||||
break
|
||||
else:
|
||||
self.error = 'No "Password:" prompt from ' + self.addr
|
||||
return
|
||||
self.sock.sendall(conf.dxClPassword.encode('utf-8', errors='ignore') + b"\r\n")
|
||||
self.error = ''
|
||||
self.bytes = bytearray(0)
|
||||
|
||||
def telnetRead(self):
|
||||
message = self.tn.read_until(b'\n', 60).decode(encoding='utf-8', errors='replace')
|
||||
if self.doQuit.isSet() == False:
|
||||
dxEntry = DxEntry();
|
||||
if dxEntry.parseMessage(message):
|
||||
for i, listElement in enumerate(self.dxSpots):
|
||||
if (listElement.equal(dxEntry)):
|
||||
listElement.join (dxEntry)
|
||||
return
|
||||
if listElement.isExpired():
|
||||
del (self.dxSpots[i])
|
||||
self.dxSpots.append(dxEntry)
|
||||
if self.listener:
|
||||
self.listener()
|
||||
|
||||
def getHost(self):
|
||||
return self.tn.host + ':' + str(self.tn.port)
|
||||
def Poll(self):
|
||||
with self.dxLock:
|
||||
index = self.bytes.find(b"\n")
|
||||
if index >= 0:
|
||||
message = self.bytes[0:index + 1]
|
||||
self.bytes = self.bytes[index + 1:]
|
||||
else:
|
||||
return
|
||||
message = message.decode(encoding='utf-8', errors='replace')
|
||||
dxEntry = DxEntry()
|
||||
if dxEntry.parseMessage(message):
|
||||
for i, listElement in enumerate(self.dxSpots):
|
||||
if (listElement.equal(dxEntry)):
|
||||
listElement.join (dxEntry)
|
||||
return True
|
||||
if listElement.isExpired():
|
||||
del (self.dxSpots[i])
|
||||
self.dxSpots.append(dxEntry)
|
||||
return True
|
||||
|
||||
def stop(self):
|
||||
self.doQuit.set()
|
||||
|
||||
def dxStatus(self):
|
||||
if self.error:
|
||||
return self.error
|
||||
nSpots = len(self.dxSpots)
|
||||
if nSpots == 0:
|
||||
return self.msg_no_spots
|
||||
elif nSpots == 1:
|
||||
return self.msg_one_spot
|
||||
return str(nSpots) + self.msg_spots
|
||||
|
||||
@@ -402,6 +402,8 @@ class Hardware(BaseHardware):
|
||||
if do_tx:
|
||||
try:
|
||||
self.rx_udp_socket.send(s)
|
||||
if DEBUG:
|
||||
self.PrintStatus(' Send', self.want_udp_status)
|
||||
except:
|
||||
pass
|
||||
def SetVNA(self, key_down=None, vna_start=None, vna_stop=None, vna_count=None, do_tx=False):
|
||||
|
||||
@@ -91,6 +91,8 @@ class Hardware(BaseHardware):
|
||||
conf.si570_direct_control = False
|
||||
conf.si570_xtal_freq = 114285000
|
||||
conf.repeater_delay = 0.25
|
||||
self.ptt_count = 200
|
||||
self.ptt_on = 0
|
||||
BaseHardware.__init__(self, app, conf)
|
||||
QS.set_sparams(multus_cw_samples=1)
|
||||
self.use_softrock = True
|
||||
@@ -104,6 +106,13 @@ class Hardware(BaseHardware):
|
||||
self.usb_dev.ctrl_transfer(OUT, address, self.si570_i2c_address + 0x700, 0, message)
|
||||
if DEBUG:
|
||||
print ("USB send to 0x%X" % address, message)
|
||||
def TransferIn(self, address, length):
|
||||
if self.usb_dev:
|
||||
recv = self.usb_dev.ctrl_transfer(IN, address, self.si570_i2c_address + 0x700, 0, length)
|
||||
if DEBUG:
|
||||
print ("USB receive from 0x%X" % address, recv)
|
||||
return recv
|
||||
return None
|
||||
def open(self):
|
||||
text = BaseHardware.open(self)
|
||||
self.InitKeyer()
|
||||
@@ -120,8 +129,20 @@ class Hardware(BaseHardware):
|
||||
print ("Mode is not CW")
|
||||
self.TransferOut(0x70, cw_mode)
|
||||
return ret
|
||||
def PollCwKey(self): # Called frequently by Quisk to check the CW key status
|
||||
def PollCwKey(self): # Called frequently from the sound thread to check the CW key status
|
||||
return # Quisk is always in Rx
|
||||
def PollGuiControl(self): # Called frequently from the GUI thread
|
||||
self.ptt_count -= 1
|
||||
if self.ptt_count <= 0:
|
||||
self.ptt_count = 200
|
||||
reply = self.TransferIn(0xA5, 1)
|
||||
if DEBUG:
|
||||
print ("PollGuiControl got", reply)
|
||||
if reply:
|
||||
ptt = reply[0] # This is 255 for error
|
||||
if ptt in (0, 1) and ptt != self.ptt_on:
|
||||
self.ptt_on = ptt
|
||||
self.application.pttButton.SetValue(ptt, True)
|
||||
def InitKeyer(self):
|
||||
# Initialize the keyer parameters
|
||||
conf = self.conf
|
||||
|
||||
@@ -1434,12 +1434,8 @@ class ConfigStatus(wx.ScrolledCanvas):
|
||||
self.MakeRow2("Sample interrupts", self.interrupts, cfile)
|
||||
self.MakeRow2("Microphone or DGT level dB", level, qfile)
|
||||
self.MakeRow2("FFT number of points", self.fft_size, err_msg)
|
||||
if conf.dxClHost: # connection to dx cluster
|
||||
nSpots = len(application.dxCluster.dxSpots)
|
||||
if nSpots > 0:
|
||||
msg = str(nSpots) + ' DX spot' + ('' if nSpots==1 else 's') + ' received from ' + application.dxCluster.getHost()
|
||||
else:
|
||||
msg = "No DX Cluster data from %s" % conf.dxClHost
|
||||
if application.dxCluster:
|
||||
msg = application.dxCluster.dxStatus()
|
||||
self.MakeRow2("FFT number of errors", self.fft_error, msg)
|
||||
else:
|
||||
self.MakeRow2("FFT number of errors", self.fft_error)
|
||||
@@ -2123,7 +2119,7 @@ class GraphScreen(wx.Window):
|
||||
"""For mouse clicks in our display, translate to our screen coordinates."""
|
||||
mouse_x, mouse_y = event.GetPosition()
|
||||
win = event.GetEventObject()
|
||||
if win is not self:
|
||||
if win and win is not self:
|
||||
x, y = win.GetPosition().Get()
|
||||
mouse_x += x
|
||||
mouse_y += y
|
||||
@@ -3524,6 +3520,7 @@ class App(wx.App):
|
||||
if not os.path.isdir(self.QuiskFilesDir):
|
||||
self.QuiskFilesDir = DefaultConfigDir
|
||||
self.std_out_err = StdOutput(self)
|
||||
self.std_out_err.Logfile("WxPython " + wx.version())
|
||||
QS.set_params(quisk_is_vna=0) # We are not the VNA program
|
||||
# Read in configuration from the selected radio
|
||||
self.BandPlan = []
|
||||
@@ -3614,6 +3611,7 @@ class App(wx.App):
|
||||
setattr(conf, 'widgets_file_name', '')
|
||||
Hardware = self.Hardware
|
||||
self.use_fast_heart_beat = hasattr(Hardware, "FastHeartBeat")
|
||||
self.poll_gui_control = hasattr(Hardware, "PollGuiControl")
|
||||
# Initialization - may be over-written by persistent state
|
||||
self.local_conf.Initialize()
|
||||
self.clip_time0 = 0 # timer to display a CLIP message on ADC overflow
|
||||
@@ -3989,6 +3987,7 @@ class App(wx.App):
|
||||
minh = 100
|
||||
maxh = -1
|
||||
self.main_frame.SetSizeHints(minw, minh, maxw, maxh)
|
||||
self.main_frame.SetClientSize(wx.Size(width, self.height))
|
||||
if hasattr(Hardware, 'pre_open'): # pre_open() is called before open()
|
||||
Hardware.pre_open()
|
||||
if self.local_conf.GetWidgets(self, Hardware, conf, frame, gbs, vertBox):
|
||||
@@ -4028,7 +4027,6 @@ class App(wx.App):
|
||||
if conf.dxClHost:
|
||||
# create DX Cluster and register listener for change notification
|
||||
self.dxCluster = dxcluster.DxCluster()
|
||||
self.dxCluster.setListener(self.OnDxClChange)
|
||||
self.dxCluster.start()
|
||||
# Create shortcut keys for buttons
|
||||
if conf.button_layout == 'Large screen':
|
||||
@@ -4379,8 +4377,6 @@ class App(wx.App):
|
||||
conf.tx_ip, conf.tx_audio_port,
|
||||
conf.mic_sample_rate, conf.mic_channel_I, conf.mic_channel_Q,
|
||||
0.7, conf.mic_playback_rate)
|
||||
def OnDxClChange(self):
|
||||
self.station_screen.Refresh()
|
||||
def OnIdle(self, event):
|
||||
if self.screen:
|
||||
self.screen.OnIdle(event)
|
||||
@@ -6455,6 +6451,8 @@ class App(wx.App):
|
||||
self.hamlib_com2_handler.Process()
|
||||
if self.use_fast_heart_beat:
|
||||
Hardware.FastHeartBeat()
|
||||
if self.poll_gui_control:
|
||||
Hardware.PollGuiControl()
|
||||
if conf.do_repeater_offset:
|
||||
hold = QS.tx_hold_state(-1)
|
||||
if hold == 2: # Tx is being held for an FM repeater TX frequency shift
|
||||
@@ -6635,6 +6633,9 @@ class App(wx.App):
|
||||
self.ChangeDisplayFrequency(tune - vfo, vfo)
|
||||
self.FldigiPoll()
|
||||
self.HamlibPoll()
|
||||
if self.dxCluster:
|
||||
if self.dxCluster.Poll():
|
||||
self.station_screen.Refresh()
|
||||
if self.timer - self.slowheart_time0 > 0.5:
|
||||
self.slowheart_time0 = self.timer
|
||||
if self.w_phase:
|
||||
|
||||
@@ -120,6 +120,8 @@ class Hardware:
|
||||
self.application.bandscope_clock = clock
|
||||
#def PollCwKey(self): # Optional. Called frequently by the sound thread to check the CW key status.
|
||||
# pass # Do not define if not needed.
|
||||
#def PollGuiControl(self): # Optional. Called frequently by the GUI thread to change GUI settings (PTT etc.)
|
||||
# pass # Do not define if not needed.
|
||||
def StartSamples(self): # Quisk calls this from the sound thread to start sending samples.
|
||||
# If you return a string, it replaces the string returned from hardware open()
|
||||
pass
|
||||
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
# You must define the version here. A title string including
|
||||
# the version will be written to __init__.py and read by quisk.py.
|
||||
|
||||
Version = '4.2.38'
|
||||
Version = '4.2.40'
|
||||
|
||||
fp = open("__init__.py", "w") # write title string
|
||||
fp.write("#Quisk version %s\n" % Version)
|
||||
|
||||
Reference in New Issue
Block a user