Merge pull request #293 from DJ2LS/ls-bugfix

bugfixes for better BPQ support
This commit is contained in:
DJ2LS 2022-11-29 08:58:25 +01:00 committed by GitHub
commit 18c53329ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 33 deletions

View file

@ -56,14 +56,15 @@ class CONFIG:
}
self.config['RADIO'] = {'#Radio settings': None,
'radiocontrol': data[13],
'devicename': data[5],
'deviceport': data[6],
'serialspeed': data[7],
'pttprotocol': data[8],
'pttport': data[9],
'data_bits': data[10],
'stop_bits': data[11],
'handshake': data[12],
# TODO: disabled because we dont need these settings anymore
#'devicename': data[5],
#'deviceport': data[6],
#'serialspeed': data[7],
#'pttprotocol': data[8],
#'pttport': data[9],
#'data_bits': data[10],
#'stop_bits': data[11],
#'handshake': data[12],
'rigctld_ip': data[14],
'rigctld_port': data[15]
}

View file

@ -76,7 +76,7 @@ if __name__ == "__main__":
nargs="*",
default=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
help="SSID list we are responding to",
type=str,
type=int,
)
PARSER.add_argument(
"--mygrid",
@ -273,19 +273,20 @@ if __name__ == "__main__":
static.MYCALLSIGN = helpers.bytes_to_callsign(mycallsign)
static.MYCALLSIGN_CRC = helpers.get_crc_24(static.MYCALLSIGN)
static.SSID_LIST = [] ####
static.SSID_LIST = config['STATION']['ssid']
static.MYGRID = bytes(config['STATION']['mygrid'], "utf-8")
static.AUDIO_INPUT_DEVICE = int(config['AUDIO']['rx'])
static.AUDIO_OUTPUT_DEVICE = int(config['AUDIO']['tx'])
static.PORT = int(config['NETWORK']['tncport'])
static.HAMLIB_DEVICE_NAME = config['RADIO']['devicename']
static.HAMLIB_DEVICE_PORT = config['RADIO']['deviceport']
static.HAMLIB_PTT_TYPE = config['RADIO']['pttprotocol']
static.HAMLIB_PTT_PORT = config['RADIO']['pttport']
static.HAMLIB_SERIAL_SPEED = str(config['RADIO']['serialspeed'])
static.HAMLIB_DATA_BITS = str(config['RADIO']['data_bits'])
static.HAMLIB_STOP_BITS = str(config['RADIO']['stop_bits'])
static.HAMLIB_HANDSHAKE = config['RADIO']['handshake']
# TODO: disabled because we don't need these settings anymore.
#static.HAMLIB_DEVICE_NAME = config['RADIO']['devicename']
#static.HAMLIB_DEVICE_PORT = config['RADIO']['deviceport']
#static.HAMLIB_PTT_TYPE = config['RADIO']['pttprotocol']
#static.HAMLIB_PTT_PORT = config['RADIO']['pttport']
#static.HAMLIB_SERIAL_SPEED = str(config['RADIO']['serialspeed'])
#static.HAMLIB_DATA_BITS = str(config['RADIO']['data_bits'])
#static.HAMLIB_STOP_BITS = str(config['RADIO']['stop_bits'])
#static.HAMLIB_HANDSHAKE = config['RADIO']['handshake']
static.HAMLIB_RADIOCONTROL = config['RADIO']['radiocontrol']
static.HAMLIB_RIGCTLD_IP = config['RADIO']['rigctld_ip']
static.HAMLIB_RIGCTLD_PORT = str(config['RADIO']['rigctld_port'])

View file

@ -569,22 +569,25 @@ class RF:
:rtype: int
"""
nbytes = 0
while self.stream.active:
threading.Event().wait(0.01)
while audiobuffer.nbuffer >= nin:
# demodulate audio
nbytes = codec2.api.freedv_rawdatarx(
freedv, bytes_out, audiobuffer.buffer.ctypes
)
audiobuffer.pop(nin)
nin = codec2.api.freedv_nin(freedv)
if nbytes == bytes_per_frame:
self.log.debug(
"[MDM] [demod_audio] Pushing received data to received_queue"
try:
while self.stream.active:
threading.Event().wait(0.01)
while audiobuffer.nbuffer >= nin:
# demodulate audio
nbytes = codec2.api.freedv_rawdatarx(
freedv, bytes_out, audiobuffer.buffer.ctypes
)
self.modem_received_queue.put([bytes_out, freedv, bytes_per_frame])
self.get_scatter(freedv)
self.calculate_snr(freedv)
audiobuffer.pop(nin)
nin = codec2.api.freedv_nin(freedv)
if nbytes == bytes_per_frame:
self.log.debug(
"[MDM] [demod_audio] Pushing received data to received_queue"
)
self.modem_received_queue.put([bytes_out, freedv, bytes_per_frame])
self.get_scatter(freedv)
self.calculate_snr(freedv)
except Exception as e:
self.log.warning("[MDM] [demod_audio] Stream not active anymore", e=e)
return nin
def init_codec2_mode(self, mode, adv):
@ -1011,6 +1014,13 @@ def set_audio_volume(datalist, volume: float) -> np.int16:
:return: Scaled audio samples
:rtype: np.int16
"""
# make sure we have float as data type to avoid crash
try:
volume = float(volume)
except Exception as e:
print(f"[MDM] changing audio volume failed with error: {e}")
volume = 100.0
# Clip volume provided to acceptable values
volume = np.clip(volume, 0, 200) # limit to max value of 255
# Scale samples by the ratio of volume / 100.0

View file

@ -221,6 +221,18 @@ def process_tnc_commands(data):
command=received_json,
)
# SET ENABLE RESPOND TO CQ -----------------------------------------------------
if received_json["type"] == "set" and received_json["command"] == "respond_to_cq":
try:
static.RESPOND_TO_CQ = received_json["state"] in ['true', 'True', True]
command_response("respond_to_cq", True)
except Exception as err:
command_response("respond_to_cq", False)
log.warning(
"[SCK] CQ command execution error", e=err, command=received_json
)
# TRANSMIT TEST FRAME ----------------------------------------------------
if (
received_json["type"] == "set"