⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1b.frm

📁 设置滤波器类型
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         TabIndex        =   88
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   73
         Left            =   3120
         TabIndex        =   87
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   72
         Left            =   2760
         TabIndex        =   86
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   71
         Left            =   2400
         TabIndex        =   85
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   70
         Left            =   2040
         TabIndex        =   84
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   69
         Left            =   1680
         TabIndex        =   83
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   68
         Left            =   1320
         TabIndex        =   82
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   67
         Left            =   960
         TabIndex        =   81
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   66
         Left            =   600
         TabIndex        =   80
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.TextBox senddata 
         Height          =   375
         Index           =   65
         Left            =   240
         TabIndex        =   79
         Text            =   "28"
         Top             =   5760
         Width           =   395
      End
      Begin VB.CheckBox filter_data 
         Caption         =   "Filter Data"
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   5160
         Width           =   1335
      End
      Begin VB.ListBox List1 
         Height          =   4545
         ItemData        =   "Form1b.frx":0442
         Left            =   120
         List            =   "Form1b.frx":0444
         TabIndex        =   3
         Top             =   360
         Width           =   4455
      End
   End
   Begin VB.CommandButton Clear 
      Caption         =   "Clear"
      Height          =   375
      Left            =   1200
      TabIndex        =   1
      Top             =   5280
      Width           =   1215
   End
   Begin VB.CommandButton writetoflash 
      Caption         =   "Write to Flash"
      Height          =   375
      Left            =   6240
      TabIndex        =   0
      Top             =   2040
      Width           =   2055
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   1920
      Top             =   5880
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      InBufferSize    =   4096
      InputLen        =   8
      OutBufferSize   =   4096
      RThreshold      =   11
      BaudRate        =   1200
      EOFEnable       =   -1  'True
      InputMode       =   1
   End
   Begin VB.Menu File 
      Caption         =   "File"
      Begin VB.Menu Load 
         Caption         =   "Load"
      End
      Begin VB.Menu Save 
         Caption         =   "Save As"
      End
      Begin VB.Menu Exit 
         Caption         =   "Exit"
      End
   End
   Begin VB.Menu Setting 
      Caption         =   "Setting"
   End
   Begin VB.Menu Read_me 
      Caption         =   "Read_me"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim bb(0) As Byte   'for transmit
Dim receive_buffer(0 To 25) As Byte   'for receiving data
'Dim temp As String  'for displaying receiving data
Dim last_temp As String  'for displaying receiving data
Dim last_delay As String  'for displaying receiving data

Dim status As Byte  'for displaying data
'status uses 8bits  7 6 5 4 3 2 1 0
'                   - - - - - - - -
'                   | | | | | | | |_Filter is checked
'                   | | | | | | |___Filter 1 is not empty
'                   | | | | | |_____Filter 2 is not empty
'                   | | | | |_______delay can be displayed
'                   | | | |_________The first packet is the same

Dim receive_pointer As Byte

Private Sub Clear_Click()
    List1.Clear
End Sub

Private Sub FlashCopy_Click()
On Error GoTo 1
Dim bytrec() As Byte
Dim i As Long
MousePointer = vbHourglass
Form_Load1
MSComm1.InBufferCount = 0       'clear buffer
For i = 0 To 7
    bb(0) = &H7D    'write to flash
    MSComm1.Output = bb
Next i
wbptr = 0   'receive pointer

Timer1.Interval = 3000
Timer1.Enabled = True
writetoflash.Enabled = False
readflash.Enabled = False
FlashCopy.Enabled = False
MousePointer = vbHourglass
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub

Private Sub readflash_Click()
'On Error GoTo 1
Dim bytrec() As Byte
Dim i As Long
MousePointer = vbHourglass
Form_Load1
MSComm1.InBufferCount = 0       'clear buffer
For i = 0 To 7
    bb(0) = &H9D    'write to flash
    MSComm1.Output = bb
Next i
wbptr = 0   'receive pointer

Timer1.Interval = 7000
Timer1.Enabled = True
writetoflash.Enabled = False
readflash.Enabled = False
FlashCopy.Enabled = False

Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub

Private Sub Command2_Click()
On Error GoTo 1
Dim bytrec() As Byte
Dim i As Long
Dim temp As String
Timer1.Enabled = False
For i = 0 To 7 'maxsendsize - 2
    If senddata(i).Text = "" Then Exit For
    bb(0) = "&h" + senddata(i).Text
    MSComm1.Output = bb
Next i
'For i = 0 To maxsendsize - 2
'    If senddata(i).Text = "" Then Exit For
'    bb(0) = "&h" + senddata(i).Text
'    MSComm1.Output = bb
'Next i
'Timer1.Enabled = True
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub

Private Sub Exit_Click()
If (Form1.MSComm1.PortOpen) Then
    Form1.MSComm1.PortOpen = False
End If
Form2.Visible = False
End
End Sub

