?? 硬件調試接受窗口.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 8205
ClientLeft = 675
ClientTop = 1290
ClientWidth = 9750
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 8205
ScaleWidth = 9750
Begin VB.CommandButton Command4
Caption = "自動取數據"
Height = 495
Left = 8280
TabIndex = 15
Top = 480
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "已復位"
Height = 375
Left = 600
TabIndex = 14
Top = 360
Width = 855
End
Begin VB.TextBox Text2
Height = 270
Left = 6120
MultiLine = -1 'True
TabIndex = 12
Top = 2520
Width = 1695
End
Begin VB.CheckBox Check_hex
Caption = "十六進制顯示"
Height = 375
Left = 3960
TabIndex = 11
Top = 4800
Width = 1575
End
Begin VB.TextBox Text_r
Height = 2775
Left = 3720
MultiLine = -1 'True
TabIndex = 10
Top = 5280
Width = 5295
End
Begin VB.CheckBox Check1
Height = 255
Left = 1320
TabIndex = 8
Top = 1800
Width = 255
End
Begin VB.TextBox Text3
Height = 375
Left = 1320
TabIndex = 5
Top = 2160
Width = 375
End
Begin VB.Timer Timer1
Interval = 300
Left = 120
Top = 1680
End
Begin VB.CommandButton Command2
Caption = "清空"
Height = 375
Left = 5760
TabIndex = 3
Top = 4800
Width = 735
End
Begin VB.CommandButton Command1
Caption = "send"
Height = 375
Left = 360
TabIndex = 1
Top = 960
Width = 1095
End
Begin VB.TextBox Text1
Height = 2055
Left = 1920
MultiLine = -1 'True
TabIndex = 0
Top = 360
Width = 5895
End
Begin MSCommLib.MSComm MSComm1
Left = 9120
Top = 7560
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InputMode = 1
End
Begin VB.Shape Shape1
BackStyle = 1 'Opaque
FillColor = &H0000FF00&
FillStyle = 0 'Solid
Height = 375
Left = 120
Shape = 3 'Circle
Top = 360
Width = 375
End
Begin VB.Label Label6
Caption = "發送字節"
Height = 195
Left = 4800
TabIndex = 13
Top = 2640
Width = 795
End
Begin VB.Label Label5
Caption = "(重值周期后再次選擇自動發送)"
Height = 255
Left = 120
TabIndex = 9
Top = 2760
Width = 2535
End
Begin VB.Label Label4
Caption = "自動發送"
Height = 255
Left = 360
TabIndex = 7
Top = 1920
Width = 735
End
Begin VB.Label Label3
Caption = "發送周期"
Height = 255
Left = 360
TabIndex = 6
Top = 2280
Width = 735
End
Begin VB.Label Label2
Caption = "發送區"
Height = 255
Left = 2160
TabIndex = 4
Top = 120
Width = 615
End
Begin VB.Label Label1
Caption = "接受區"
Height = 255
Left = 3600
TabIndex = 2
Top = 4560
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetTickCount Lib "kernel32" _
() As Long
Public Sub TimeDelay(DT As Long)
Dim tt As Long
tt = GetTickCount()
Do
DoEvents
Loop Until GetTickCount - tt >= DT
End Sub
Public Sub Send_Data(hh As Integer)
Dim mysend() As Byte
Dim sendbyte(1) As Byte
Dim tempstr As String
Dim in_num As Integer
tempstr = Text1.Text
in_num = Len(tempstr)
ReDim mysend(1 To in_num) As Byte
For i = 1 To in_num
mysend(i) = Asc(Mid(tempstr, i, 1))
Next i
For ii = 1 To in_num
sendbyte(0) = mysend(ii)
MSComm1.Output = sendbyte '一個字節一發送 'mysend一串發'
'TimeDelay (1)
Shape1.FillColor = vbGreen
Next ii
Shape1.FillColor = vbWhite
Text2.Text = Val(Text2.Text) + in_num
If Val(Text2.Text) > 100 Then
Timer1.Enabled = False
Text1.Text = "單片機存儲超量,程序自動停止發送,請手動復位單片機"
Shape1.FillColor = vbRed
g_SendOverFg = True
End If
End Sub
Private Sub Check1_Click()
Dim sendhead(1) As Byte
If Check1.Value = 1 Then
Timer1.Enabled = True
Timer1.Interval = Val(Text3.Text) * 20
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Command3_Click() '已復位按鈕
If g_SendOverFg = True Then
Text2.Text = ""
Text1.Text = g_InitialStr
Shape1.FillColor = vbGreen
g_SendOverFg = False
End If
End Sub
Private Sub Command4_Click() '--------auto_create_and_send_data-------------
Dim sendone(1) As Byte
Dim gewei As String
Dim shiwei As String
Dim num As Integer
g_flag = 4
gewei = 0
shiwei = 0
sendone(0) = 33 '! 十進制表示asc碼
MSComm1.Output = sendone
TimeDelay (10) '延時等待單片機執行完8個周期
gewei = Right((Trim(Text1.Text)), 1)
If Len(Trim(Text1.Text)) = 2 Then
shiwei = Left((Trim(Text1.Text)), 1)
End If
num = Val(shiwei) * 10 + Val(gewei)
sendone(0) = num + 34 '協議: !=chr(33)表開始,"=chr(34)表示基準,asc和十進制轉換
MSComm1.OutBufferCount = 0
MSComm1.Output = sendone
'e r r o r F 6 1 1 0 5 1 2 3 4 6 1 1 0 : 1 2 3 4 6 1 1 0 ? 1 2 3 4 6 1 1 0 D 1 2 3 4 6 1 1 0 I 1 2 3 4 6 1 1 0 N 1 2 3 4 6 1 1 0 S 1 2 3 4 6 1 1 0 X 1 2 3 4 6 1 1 0 ] 1 2 3 4 6 1 1 0 b 1 2 3 4 6 1 1 0 g 1 2 3 4 6 1 1 0 l 1 2 3 4 6 1 1 1 q 1 2 3 4 6 1 1 2 v 1 2 3 4 6 1 1 3 { 1 2 3 4 6 1 1 4
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -