[chirp_devel] FIx for #5599

Dan Smith
Fri Mar 30 08:07:53 PDT 2018


> The Clone test will report Failed, since I trap a radio download timeout and generate an empty memory set.

Okay, but that's not valid behavior for a clone, so please make it behave like the other drivers unless there is a fundamental reason why that's not reasonable.

> The radios were sold with a USB dongle that does not handshake the download dump. There may be a future patch to fix this if I ever find a dongle that works. Meanwhile it is a "write-only" device. This is explained in the download prompts.

Does this mean you just dump things to the serial port and just hope the driver got it? A USB adapter normally has nothing to do with the handshaking of a device like this, so that seems a little strange to me. Are you saying this is a problem with your USB dongle and that a future patch to its firmware, or to CHIRP, would fix it?

> +def load_empty_mem(self):
> +    """Create a blank memory data set"""
> +    Spc1 = [0x1A,0x7F,0x23,0x3F,0x93,0xBF,0x96,0x7F,0x5D,0x80,0x64,
> +                    0x80]
> +    Spc2 = [0x48,0,0x40,0xFB,0,0,0x5E,0x46,8,0,0xB0,0x1E,8,0,0x34,
> +            0x1B,8,0,0x59,0xFC]
> +    Spc3 = [7,0x0F,0,0,0x15,3,0,9,0x33,0x3F,0x3D,0xFF,0x81,0xFF,0x8C,
> +                    0x3F,0x11,0x3F,0x18,0x6F,0x9E,0xFF,0xA4,0x3F,0,0,
> +                    0x7F,0,0,0]
> +    dx = ""
> +    for nb in range(0, BLOCKS):
> +        for nc in range(0, BLOCK_SIZE):
> +            chx = chr(0)            # Load empty data
> +            nx = nb * BLOCK_SIZE + nc
> +            if (nx >= 0xCC4 and nx <= 0xCCF):
> +                chx = chr(Spc1[nx -0xCC4])
> +            if (nx >= 0xE07 and nx <= 0xE1A):
> +                # Init Chan and mode, PRI Freq, dir and mode
> +                chx = chr(Spc2[nx -0xE07])
> +            if (nx >= 0xE22 and nx <= 0xE3F):
> +                chx = chr(Spc3[nx -0xE22])
> +            if (nx >= 0xE40 and nx <  0xE6A ):
> +                chx = chr(0x30)
> +            dx += chx
> +    dx += self.MODEL.ljust(8)
> +    return dx

As mentioned above, this is highly unusual for a driver, and isn't in a very maintainable form. Is there some fundamental reason why this is necessary for this driver? Is it because you can't actually read an image out of the device? How did you get an image in the first place?

> +def do_download(radio, flg):
> +    """Download Scanner Memory."""
> +    # 'flg' is boolean to clear data or not
> +    radio.pipe.baudrate = BAUD_RATE
> +    radio.pipe.timeout = STIMEOUT
> +    # Get the serial port connection
> +    serial = radio.pipe
> +    _clean_buffer(radio)
> +
> +    # UI progress
> +    status = chirp_common.Status()
> +    status.cur = 0
> +    status.max = BLOCKS
> +    status.msg = "Downloading from Scanner Memory..."
> +    radio.status_fn(status)
> +
> +    #Download data array
> +    # ---- SO FAR: Does not read the dump ----!!!
> +    Wcmd = "\xec"
> +    serial.write(Wcmd)
> +    ack = serial.read(len(Wcmd))            #  cmd readback
> +    if (flg):
> +        data =  ""
> +    for nb in range(0, BLOCKS):
> +        serial.write("D")        # Gimme a block
> +        ack = serial.read(1)
> +        cnt = 1
> +        time.sleep(.01)
> +        for nc in range(0, BLOCK_SIZE):
> +            chx = serial.read(cnt)
> +            if len(chx) == 0:            # Timeout error; quit reading
> +                msg = "Timeout reading data from scanner."
> +                # Raise a different error type; trapped in sync_in
> +                raise errors.InvalidDataError(msg)
> +            if len(chx) != cnt:
> +                msg = "Error: Not the amount of data expected."
> +                raise errors.RadioError(msg)
> +            data += chx
> +        # End for nc
> +        cbx = serial.read(2)        # get 2 checksum bytes and ignore
> +        # UI Update after each 8-chan block
> +        status.cur =  nb
> +        radio.status_fn(status)
> +    # End for nb		
> +    data += radio.MODEL.ljust(8)    # Append model code
> +    return data