Private Sub Form_Load1()
'On Error GoTo 1
    If (Form1.MSComm1.PortOpen) Then
        Form1.MSComm1.PortOpen = False
    End If
    Form1.MSComm1.CommPort = Mid$(Form2.com.Text, 1, 1)
    Form1.MSComm1.Handshaking = Mid$(Form2.Flowcontrol.Text, 1, 1)
    Form1.MSComm1.Settings = Form2.baud.Text + "," + Mid$(Form2.Parity.Text, 1, 1) + "," + Form2.DataBit.Text + "," + Form2.StopBit.Text
    Form1.MSComm1.PortOpen = True
    Form2.Visible = False
    wbptr = 0
    Dim i As Double
    For i = 1 To 4990000
    Next i
    
    Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub



Private Sub Form_Unload(Cancel As Integer)
If (Form1.MSComm1.PortOpen) Then
    Form1.MSComm1.PortOpen = False
End If
End
End Sub
Private Sub Form_Unload1(Cancel As Integer)
If (Form1.MSComm1.PortOpen) Then
    Form1.MSComm1.PortOpen = False
End If
End Sub

Private Sub Load_Click()
Dim strFileName As String
With dlgopen
        .DialogTitle = "Load Config file"
        .CancelError = False
        .Filter = "access(*.flash)|*.flash" '".flash"
        .ShowOpen
        If Len(.filename) = 0 Then
            Exit Sub
        End If
        strFileName = .filename
End With
Dim i As Integer
Dim j As Integer
Dim temp As Byte
Open strFileName For Binary As #1
   For j = 0 To 4096
        i = i + 1
        Get #1, i, workingbuf(j)
   Next j
Close #1
wbptr = 0
MSComm1.InBufferCount = 0       'clear buffer
End Sub




Private Sub MSComm1_OnComm()

Select Case MSComm1.CommEvent
    Case comEvReceive
        Dim bytrec() As Byte
        Dim i As Integer
        Dim temp As String
        temp = ""
        bytrec() = MSComm1.Input
        If MSComm1.InBufferCount > 0 Then
        For i = 0 To 7 'MSComm1.InBufferCount - 1
        temp = temp + Hex(bytrec(i)) + " "
        'List1.AddItem Hex(bytrec(i))
        'List1.ListIndex = List1.ListCount - 1
        workingbuf(wbptr) = bytrec(i)
        wbptr = wbptr + 1
        If wbptr > 4095 Then wbptr = 0
        Next i
        List1.AddItem temp
        List1.ListIndex = List1.ListCount - 1
        End If
    End Select
End Sub

Private Sub Read_me_Click()
    HelpFunction Me.hwnd, 3, "" 'HELP_INDEX, ""
End Sub
Private Sub Save_Click()
Dim strFileName As String
With dlgopen
        .DialogTitle = "save Config file"
        .CancelError = False
        .Filter = "access(*.flash)|*.flash" '".flash"
        .ShowSave
        If Len(.filename) = 0 Then
            Exit Sub
        End If
        strFileName = .filename
End With
Dim i As Integer
Dim j As Integer
Open strFileName For Binary As #1
   For j = 0 To 4095 'wbptr
   i = i + 1
   
            Put #1, i, workingbuf(j)
  Next j
Close #1
End Sub


Private Sub Setting_Click()
Dim s As String
s = Form1.MSComm1.Settings
Dim i As Byte
 Form2.com.Text = Hex$(Form1.MSComm1.CommPort) + " - COM" + Hex$(Form1.MSComm1.CommPort)
For i = 1 To 10
If Mid$(s, i, 1) = "," Then
i = i - 1
Exit For
End If
Next i
Form2.baud.Text = Mid$(s, 1, i) 'baud

Form2.DataBit.Text = Mid$(s, i + 4, 1)
Form2.Parity.Text = Mid$(s, i + 2, 1)
Form2.StopBit.Text = Mid$(s, i + 6, 1)

Select Case Form2.Parity.Text
    Case "e"
        Form2.Parity.Text = "Even"
    Case "m"
        Form2.Parity.Text = "Mark"
    Case "n"
        Form2.Parity.Text = "None"
    Case "o"
        Form2.Parity.Text = "Odd"
    Case "s"
        Form2.Parity.Text = "Space"
End Select

Select Case Form1.MSComm1.Handshaking
Case 0
    Form2.Flowcontrol.Text = "0 - comNone"
Case 1
    Form2.Flowcontrol.Text = "1 - comXonXoff"
Case 2
    Form2.Flowcontrol.Text = "2 - comRTS"
Case 3
    Form2.Flowcontrol.Text = "3 - comRTSXonXoff"
End Select

Form2.Visible = True
End Sub




Private Sub Timer1_Timer()
Timer1.Enabled = False
writetoflash.Enabled = True
readflash.Enabled = True
FlashCopy.Enabled = True
MousePointer = 1
Form_Unload1 (0)
End Sub

Private Sub writetoflash_Click()

On Error GoTo 1
Dim bytrec() As Byte
Dim i As Long
MousePointer = vbHourglass
Form_Load1
For i = 0 To 7
    bb(0) = &H62    'write to flash
    MSComm1.Output = bb
Next i
For i = 0 To 4095
Next i
Timer1.Interval = 5000
Timer1.Enabled = True
writetoflash.Enabled = False
readflash.Enabled = False
FlashCopy.Enabled = False

For i = 0 To 4095
   bb(0) = workingbuf(i) '(i) And &HFF
    MSComm1.Output = bb
Next i
Exit Sub
1 MsgBox ("The serial port is already in use, Please set to the other port")
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -