exporting patch: # HG changeset patch # User Mathias Weyland # Date 1483971573 -3600 # Mon Jan 09 15:19:33 2017 +0100 # Node ID 54c7fc41fce147d5c4cfe7d2de4192c6fa402ccb # Parent 953e2a13ed3ea09e541c9955c70a6b7c1ce6e2b1 Alinco DJ-G7: Try slower baud rate if default rate fails (#4355) Alinco support is suggesting to use lower baud rates if the programming software fails to communicate with the radio reliably. This patch alters the code for the Alinco DJ-G7 radio such that if falls back to 19200 baud if the default of 57600 baud does not work. The user must set his radio to 19200 baud for this mechanism to kick in. Dialog boxes were added accordingly using the chirp_common.RadioPrompts() feature. diff -r 953e2a13ed3e -r 54c7fc41fce1 chirp/drivers/alinco.py --- a/chirp/drivers/alinco.py Sat Jan 07 12:05:37 2017 -0500 +++ b/chirp/drivers/alinco.py Mon Jan 09 15:19:33 2017 +0100 @@ -18,6 +18,8 @@ from chirp.settings import RadioSettingGroup, RadioSetting from chirp.settings import RadioSettingValueBoolean, RadioSettings +from textwrap import dedent + import time import logging @@ -612,6 +614,31 @@ _memsize = 0x1a7c0 _range = [(500000, 1300000000)] + @classmethod + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.pre_download = _(dedent("""\ + 1. Ensure your firmware version is 4_10 or higher + 2. Turn radio off + 3. Connect your interface cable + 4. Turn radio on + 5. Press and release PTT 3 times while holding MONI key + 6. Supported baud rates: 57600 (default) and 19200 + (rotate dial while holding MONI to change) + 7. Click OK + """)) + rp.pre_upload = _(dedent("""\ + 1. Ensure your firmware version is 4_10 or higher + 2. Turn radio off + 3. Connect your interface cable + 4. Turn radio on + 5. Press and release PTT 3 times while holding MONI key + 6. Supported baud rates: 57600 (default) and 19200 + (rotate dial while holding MONI to change) + 7. Click OK + """)) + return rp + def get_features(self): rf = chirp_common.RadioFeatures() rf.has_dtcs_polarity = False @@ -655,8 +682,18 @@ return data + def _detect_baudrate_and_identify(self): + if self._identify(): + return True + else: + # Apparenly Alinco support suggests to try again at a lower baud + # rate if their cable fails with the default rate. See #4355. + LOG.info("Could not talk to radio. Trying again at 19200 baud") + self.pipe.baudrate = 19200 + return self._identify() + def _download(self, limit): - self._identify() + self._detect_baudrate_and_identify() data = "\x00"*0x200 @@ -688,7 +725,7 @@ raise Exception("Unexpected response from radio: %s" % resp) def _upload(self, limit): - if not self._identify(): + if not self._detect_baudrate_and_identify(): raise Exception("I can't talk to this model") for addr in range(0x200, self._memsize, 0x40):