Hi Klaus,
# HG changeset patch # User Klaus Ruebsam dg5eau@ruebsam.eu # Date 1535360123 -7200 # Mon Aug 27 10:55:23 2018 +0200 # Node ID 26da631376cd1b9c349e26a5ffe6b787712df1ad # Parent 4873d5437a583c3a1b169808c3d29a53524bc5b2 Added support for Radioddity R2
This needs an issue number prefixed by a hash so I can push it up and have it link to an issue. Just create a "new model" request on the site for this model and use that number here. See here for more details:
https://chirp.danplanet.com/projects/chirp/wiki/DevelopersProcess#Bug-Tracki...
+MEM_FORMAT = """ +#seekto 0x0010; +struct {
- lbcd rx_freq[4];
- lbcd tx_freq[4];
- lbcd rx_tone[2];
- lbcd tx_tone[2];
- u8 unknown1:1,
- compand:1,
- scramb:1,
- scanadd:1,
- power:1,
- mode:1,
- unknown2:1,
- bclo:1;
- u8 unknown3 [3];
Extraneous space before the [.
+TONES = chirp_common.TONES +#TONES.remove(254.1)
Remove this?
+def _r2_enter_programming_mode(radio):
- serial = radio.pipe
- magic = "TYOGRAM"
- exito = False
- serial.write(CMD_STX)
- for i in range(0, 5):
for j in range(0, len(magic)):
serial.write(magic[j])
ack = serial.read(1)
try:
if ack == CMD_ACK:
exito = True
break
except:
LOG.debug("Attempt #%s, failed, trying again" % i)
pass
I don't think there's anything in this try..except block that can raise, so I would just remove it.
- # check if we had EXITO
- if exito is False:
msg = "The radio did not accept program mode after five tries.\n"
msg += "Check you interface cable and power cycle your radio."
raise errors.RadioError(msg)
- try:
serial.write(CMD_STX)
ident = serial.read(8)
- except:
_r2_exit_programming_mode(radio)
raise errors.RadioError("Error communicating with radio")
- # No idea yet what the next 7 bytes stand for
- # as long as they start with ACK we are fine
- if not ident.startswith(CMD_ACK):
_r2_exit_programming_mode(radio)
LOG.debug(util.hexprint(ident))
raise errors.RadioError("Radio returned unknown identification string")
- try:
serial.write(CMD_ACK)
ack = serial.read(1)
- except:
_r2_exit_programming_mode(radio)
It would probably be best to wrap this function in something that always tries to exit programming mode if it raises so you don't need to have it on all the exit paths. Something like
def _r2_enter_programming_mode(radio): try: return _really_enter(radio) except: _r2_exit_programming_mode(radio) raise # will re-raise the original error
+@directory.register
+class RadioddityR2Radio(chirp_common.CloneModeRadio):
Extra blank line here should be removed.
- def process_mmap(self):
"""Process the mem map into the mem object"""
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
# to set the vars on the class to the correct ones
Should this comment be removed?
# 166666665*10 is the equivalent for FF FF FF FF storesd in the TX field
s/storesd/stored/ :)
- def set_memory(self, mem):
bitpos = (1 << ((mem.number - 1) % 8))
Extra blank line here too.
diff --git a/tests/images/Radioddity_R2.img b/tests/images/Radioddity_R2.img new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0bbd8468beda1c4f90b1be24385a530da662c710 GIT binary patch literal 1181 zc%1Ez&1!={6h>{KK0}w?WS`nva2dQPBZPt>@n<!o1T$({X*&e7>$=OlXCI;V-kDit z({&-2bHM92&WGwGK%o<kLT4@qQt#@PBS7kXcFz$YO&)RtNRw|k0;I`z90AhgpBw?w z<R^{*X>wN}K-zwR0BQRL0;KI12#~g4AVAuFfdFay1p=h)7wYW)FLRmyG+#H4>p0W3 zUVi>QpL%zCoT=W)x8Ymv8|P{}CSIBOUG>1^vs}paKI%jkbY<Mnw=4F}!sMg!(!L7W z6F#q&Qon0O+>dn>cx9d(@w{T~Ys1=wT8@v0GTwMh9vb$Nv{f7(>(P8$Wa)r+bs|sw Vb!+!g-{%#1G8CCV*Z0UI_yseAoGAbR
This looks like maybe you committed the image in a previous changeset and then just tweaked it in this one? Either add it in the same patch, or you can attach it to the issue you create and I can snag it from there.
Also, I know you said you were having trouble running the style checks on windows, so I have included the output of it for you at the end here.
Otherwise this looks really close, thanks! I'd like to get the image so I can run the tests and get as much of the style and other nits above cleaned up and then I'm good with it.
--Dan
$ ./tools/cpep8.py chirp/drivers/radioddity_r2.py chirp/drivers/radioddity_r2.py:59:19: W291 trailing whitespace chirp/drivers/radioddity_r2.py:106:1: E265 block comment should start with '# ' chirp/drivers/radioddity_r2.py:197:1: E302 expected 2 blank lines, found 1 chirp/drivers/radioddity_r2.py:307:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:311:9: E265 block comment should start with '# ' chirp/drivers/radioddity_r2.py:316:1: E302 expected 2 blank lines, found 1 chirp/drivers/radioddity_r2.py:318:1: E304 blank lines found after function decorator chirp/drivers/radioddity_r2.py:332:23: W291 trailing whitespace chirp/drivers/radioddity_r2.py:374:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:406:5: E303 too many blank lines (2) chirp/drivers/radioddity_r2.py:460:80: E501 line too long (80 > 79 characters) chirp/drivers/radioddity_r2.py:460:81: W291 trailing whitespace chirp/drivers/radioddity_r2.py:473:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:479:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:487:33: E127 continuation line over-indented for visual indent chirp/drivers/radioddity_r2.py:493:33: E127 continuation line over-indented for visual indent chirp/drivers/radioddity_r2.py:499:33: E127 continuation line over-indented for visual indent chirp/drivers/radioddity_r2.py:540:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:546:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:559:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:560:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:561:5: E303 too many blank lines (2) chirp/drivers/radioddity_r2.py:578:80: E501 line too long (80 > 79 characters) chirp/drivers/radioddity_r2.py:606:9: E303 too many blank lines (2) chirp/drivers/radioddity_r2.py:648:1: W293 blank line contains whitespace chirp/drivers/radioddity_r2.py:656:1: W391 blank line at end of file