-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhexinThreading.py
40 lines (29 loc) · 1.09 KB
/
hexinThreading.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# !/usr/bin/python
# Python: 3.6.5
# Platform: Windows/Linux
# Author: Heyn ([email protected])
# Program: hexin threading.
# History: 2019-05-30 Ver:0.1 [Heyn] Initialization
import time
import queue
from PyQt5 import QtCore
from drivers.hexinJLink import hexinJLink
class Communicate( QtCore.QObject ):
logsignal = QtCore.pyqtSignal( str )
def programThreading( logscallback, jlinkSN, device, hexfile, address ):
hexinSlot = Communicate()
hexinSlot.logsignal.connect ( logscallback )
def on_progress( action, progress_string, percentage ):
hexinSlot.logsignal.emit( '{}-{}%'.format( action.decode('utf-8'), percentage ) )
hexinSlot.logsignal.emit('开始烧录')
jlink = hexinJLink()
while True:
jlink.connect( sn=jlinkSN, chip=device )
try:
jlink.connect( sn=jlinkSN, chip=device )
jlink.reset()
jlink.halt()
jlink.download_file( hexfile, address, False, on_progress )
except BaseException as err:
hexinSlot.logsignal.emit( '烧录失败:{}'.format( err ) )
hexinSlot.logsignal.emit('烧录成功')