wouxun6.patch

Initial wouxun6 patch - Dan Smith, 03/14/2012 05:32 pm

Download (2.2 kB)

b/chirp/wouxun.py Wed Mar 14 17:30:33 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 56
        if len(r) != 9:
57
            print "Got:\n%s" % util.hexprint(r)
57 58
            print "Retrying identification..."
58 59
            time.sleep(1)
59 60
            continue
60 61
        if r[2:8] != radio._model:
62
            print "Model:\n%s" % util.hexprint(r)
61 63
            raise Exception("I can't talk to this model")
62 64
        return
63 65
    if len(r) == 0:
......
65 67
    else:
66 68
        raise Exception("Unable to identify radio")
67 69

  
70
def wouxun_identify(radio):
71
    return _wouxun_identify(radio, "HiWOUXUN\x02")
72

  
73
def wouxun6_identify(radio):
74
    return _wouxun_identify(radio, "HiWXUVD1")
75

  
68 76
def wouxun_start_transfer(radio):
69 77
    radio.pipe.write("\x02\x06")
70 78
    time.sleep(0.05)
......
131 139
    wouxun_start_transfer(radio)
132 140
    return do_upload(radio, 0x0000, 0x2000, 0x0010)
133 141

  
142
def wouxun6_download(radio):
143
    wouxun_identify(radio)
144
    wouxun_start_transfer(radio)
145
    return do_download(radio, 0x0000, 0x2000, 0x0040)
146

  
147
def wouxun6_upload(radio):
148
    wouxun6_identify(radio)
149
    wouxun_start_transfer(radio)
150
    return do_upload(radio, 0x0000, 0x2000, 0x0010)
151

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

  
......
309 327
            return True
310 328
        return False
311 329

  
330
@directory.register
331
class KGUV6DRadio(KGUVD1PRadio):
332
    MODEL = "KG-UV6D"
333
    _model = "KG????"
334

  
335
    def sync_in(self):
336
        self._mmap = wouxun6_download(self)
337
        self.process_mmap()
338

  
339
    def sync_out(self):
340
        wouxun6_upload(self)
341

  
312 342
def _puxing_prep(radio):
313 343
    radio.pipe.write("\x02PROGRA")
314 344
    ack = radio.pipe.read(1)