Things started working.

This commit is contained in:
Marat Fayzullin 2024-11-18 21:29:05 -05:00
parent b8f6969b53
commit 44f82cec94
3 changed files with 18 additions and 19 deletions

View File

@ -224,9 +224,9 @@ class RdsDemodulator(ServiceDemodulator, DialFrequencyReceiver):
class CwSkimmerDemodulator(ServiceDemodulator, DialFrequencyReceiver):
def __init__(self, sampleRate: int = 12000, charCount: int = 8):
def __init__(self, sampleRate: int = 12000, charTotal: int = 64, charCount: int = 1):
self.sampleRate = sampleRate
self.parser = CwSkimmerParser()
self.parser = CwSkimmerParser(charTotal)
workers = [
Convert(Format.FLOAT, Format.SHORT),
CwSkimmerModule(sampleRate, charCount),

View File

@ -893,7 +893,7 @@ CwSkimmerMessagePanel.prototype.supportsMessage = function(message) {
CwSkimmerMessagePanel.prototype.render = function() {
$(this.el).append($(
'<table>' +
'<table width="100%">' +
'<thead><tr>' +
'<th class="frequency">Freq</th>' +
'<th class="data">Message</th>' +
@ -904,27 +904,33 @@ CwSkimmerMessagePanel.prototype.render = function() {
};
CwSkimmerMessagePanel.prototype.pushMessage = function(msg) {
// Must have some text
if (!msg.text) return;
// Find existing frequency
var j = this.freqs.indexOf(msg.freq);
if (j >= 0) {
// Update existing entry
this.texts[j] = msg.text;
this.texts[j] = (this.texts[j] + msg.text).slice(-64);
} else {
// Add a new entry
this.freqs.push(msg.freq);
this.texts.push(msg.text);
// Limit the number of active frequencies
if (this.freqs.length > 10) {
this.freqs.pop();
this.texts.pop();
}
// if (this.freqs.length > 16) {
// this.freqs.shift();
// this.texts.shift();
// }
}
// Generate table body
var body = '';
for (j = 0 ; j < this.freqs.length ; j++) {
body += '<tr><td>' + this.freqs[j] + '</td><td>' + this.texts[j] + '</td></tr>\n';
body +=
'<tr style="color:black;background-color:' + (j&1? '#E0FFE0':'#FFFFFF') +
';"><td style="text-align:right;">' + Math.round(this.freqs[j]/10)/100 +
'</td><td style="font-family:monospace;white-space:nowrap;">' +
this.texts[j] + '</td></tr>\n';
}
// Assign new table body

View File

@ -417,10 +417,9 @@ class EasParser(TextParser):
class CwSkimmerParser(TextParser):
def __init__(self, charTotal: int = 32, service: bool = False):
self.reLine = re.compile("^(\d+):\s*(.*)$")
def __init__(self, charTotal: int = 64, service: bool = False):
self.reLine = re.compile("^(\d+):(.+)$")
self.charTotal = charTotal
self.cwCache = {}
# Construct parent object
super().__init__(filePrefix="CW", service=service)
@ -434,12 +433,6 @@ class CwSkimmerParser(TextParser):
if r is not None:
freq = int(r.group(1))
text = r.group(2)
# Add up newly decoded characters
if freq in self.cwCache:
text = self.cwCache[freq] + text
# Truncate received text to charTotal
text = text if len(text) <= self.charTotal else text[:self.charTotal]
self.cwCache[freq] = text
# Compose output
out = { "mode": "CW", "text": text }
# Add frequency, if known