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

📄 frmsegconf.frm

📁 TCP/IP协议芯片使用说明
💻 FRM
📖 第 1 页 / 共 4 页
字号:
            WinsockDirect.Connect
            
            While Not bDirectUpload
               DoEvents
            Wend
            
        Else
            WinsockUDP.RemoteHost = "255.255.255.255"
            WinsockUDP.RemotePort = 1460
            WinsockUDP.SendData sendD
            Erase sendD
        End If
        
        
        If chkDirect.Value = 1 Then
            destIP = txtDirectIP.Text
            Sleep (3000)
        Else
            destIP = txtIP.Text
            Sleep (500)
        End If
        
        'destIP = txtIP.Text
        'destIP = "211.171.137.58"
        Call ShowMsgWindow
        WinsockDirect.Close
        
    End If

End Sub


Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    On Error Resume Next
    Select Case Button.Key
        Case "SearchBoard"
            Call func_SearchBoard
        Case "SettingBoard"
            Call func_SettingBoard
        Case "Upload"
            Call func_Upload
        Case "Exit"
            Form_Unload 0
    End Select
End Sub

Public Sub ListBoards_FirstRowSelect()
    ListBoards_ItemClick ListBoards.ListItems(1)
    ListBoards.ListItems(1).Selected = True
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''
' Name : ListBoards_ItemClick
' Parameter : Item is string of selected board's key.
'
' Save key string to "BoardKey" variable
' Save configuration data to "BoardInfo" variable.
' Show configuration data of selected Board.
'
''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub ListBoards_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim dd() As Byte
    Dim i As Long
    
On Error GoTo click_ERROR
    
    bSelect = True
    dd = colBoards.Item(Item.Key)
    BoardKey = Item.Key
    CopyMemory BoardInfo, dd(0), Len(BoardInfo)
    
    txtVersion.Text = BoardInfo.AppVer(0) & "." & BoardInfo.AppVer(1)
    If BoardInfo.debugoff = 0 Then
        chkDebug.Value = 1
    Else
        chkDebug.Value = 0
    End If
    If BoardInfo.DHCP = 1 Then
        chkDHCP.Value = 1
    Else
        chkDHCP.Value = 0
    End If
    If BoardInfo.UDP = 1 Then
        chkUDPMode.Value = 1
    Else
        chkUDPMode.Value = 0
    End If
    If BoardInfo.Connect = 1 Then
        txtConnect.Text = "Connected"
    Else
        txtConnect.Text = "Not Connected"
    End If
        
    txtIP.Text = BoardInfo.ip(0) & "." & BoardInfo.ip(1) & "." & BoardInfo.ip(2) & "." & BoardInfo.ip(3)
    txtSubnet.Text = BoardInfo.subnet(0) & "." & BoardInfo.subnet(1) & "." & BoardInfo.subnet(2) & "." & BoardInfo.subnet(3)
    txtGW.Text = BoardInfo.gw(0) & "." & BoardInfo.gw(1) & "." & BoardInfo.gw(2) & "." & BoardInfo.gw(3)
    i = BoardInfo.myport(0)
    i = (i * &H100)
    i = i + BoardInfo.myport(1)
    txtPort.Text = CStr(i)
    
    optClientMode.Item(BoardInfo.bserver).Value = True
    
    txtServerIP.Text = BoardInfo.peerip(0) & "." & BoardInfo.peerip(1) & "." & BoardInfo.peerip(2) & "." & BoardInfo.peerip(3)
    i = BoardInfo.peerport(0)
    i = (i * &H100)
    i = i + BoardInfo.peerport(1)
    txtServerPort.Text = CStr(i)
    
    i = BoardInfo.I_time(0)
    i = (i * &H100)
    i = i + BoardInfo.I_time(1)
    txtITime.Text = CStr(i)
    
    i = BoardInfo.D_time(0)
    i = (i * &H100)
    i = i + BoardInfo.D_time(1)
    txtDTime.Text = CStr(i)
    
    i = (BoardInfo.D_size(0) * &H100) + BoardInfo.D_size(1)
    txtDSize.Text = CStr(i)
    If BoardInfo.D_ch > 15 Then
        txtDChar.Text = Hex(BoardInfo.D_ch)
    Else
        txtDChar.Text = "0" & Hex(BoardInfo.D_ch)
    End If
    
    
    Select Case BoardInfo.speed
        Case &HBB
            cboSpeed.ListIndex = 8
        Case &HFF
            cboSpeed.ListIndex = 7
        Case &HFE
            cboSpeed.ListIndex = 6
        Case &HFD
            cboSpeed.ListIndex = 5
        Case &HFA
            cboSpeed.ListIndex = 4
        Case &HF4
            cboSpeed.ListIndex = 3
        Case &HE8
            cboSpeed.ListIndex = 2
        Case &HD0
            cboSpeed.ListIndex = 1
        Case &HA0
            cboSpeed.ListIndex = 0
        Case Else
            cboSpeed.ListIndex = 0
    End Select
    cboDataBits.Text = CStr(BoardInfo.databit)
    cboStopBits.Text = CStr(BoardInfo.stopbit)
    'cboParity.ListIndex = BoardInfo.parity
    Select Case BoardInfo.parity
        Case &H0
            cboParity.Text = "None"
        Case &H1
            cboParity.Text = "Odd"
        Case &H2
            cboParity.Text = "Even"
        Case Else
            cboParity.Text = "None"
    End Select
    cboFlow.ListIndex = BoardInfo.flow
    
    Erase dd
    Exit Sub

click_ERROR:
    cboFlow.ListIndex = 0
    Call MessageBox("Invalid parameter's value.")
    
End Sub

Private Sub cboDataBits_Click()
    If cboDataBits.Text = "7" Then
        cboParity.Clear
        'cboParity.AddItem "None", 0
        'cboParity.ItemData(0) = &H0
        cboParity.AddItem "Odd", 0
        cboParity.ItemData(0) = &H1
        cboParity.AddItem "Even", 1
        cboParity.ItemData(1) = &H2
        cboParity.ListIndex = 0
    Else
        cboParity.Clear
        cboParity.AddItem "None", 0
        cboParity.ItemData(0) = &H0
        cboParity.AddItem "Odd", 1
        cboParity.ItemData(1) = &H1
        cboParity.AddItem "Even", 2
        cboParity.ItemData(2) = &H2
        cboParity.ListIndex = 0
    End If

End Sub

Private Sub WinsockDirect_Connect()
    Dim sendD() As Byte
    
    
    Select Case ToolMode
    Case modeSearching
            ReDim sendD(0 To 3) As Byte
            sendD(0) = Asc("F")
            sendD(1) = Asc("I")
            sendD(2) = Asc("N")
            sendD(3) = Asc("D")
    
    Case modeSetting
            ' Sending SETT message
            ReDim sendD(0 To Len(BoardInfo) + 3) As Byte
            sendD(0) = Asc("S")
            sendD(1) = Asc("E")
            sendD(2) = Asc("T")
            sendD(3) = Asc("T")
            CopyMemory sendD(4), BoardInfo, Len(BoardInfo)
    
    Case modeUploading
            ReDim sendD(0 To Len(BoardInfo) + 3) As Byte
            sendD(0) = Asc("F")
            sendD(1) = Asc("I")
            sendD(2) = Asc("R")
            sendD(3) = Asc("S")
            CopyMemory sendD(4), BoardInfo, Len(BoardInfo)
    Case Else
        WinsockDirect.Close
        Exit Sub
    End Select
    
    WinsockDirect.SendData sendD
    Erase sendD
    
    bDirectUpload = True

End Sub

Private Sub WinsockDirect_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

    WinsockDirect.Close

End Sub

Private Sub WinsockDirect_DataArrival(ByVal bytesTotal As Long)
On Error GoTo WinsockDirect_DataArrival_ERROR
'On Error Resume Next
    Dim getd() As Byte
    Dim getboard(BoardInfoSize_3_4) As Byte
    Dim getkind(3) As Byte
    
    'Do
        If WinsockDirect.BytesReceived < BoardInfoSize_3_0 Then
            ReDim getd(0 To WinsockDirect.BytesReceived - 1) As Byte
            WinsockDirect.GetData getd, vbByte, WinsockDirect.BytesReceived
            Erase getd
            Exit Sub
        Else
            ReDim getd(0 To 100) As Byte
            WinsockDirect.GetData getd, vbByte, 100
            CopyMemory getkind(0), getd(0), 4
            CopyMemory getboard(0), getd(4), BoardInfoSize_3_4 - 4
            Erase getd
            
            If (getkind(0) = Asc("I")) And (getkind(1) = Asc("M")) And (getkind(2) = Asc("I")) And (getkind(3) = Asc("N")) Then
                If ToolMode = modeSearching Then
                    Call BoardAdd(getboard)
                    'ToolMode = None
                End If
                
            ElseIf (getkind(0) = Asc("S")) And (getkind(1) = Asc("E")) And (getkind(2) = Asc("T")) And (getkind(3) = Asc("C")) Then
                If ToolMode = modeSetting Then
                    Call BoardUpdate(getboard)
                End If
            End If
            'Exit Sub
        End If
    
    'Loop While WinsockDirect.BytesReceived
    WinsockDirect.Close
    
    'Erase getd
    Exit Sub

WinsockDirect_DataArrival_ERROR:
    If Err Then
        MsgBox "Retry, please"
    End If
    Erase getd

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''
' Name : WinsockUDP_DataArrival
' Parameter : bytesTotal is count of receiving data from "WinsockUDP" control
'
' Receive configuration message.
' "IMIN" message => BoardAdd
' "SETC" message => BoardUpdate
'
''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub WinsockUDP_DataArrival(ByVal bytesTotal As Long)
On Error GoTo WinsockUDP_DataArrival_ERROR
'On Error Resume Next
    Dim getd() As Byte
    Dim getboard(BoardInfoSize_3_4) As Byte
    Dim getkind(3) As Byte
    
    'Do
        If WinsockUDP.BytesReceived < BoardInfoSize_3_0 Then
            ReDim getd(0 To WinsockUDP.BytesReceived - 1) As Byte
            WinsockUDP.GetData getd, vbByte, WinsockUDP.BytesReceived
            Erase getd
            Exit Sub
        Else
            ReDim getd(0 To 100) As Byte
            WinsockUDP.GetData getd, vbByte, 100
            CopyMemory getkind(0), getd(0), 4
            CopyMemory getboard(0), getd(4), BoardInfoSize_3_4 - 4
            Erase getd
            
            If (getkind(0) = Asc("I")) And (getkind(1) = Asc("M")) And (getkind(2) = Asc("I")) And (getkind(3) = Asc("N")) Then
                If ToolMode = modeSearching Then
                    Call BoardAdd(getboard)
                    'ToolMode = None
                End If
                
            ElseIf (getkind(0) = Asc("S")) And (getkind(1) = Asc("E")) And (getkind(2) = Asc("T")) And (getkind(3) = Asc("C")) Then
                If ToolMode = modeSetting Then
                    Call BoardUpdate(getboard)
                End If
            End If
            'Exit Sub
        End If
    'Loop While WinsockUDP.BytesReceived
    
    'Erase getd
    Exit Sub

WinsockUDP_DataArrival_ERROR:
    If Err Then
        MsgBox "Retry, please"
    End If
    Erase getd
    
End Sub

Private Sub chkDirect_Click()
    If chkDirect.Value = 1 Then
        txtDirectIP.Visible = True
    Else
        txtDirectIP.Visible = False
    End If
    
End Sub


''''''''''''''''''''''''''''''''''''''''''''''''
' Name : TEXT Box filtering
' Parameter : None
'
' Filtering textbox's data
' ex) Port text box support only number
'
''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub txtVersion_KeyPress(KeyAscii As Integer)
    
        KeyAscii = 0

End Sub

Private Sub txtDChar_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102) Then
    ' backspace or 0~9 or A~F or a~f
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtDTime_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtITime_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtDSize_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtIP_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii = 46) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or . or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtDirectIP_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii = 46) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or . or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtServerIP_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii = 46) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or . or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtPort_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtServerPort_KeyPress(KeyAscii As Integer)
    
    If (KeyAscii = 8) Or (KeyAscii >= 48 And KeyAscii <= 57) Then
    ' backspace or 0~9
    Else
    ' else ignore
        KeyAscii = 0
    End If

End Sub

Private Sub txtConnect_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
End Sub

⌨️ 快捷键说明

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