Project

General

Profile

Bug #4687 » icf.py.diff

Takayoshi SASANO, 09/05/2017 08:53 AM

View differences:

chirp/drivers/icf.py Mon Jul 10 17:45:50 2017 -0400 → chirp/drivers/icf.py Wed Sep 06 00:46:01 2017 +0900
164 164
    return resp
165 165

  
166 166

  
167
def discard_echoback(pipe, data):
168
    """Discard echoback when sending frame"""
169
    i = 0
170
    length = len(data)
171
    echo = ""
172
    while i < length:
173
        d = pipe.read(1)
174

  
175
        while i < length:
176
            if d != data[i]:
177
                i += 1
178
            else:
179
                echo += d
180
                break
181

  
182
        i += 1
183
            
184
    if echo != data:
185
        LOG.debug("Received echoback is different from sent frame")
186
        LOG.debug("Sent frame (%i):\n%s" % (length, util.hexprint(data)))
187
        LOG.debug("Echoback (%i):\n%s" % (len(echo), util.hexprint(echo)))
188
    return
189

  
190

  
167 191
def send_clone_frame(pipe, cmd, data, raw=False, checksum=False):
168 192
    """Send a clone frame with @cmd and @data to the radio attached
169 193
    to @pipe"""
......
199 223

  
200 224
    pipe.write(frame)
201 225
    pipe.flush()
202
    pipe.read(len(frame))  # discard echoback
226
    discard_echoback(pipe, frame)
203 227

  
204 228
    return frame
205 229

  
......
263 287
    LOG.debug("Starting HiSpeed Clone:\n%s" % util.hexprint(buf))
264 288
    radio.pipe.write(buf)
265 289
    radio.pipe.flush()
266
    radio.pipe.read(len(buf))  # discard echoback
290
    discard_echoback(radio.pipe, buf)
267 291

  
268 292

  
269 293
def _clone_from_radio(radio):
    (1-1/1)