资源简介

利用python语言开发的串口助手, 学习单片机,STM32好长时间了,也做了一些项目,一直想利用上位机实现电脑与单片机之间的传输数据,利用串口助手是最直接的通信方式,但串口助手不适合做上位机,如果会写串口助手的软件,基本能写自己写一个上位机。有对应的制作教程和代码讲解教程。链接:https://blog.csdn.net/scx2006114/article/details/99718264

资源截图

代码片段和文件信息

# coding:utf-8

import sys
from PyQt5.QtWidgets import QApplication QWidget QPushButton QLineEdit \
                            QGridLayout QLabel QMessageBox QComboBox \
                            QCheckBox
import serial
import binascii
import time
import serial.tools.list_ports

class CO2UI(QWidget):
    def __init__(self):
        super(CO2UI self).__init__()   #继承父类,并初始化
        self.initUI()        #编写界面布局和操作方法
        global flag_open     #标志位,判断串口是否打开
        global flag_char     #标志位,标志串口发送字符串类型
        global flag_hex      #标志位,标志串口发送十六进制类型
        global flagreceive_hex #标志位,标志串口接收字符串类型
        global flagreceive_char #标志位,标志串口接收十六进制类型
        self.flag_char = 0   #初始化
        self.flag_hex =0
        self.flag_open = 0
        self.flagreceive_hex = 0
        self.flagreceive_char = 0
    def initUI(self):
        grid = QGridLayout()        #网格布局

        buadlist = [‘9600‘ ‘14400‘ ‘19200‘ ‘384000‘]

        self.portname = QLabel(“端口号“)        #设置布局属性
        self.portbuad = QLabel(“波特率“)
        self.datanumber = QLabel(“发送数据位数:“)
        self.datasender = QLabel(“发送数据:“)
        self.datareview = QLabel(“接收数据:“)
        self.sendTepy = QLabel(“发送数据类型:“)
        self.charTepy = QCheckBox(“字符串“)
        self.hexTepy = QCheckBox(“十六进制“)
        self.receiveTepy= QLabel(“接收数据类型:“)
        self.receivechar = QCheckBox(“字符串“)
        self.receivehex = QCheckBox(“十六进制“)
        self.sendbutton = QPushButton(“发送“)
        self.open_button = QPushButton(“打开“)
        self.closebutton = QPushButton(“关闭“)
        self.portcomob = QComboBox(self)
        self.buadcomob = QComboBox(self)
        self.buadcomob.addItems(buadlist)
        self.datasenderEdit = QLineEdit()
        self.datareviewEdit = QLineEdit()
        self.datanumberEdit = QLineEdit()
        # 设置属性的位置
        grid.addWidget(self.portname 1 0)      #端口
        grid.addWidget(self.portcomob 1 1)
        grid.addWidget(self.portbuad 2 0)       #波特率
        grid.addWidget(self.buadcomob 2 1)
        grid.addWidget(self.datanumber 3 0)
        grid.addWidget(self.datanumberEdit 3 1)
        grid.addWidget(self.datasender 4 0)
        grid.addWidget(self.datasenderEdit 4 1 1 6)
        grid.addWidget(self.datareview 5 0)
        grid.addWidget(self.datareviewEdit 5 1 1 6)
        grid.addWidget(self.sendTepy 6 0)
        grid.addWidget(self.charTepy 6 1)
        grid.addWidget(self.hexTepy 6 2)
        grid.addWidget(self.receiveTepy 7 0)
        grid.addWidget(self.receivechar 7 1)
        grid.addWidget(self.receivehex 7 2)
        grid.addWidget(self.open_button 8 1)
        grid.addWidget(self.closebutton 8 2)
        grid.addWidget(self.sendbutton 8 3)
        self.setLayout(grid)    #布局

        self.SelctPort()
        self.sendbutton.clicked.connect(self.Cosender)   #按键触发信号
        self.open_button.clicked.connect(self.Check_serial)
        self

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      28220  2019-08-19 16:24  Serial assistant\build\Serial_assistant\Analysis-00.toc

     文件     770880  2019-08-19 16:24  Serial assistant\build\Serial_assistant\base_library.zip

     文件      14290  2019-08-19 16:24  Serial assistant\build\Serial_assistant\COLLECT-00.toc

     文件       2467  2019-08-19 16:24  Serial assistant\build\Serial_assistant\EXE-00.toc

     文件    1218328  2019-08-19 16:24  Serial assistant\build\Serial_assistant\PKG-00.pkg

     文件       1390  2019-08-19 16:24  Serial assistant\build\Serial_assistant\PKG-00.toc

     文件    1200135  2019-08-19 16:24  Serial assistant\build\Serial_assistant\PYZ-00.pyz

     文件      13770  2019-08-19 16:24  Serial assistant\build\Serial_assistant\PYZ-00.toc

     文件    1491224  2019-08-19 16:24  Serial assistant\build\Serial_assistant\Serial_assistant.exe

     文件       1041  2019-08-19 16:24  Serial assistant\build\Serial_assistant\Serial_assistant.exe.manifest

     文件       3739  2019-08-19 16:24  Serial assistant\build\Serial_assistant\warn-Serial_assistant.txt

     文件     308100  2019-08-19 16:24  Serial assistant\build\Serial_assistant\xref-Serial_assistant.html

     文件      19864  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-console-l1-1-0.dll

     文件      19352  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-datetime-l1-1-0.dll

     文件      19352  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-debug-l1-1-0.dll

     文件      19376  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-errorhandling-l1-1-0.dll

     文件      22928  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-file-l1-1-0.dll

     文件      19344  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-file-l1-2-0.dll

     文件      19336  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-file-l2-1-0.dll

     文件      19352  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-handle-l1-1-0.dll

     文件      19856  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-heap-l1-1-0.dll

     文件      19368  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-interlocked-l1-1-0.dll

     文件      19888  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-libraryloader-l1-1-0.dll

     文件      21936  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-localization-l1-2-0.dll

     文件      19856  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-memory-l1-1-0.dll

     文件      19360  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-namedpipe-l1-1-0.dll

     文件      20424  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-processenvironment-l1-1-0.dll

     文件      21432  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-processthreads-l1-1-0.dll

     文件      19896  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-processthreads-l1-1-1.dll

     文件      18840  2019-07-08 18:17  Serial assistant\dist\Serial_assistant\api-ms-win-core-profile-l1-1-0.dll

............此处省略118个文件信息

评论

共有 条评论