mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 10:37:15 +00:00
Fix Icom radio detection
Icom radio detection has been broken for a long time, because the detection code is expecting to be passed a radio instance, but is being passed a serial port instead. Since we are trying to determine the model, we don't have the relevant class yet. Instead, create a minimal radio instance to allow us to query for the model. These changes fix both the 'Detect' option in the 'Download From Radio' menu and the 'chirpc --id' command. Fixes #7905
This commit is contained in:
parent
da64bcd319
commit
1e8e4c75f7
@ -16,12 +16,20 @@
|
||||
import serial
|
||||
import logging
|
||||
|
||||
from chirp import errors, directory
|
||||
from chirp import chirp_common, errors, directory
|
||||
from chirp.drivers import ic9x_ll, icf, kenwood_live, icomciv
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DetectorRadio(chirp_common.Radio):
|
||||
"""Minimal radio for model detection"""
|
||||
MUNCH_CLONE_RESP = False
|
||||
|
||||
def get_payload(self, data, raw, checksum):
|
||||
return data
|
||||
|
||||
|
||||
def _icom_model_data_to_rclass(md):
|
||||
for _rtype, rclass in directory.DRV_TO_RADIO.items():
|
||||
if rclass.VENDOR != "Icom":
|
||||
@ -40,7 +48,7 @@ def _detect_icom_radio(ser):
|
||||
|
||||
try:
|
||||
ser.baudrate = 9600
|
||||
md = icf.get_model_data(ser)
|
||||
md = icf.get_model_data(DetectorRadio(ser))
|
||||
return _icom_model_data_to_rclass(md)
|
||||
except errors.RadioError, e:
|
||||
LOG.error("_detect_icom_radio: %s", e)
|
||||
|
7
chirpc
7
chirpc
@ -196,10 +196,9 @@ if __name__ == "__main__":
|
||||
sys.exit(0)
|
||||
|
||||
if options.id:
|
||||
from chirp import icf
|
||||
s = serial.Serial(port=options.serial, baudrate=9600, timeout=0.5)
|
||||
md = icf.get_model_data(s)
|
||||
print "Model:\n%s" % util.hexprint(md)
|
||||
from chirp import detect
|
||||
md = detect.detect_icom_radio(options.serial)
|
||||
print "Model:\n%s" % md.MODEL
|
||||
sys.exit(0)
|
||||
|
||||
if not options.radio:
|
||||
|
Loading…
Reference in New Issue
Block a user