|
1 | 1 | # -*- coding: utf-8 -*
|
2 |
| -# python3 |
| 2 | +# python2 |
3 | 3 | import os
|
4 | 4 | import time
|
5 | 5 | import threading
|
@@ -191,7 +191,10 @@ def send_file(ser, input_file_path, target_file_path):
|
191 | 191 | input_file_fd = open(input_file_path, 'rb')
|
192 | 192 | input_file_data = input_file_fd.read()
|
193 | 193 | input_file_len = len(input_file_data)
|
194 |
| - progress_bar.start(input_file_len) |
| 194 | + try: |
| 195 | + progress_bar.start(input_file_len) |
| 196 | + except: |
| 197 | + progress_bar.start() |
195 | 198 | # Send file header
|
196 | 199 | # 1(file_type) + 4(file_size) + 4(file_check_sum) = 0x09
|
197 | 200 | cmd_len_str = int2byte(0x09 + len(target_file_path), 2, 'little')
|
@@ -220,7 +223,7 @@ def send_file(ser, input_file_path, target_file_path):
|
220 | 223 | retransmission_count = retransmission_count + 1
|
221 | 224 | print("resend the file header[" + str(retransmission_count) + "]")
|
222 | 225 | ser.write(binascii.a2b_hex(send_head_str))
|
223 |
| - if retransmission_count >= 2: |
| 226 | + if retransmission_count >= 5: |
224 | 227 | failed_to_exit = True
|
225 | 228 | update_completed = False
|
226 | 229 | print("Send header time out!")
|
@@ -261,7 +264,7 @@ def send_file(ser, input_file_path, target_file_path):
|
261 | 264 | retransmission_count = retransmission_count + 1
|
262 | 265 | print("resend the file block[" + str(retransmission_count) + "]")
|
263 | 266 | ser.write(send_block_bytes)
|
264 |
| - if retransmission_count >= 2: |
| 267 | + if retransmission_count >= 3: |
265 | 268 | failed_to_exit = True
|
266 | 269 | update_completed = False
|
267 | 270 | print("Send file block time out!")
|
|
0 commit comments