wouxun6_r4.patch

Wouxun patch to accept id and attempt download - Dan Smith, 03/17/2012 10:18 am

Download (2.3 kB)

b/chirp/wouxun.py Sat Mar 17 10:16:30 2012 -0700
49 49
} names[128];
50 50
"""
51 51

  
52
def wouxun_identify(radio):
52
def _wouxun_identify(radio, string):
53 53
    for i in range(0, 5):
54
        radio.pipe.write("HiWOUXUN\x02")
54
        radio.pipe.write(string)
55 55
        r = radio.pipe.read(9)
56

  
57
        # New style, single ACK?
58
        if len(r) == 1 and r == "\x06":
59
            return
60

  
61
        # Old style, some radio model info
56 62
        if len(r) != 9:
63
            print "Got:\n%s" % util.hexprint(r)
57 64
            print "Retrying identification..."
58 65
            time.sleep(1)
59 66
            continue
60 67
        if r[2:8] != radio._model:
68
            print "Model:\n%s" % util.hexprint(r)
61 69
            raise Exception("I can't talk to this model")
62 70
        return
63 71
    if len(r) == 0:
......
65 73
    else:
66 74
        raise Exception("Unable to identify radio")
67 75

  
76
def wouxun_identify(radio):
77
    return _wouxun_identify(radio, "HiWOUXUN\x02")
78

  
79
def wouxun6_identify(radio):
80
    return _wouxun_identify(radio, "HiWXUVD1")
81

  
68 82
def wouxun_start_transfer(radio):
69 83
    radio.pipe.write("\x02\x06")
70 84
    time.sleep(0.05)
......
131 145
    wouxun_start_transfer(radio)
132 146
    return do_upload(radio, 0x0000, 0x2000, 0x0010)
133 147

  
148
def wouxun6_download(radio):
149
    wouxun6_identify(radio)
150
    wouxun_start_transfer(radio)
151
    return do_download(radio, 0x0000, 0x2000, 0x0040)
152

  
153
def wouxun6_upload(radio):
154
    wouxun6_identify(radio)
155
    wouxun_start_transfer(radio)
156
    return do_upload(radio, 0x0000, 0x2000, 0x0010)
157

  
134 158
CHARSET = list("0123456789") + [chr(x + ord("A")) for x in range(0, 26)] + \
135 159
    list("?+ ")
136 160

  
......
309 333
            return True
310 334
        return False
311 335

  
336
@directory.register
337
class KGUV6DRadio(KGUVD1PRadio):
338
    MODEL = "KG-UV6D"
339
    _model = "KG????"
340

  
341
    def sync_in(self):
342
        self._mmap = wouxun6_download(self)
343
        self.process_mmap()
344

  
345
    def sync_out(self):
346
        wouxun6_upload(self)
347

  
312 348
def _puxing_prep(radio):
313 349
    radio.pipe.write("\x02PROGRA")
314 350
    ack = radio.pipe.read(1)