├── .gitignore ├── README.md ├── hextool ├── main.py └── ui │ └── hextool_ui.py ├── hideme └── main.py ├── image └── README │ ├── image-20220316124209719.png │ ├── image-20220317094813153.png │ ├── image-20220317110800468.png │ ├── image-20220317175640708.png │ └── usbhid_test.png ├── led.hex ├── monkey.ico ├── pyside_start ├── main.py └── ui │ └── main_ui.py ├── requirements.txt ├── serialtool ├── main.py └── ui │ └── serial_ui.py └── usbhid_test ├── ui ├── test.ui └── ui_test.py └── usbhid_test.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.csv 2 | __pycache__ 3 | .qt_for_python -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Monkey-Helper-Tools-py 2 | Some little tools that might help me in my development, write in python code. 3 | 4 | #### note and details: https://makerinchina.cn/categories/Python/ 5 | 6 | - [x] pyside start 7 | 8 | this is just a very simple example to use pyside. 9 | 10 | - detials in my blog: [PySide2入门-设计界面和简单美化](https://makerinchina.cn/pyside2%e5%85%a5%e9%97%a8-%e8%ae%be%e8%ae%a1%e7%95%8c%e9%9d%a2%e5%92%8c%e7%ae%80%e5%8d%95%e7%be%8e%e5%8c%96/) 11 | 12 | ![image-20220316124209719](image/README/image-20220316124209719.png) 13 | 14 | 15 | 16 | - [x] usb hid test tool 17 | 18 | usb hid scan,and read ,write in hex format. 19 | 20 | - detials in my blog:[PySide2示例-USB HID测试工具](https://makerinchina.cn/pyside2示例-usb-hid测试工具/) 21 | 22 | ![usbhid_test](image/README/usbhid_test.png) 23 | 24 | 25 | 26 | - [x] serial tool 27 | 28 | a simple serial tool use QtSerialPort. 29 | 30 | - detials in my blog:[PySide2示例-简单的串口工具](https://makerinchina.cn/pyside2示例-简单的串口工具/) 31 | 32 | ![image-20220317094813153](image/README/image-20220317094813153.png) 33 | 34 | 35 | 36 | - [x] hideme tool 37 | 38 | no need to explain, not to skiving (moyu?), pls just study! 39 | 40 | ![image-20220317175640708](image/README/image-20220317175640708.png) 41 | 42 | 43 | 44 | - [x] hex2bin tool 45 | 46 | convert hex file to binary. 47 | 48 | - detials in my blog:[PySide2示例-简单的Hex转换工具](https://makerinchina.cn/pyside2示例-简单的hex转换工具/) 49 | 50 | ![image-20220317110800468](image/README/image-20220317110800468.png) 51 | 52 | 53 | 54 | - [ ] ..... 55 | -------------------------------------------------------------------------------- /hextool/main.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from PySide2.QtWidgets import * 4 | from PySide2.QtCore import * 5 | from PySide2.QtGui import * 6 | 7 | from ui.hextool_ui import Ui_MainWindow 8 | 9 | from intelhex import IntelHex 10 | 11 | from qtmodern.styles import dark 12 | from qtmodern.windows import ModernWindow 13 | 14 | class MainWindow(Ui_MainWindow,QMainWindow): 15 | def __init__(self): 16 | super(MainWindow,self).__init__() 17 | self.setupUi(self) 18 | 19 | self.btnChooseHex.clicked.connect(self.choose_hexfile) 20 | self.btnChooseBin.clicked.connect(self.choose_binfile) 21 | self.btnConvert.clicked.connect(self.convert_hex2bin) 22 | 23 | self.hexfile = "" 24 | self.binfile = "" 25 | self.ih = None 26 | 27 | def choose_hexfile(self): 28 | self.hexfile = QFileDialog.getOpenFileName(None,"choose hex file",".","*.hex")[0] 29 | self.editHexFile.setText(self.hexfile) 30 | self.ih = IntelHex(self.hexfile) 31 | 32 | def choose_binfile(self): 33 | self.binfile = QFileDialog.getSaveFileName(None,"save bin file",".","*.bin")[0] 34 | self.editBinFile.setText(self.binfile) 35 | 36 | def convert_hex2bin(self): 37 | with open('dump.txt','w') as dump: 38 | self.ih.dump(dump) 39 | 40 | with open('dump.txt','r') as dump: 41 | self.editDump.appendPlainText(dump.read()) 42 | 43 | #write to bin file 44 | self.ih.tobinfile(self.binfile) 45 | 46 | if __name__ == "__main__": 47 | app = QApplication(sys.argv) 48 | 49 | app.setWindowIcon(QIcon("../monkey.ico")) 50 | 51 | dark(app) 52 | 53 | mwin = MainWindow() 54 | 55 | mwin.setWindowTitle("Hex2Bin file tool") 56 | 57 | win = ModernWindow(mwin) 58 | 59 | win.show() 60 | 61 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /hextool/ui/hextool_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ################################################################################ 4 | ## Form generated from reading UI file 'designerXgIxMf.ui' 5 | ## 6 | ## Created by: Qt User Interface Compiler version 5.15.2 7 | ## 8 | ## WARNING! All changes made in this file will be lost when recompiling UI file! 9 | ################################################################################ 10 | 11 | from PySide2.QtCore import * 12 | from PySide2.QtGui import * 13 | from PySide2.QtWidgets import * 14 | 15 | 16 | class Ui_MainWindow(object): 17 | def setupUi(self, MainWindow): 18 | if not MainWindow.objectName(): 19 | MainWindow.setObjectName(u"MainWindow") 20 | MainWindow.resize(800, 600) 21 | self.centralwidget = QWidget(MainWindow) 22 | self.centralwidget.setObjectName(u"centralwidget") 23 | self.verticalLayout_2 = QVBoxLayout(self.centralwidget) 24 | self.verticalLayout_2.setObjectName(u"verticalLayout_2") 25 | self.horizontalLayout = QHBoxLayout() 26 | self.horizontalLayout.setObjectName(u"horizontalLayout") 27 | self.label = QLabel(self.centralwidget) 28 | self.label.setObjectName(u"label") 29 | 30 | self.horizontalLayout.addWidget(self.label) 31 | 32 | self.editHexFile = QLineEdit(self.centralwidget) 33 | self.editHexFile.setObjectName(u"editHexFile") 34 | 35 | self.horizontalLayout.addWidget(self.editHexFile) 36 | 37 | self.btnChooseHex = QToolButton(self.centralwidget) 38 | self.btnChooseHex.setObjectName(u"btnChooseHex") 39 | 40 | self.horizontalLayout.addWidget(self.btnChooseHex) 41 | 42 | 43 | self.verticalLayout_2.addLayout(self.horizontalLayout) 44 | 45 | self.horizontalLayout_2 = QHBoxLayout() 46 | self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") 47 | self.label_2 = QLabel(self.centralwidget) 48 | self.label_2.setObjectName(u"label_2") 49 | 50 | self.horizontalLayout_2.addWidget(self.label_2) 51 | 52 | self.editBinFile = QLineEdit(self.centralwidget) 53 | self.editBinFile.setObjectName(u"editBinFile") 54 | 55 | self.horizontalLayout_2.addWidget(self.editBinFile) 56 | 57 | self.btnChooseBin = QToolButton(self.centralwidget) 58 | self.btnChooseBin.setObjectName(u"btnChooseBin") 59 | 60 | self.horizontalLayout_2.addWidget(self.btnChooseBin) 61 | 62 | 63 | self.verticalLayout_2.addLayout(self.horizontalLayout_2) 64 | 65 | self.horizontalLayout_3 = QHBoxLayout() 66 | self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") 67 | self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) 68 | 69 | self.horizontalLayout_3.addItem(self.horizontalSpacer) 70 | 71 | self.btnConvert = QPushButton(self.centralwidget) 72 | self.btnConvert.setObjectName(u"btnConvert") 73 | 74 | self.horizontalLayout_3.addWidget(self.btnConvert) 75 | 76 | 77 | self.verticalLayout_2.addLayout(self.horizontalLayout_3) 78 | 79 | self.groupBox = QGroupBox(self.centralwidget) 80 | self.groupBox.setObjectName(u"groupBox") 81 | self.verticalLayout = QVBoxLayout(self.groupBox) 82 | self.verticalLayout.setObjectName(u"verticalLayout") 83 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) 84 | self.editDump = QPlainTextEdit(self.groupBox) 85 | self.editDump.setObjectName(u"editDump") 86 | self.editDump.setReadOnly(True) 87 | 88 | self.verticalLayout.addWidget(self.editDump) 89 | 90 | 91 | self.verticalLayout_2.addWidget(self.groupBox) 92 | 93 | MainWindow.setCentralWidget(self.centralwidget) 94 | self.menubar = QMenuBar(MainWindow) 95 | self.menubar.setObjectName(u"menubar") 96 | self.menubar.setGeometry(QRect(0, 0, 800, 26)) 97 | MainWindow.setMenuBar(self.menubar) 98 | self.statusbar = QStatusBar(MainWindow) 99 | self.statusbar.setObjectName(u"statusbar") 100 | MainWindow.setStatusBar(self.statusbar) 101 | 102 | self.retranslateUi(MainWindow) 103 | 104 | QMetaObject.connectSlotsByName(MainWindow) 105 | # setupUi 106 | 107 | def retranslateUi(self, MainWindow): 108 | MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) 109 | self.label.setText(QCoreApplication.translate("MainWindow", u"Hex:", None)) 110 | self.btnChooseHex.setText(QCoreApplication.translate("MainWindow", u"...", None)) 111 | self.label_2.setText(QCoreApplication.translate("MainWindow", u"Bin:", None)) 112 | self.btnChooseBin.setText(QCoreApplication.translate("MainWindow", u"...", None)) 113 | self.btnConvert.setText(QCoreApplication.translate("MainWindow", u"\u8f6c\u6362", None)) 114 | self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"dump", None)) 115 | # retranslateUi 116 | 117 | -------------------------------------------------------------------------------- /hideme/main.py: -------------------------------------------------------------------------------- 1 | 2 | from PySide2.QtWidgets import * 3 | from PySide2.QtGui import * 4 | from PySide2.QtCore import * 5 | 6 | import sys,os 7 | 8 | import psutil 9 | import win32gui 10 | import win32con 11 | import win32process 12 | from win32ctypes import * 13 | from system_hotkey import SystemHotkey 14 | 15 | import qtmodern.styles 16 | import qtmodern.windows 17 | 18 | global hide_key 19 | hide_key = ('control','shift','h') 20 | 21 | class PreferenceWin(QDialog): 22 | def __init__(self): 23 | super(PreferenceWin, self).__init__() 24 | 25 | self.setWindowFlags(Qt.FramelessWindowHint ) 26 | 27 | self.mainLayout = QVBoxLayout(self) 28 | 29 | self.keysquenceedit = QKeySequenceEdit(self) 30 | self.mainLayout.addWidget(self.keysquenceedit) 31 | 32 | self.btnlayout = QHBoxLayout(self) 33 | self.btnOk = QPushButton(f'OK',self,clicked=self.setKeyOk) 34 | self.btnCancel= QPushButton(f'Cancel', self,clicked=lambda:self.reject()) 35 | self.btnlayout.addWidget(self.btnOk) 36 | self.btnlayout.addWidget(self.btnCancel) 37 | self.mainLayout.addLayout(self.btnlayout) 38 | 39 | def setKeyOk(self): 40 | global hide_key 41 | keystr = self.keysquenceedit.keySequence().toString().lower() 42 | keystr_l = keystr.split('+') 43 | for i in range(0,len(keystr_l)): 44 | if keystr_l[i] == 'ctrl': 45 | keystr = keystr_l[i] = 'control' 46 | hide_key = tuple(keystr_l) 47 | print(f'setKeyOk {hide_key}') 48 | self.accept() 49 | 50 | def setKeyCancel(self): 51 | print('setKeyCancel') 52 | 53 | class MainWindow(QMainWindow): 54 | def __init__(self): 55 | super(MainWindow, self).__init__() 56 | 57 | self.setStatusBar(QStatusBar(self)) 58 | 59 | self.me_hwnd = 0 60 | self.me_hide = False 61 | 62 | self.hidekey = SystemHotkey() 63 | 64 | print(f'register key {hide_key}') 65 | self.hidekey.register(hide_key,callback=lambda x:self.hideme()) 66 | 67 | self.menubar = QMenuBar(self) 68 | self.menuFile = QMenu(f'File', self) 69 | self.actRefresh = self.menuFile.addAction(QAction(f'Refresh',self,triggered=self.refreshProcess)) 70 | self.actPreference = self.menuFile.addAction(QAction(f'Preference',self,triggered=self.setPreference)) 71 | self.actExit = self.menuFile.addAction(QAction(f'Exit',self,triggered=self.exitApp)) 72 | self.menubar.addMenu(self.menuFile) 73 | self.setMenuBar(self.menubar) 74 | 75 | self.table = QTableWidget(self) 76 | self.table.setColumnCount(4) 77 | self.header = QHeaderView(Qt.Vertical) 78 | self.header.setVisible(False) 79 | self.table.setVerticalHeader(self.header) 80 | 81 | self.addProgressToTable() 82 | 83 | # contex menu 84 | self.table.setContextMenuPolicy(Qt.CustomContextMenu) 85 | self.table.customContextMenuRequested.connect(self.contextMenuSlot) 86 | 87 | self.setCentralWidget(self.table) 88 | 89 | self.resize(1000,600) 90 | self.show() 91 | 92 | def addProgressToTable(self): 93 | self.table.clear() 94 | self.table.setRowCount(0) 95 | for handle,title in self.getAllWindows().items(): 96 | if title != '': 97 | print(f"window title:{title}") 98 | 99 | rowcnt = self.table.rowCount() 100 | self.table.insertRow(rowcnt) 101 | 102 | tid, pid = win32process.GetWindowThreadProcessId(handle) 103 | 104 | pname = psutil.Process(pid).name() 105 | cwd = psutil.Process(pid).cwd() 106 | 107 | pid_me = os.getpid() 108 | print(f"pid me:{pid_me} , {pid}") 109 | 110 | if int(pid_me) == int(pid): 111 | self.me_hwnd = handle 112 | print(f"get me handle:{self.me_hwnd}") 113 | 114 | self.table.setItem(rowcnt, 0, QTableWidgetItem(f'{handle}')) 115 | self.table.setItem(rowcnt,1,QTableWidgetItem(title)) 116 | self.table.setItem(rowcnt,2,QTableWidgetItem(f'{pid}')) 117 | self.table.setItem(rowcnt,3,QTableWidgetItem(cwd)) 118 | 119 | self.table.setHorizontalHeaderLabels(['Handle','Title','pid','cwd']) 120 | self.table.resizeColumnsToContents() 121 | 122 | def contextMenuSlot(self,pos): 123 | menu = QMenu() 124 | 125 | hideact = menu.addAction(f'Hide Me') 126 | showact = menu.addAction(f'Show Me') 127 | action = menu.exec_(self.table.mapToGlobal(pos)) 128 | 129 | rownum = self.table.itemAt(pos).row() 130 | handle = self.table.item(rownum,0).text() 131 | handle = int(handle) 132 | 133 | print(f'get hwnd {handle}') 134 | 135 | if action == hideact: 136 | win32gui.ShowWindow(handle, win32con.SW_HIDE) 137 | elif action == showact: 138 | win32gui.ShowWindow(handle, win32con.SW_SHOW) 139 | 140 | def getAllWindows(self): 141 | hwnd_title = {} 142 | 143 | def get_all_hwnd(hwnd,_): 144 | if (win32gui.IsWindow(hwnd) and 145 | win32gui.IsWindowEnabled(hwnd) and 146 | win32gui.IsWindowVisible(hwnd)): 147 | hwnd_title.update({hwnd: win32gui.GetWindowText(hwnd)}) 148 | 149 | win32gui.EnumWindows(get_all_hwnd, 0) 150 | 151 | return hwnd_title 152 | 153 | def refreshProcess(self): 154 | print('refreshProcess') 155 | 156 | self.addProgressToTable() 157 | 158 | 159 | def setPreference(self): 160 | print('setPreference') 161 | 162 | self.winset = PreferenceWin() 163 | self.winset.exec_() 164 | 165 | global hide_key 166 | if len(hide_key) < 2: 167 | hide_key = ('control','shift','h') 168 | print(f'set key to default{hide_key}') 169 | 170 | self.hidekey.register(hide_key,callback=lambda x:self.hideme()) 171 | 172 | def hideme(self): 173 | print('hideme') 174 | 175 | print(f'me hwnd={self.me_hwnd}') 176 | # fixme: should refresh before hide me 177 | if self.me_hwnd == 0: 178 | print('no hwnd of me') 179 | return 180 | if self.me_hide == False: 181 | 182 | win32gui.ShowWindow(self.me_hwnd, win32con.SW_HIDE) 183 | self.me_hide = True 184 | else : 185 | # fixme: lost focus if only set SW_SHOW 186 | win32gui.ShowWindow(self.me_hwnd, win32con.SW_SHOW|win32con.SW_MINIMIZE) 187 | self.me_hide = False 188 | 189 | def exitApp(self): 190 | print('exitApp') 191 | 192 | sys.exit(0) 193 | 194 | if __name__=='__main__': 195 | app = QApplication(sys.argv) 196 | 197 | app.setWindowIcon(QIcon("../monkey.ico")) 198 | 199 | win = MainWindow() 200 | 201 | win.setWindowTitle(f'HideMe @MakerInChina.cn') 202 | 203 | qtmodern.styles.dark(app) 204 | mw = qtmodern.windows.ModernWindow(win) 205 | mw.show() 206 | 207 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /image/README/image-20220316124209719.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/image/README/image-20220316124209719.png -------------------------------------------------------------------------------- /image/README/image-20220317094813153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/image/README/image-20220317094813153.png -------------------------------------------------------------------------------- /image/README/image-20220317110800468.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/image/README/image-20220317110800468.png -------------------------------------------------------------------------------- /image/README/image-20220317175640708.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/image/README/image-20220317175640708.png -------------------------------------------------------------------------------- /image/README/usbhid_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/image/README/usbhid_test.png -------------------------------------------------------------------------------- /led.hex: -------------------------------------------------------------------------------- 1 | :020000040800F2 2 | :10000000300B0020890100080B0C0008950B00083C 3 | :10001000090C00087F030008B70E0008000000006C 4 | :10002000000000000000000000000000510E000869 5 | :1000300081030008000000000D0C0008530E0008AA 6 | :10004000A3010008A3010008A3010008A301000800 7 | :10005000A3010008A3010008A3010008A3010008F0 8 | :10006000A3010008A3010008A3010008A3010008E0 9 | :10007000A3010008A3010008A3010008A3010008D0 10 | :10008000A3010008A3010008A3010008A3010008C0 11 | :10009000A3010008A3010008A3010008A3010008B0 12 | :1000A000A3010008A3010008A3010008A3010008A0 13 | :1000B000A3010008A3010008A3010008A301000890 14 | :1000C000A3010008A3010008A3010008A301000880 15 | :1000D000A3010008A3010008A3010008A301000870 16 | :1000E000A3010008A3010008A301000800F002F822 17 | :1000F00000F03AF80AA090E8000C82448344AAF188 18 | :100100000107DA4501D100F02FF8AFF2090EBAE885 19 | :100110000F0013F0010F18BFFB1A43F0010318473B 20 | :100120003811000058110000103A24BF78C878C177 21 | :10013000FAD8520724BF30C830C144BF04680C60ED 22 | :10014000704700000023002400250026103A28BF35 23 | :1001500078C1FBD8520728BF30C148BF0B60704739 24 | :100160001FB51FBD10B510BD00F0CFF81146FFF749 25 | :10017000F7FF01F027F800F0EDF803B4FFF7F2FF06 26 | :1001800003BC00F0F5F80000094880470948004723 27 | :10019000FEE7FEE7FEE7FEE7FEE7FEE7FEE7FEE737 28 | :1001A000FEE7FEE704480549054A064B7047000094 29 | :1001B000B50E0008ED00000830050020300B0020CF 30 | :1001C0003007002030070020032A40F2308010F072 31 | :1001D000030C00F0158011F8013BBCF1020F6244E2 32 | :1001E00098BF11F801CB00F8013B38BF11F8013B73 33 | :1001F000A2F1040298BF00F801CB38BF00F8013B20 34 | :1002000011F0030300F04F80083AC0F0088051F865 35 | :10021000043B083A51F804CBA0E80810F5E7121D9A 36 | :100220005CBF51F8043B40F8043BAFF30080D207B9 37 | :1002300024BF11F8013B11F801CB48BF11F8012B85 38 | :1002400024BF00F8013B00F801CB48BF00F8012BA8 39 | :1002500070474FF0000200B5134694469646203989 40 | :1002600022BFA0E80C50A0E80C50B1F12001BFF46F 41 | :10027000F7AF090728BFA0E80C5048BF0CC05DF8D5 42 | :1002800004EB890028BF40F8042B08BF704748BF23 43 | :1002900020F8022B11F0804F18BF00F8012B704797 44 | :1002A00070477047704710B5203AC0F00B80B1E836 45 | :1002B0001850203AA0E81850B1E81850A0E818509B 46 | :1002C000BFF4F5AF5FEA027C24BFB1E81850A0E8A4 47 | :1002D000185044BF18C918C0BDE810405FEA827CBE 48 | :1002E00024BF51F8043B40F8043B08BF7047D207D5 49 | :1002F00028BF31F8023B48BF11F8012B28BF20F876 50 | :10030000023B48BF00F8012B7047754600F02CF8FF 51 | :10031000AE4605006946534620F00700854618B0F2 52 | :1003200020B5FFF73FFFBDE820404FF000064FF03B 53 | :1003300000074FF000084FF0000B21F00701AC461A 54 | :10034000ACE8C009ACE8C009ACE8C009ACE8C00939 55 | :100350008D46704710B50446AFF300802046BDE8D7 56 | :100360001040FFF70ABF000000487047CC0400208F 57 | :1003700001491820ABBEFEE7260002007047FEE7E9 58 | :100380007047000070B5044600F004F90546601C93 59 | :1003900002D004480078044400F0FCF8401BA0425E 60 | :1003A000FAD370BD040000202DE9F84FDFF8B891B2 61 | :1003B000002409F1040A0AF1040B23460F270BF16C 62 | :1003C000040EC9E00125A5402A40AA427DD1674E0E 63 | :1003D000D1F804C0ACEB0608B44532D014DCBCF153 64 | :1003E000030F3AD009DCBCF1000F2AD0BCF1010F99 65 | :1003F0001CD0BCF1020F31D11DE0BCF1110F17D0A0 66 | :10040000BCF1120F2AD119E0B8F5881F19D006DC0B 67 | :10041000B8F5803F15D0B8F5801F1FD111E0B8F5B1 68 | :10042000001F0ED0B8F5041F18D10AE0CB6815E004 69 | :10043000CB681B1D12E0CB6808330FE0CB680C3390 70 | :100440000CE08B682BB1012B4FF0080303D0456102 71 | :1004500004E0042302E0056100E00023FF2A01D844 72 | :10046000064601E000F104064FEA840501D9A5F132 73 | :100470002005D6F8008007FA05FC28EA0C0803FAE4 74 | :1004800005F548EA0508C6F800804D68ED0062D51C 75 | :10049000374DAE6946F00106AE61AD6924F0030642 76 | :1004A00005F001050095334D06EB050CDCF808500E 77 | :1004B000A607360F07FA06F825EA0805DFF8B88020 78 | :1004C000404503D14FF0000817E044E0DFF8AC806E 79 | :1004D000404502D14FF001080FE0DFF8A48040450D 80 | :1004E00002D14FF0020808E0DFF89880404502D1C1 81 | :1004F0004FF0030801E04FF0040808FA06F848EA54 82 | :100500000508CCF808804D68D9F80060ED034D4629 83 | :1005100001D5164300E096432E604D68DAF800607E 84 | :10052000AD03554601D5164300E096432E604D6855 85 | :10053000DBF80060ED025D4601D5164300E096430E 86 | :100540002E604D68DEF80060AD02754601D5164399 87 | :1005500000E096432E60641C0D682A46E5407FF457 88 | :1005600031AFBDE8F88F0000000401400000111019 89 | :10057000001002400000014000080140000C014052 90 | :1005800000100140001401400AB1016170470904E4 91 | :10059000FBE700000148806870470000040000206D 92 | :1005A000024881680278114481607047040000208D 93 | :1005B000074810B5016841F010010160032000F008 94 | :1005C00067F80F2000F006F800F024F8002010BDB6 95 | :1005D0000020024070B50D4D04464FF47A71287822 96 | :1005E000B1FBF0F00A490968B1FBF0F000F0BEFA87 97 | :1005F00048B9102C07D200222146501E00F028F8DE 98 | :1006000000206C6070BD012070BD0000040000205F 99 | :10061000100000200C4808B5816941F0010181619A 100 | :10062000816901F001010091C16941F08051C1610E 101 | :10063000C06900F0805000900448416821F0E061FA 102 | :1006400041F00071416008BD00100240000001400F 103 | :10065000F0B40E4B1B680C46C3F30223C3F107052D 104 | :10066000042D00D90425191D072901D2002300E01B 105 | :10067000DB1E012606FA05F1491E214099409E40E5 106 | :10068000761E16403143F0BC00F08BBD0CED00E04F 107 | :10069000064900F0070208684FF6FF03184040EAD9 108 | :1006A0000220034A10430860704700000CED00E090 109 | :1006B0000000FA052DE9F0470F46050061D0434ED2 110 | :1006C000306800F00700B84209D2306820F0070017 111 | :1006D00038433060306800F00700B84251D12868D4 112 | :1006E0003B4C810712D5400703D5606840F4E060B9 113 | :1006F00060602878000703D5606840F4605060604F 114 | :100700006068A96820F0F000084360602878C0079E 115 | :1007100028D06868012810D02168022810D08907E5 116 | :1007200000292EDA616821F0030101436160FFF7BF 117 | :1007300031FF804641F288390DE021688903EFE7F7 118 | :100740008901EDE7FFF726FFA0EB0801494502D933 119 | :100750000320BDE8F0876068696800F00C00B0EB2A 120 | :10076000810FEFD1306800F00700B8420BD9306834 121 | :1007700020F0070038433060306800F00700B842CE 122 | :1007800001D00120E5E72878400705D56068E968D1 123 | :1007900020F4E060084360602878000706D56068B0 124 | :1007A000296920F4605040EAC100606000F018F848 125 | :1007B0006168084AC1F30311515CC84006490860EA 126 | :1007C00006480068FFF706FF0020C2E7002002404D 127 | :1007D0000010024024120008100000200800002031 128 | :1007E00012A185B00FC98DE80F0014A0144A00684B 129 | :1007F00004905168134801F00C03042B10D0082B0F 130 | :100800000ED1C1F38343C9031DF803000AD5516813 131 | :1008100004AAC1F34041515C0A4A5043B0FBF1F0D5 132 | :1008200005B0704708494843FAE700000203040591 133 | :10083000060708090A0B0C0D0E0F1010010200002C 134 | :100840000010024000127A0000093D002DE9F84F27 135 | :10085000040070D02078C04DC00749D06868C0F34C 136 | :100860008100012807D06868C0F38100022809D1FF 137 | :100870006868C00306D52868800339D560680028F9 138 | :10088000E7D035E06068B0F5803F0BD010B1B0F52F 139 | :10089000A02F11D0286820F480302860286820F428 140 | :1008A000802002E0286840F480302860606890B1C1 141 | :1008B000FFF770FE06460AE0286840F480202860B2 142 | :1008C000F0E700BFFFF766FE801B642873D8286836 143 | :1008D0008003F7D50CE0FFF75DFE064605E000BF9C 144 | :1008E000FFF758FE801B6428F0D828688003F7D4EF 145 | :1008F00020789A4E80074FF001094FF0000839D553 146 | :10090000686810F00C0F07D06868C0F381000228F7 147 | :1009100009D16868C00306D42868800714D5206907 148 | :10092000012808D110E02069B0B1C6F80090FFF7A7 149 | :1009300031FE074605E00AE1FFF72CFEC01B022846 150 | :10094000C4D828688007F7D52868616920F0F800C6 151 | :1009500040EAC10028600DE0C6F80080FFF71AFEEB 152 | :10096000074604E0FFF716FEC01B022823D82868BC 153 | :100970008007F7D4207800072CD57948A169D9B130 154 | :10098000C0F80090FFF706FE074604E0FFF702FEFE 155 | :10099000C01B02280FD8686A8007F7D571484FF44A 156 | :1009A000FA510068B0FBF1F0009000BF0098411EC2 157 | :1009B0000091FAD20EE080E0C0F80080FFF7EAFD77 158 | :1009C000074604E0FFF7E6FDC01B022875D8686AF9 159 | :1009D0008007F7D42078400760D5E8690027C00079 160 | :1009E00008D4E86940F08050E861E869012700F028 161 | :1009F000805000905C480168C90513D401688346A3 162 | :100A000041F480710160FFF7C5FD824606E000BF3A 163 | :100A1000FFF7C0FDA0EB0A0064284ED8DBF8000009 164 | :100A2000C005F5D5E06801280AD008B1052813D023 165 | :100A3000286A20F001002862286A20F0040002E001 166 | :100A4000286A40F001002862E06841F2883B98B1D2 167 | :100A5000FFF7A0FD82460BE0286A40F00400286200 168 | :100A6000EEE700BFFFF796FDA0EB0A0159455AD803 169 | :100A7000286A8007F6D50CE0FFF78CFD824605E07A 170 | :100A8000FFF788FDA0EB0A0159454CD8286A80077A 171 | :100A9000F6D41FB1E86920F08050E861E06988B3BE 172 | :100AA0006968C1F38101022944D00228C6F8608038 173 | :100AB00004D0FFF76FFD044638E034E0FFF76AFD2D 174 | :100AC000074604E0FFF766FDC01B02282BD8286804 175 | :100AD0008001F7D4206AB0F5803F05D16868A1682D 176 | :100AE00020F4003008436860D4E9080108436968CD 177 | :100AF00021F4741108436860C6F86090FFF74AFD5E 178 | :100B0000044606E025E000BFFFF744FD001B022875 179 | :100B100009D828688001F7D51BE000BFFFF73AFD30 180 | :100B2000001B022802D90320BDE8F88F2868800145 181 | :100B3000F4D40EE00128F7D06868226A00F480310E 182 | :100B4000914204D1616A00F47010884201D0012002 183 | :100B5000EAE70020E8E700000010024000004242FF 184 | :100B600080044242100000200070004010B5401E7A 185 | :100B7000B0F1807F01D3012010BD4FF0E02460610F 186 | :100B80000F21601700F00DFB0020A06107202061FD 187 | :100B9000002010BDFEE7000070B586B000241848A4 188 | :100BA0000094019402940394816941F010018161E1 189 | :100BB000816901F010010491816941F02001816196 190 | :100BC000816901F020010491816941F00401816192 191 | :100BD00080690C4E00F004004FF400550490002290 192 | :100BE00029463046FFF7D0FC01200095CDE90104ED 193 | :100BF0000220039069463046FFF7D6FB06B070BD71 194 | :100C00000010024000100140FEE7FEE770470000C0 195 | :100C10002DE9F04107460B4815460E46007808B905 196 | :100C200000F04AF9EFF31184202080F311882A465E 197 | :100C30003146384600F008F8E1B281F31188BDE88A 198 | :100C4000F08100001400002070B50E46144900EB3E 199 | :100C5000400001EBC0051446E86A183520B10128B0 200 | :100C60000FD0022805D113E0284600F053F9A04226 201 | :100C700001D2002411E022463146284600F070FAE5 202 | :100C80000BE0284600F046F9A042F4D20446F2E711 203 | :100C90003146284600F037FA0446204670BD000071 204 | :100CA000140000200FB408B504A900916A46039906 205 | :100CB00000F003F801B05DF814FB2DE9F04198B0A5 206 | :100CC000064607A8029040200025CDE90305CDE99E 207 | :100CD000055690460C4614F8011B002973D02529AF 208 | :100CE00008D002A800F0F0F905980028F3DA18B04F 209 | :100CF000BDE8F081002001212278232A1ED02B2A72 210 | :100D000019D02D2A02D0302A08D102E040F001008B 211 | :100D100001E040F00200641C0029EDD1002221789E 212 | :100D2000A1F130030A2B0CD202EB820201EB42024A 213 | :100D3000303A641CF3E740F00400ECE740F00800B0 214 | :100D4000E9E70023CFB22E2F0BD114F8011FA1F138 215 | :100D500030070A2F05D203EB830301EB4303303B3B 216 | :100D6000F3E76C290DD068290BD0702954D00BDC27 217 | :100D7000252916D0582931D063290CD0642913D1E4 218 | :100D800014E014F8011FECE7732934D075291BD047 219 | :100D9000782909D122E0D8F80000011DC8F8001018 220 | :100DA000017802A800F090F9641C9DE7D8F80010C3 221 | :100DB0000F1DC8F800700968CDE900200A2202A8BA 222 | :100DC00000F0B4F8F0E733E0D8F800100F1DC8F8D1 223 | :100DD00000700968CDE900200A2208E0D8F8001068 224 | :100DE0000F1DC8F800700968CDE90020102202A884 225 | :100DF00000F000F9D8E7D8F80000011DC8F800108D 226 | :100E0000076817F8011B0029CED002A800F05CF992 227 | :100E100005980028F5DAC7E7D8F80000011DC8F8E2 228 | :100E2000001001680820CDE9000503461022DEE726 229 | :100E3000059800287FF75BAF049820B1024607A908 230 | :100E40003046FFF7E5FEDDE90410084405904EE763 231 | :100E50007047FFF7A5BB30B58FB028216846FFF774 232 | :100E6000F8F914210AA8FFF7F4F901210804CDE9E3 233 | :100E700000100024029402250491CDE907504FF49C 234 | :100E8000E01009906846FFF7E1FC08B172B6FEE792 235 | :100E90000F20CDE90A054FF48060CDE90C40022116 236 | :100EA0000AA80E94FFF706FC002801D072B6FEE7F0 237 | :100EB0000FB030BD7047FEE7114803210161416169 238 | :100EC00010A1816100F1A801C1614FF4806101624C 239 | :100ED000002181624162C1620AA2026600F5956248 240 | :100EE0004266102282660167C1664167084A00BFF8 241 | :100EF000C1F10F03D35C4354491C1029F8D3704748 242 | :100F0000140000205465726D696E616C0000000071 243 | :100F1000341200080269C1688A4203D88068401A06 244 | :100F2000104400E0501A401E704700002DE9FC5F9D 245 | :100F30000E008146DDE90C47C6F100009846934655 246 | :100F4000824600D40846012503E000BF90FBFBF079 247 | :100F50006D1C5845FADAA84500D9454624B1002E43 248 | :100F600001DB780700D5641EB80702D5B8F1000F81 249 | :100F70000FD0F8070DD164B1A5420AD2202148460E 250 | :100F8000641E00F0A1F8D9F80C000028F3DABDE8DF 251 | :100F9000FC9FD9F80C000028F9DB002E02DA564637 252 | :100FA0002D2102E0780707D52B21484600F08CF868 253 | :100FB000D9F80C000028EADB07F0030002280FD163 254 | :100FC000B8F1000F0CD15CB1A54209D230214846DE 255 | :100FD000641E00F079F8D9F80C000028F3DAD6E79F 256 | :100FE000CDE9004743465A463146484600F002F8EC 257 | :100FF000CDE700002DE9F84F8246DDE90A4B0126D6 258 | :10100000984691460D460846374602E0B0FBF9F097 259 | :101010007F1C4845FAD2B84500D947465FEACB70F5 260 | :1010200017D1B4B15FEA8B7002D5B8F1000F02D0CE 261 | :10103000202000900BE03020FBE75046641E009912 262 | :1010400000F042F8DAF80C00002838DB0CB1A742B7 263 | :10105000F3D3DAF80C00002831DB00BFB8F1010F40 264 | :1010600002D9A8F1010803E0B5FBF6F0484502D328 265 | :1010700006FB09F6F2E7DFF84C8000BFB5FBF6F09F 266 | :1010800000FB165518F80010504600F01DF8DAF86D 267 | :101090000C00002803DBB6FBF9F6002EEED15FEA68 268 | :1010A000CB700CD0002C0AD0A74208D22021504689 269 | :1010B000641E00F009F8DAF80C000028F2DABDE846 270 | :1010C000F88F00004512000810B50446D4E901303D 271 | :1010D000421C934205D323681954A260E068401C67 272 | :1010E000E060D4E90102824209D121682069FFF75A 273 | :1010F0008FFDA168884203D04FF0FF30E06010BD43 274 | :101100000020A06010BD2DE9F047C468174689464D 275 | :1011100006464FF000083069A04201D9051B02E0E5 276 | :10112000B168201A0D1AB0686D1E001BA84200D8C5 277 | :101130000546BD4200D33D4670682A4620444946D4 278 | :10114000FFF742F8B0687F1B2C44A844A944A04292 279 | :1011500000D10024F460002FDDD14046BDE8F087C7 280 | :101160002DE9F04104468846D4E90207C51BE16831 281 | :10117000606816460844B54206D94146FFF724F890 282 | :10118000B819E060BDE8F0812A464146FFF71CF837 283 | :10119000761B08EB050132466068FFF715F8E6603C 284 | :1011A000F0E70907090E002804DB00F1E02080F8D1 285 | :1011B0000014704700F00F0000F1E02080F8141DCB 286 | :1011C00070470000FFF7F4F9FFF745FEFFF7E4FC76 287 | :1011D0000D4D0E4C4FF400560DA10020FFF762FD9F 288 | :1011E000012231462846FFF7CFF96420FFF7CAF8FD 289 | :1011F000002231462846FFF7C7F9C820FFF7C2F89A 290 | :101200002068401C2060E7E700100140000000203B 291 | :1012100074657374696E672072747420766965777B 292 | :1012200065720000000000000000000001020304DD 293 | :1012300006070809000000000000545452205245DF 294 | :10124000474745530030313233343536373839412A 295 | :101250004243444546000000781200080000002088 296 | :1012600014000000280100088C120008140000205F 297 | :101270001C0B0000440100080000000001000000F9 298 | :0C12800010000000000000000024F4003A 299 | :04000005080000ED02 300 | :00000001FF 301 | -------------------------------------------------------------------------------- /monkey.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makerinchina-iot/Monkey-Helper-Tools-py/9d3a6f9bbc1c3565388b0508797094d31eb28dca/monkey.ico -------------------------------------------------------------------------------- /pyside_start/main.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from PySide2.QtWidgets import * 4 | from PySide2.QtCore import * 5 | from PySide2.QtGui import * 6 | 7 | from ui.main_ui import Ui_MainWindow 8 | 9 | import qtmodern.styles 10 | import qtmodern.windows 11 | 12 | class MainWindow(Ui_MainWindow,QMainWindow): 13 | def __init__(self): 14 | super(MainWindow,self).__init__() 15 | self.setupUi(self) 16 | 17 | self.pushButton.clicked.connect(self.on_pushbutton) 18 | 19 | def on_pushbutton(self): 20 | msgbox = QMessageBox.information(self,"msg","you login succeed!") 21 | 22 | if __name__ == "__main__": 23 | app = QApplication(sys.argv) 24 | 25 | app.setWindowIcon(QIcon("../monkey.ico")) 26 | 27 | qtmodern.styles.dark(app) 28 | 29 | mwin = MainWindow() 30 | 31 | mwin.setWindowTitle("pyside start example") 32 | 33 | win = qtmodern.windows.ModernWindow(mwin) 34 | 35 | win.show() 36 | 37 | sys.exit(app.exec_()) 38 | -------------------------------------------------------------------------------- /pyside_start/ui/main_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ################################################################################ 4 | ## Form generated from reading UI file 'designeryaxABJ.ui' 5 | ## 6 | ## Created by: Qt User Interface Compiler version 5.15.2 7 | ## 8 | ## WARNING! All changes made in this file will be lost when recompiling UI file! 9 | ################################################################################ 10 | 11 | from PySide2.QtCore import * 12 | from PySide2.QtGui import * 13 | from PySide2.QtWidgets import * 14 | 15 | 16 | class Ui_MainWindow(object): 17 | def setupUi(self, MainWindow): 18 | if not MainWindow.objectName(): 19 | MainWindow.setObjectName(u"MainWindow") 20 | MainWindow.resize(364, 195) 21 | self.centralwidget = QWidget(MainWindow) 22 | self.centralwidget.setObjectName(u"centralwidget") 23 | self.verticalLayout = QVBoxLayout(self.centralwidget) 24 | self.verticalLayout.setObjectName(u"verticalLayout") 25 | self.horizontalLayout = QHBoxLayout() 26 | self.horizontalLayout.setObjectName(u"horizontalLayout") 27 | self.label = QLabel(self.centralwidget) 28 | self.label.setObjectName(u"label") 29 | 30 | self.horizontalLayout.addWidget(self.label) 31 | 32 | self.lineEdit = QLineEdit(self.centralwidget) 33 | self.lineEdit.setObjectName(u"lineEdit") 34 | 35 | self.horizontalLayout.addWidget(self.lineEdit) 36 | 37 | 38 | self.verticalLayout.addLayout(self.horizontalLayout) 39 | 40 | self.horizontalLayout_2 = QHBoxLayout() 41 | self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") 42 | self.label_2 = QLabel(self.centralwidget) 43 | self.label_2.setObjectName(u"label_2") 44 | 45 | self.horizontalLayout_2.addWidget(self.label_2) 46 | 47 | self.lineEdit_2 = QLineEdit(self.centralwidget) 48 | self.lineEdit_2.setObjectName(u"lineEdit_2") 49 | 50 | self.horizontalLayout_2.addWidget(self.lineEdit_2) 51 | 52 | 53 | self.verticalLayout.addLayout(self.horizontalLayout_2) 54 | 55 | self.checkBox = QCheckBox(self.centralwidget) 56 | self.checkBox.setObjectName(u"checkBox") 57 | 58 | self.verticalLayout.addWidget(self.checkBox) 59 | 60 | self.horizontalLayout_3 = QHBoxLayout() 61 | self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") 62 | self.pushButton = QPushButton(self.centralwidget) 63 | self.pushButton.setObjectName(u"pushButton") 64 | 65 | self.horizontalLayout_3.addWidget(self.pushButton) 66 | 67 | self.pushButton_2 = QPushButton(self.centralwidget) 68 | self.pushButton_2.setObjectName(u"pushButton_2") 69 | 70 | self.horizontalLayout_3.addWidget(self.pushButton_2) 71 | 72 | 73 | self.verticalLayout.addLayout(self.horizontalLayout_3) 74 | 75 | MainWindow.setCentralWidget(self.centralwidget) 76 | self.menubar = QMenuBar(MainWindow) 77 | self.menubar.setObjectName(u"menubar") 78 | self.menubar.setGeometry(QRect(0, 0, 364, 26)) 79 | MainWindow.setMenuBar(self.menubar) 80 | self.statusbar = QStatusBar(MainWindow) 81 | self.statusbar.setObjectName(u"statusbar") 82 | MainWindow.setStatusBar(self.statusbar) 83 | 84 | self.retranslateUi(MainWindow) 85 | 86 | QMetaObject.connectSlotsByName(MainWindow) 87 | # setupUi 88 | 89 | def retranslateUi(self, MainWindow): 90 | MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) 91 | self.label.setText(QCoreApplication.translate("MainWindow", u"\u7528\u6237\u540d\uff1a", None)) 92 | self.label_2.setText(QCoreApplication.translate("MainWindow", u"\u5bc6 \u7801\uff1a", None)) 93 | self.checkBox.setText(QCoreApplication.translate("MainWindow", u"\u8bb0\u4f4f\u5bc6\u7801", None)) 94 | self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u767b\u5f55", None)) 95 | self.pushButton_2.setText(QCoreApplication.translate("MainWindow", u"\u53d6\u6d88", None)) 96 | # retranslateUi 97 | 98 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | hid==1.0.5 2 | hidapi==0.11.0.post2 3 | intelhex==2.3.0 4 | psutil==5.9.0 5 | PySide2==5.15.2.1 6 | pywin32==225 7 | pywin32_ctypes==0.2.0 8 | qtmodern==0.2.0 9 | system_hotkey==1.0.3 10 | win32gui==221.6 11 | -------------------------------------------------------------------------------- /serialtool/main.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | from PySide2.QtWidgets import * 4 | from PySide2.QtCore import * 5 | from PySide2.QtGui import * 6 | from PySide2.QtSerialPort import * 7 | 8 | from ui.serial_ui import Ui_MainWindow 9 | 10 | import qtmodern.styles 11 | import qtmodern.windows 12 | 13 | class MainWindow(Ui_MainWindow,QMainWindow): 14 | def __init__(self): 15 | super(MainWindow,self).__init__() 16 | self.setupUi(self) 17 | 18 | serial_list = QSerialPortInfo.availablePorts() 19 | for port in serial_list: 20 | self.comboPort.addItem(port.portName()) 21 | 22 | self.comboBaudrate.addItems(['9600','115200']) 23 | 24 | self.serial = QSerialPort() 25 | self.btnOpen.setText('打开') 26 | self.btnOpen.clicked.connect(self.open_serial) 27 | 28 | self.btnSend.clicked.connect(self.send_data) 29 | self.serial.readyRead.connect(self.read_data) 30 | 31 | self.btnClear.clicked.connect(self.editRecv.clear) 32 | 33 | def open_serial(self): 34 | self.serial.setPortName(self.comboPort.currentText()) 35 | 36 | if self.btnOpen.text() == '打开': 37 | self.serial.open(QIODevice.ReadWrite) 38 | 39 | self.serial.setBaudRate(int(self.comboBaudrate.currentText())) 40 | self.btnOpen.setText('关闭') 41 | else: 42 | self.serial.close() 43 | self.btnOpen.setText('打开') 44 | 45 | def send_data(self): 46 | if self.serial.isOpen(): 47 | str = self.editSend.text()+"\r\n" 48 | ba = QTextCodec.codecForLocale().fromUnicode(str) 49 | self.serial.write(ba) 50 | 51 | def read_data(self): 52 | ba = self.serial.readAll() 53 | str = QTextCodec.codecForLocale().toUnicode(ba.data()) 54 | self.editRecv.appendPlainText(str) 55 | 56 | if __name__ == "__main__": 57 | app = QApplication(sys.argv) 58 | 59 | qtmodern.styles.dark(app) 60 | 61 | app.setWindowIcon(QIcon("../monkey.ico")) 62 | 63 | 64 | mwin = MainWindow() 65 | 66 | win = qtmodern.windows.ModernWindow(mwin) 67 | 68 | win.show() 69 | 70 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /serialtool/ui/serial_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ################################################################################ 4 | ## Form generated from reading UI file 'designerYRIXvo.ui' 5 | ## 6 | ## Created by: Qt User Interface Compiler version 5.15.2 7 | ## 8 | ## WARNING! All changes made in this file will be lost when recompiling UI file! 9 | ################################################################################ 10 | 11 | from PySide2.QtCore import * 12 | from PySide2.QtGui import * 13 | from PySide2.QtWidgets import * 14 | 15 | 16 | class Ui_MainWindow(object): 17 | def setupUi(self, MainWindow): 18 | if not MainWindow.objectName(): 19 | MainWindow.setObjectName(u"MainWindow") 20 | MainWindow.resize(800, 600) 21 | self.centralwidget = QWidget(MainWindow) 22 | self.centralwidget.setObjectName(u"centralwidget") 23 | self.verticalLayout_2 = QVBoxLayout(self.centralwidget) 24 | self.verticalLayout_2.setObjectName(u"verticalLayout_2") 25 | self.horizontalLayout_3 = QHBoxLayout() 26 | self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") 27 | self.label = QLabel(self.centralwidget) 28 | self.label.setObjectName(u"label") 29 | 30 | self.horizontalLayout_3.addWidget(self.label) 31 | 32 | self.comboPort = QComboBox(self.centralwidget) 33 | self.comboPort.setObjectName(u"comboPort") 34 | 35 | self.horizontalLayout_3.addWidget(self.comboPort) 36 | 37 | self.label_2 = QLabel(self.centralwidget) 38 | self.label_2.setObjectName(u"label_2") 39 | 40 | self.horizontalLayout_3.addWidget(self.label_2) 41 | 42 | self.comboBaudrate = QComboBox(self.centralwidget) 43 | self.comboBaudrate.setObjectName(u"comboBaudrate") 44 | 45 | self.horizontalLayout_3.addWidget(self.comboBaudrate) 46 | 47 | self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) 48 | 49 | self.horizontalLayout_3.addItem(self.horizontalSpacer) 50 | 51 | self.btnClear = QPushButton(self.centralwidget) 52 | self.btnClear.setObjectName(u"btnClear") 53 | 54 | self.horizontalLayout_3.addWidget(self.btnClear) 55 | 56 | self.btnOpen = QPushButton(self.centralwidget) 57 | self.btnOpen.setObjectName(u"btnOpen") 58 | 59 | self.horizontalLayout_3.addWidget(self.btnOpen) 60 | 61 | 62 | self.verticalLayout_2.addLayout(self.horizontalLayout_3) 63 | 64 | self.groupBox = QGroupBox(self.centralwidget) 65 | self.groupBox.setObjectName(u"groupBox") 66 | self.verticalLayout = QVBoxLayout(self.groupBox) 67 | self.verticalLayout.setObjectName(u"verticalLayout") 68 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) 69 | self.editRecv = QPlainTextEdit(self.groupBox) 70 | self.editRecv.setObjectName(u"editRecv") 71 | self.editRecv.setReadOnly(True) 72 | 73 | self.verticalLayout.addWidget(self.editRecv) 74 | 75 | 76 | self.verticalLayout_2.addWidget(self.groupBox) 77 | 78 | self.groupBox_2 = QGroupBox(self.centralwidget) 79 | self.groupBox_2.setObjectName(u"groupBox_2") 80 | self.horizontalLayout_2 = QHBoxLayout(self.groupBox_2) 81 | self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") 82 | self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) 83 | self.horizontalLayout = QHBoxLayout() 84 | self.horizontalLayout.setObjectName(u"horizontalLayout") 85 | self.editSend = QLineEdit(self.groupBox_2) 86 | self.editSend.setObjectName(u"editSend") 87 | 88 | self.horizontalLayout.addWidget(self.editSend) 89 | 90 | self.btnSend = QPushButton(self.groupBox_2) 91 | self.btnSend.setObjectName(u"btnSend") 92 | 93 | self.horizontalLayout.addWidget(self.btnSend) 94 | 95 | 96 | self.horizontalLayout_2.addLayout(self.horizontalLayout) 97 | 98 | 99 | self.verticalLayout_2.addWidget(self.groupBox_2) 100 | 101 | MainWindow.setCentralWidget(self.centralwidget) 102 | self.menubar = QMenuBar(MainWindow) 103 | self.menubar.setObjectName(u"menubar") 104 | self.menubar.setGeometry(QRect(0, 0, 800, 26)) 105 | MainWindow.setMenuBar(self.menubar) 106 | self.statusbar = QStatusBar(MainWindow) 107 | self.statusbar.setObjectName(u"statusbar") 108 | MainWindow.setStatusBar(self.statusbar) 109 | 110 | self.retranslateUi(MainWindow) 111 | 112 | QMetaObject.connectSlotsByName(MainWindow) 113 | # setupUi 114 | 115 | def retranslateUi(self, MainWindow): 116 | MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) 117 | self.label.setText(QCoreApplication.translate("MainWindow", u"\u4e32\u53e3\u53f7\uff1a", None)) 118 | self.label_2.setText(QCoreApplication.translate("MainWindow", u"\u6ce2\u7279\u7387\uff1a", None)) 119 | self.btnClear.setText(QCoreApplication.translate("MainWindow", u"\u6e05\u7a7a", None)) 120 | self.btnOpen.setText(QCoreApplication.translate("MainWindow", u"\u6253\u5f00", None)) 121 | self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"\u63a5\u6536\uff1a", None)) 122 | self.groupBox_2.setTitle(QCoreApplication.translate("MainWindow", u"\u53d1\u9001\uff1a", None)) 123 | self.btnSend.setText(QCoreApplication.translate("MainWindow", u"\u53d1\u9001", None)) 124 | # retranslateUi 125 | 126 | -------------------------------------------------------------------------------- /usbhid_test/ui/test.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1098 10 | 606 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | usbhid port: 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | PushButton 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | recv: 48 | 49 | 50 | 51 | 0 52 | 53 | 54 | 0 55 | 56 | 57 | 0 58 | 59 | 60 | 0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | send multiple 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Send 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Send 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | Send 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | Send 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | Send 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | Send 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | Send 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | Send 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | Send 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | Send 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | Save 290 | 291 | 292 | 293 | 294 | 295 | 296 | Load 297 | 298 | 299 | 300 | 301 | 302 | 303 | Send All Once 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | send: 318 | 319 | 320 | 321 | 0 322 | 323 | 324 | 0 325 | 326 | 327 | 0 328 | 329 | 330 | 0 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | Send 339 | 340 | 341 | 342 | 343 | 344 | 345 | ... 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | -------------------------------------------------------------------------------- /usbhid_test/ui/ui_test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | ################################################################################ 4 | ## Form generated from reading UI file 'testakpTgj.ui' 5 | ## 6 | ## Created by: Qt User Interface Compiler version 5.15.2 7 | ## 8 | ## WARNING! All changes made in this file will be lost when recompiling UI file! 9 | ################################################################################ 10 | 11 | from PySide2.QtCore import * 12 | from PySide2.QtGui import * 13 | from PySide2.QtWidgets import * 14 | 15 | 16 | class Ui_MainWindow(object): 17 | def setupUi(self, MainWindow): 18 | if not MainWindow.objectName(): 19 | MainWindow.setObjectName(u"MainWindow") 20 | MainWindow.resize(1098, 606) 21 | self.centralwidget = QWidget(MainWindow) 22 | self.centralwidget.setObjectName(u"centralwidget") 23 | self.verticalLayout_3 = QVBoxLayout(self.centralwidget) 24 | self.verticalLayout_3.setObjectName(u"verticalLayout_3") 25 | self.horizontalLayout = QHBoxLayout() 26 | self.horizontalLayout.setObjectName(u"horizontalLayout") 27 | self.label = QLabel(self.centralwidget) 28 | self.label.setObjectName(u"label") 29 | 30 | self.horizontalLayout.addWidget(self.label) 31 | 32 | self.comboPort = QComboBox(self.centralwidget) 33 | self.comboPort.setObjectName(u"comboPort") 34 | 35 | self.horizontalLayout.addWidget(self.comboPort) 36 | 37 | self.btnConnect = QPushButton(self.centralwidget) 38 | self.btnConnect.setObjectName(u"btnConnect") 39 | 40 | self.horizontalLayout.addWidget(self.btnConnect) 41 | 42 | self.horizontalLayout.setStretch(0, 1) 43 | self.horizontalLayout.setStretch(1, 8) 44 | self.horizontalLayout.setStretch(2, 2) 45 | 46 | self.verticalLayout_3.addLayout(self.horizontalLayout) 47 | 48 | self.horizontalLayout_3 = QHBoxLayout() 49 | self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") 50 | self.groupBox = QGroupBox(self.centralwidget) 51 | self.groupBox.setObjectName(u"groupBox") 52 | self.groupBox.setStyleSheet(u"") 53 | self.verticalLayout = QVBoxLayout(self.groupBox) 54 | self.verticalLayout.setObjectName(u"verticalLayout") 55 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) 56 | self.editRecv = QPlainTextEdit(self.groupBox) 57 | self.editRecv.setObjectName(u"editRecv") 58 | 59 | self.verticalLayout.addWidget(self.editRecv) 60 | 61 | 62 | self.horizontalLayout_3.addWidget(self.groupBox) 63 | 64 | self.groupBoxSendMultiple = QGroupBox(self.centralwidget) 65 | self.groupBoxSendMultiple.setObjectName(u"groupBoxSendMultiple") 66 | self.verticalLayout_2 = QVBoxLayout(self.groupBoxSendMultiple) 67 | self.verticalLayout_2.setObjectName(u"verticalLayout_2") 68 | self.horizontalLayout_4 = QHBoxLayout() 69 | self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") 70 | self.checkSend1 = QCheckBox(self.groupBoxSendMultiple) 71 | self.checkSend1.setObjectName(u"checkSend1") 72 | 73 | self.horizontalLayout_4.addWidget(self.checkSend1) 74 | 75 | self.editSend1 = QLineEdit(self.groupBoxSendMultiple) 76 | self.editSend1.setObjectName(u"editSend1") 77 | 78 | self.horizontalLayout_4.addWidget(self.editSend1) 79 | 80 | self.btnSend1 = QPushButton(self.groupBoxSendMultiple) 81 | self.btnSend1.setObjectName(u"btnSend1") 82 | 83 | self.horizontalLayout_4.addWidget(self.btnSend1) 84 | 85 | 86 | self.verticalLayout_2.addLayout(self.horizontalLayout_4) 87 | 88 | self.horizontalLayout_13 = QHBoxLayout() 89 | self.horizontalLayout_13.setObjectName(u"horizontalLayout_13") 90 | self.checkSend2 = QCheckBox(self.groupBoxSendMultiple) 91 | self.checkSend2.setObjectName(u"checkSend2") 92 | 93 | self.horizontalLayout_13.addWidget(self.checkSend2) 94 | 95 | self.editSend2 = QLineEdit(self.groupBoxSendMultiple) 96 | self.editSend2.setObjectName(u"editSend2") 97 | 98 | self.horizontalLayout_13.addWidget(self.editSend2) 99 | 100 | self.btnSend2 = QPushButton(self.groupBoxSendMultiple) 101 | self.btnSend2.setObjectName(u"btnSend2") 102 | 103 | self.horizontalLayout_13.addWidget(self.btnSend2) 104 | 105 | 106 | self.verticalLayout_2.addLayout(self.horizontalLayout_13) 107 | 108 | self.horizontalLayout_12 = QHBoxLayout() 109 | self.horizontalLayout_12.setObjectName(u"horizontalLayout_12") 110 | self.checkSend3 = QCheckBox(self.groupBoxSendMultiple) 111 | self.checkSend3.setObjectName(u"checkSend3") 112 | 113 | self.horizontalLayout_12.addWidget(self.checkSend3) 114 | 115 | self.editSend3 = QLineEdit(self.groupBoxSendMultiple) 116 | self.editSend3.setObjectName(u"editSend3") 117 | 118 | self.horizontalLayout_12.addWidget(self.editSend3) 119 | 120 | self.btnSend3 = QPushButton(self.groupBoxSendMultiple) 121 | self.btnSend3.setObjectName(u"btnSend3") 122 | 123 | self.horizontalLayout_12.addWidget(self.btnSend3) 124 | 125 | 126 | self.verticalLayout_2.addLayout(self.horizontalLayout_12) 127 | 128 | self.horizontalLayout_11 = QHBoxLayout() 129 | self.horizontalLayout_11.setObjectName(u"horizontalLayout_11") 130 | self.checkSend4 = QCheckBox(self.groupBoxSendMultiple) 131 | self.checkSend4.setObjectName(u"checkSend4") 132 | 133 | self.horizontalLayout_11.addWidget(self.checkSend4) 134 | 135 | self.editSend4 = QLineEdit(self.groupBoxSendMultiple) 136 | self.editSend4.setObjectName(u"editSend4") 137 | 138 | self.horizontalLayout_11.addWidget(self.editSend4) 139 | 140 | self.btnSend4 = QPushButton(self.groupBoxSendMultiple) 141 | self.btnSend4.setObjectName(u"btnSend4") 142 | 143 | self.horizontalLayout_11.addWidget(self.btnSend4) 144 | 145 | 146 | self.verticalLayout_2.addLayout(self.horizontalLayout_11) 147 | 148 | self.horizontalLayout_10 = QHBoxLayout() 149 | self.horizontalLayout_10.setObjectName(u"horizontalLayout_10") 150 | self.checkSend5 = QCheckBox(self.groupBoxSendMultiple) 151 | self.checkSend5.setObjectName(u"checkSend5") 152 | 153 | self.horizontalLayout_10.addWidget(self.checkSend5) 154 | 155 | self.editSend5 = QLineEdit(self.groupBoxSendMultiple) 156 | self.editSend5.setObjectName(u"editSend5") 157 | 158 | self.horizontalLayout_10.addWidget(self.editSend5) 159 | 160 | self.btnSend5 = QPushButton(self.groupBoxSendMultiple) 161 | self.btnSend5.setObjectName(u"btnSend5") 162 | 163 | self.horizontalLayout_10.addWidget(self.btnSend5) 164 | 165 | 166 | self.verticalLayout_2.addLayout(self.horizontalLayout_10) 167 | 168 | self.horizontalLayout_9 = QHBoxLayout() 169 | self.horizontalLayout_9.setObjectName(u"horizontalLayout_9") 170 | self.checkSend6 = QCheckBox(self.groupBoxSendMultiple) 171 | self.checkSend6.setObjectName(u"checkSend6") 172 | 173 | self.horizontalLayout_9.addWidget(self.checkSend6) 174 | 175 | self.editSend6 = QLineEdit(self.groupBoxSendMultiple) 176 | self.editSend6.setObjectName(u"editSend6") 177 | 178 | self.horizontalLayout_9.addWidget(self.editSend6) 179 | 180 | self.btnSend6 = QPushButton(self.groupBoxSendMultiple) 181 | self.btnSend6.setObjectName(u"btnSend6") 182 | 183 | self.horizontalLayout_9.addWidget(self.btnSend6) 184 | 185 | 186 | self.verticalLayout_2.addLayout(self.horizontalLayout_9) 187 | 188 | self.horizontalLayout_8 = QHBoxLayout() 189 | self.horizontalLayout_8.setObjectName(u"horizontalLayout_8") 190 | self.checkSend7 = QCheckBox(self.groupBoxSendMultiple) 191 | self.checkSend7.setObjectName(u"checkSend7") 192 | 193 | self.horizontalLayout_8.addWidget(self.checkSend7) 194 | 195 | self.editSend7 = QLineEdit(self.groupBoxSendMultiple) 196 | self.editSend7.setObjectName(u"editSend7") 197 | 198 | self.horizontalLayout_8.addWidget(self.editSend7) 199 | 200 | self.btnSend7 = QPushButton(self.groupBoxSendMultiple) 201 | self.btnSend7.setObjectName(u"btnSend7") 202 | 203 | self.horizontalLayout_8.addWidget(self.btnSend7) 204 | 205 | 206 | self.verticalLayout_2.addLayout(self.horizontalLayout_8) 207 | 208 | self.horizontalLayout_7 = QHBoxLayout() 209 | self.horizontalLayout_7.setObjectName(u"horizontalLayout_7") 210 | self.checkSend8 = QCheckBox(self.groupBoxSendMultiple) 211 | self.checkSend8.setObjectName(u"checkSend8") 212 | 213 | self.horizontalLayout_7.addWidget(self.checkSend8) 214 | 215 | self.editSend8 = QLineEdit(self.groupBoxSendMultiple) 216 | self.editSend8.setObjectName(u"editSend8") 217 | 218 | self.horizontalLayout_7.addWidget(self.editSend8) 219 | 220 | self.btnSend8 = QPushButton(self.groupBoxSendMultiple) 221 | self.btnSend8.setObjectName(u"btnSend8") 222 | 223 | self.horizontalLayout_7.addWidget(self.btnSend8) 224 | 225 | 226 | self.verticalLayout_2.addLayout(self.horizontalLayout_7) 227 | 228 | self.horizontalLayout_6 = QHBoxLayout() 229 | self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") 230 | self.checkSend9 = QCheckBox(self.groupBoxSendMultiple) 231 | self.checkSend9.setObjectName(u"checkSend9") 232 | 233 | self.horizontalLayout_6.addWidget(self.checkSend9) 234 | 235 | self.editSend9 = QLineEdit(self.groupBoxSendMultiple) 236 | self.editSend9.setObjectName(u"editSend9") 237 | 238 | self.horizontalLayout_6.addWidget(self.editSend9) 239 | 240 | self.btnSend9 = QPushButton(self.groupBoxSendMultiple) 241 | self.btnSend9.setObjectName(u"btnSend9") 242 | 243 | self.horizontalLayout_6.addWidget(self.btnSend9) 244 | 245 | 246 | self.verticalLayout_2.addLayout(self.horizontalLayout_6) 247 | 248 | self.horizontalLayout_5 = QHBoxLayout() 249 | self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") 250 | self.checkSend10 = QCheckBox(self.groupBoxSendMultiple) 251 | self.checkSend10.setObjectName(u"checkSend10") 252 | 253 | self.horizontalLayout_5.addWidget(self.checkSend10) 254 | 255 | self.editSend10 = QLineEdit(self.groupBoxSendMultiple) 256 | self.editSend10.setObjectName(u"editSend10") 257 | 258 | self.horizontalLayout_5.addWidget(self.editSend10) 259 | 260 | self.btnSend10 = QPushButton(self.groupBoxSendMultiple) 261 | self.btnSend10.setObjectName(u"btnSend10") 262 | 263 | self.horizontalLayout_5.addWidget(self.btnSend10) 264 | 265 | 266 | self.verticalLayout_2.addLayout(self.horizontalLayout_5) 267 | 268 | self.horizontalLayout_14 = QHBoxLayout() 269 | self.horizontalLayout_14.setObjectName(u"horizontalLayout_14") 270 | self.btnSaveCmd = QPushButton(self.groupBoxSendMultiple) 271 | self.btnSaveCmd.setObjectName(u"btnSaveCmd") 272 | 273 | self.horizontalLayout_14.addWidget(self.btnSaveCmd) 274 | 275 | self.btnLoadCmd = QPushButton(self.groupBoxSendMultiple) 276 | self.btnLoadCmd.setObjectName(u"btnLoadCmd") 277 | 278 | self.horizontalLayout_14.addWidget(self.btnLoadCmd) 279 | 280 | self.btnSendAll = QPushButton(self.groupBoxSendMultiple) 281 | self.btnSendAll.setObjectName(u"btnSendAll") 282 | 283 | self.horizontalLayout_14.addWidget(self.btnSendAll) 284 | 285 | 286 | self.verticalLayout_2.addLayout(self.horizontalLayout_14) 287 | 288 | 289 | self.horizontalLayout_3.addWidget(self.groupBoxSendMultiple) 290 | 291 | self.horizontalLayout_3.setStretch(0, 7) 292 | self.horizontalLayout_3.setStretch(1, 3) 293 | 294 | self.verticalLayout_3.addLayout(self.horizontalLayout_3) 295 | 296 | self.groupBox_2 = QGroupBox(self.centralwidget) 297 | self.groupBox_2.setObjectName(u"groupBox_2") 298 | self.horizontalLayout_2 = QHBoxLayout(self.groupBox_2) 299 | self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") 300 | self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) 301 | self.editSend = QLineEdit(self.groupBox_2) 302 | self.editSend.setObjectName(u"editSend") 303 | 304 | self.horizontalLayout_2.addWidget(self.editSend) 305 | 306 | self.btnSend = QPushButton(self.groupBox_2) 307 | self.btnSend.setObjectName(u"btnSend") 308 | 309 | self.horizontalLayout_2.addWidget(self.btnSend) 310 | 311 | self.btnSendMultiple = QToolButton(self.groupBox_2) 312 | self.btnSendMultiple.setObjectName(u"btnSendMultiple") 313 | 314 | self.horizontalLayout_2.addWidget(self.btnSendMultiple) 315 | 316 | self.horizontalLayout_2.setStretch(0, 9) 317 | self.horizontalLayout_2.setStretch(1, 1) 318 | 319 | self.verticalLayout_3.addWidget(self.groupBox_2) 320 | 321 | MainWindow.setCentralWidget(self.centralwidget) 322 | self.statusBar = QStatusBar(MainWindow) 323 | self.statusBar.setObjectName(u"statusBar") 324 | MainWindow.setStatusBar(self.statusBar) 325 | 326 | self.retranslateUi(MainWindow) 327 | 328 | QMetaObject.connectSlotsByName(MainWindow) 329 | # setupUi 330 | 331 | def retranslateUi(self, MainWindow): 332 | MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None)) 333 | self.label.setText(QCoreApplication.translate("MainWindow", u"usbhid port:", None)) 334 | self.btnConnect.setText(QCoreApplication.translate("MainWindow", u"PushButton", None)) 335 | self.groupBox.setTitle(QCoreApplication.translate("MainWindow", u"recv:", None)) 336 | self.groupBoxSendMultiple.setTitle(QCoreApplication.translate("MainWindow", u"send multiple", None)) 337 | self.checkSend1.setText("") 338 | self.btnSend1.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 339 | self.checkSend2.setText("") 340 | self.btnSend2.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 341 | self.checkSend3.setText("") 342 | self.btnSend3.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 343 | self.checkSend4.setText("") 344 | self.btnSend4.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 345 | self.checkSend5.setText("") 346 | self.btnSend5.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 347 | self.checkSend6.setText("") 348 | self.btnSend6.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 349 | self.checkSend7.setText("") 350 | self.btnSend7.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 351 | self.checkSend8.setText("") 352 | self.btnSend8.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 353 | self.checkSend9.setText("") 354 | self.btnSend9.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 355 | self.checkSend10.setText("") 356 | self.btnSend10.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 357 | self.btnSaveCmd.setText(QCoreApplication.translate("MainWindow", u"Save", None)) 358 | self.btnLoadCmd.setText(QCoreApplication.translate("MainWindow", u"Load", None)) 359 | self.btnSendAll.setText(QCoreApplication.translate("MainWindow", u"Send All Once", None)) 360 | self.groupBox_2.setTitle(QCoreApplication.translate("MainWindow", u"send:", None)) 361 | self.btnSend.setText(QCoreApplication.translate("MainWindow", u"Send", None)) 362 | self.btnSendMultiple.setText(QCoreApplication.translate("MainWindow", u"...", None)) 363 | # retranslateUi 364 | 365 | -------------------------------------------------------------------------------- /usbhid_test/usbhid_test.py: -------------------------------------------------------------------------------- 1 | 2 | import csv 3 | import sys 4 | import hid 5 | 6 | from PySide2.QtWidgets import * 7 | from PySide2.QtCore import * 8 | from PySide2.QtGui import * 9 | 10 | from ui.ui_test import Ui_MainWindow 11 | 12 | import qtmodern.styles 13 | import qtmodern.windows 14 | 15 | hid_packet_size = 64 16 | 17 | class MainWindow(Ui_MainWindow,QMainWindow): 18 | def __init__(self): 19 | super(MainWindow,self).__init__() 20 | self.setupUi(self) 21 | 22 | #scan usbhid device 23 | devices = hid.enumerate() 24 | 25 | self.dev = hid.device() 26 | 27 | index = 0 28 | for devinfo in devices: 29 | product_str = devinfo['product_string'] 30 | manu_str = devinfo['manufacturer_string'] 31 | vid = devinfo['vendor_id'] 32 | pid = devinfo['product_id'] 33 | 34 | name_str = product_str + f' by {manu_str}' 35 | print(name_str) 36 | if product_str != '': 37 | self.comboPort.addItem(name_str) 38 | self.comboPort.setItemData(index,pid,Qt.UserRole+1) 39 | self.comboPort.setItemData(index,vid,Qt.UserRole+2) 40 | index += 1 41 | 42 | self.editSend.setPlaceholderText('send hex str') 43 | self.btnConnect.setText('connect') 44 | self.btnConnect.clicked.connect(self.connect_device) 45 | 46 | self.timer_read = QTimer(self) 47 | self.timer_read.setInterval(100) 48 | self.timer_read.timeout.connect(self.read_device) 49 | 50 | self.btnSend.clicked.connect(self.write_device) 51 | 52 | self.btnSendMultiple.setCheckable(True) 53 | self.btnSendMultiple.toggled.connect(self.toggle_send_multiple) 54 | self.groupBoxSendMultiple.setVisible(False) 55 | self.btnSendMultiple.setChecked(False) 56 | 57 | self.btnSendAll.clicked.connect(self.send_all_cmd) 58 | 59 | self.btnSend1.clicked.connect(self.send_cmd1) 60 | self.btnSend2.clicked.connect(self.send_cmd2) 61 | self.btnSend3.clicked.connect(self.send_cmd3) 62 | self.btnSend4.clicked.connect(self.send_cmd4) 63 | self.btnSend5.clicked.connect(self.send_cmd5) 64 | self.btnSend6.clicked.connect(self.send_cmd6) 65 | self.btnSend7.clicked.connect(self.send_cmd7) 66 | self.btnSend8.clicked.connect(self.send_cmd8) 67 | self.btnSend9.clicked.connect(self.send_cmd9) 68 | self.btnSend10.clicked.connect(self.send_cmd10) 69 | 70 | self.btnSaveCmd.clicked.connect(self.save_cmd) 71 | self.btnLoadCmd.clicked.connect(self.load_cmd) 72 | 73 | def toggle_send_multiple(self): 74 | print("Toggling send multiple") 75 | if self.btnSendMultiple.isChecked(): 76 | self.groupBoxSendMultiple.setVisible(True) 77 | else: 78 | self.groupBoxSendMultiple.setVisible(False) 79 | 80 | def connect_device(self): 81 | pid = self.comboPort.itemData(self.comboPort.currentIndex(),Qt.UserRole+1) 82 | vid = self.comboPort.itemData(self.comboPort.currentIndex(),Qt.UserRole+2) 83 | product_str = self.comboPort.currentText() 84 | 85 | print(f'current device:{product_str},pid={pid:#0x}, vid={vid:#0x}') 86 | 87 | if self.btnConnect.text() == 'connect': 88 | self.btnConnect.setText('disconnect') 89 | 90 | try: 91 | print('open the device') 92 | self.dev.open(vid,pid) 93 | except IOError as exc: 94 | print((f'open usb device failed:{exc}')) 95 | self.editRecv.appendPlainText(f'open usb device failed:{exc}') 96 | 97 | self.editRecv.clear() 98 | self.editRecv.appendPlainText(f'open device: {product_str}') 99 | 100 | self.dev.set_nonblocking(True) 101 | print('now read the process.') 102 | self.timer_read.start() 103 | else: 104 | self.timer_read.stop() 105 | self.dev.close() 106 | self.btnConnect.setText('connect') 107 | 108 | def read_device(self): 109 | # print('read device') 110 | 111 | if self.dev != None: 112 | recv_buff = self.dev.read(hid_packet_size) 113 | 114 | if len(recv_buff) != 0: 115 | recv_str = ' '.join([f'{i:#02x}' for i in bytes(recv_buff).rstrip(b'\x00')]) 116 | print(recv_str) 117 | self.editRecv.appendPlainText(recv_str) 118 | 119 | def write_device(self): 120 | send_buff = self.editSend.text() 121 | 122 | hex_str = bytes.fromhex(send_buff) 123 | 124 | if len(hex_str) != 0: 125 | if self.dev != None: 126 | print(f'send data to device:{hex_str}') 127 | self.dev.write(hex_str) 128 | 129 | def send_cmd(self,x): 130 | sendx = bytes.fromhex(x) 131 | if len(sendx) != 0: 132 | if self.dev != None: 133 | self.dev.write(sendx) 134 | 135 | def send_all_cmd(self): 136 | if self.checkSend1.isChecked(): 137 | self.send_cmd1() 138 | if self.checkSend2.isChecked(): 139 | self.send_cmd2() 140 | if self.checkSend3.isChecked(): 141 | self.send_cmd3() 142 | if self.checkSend4.isChecked(): 143 | self.send_cmd4() 144 | if self.checkSend5.isChecked(): 145 | self.send_cmd5() 146 | if self.checkSend6.isChecked(): 147 | self.send_cmd6() 148 | if self.checkSend7.isChecked(): 149 | self.send_cmd7() 150 | if self.checkSend8.isChecked(): 151 | self.send_cmd8() 152 | if self.checkSend9.isChecked(): 153 | self.send_cmd9() 154 | if self.checkSend10.isChecked(): 155 | self.send_cmd10() 156 | 157 | def send_cmd1(self): 158 | self.send_cmd(self.editSend1.text()) 159 | 160 | def send_cmd2(self): 161 | self.send_cmd(self.editSend2.text()) 162 | 163 | def send_cmd3(self): 164 | self.send_cmd(self.editSend3.text()) 165 | 166 | def send_cmd4(self): 167 | self.send_cmd(self.editSend4.text()) 168 | 169 | def send_cmd5(self): 170 | self.send_cmd(self.editSend5.text()) 171 | 172 | def send_cmd6(self): 173 | self.send_cmd(self.editSend6.text()) 174 | 175 | def send_cmd7(self): 176 | self.send_cmd(self.editSend7.text()) 177 | 178 | def send_cmd8(self): 179 | self.send_cmd(self.editSend8.text()) 180 | 181 | def send_cmd9(self): 182 | self.send_cmd(self.editSend9.text()) 183 | 184 | def send_cmd10(self): 185 | self.send_cmd(self.editSend10.text()) 186 | 187 | def save_cmd(self): 188 | with open("cmd.csv",'w',newline='') as csv_file: 189 | wr = csv.writer(csv_file,delimiter=' ',quotechar='|',quoting=csv.QUOTE_MINIMAL) 190 | wr.writerow([f'{self.editSend1.text()}']) 191 | wr.writerow([f'{self.editSend2.text()}']) 192 | wr.writerow([f'{self.editSend3.text()}']) 193 | wr.writerow([f'{self.editSend4.text()}']) 194 | wr.writerow([f'{self.editSend5.text()}']) 195 | wr.writerow([f'{self.editSend6.text()}']) 196 | wr.writerow([f'{self.editSend7.text()}']) 197 | wr.writerow([f'{self.editSend8.text()}']) 198 | wr.writerow([f'{self.editSend9.text()}']) 199 | wr.writerow([f'{self.editSend10.text()}']) 200 | 201 | def load_cmd(self): 202 | with open("cmd.csv",newline='') as csv_file: 203 | rd = csv.reader(csv_file,delimiter=' ',quotechar='|',quoting=csv.QUOTE_MINIMAL) 204 | s = [] 205 | for l in rd: 206 | s.append(l[0]) 207 | 208 | print(s) 209 | self.editSend1.setText(s[0]) 210 | self.editSend2.setText(s[1]) 211 | self.editSend3.setText(s[2]) 212 | self.editSend4.setText(s[3]) 213 | self.editSend5.setText(s[4]) 214 | self.editSend6.setText(s[5]) 215 | self.editSend7.setText(s[6]) 216 | self.editSend8.setText(s[7]) 217 | self.editSend9.setText(s[8]) 218 | self.editSend10.setText(s[9]) 219 | 220 | 221 | if __name__ == '__main__': 222 | app = QApplication(sys.argv) 223 | 224 | mwin = MainWindow() 225 | mwin.setWindowTitle('USBHID Test tool @MakerInChina') 226 | 227 | app.setWindowIcon(QIcon("../monkey.ico")) 228 | 229 | qtmodern.styles.dark(app) 230 | win = qtmodern.windows.ModernWindow(mwin) 231 | 232 | win.show() 233 | 234 | sys.exit(app.exec_()) --------------------------------------------------------------------------------