It looks like you've got code for the download but it just doesn't work? I don't think we can merge this into the main tree without a real download routine. People will wonder why download appears to work (even if they forgot to connect the device) and why it shows none of their existing memories.

Also, the style checker has lots to say, I've included the output at the end here in case you're having trouble running it.

Aside from some complaints about the meat of some of the serial routines, I otherwise think this looks workable. If you can figure out the download part and post another rev, I can go do another pass.

Users have requested scanners before, and I've been hesitant to care, just because scanners can be really complicated with banks and channels and weird settings and such. Do you feel like this is going to provide a reasonably workable solution for people with this scanner?

Thanks!

--Dan

chirp/drivers/rs649.py:27:1: E402 module level import not at top of file
chirp/drivers/rs649.py:28:1: E402 module level import not at top of file
chirp/drivers/rs649.py:29:1: E402 module level import not at top of file
chirp/drivers/rs649.py:31:27: E231 missing whitespace after ','
chirp/drivers/rs649.py:32:1: E402 module level import not at top of file
chirp/drivers/rs649.py:95:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:95:1: W191 indentation contains tabs
chirp/drivers/rs649.py:96:1: W191 indentation contains tabs
chirp/drivers/rs649.py:96:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:97:1: W191 indentation contains tabs
chirp/drivers/rs649.py:97:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:98:1: W191 indentation contains tabs
chirp/drivers/rs649.py:98:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:99:1: W191 indentation contains tabs
chirp/drivers/rs649.py:99:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:100:1: W191 indentation contains tabs
chirp/drivers/rs649.py:100:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:101:1: W191 indentation contains tabs
chirp/drivers/rs649.py:101:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:102:1: W191 indentation contains tabs
chirp/drivers/rs649.py:102:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:103:1: W191 indentation contains tabs
chirp/drivers/rs649.py:103:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:104:1: W191 indentation contains tabs
chirp/drivers/rs649.py:104:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:105:1: W191 indentation contains tabs
chirp/drivers/rs649.py:105:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:106:1: W191 indentation contains tabs
chirp/drivers/rs649.py:106:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:107:1: W191 indentation contains tabs
chirp/drivers/rs649.py:107:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:108:1: W191 indentation contains tabs
chirp/drivers/rs649.py:108:2: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:109:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:131:9: E225 missing whitespace around operator
chirp/drivers/rs649.py:134:1: E302 expected 2 blank lines, found 1
chirp/drivers/rs649.py:146:17: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:22: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:27: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:32: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:37: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:42: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:47: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:52: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:57: E231 missing whitespace after ','
chirp/drivers/rs649.py:146:62: E231 missing whitespace after ','
chirp/drivers/rs649.py:147:21: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:148:17: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:19: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:24: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:29: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:31: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:33: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:38: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:43: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:45: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:47: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:52: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:57: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:59: E231 missing whitespace after ','
chirp/drivers/rs649.py:148:61: E231 missing whitespace after ','
chirp/drivers/rs649.py:149:17: E231 missing whitespace after ','
chirp/drivers/rs649.py:149:19: E231 missing whitespace after ','
chirp/drivers/rs649.py:149:21: E231 missing whitespace after ','
chirp/drivers/rs649.py:149:26: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:14: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:19: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:21: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:23: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:28: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:30: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:32: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:34: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:39: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:44: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:49: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:54: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:59: E231 missing whitespace after ','
chirp/drivers/rs649.py:150:64: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:21: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:151:25: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:30: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:35: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:40: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:45: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:50: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:55: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:60: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:65: E231 missing whitespace after ','
chirp/drivers/rs649.py:151:67: E231 missing whitespace after ','
chirp/drivers/rs649.py:152:21: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:152:25: E231 missing whitespace after ','
chirp/drivers/rs649.py:152:27: E231 missing whitespace after ','
chirp/drivers/rs649.py:152:29: E231 missing whitespace after ','
chirp/drivers/rs649.py:159:36: E225 missing whitespace around operator
chirp/drivers/rs649.py:162:36: E225 missing whitespace around operator
chirp/drivers/rs649.py:164:36: E225 missing whitespace around operator
chirp/drivers/rs649.py:165:37: E222 multiple spaces after operator
chirp/drivers/rs649.py:165:44: E202 whitespace before ')'
chirp/drivers/rs649.py:188:5: E265 block comment should start with '# '
chirp/drivers/rs649.py:192:45: E262 inline comment should start with '# '
chirp/drivers/rs649.py:194:15: E222 multiple spaces after operator
chirp/drivers/rs649.py:213:21: E222 multiple spaces after operator
chirp/drivers/rs649.py:215:17: W291 trailing whitespace
chirp/drivers/rs649.py:252:80: E501 line too long (82 > 79 characters)
chirp/drivers/rs649.py:255:14: E225 missing whitespace around operator
chirp/drivers/rs649.py:264:1: E302 expected 2 blank lines, found 1
chirp/drivers/rs649.py:281:11: E225 missing whitespace around operator
chirp/drivers/rs649.py:290:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:290:1: W191 indentation contains tabs
chirp/drivers/rs649.py:290:1: W293 blank line contains whitespace
chirp/drivers/rs649.py:293:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:302:5: E303 too many blank lines (2)
chirp/drivers/rs649.py:306:26: E225 missing whitespace around operator
chirp/drivers/rs649.py:306:35: E201 whitespace after '('
chirp/drivers/rs649.py:308:35: W291 trailing whitespace
chirp/drivers/rs649.py:309:51: W291 trailing whitespace
chirp/drivers/rs649.py:313:1: W293 blank line contains whitespace
chirp/drivers/rs649.py:333:5: E303 too many blank lines (2)
chirp/drivers/rs649.py:357:19: E128 continuation line under-indented for visual indent
chirp/drivers/rs649.py:367:19: E225 missing whitespace around operator
chirp/drivers/rs649.py:382:5: E303 too many blank lines (2)
chirp/drivers/rs649.py:407:5: E303 too many blank lines (2)
chirp/drivers/rs649.py:417:17: E222 multiple spaces after operator
chirp/drivers/rs649.py:424:31: E221 multiple spaces before operator
chirp/drivers/rs649.py:433:19: E222 multiple spaces after operator
chirp/drivers/rs649.py:434:20: E221 multiple spaces before operator
chirp/drivers/rs649.py:437:25: E202 whitespace before ')'
chirp/drivers/rs649.py:439:22: E222 multiple spaces after operator
chirp/drivers/rs649.py:439:43: E202 whitespace before ']'
chirp/drivers/rs649.py:446:27: E211 whitespace before '('
chirp/drivers/rs649.py:452:52: E262 inline comment should start with '# '
chirp/drivers/rs649.py:474:29: E231 missing whitespace after ','
chirp/drivers/rs649.py:475:27: E225 missing whitespace around operator
chirp/drivers/rs649.py:477:9: E115 expected an indented block (comment)
chirp/drivers/rs649.py:481:52: E262 inline comment should start with '# '
chirp/drivers/rs649.py:493:45: E221 multiple spaces before operator
chirp/drivers/rs649.py:495:18: E111 indentation is not a multiple of four
chirp/drivers/rs649.py:496:32: E202 whitespace before ')'
chirp/drivers/rs649.py:500:41: E231 missing whitespace after ','
chirp/drivers/rs649.py:510:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:514:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:518:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:522:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:526:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:530:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:534:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:538:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:542:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:546:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:550:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:554:29: E127 continuation line over-indented for visual indent
chirp/drivers/rs649.py:561:64: E231 missing whitespace after ','
chirp/drivers/rs649.py:561:75: E231 missing whitespace after ','
chirp/drivers/rs649.py:562:48: E231 missing whitespace after ','
chirp/drivers/rs649.py:597:63: E231 missing whitespace after ','
chirp/drivers/rs649.py:615:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:615:1: W191 indentation contains tabs
chirp/drivers/rs649.py:615:1: W293 blank line contains whitespace
chirp/drivers/rs649.py:616:1: E101 indentation contains mixed spaces and tabs
chirp/drivers/rs649.py:620:1: W391 blank line at end of file


More information about the chirp_devel mailing list