串口调试助手
串口调试助手(不断完善中)
说明
说明:版权所有:沧海一声笑
邮箱:minios@yeah.net
Private Declare Function ShellExecute Lib “shell32.dll“ Alias “ShellExecuteA“ (ByVal hwnd As Long, ByVal
lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Option Explicit
Dim inputsignal
Dim text_temp As String
Dim flag_dis As Boolean ’是否停止显示标志量
Dim rx_count As Single ’接收到的字符数
Dim tx_count As Single ’发送除去的字符数
’关闭程序
Private Sub Command6_Click()
MSComm1.PortOpen = False ’关闭串口
Unload Me ’关闭程序
End Sub
’单击“帮助”按钮打开网页链接
Private Sub Command7_Click()
ShellExecute Me.hwnd, “open“, “
最新源码:
Private Declare Function ShellExecute Lib “shell32.dll“ Alias “ShellExecuteA“ (ByVal hwnd As Long, ByVal
lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Option Explicit
Dim inputsignal
Dim text_temp As String
Dim flag_dis As Boolean ’是否停止显示标志量
Dim rx_count As Single ’接收到的字符数
Dim tx_count As Single ’发送除去的字符数
’***********************************
Dim x1 As String, x2 As String, x3 As String, x4 As String, x5 As String
Dim comset_temp As String
Private Sub Combo1_click()
Combo1.ForeColor = RGB(255, 0, 0)
Combo1.BackColor = RGB(12, 0, 0)
Call comm_set
End Sub
Private Sub Combo2_click()
Combo2.ForeColor = RGB(255, 0, 0)
Combo2.BackColor = RGB(12, 0, 0)
Call comm_set
End Sub
Private Sub Combo3_click()
Combo3.ForeColor = RGB(255, 0, 0)
Combo3.BackColor = RGB(12, 0, 0)
Call comm_set
End Sub
Private Sub Combo4_click()
Combo4.ForeColor = RGB(255, 0, 0)
Combo4.BackColor = RGB(12, 0, 0)
Call comm_set
End Sub
Private Sub Combo5_click()
Combo5.ForeColor = RGB(255, 0, 0)
Combo5.BackColor = RGB(12, 0, 0)
Call comm_set
End Sub
’计数清零
Private Sub Command5_Click()
rx_count = 0
tx_count = 0
End Sub
’关闭程序
Private Sub Command6_Click()
MSComm1.PortOpen = False ’关闭串口
Unload Me ’关闭程序
End Sub
’单击“帮助”按钮打开网页链接
Private Sub Command7_Click()
ShellExecute Me.hwnd, “open“, “http://domyself.cublog.cn“, ““, ““, 5
End Sub
Private Sub Command8_Click()
Call new_folder
Open Label16.Caption & “\com_data.txt“ For Append As #1
Write #1, “ 保存时间:“, Format(Now, “yyyy 年m 月dd 日 hh:mm“)
Write #1, Text1.Text
Close #1 ’关闭文件
End Sub
’’’’’’’’初始化
Private Sub form_load()
MSComm1.Settings = “9600,n,8,1“ ’串口的相关参数设置
MSComm1.CommPort = 1 ’串口1
MSComm1.InputLen = 0 ’表示一次读取所有数据
MSComm1.InBufferSize = 5120
MSComm1.InBufferCount = 0
MSComm1.OutBufferSize = 5120
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 1 ’每接收一个字符触发一次oncomm 事件
MSComm1.SThreshold = 1
MSComm1.PortOpen = True ’打开串口
Shape1.Shape = 2
Shape1.Visible = True
Shape1.FillStyle = 0 ’全部填充
Shape1.FillColor = QBColor(12) ’红色
flag_dis = False
Timer2.Enabled = True
Timer2.Interval = 250
rx_count = 0
tx_count = 0
Label14.Caption = rx_count ’接收到的字符数
Label15.Caption = tx_count ’发送出去的字符数
’串口选择
Combo1.AddItem “COM1“
Combo1.AddItem “COM2“
Combo1.AddItem “COM3“
Combo1.AddItem “COM4“
’波特率
Combo2.AddItem “300“
Combo2.AddItem “600“
Combo2.AddItem “1200“
Combo2.AddItem “2400“
Combo2.AddItem “4800“
Combo2.AddItem “9600“
Combo2.AddItem “19200“
Combo2.AddItem “38400“
Combo2.AddItem “43000“
Combo2.AddItem “115200“
’校验位
Combo3.AddItem “N“
Combo3.AddItem “E“
Combo3.AddItem “O“
’数据位
Combo4.AddItem “8“
Combo4.AddItem “7“
Combo4.AddItem “6“
’停止位
Combo5.AddItem “1“
Combo5.AddItem “2“
’设置combobox.text 初始值
Combo1.Text = “COM1“
Combo2.Text = “9600“
Combo3.Text = “N“
Combo4.Text = “8“
Combo5.Text = “1“
Call new_folder
Call comm_set
End Sub
’自动发送
Private Sub Check1_Click()
If Check1.Value Then
If Text2.Text 《》 ““ Then
Timer1.Interval = Text3.Text
Timer1.Enabled = True
End If
End If
End Sub
’手动发送
Private Sub Command1_Click()
MSComm1.Output = Text2.Text
tx_count = tx_count + Len(Text2.Text)
End Sub
’打开\关闭串口
Private Sub Command2_Click()
If Command2.Caption = “打开串口“ Then
Command2.Caption = “关闭串口“
MSComm1.PortOpen = True
Shape1.FillColor = QBColor(12) ’红色
Else
Command2.Caption = “打开串口“
MSComm1.PortOpen = False
Shape1.FillColor = QBColor(8) ’黑色
End If
End Sub
’清空接收区
Private Sub Command3_Click()
Text1.Text = ““
End Sub
’停止显示
Private Sub Command4_Click()
If flag_dis = False Then
flag_dis = True
Command4.Caption = “继续显示“
Else
flag_dis = False
Command4.Caption = “停止显示“
End If
End Sub
’串口响应事件
Private Sub mscomm1_oncomm()
Select Case MSComm1.CommEvent
Case comEvReceive
inputsignal = MSComm1.Input
rx_count = Len(Trim(inputsignal)) + rx_count
If flag_dis = True Then
text_temp = Text1.Text ’将接收区的文本信息锁存
Text1.Text = text_temp
Else
Text1.Text = (Text1.Text) & (inputsignal)
End If
Case Else
End Select
End Sub
’定时器1 用于定时发送
Private Sub Timer1_Timer()
If MSComm1.PortOpen = True Then ’如果串口处于打开的状态
If Check1.Value Then
If Text2.Text 《》 ““ Then
Timer1.Interval = Text3.Text
Timer1.Enabled = True
MSComm1.Output = Text2.Text
End If
End If
End If
End Sub
’定时器2 用于接收发送量显示
Private Sub Timer2_Timer()
Label14.Caption = rx_count
Label15.Caption = tx_count
End Sub
’创建一个文件
Public Sub new_folder()
Dim fol, fso, fil, fils, s, f, fldr
Dim aa As String
Set fso = CreateObject(“Scripting.FileSystemObject“)
On Error Resume Next
aa$ = “C:\COMDATA“
If fso.folderexists(aa$) = False Then
fol = fso.CreateFolder(aa$)
’MkDir aa
End If
aa$ = “C:\COMDATA\test“
If fso.folderexists(aa$) = False Then
fol = fso.CreateFolder(aa$)
’MkDir aa
End If
End Sub
’***************************
Public Sub comm_set()
If MSComm1.PortOpen 《》 False Then
MSComm1.PortOpen = False
End If
x1 = Combo1.Text
x2 = Combo2.Text
x3 = Combo3.Text
x4 = Combo4.Text
x5 = Combo5.Text
MSComm1.InputLen = 0 ’表示一次读取所有数据
MSComm1.InBufferSize = 512
MSComm1.InBufferCount = 0
MSComm1.OutBufferSize = 512
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 1 ’每接收一个字符触发一次oncomm 事件
MSComm1.SThreshold = 1
MSComm1.CommPort = Val(Right(x1, 1))
comset_temp = x2 & “,“ & x3 & “,“ & x4 & “,“ & x5
MSComm1.Settings = (comset_temp)
Command2.Caption = “打开串口“
Shape1.FillColor = QBColor(8) ’黑色
End Sub
效果图:
最新工程文件:
文件: 串口调试助手.rar
大小: 18KB
下载: 下载
哪个串口调试助手支持虚拟端口
首先下载虚拟串行工具,即虚拟串行端口驱动程序,然后打开软件。右侧的右侧是选择要连接的串行端口。例如,在这里,我几乎想到通往com1和com10端口的虚拟途径。您只需要在两个选项中选择com1端口和com10端口,然后,然后,然后您可以单击添加对完成添加。添加的串行端口将出现在左侧的虚拟端口中。当然,您还可以在此处添加更多串行端口,如图所示。如果我们想删除一对连接的串行端口,只需在左侧选择串行端口,然后单击“删除”按钮在右侧。删除完成后,左侧将没有一对串行端口。当然,如果我们要删除刚刚连接的所有串行端口,则可以直接单击下面的“删除所有”按钮,并且对话框可以选择“是”。删除后,左侧将没有串行端口。为了在下面演示下面的串行端口调试助手,所有串行端口均无法删除,并且我们仍然连接com1和com10。
怎么用串口调试助手配置蓝牙模块
下载PL2303串行驱动器程序并安装驱动程序PL2303_PROLIFIC_DRIVERICRLER_V1.0.EXE在用于调试蓝牙模块SKB501的计算机上
将Micro-USB电源线的USB端连接到计算机,然后连接到另一端的EVB板以打开计算机设备管理器,以查看是否存在相应的COM端口
V_OUT和V_IN与短电路盖连接,蓝牙模块SKB501连接到p0.01,rx和p0.02。开机电源开关,电源指示器已打开,您可以工作。
在调试计算机上下载并安装串行调试助手XCOM v2.0.exe,打开并运行串行端口以调试助手
选择相应的com端口,波特率为115200,发送相关的操作,而“ at sends at at at at at”的反馈结果表示硬件连接是正常的。