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

📄 d2xx_unit_net.vb

📁 free sources for gsm
💻 VB
📖 第 1 页 / 共 3 页
字号:
        If FT_Status <> FT_OK Then
            Exit Function
        End If

        FT_Serial_Number = Left(TempDevString, InStr(1, TempDevString, vbNullChar) - 1)

    End Function


    Function GetFTDeviceDescription(ByVal DeviceIndex As Integer) As Integer
        Dim TempDevString As String

        TempDevString = Space(64)

        FT_Status = FT_GetDeviceString(DeviceIndex, TempDevString, FT_LIST_BY_INDEX Or FT_OPEN_BY_DESCRIPTION)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

        FT_Description = Left(TempDevString, InStr(1, TempDevString, vbNullChar) - 1)

    End Function


    Function Open_USB_Device_By_Index(ByVal DeviceIndex As Integer) As Integer

        FT_Status = FT_OpenByIndex(DeviceIndex, FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If


    End Function


    Function Open_USB_Device_By_Serial_Number(ByVal SerialNumber As String) As Integer

        FT_Status = FT_OpenByDescription(SerialNumber, 1, FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Open_USB_Device_By_Description(ByVal Description As String) As Integer

        FT_Status = FT_OpenByDescription(Description, 2, FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Close_USB_Device() As Integer

        FT_Status = FT_Close(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Get_USB_Device_Info() As Integer
        Dim ID As Integer
        Dim pvDummy As Byte
        Dim VidPid As String
        Dim TempSerialNumber As String
        Dim TempDescription As String
        Dim lngFT_Type As Integer

        TempSerialNumber = Space(16)
        TempDescription = Space(64)

        FT_Status = FT_GetDeviceInfo(FT_Handle, lngFT_Type, ID, TempSerialNumber, TempDescription, 0)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

        FT_Serial_Number = Left(TempSerialNumber, InStr(1, TempSerialNumber, vbNullChar) - 1)
        FT_Description = Left(TempDescription, InStr(1, TempDescription, vbNullChar) - 1)

        If lngFT_Type = "0" Then
            FT_Type = "FT232/245BM"
        ElseIf lngFT_Type = "1" Then
            FT_Type = "FT232/245AM"
        ElseIf lngFT_Type = "2" Then
            FT_Type = "FT8U100AX"
        ElseIf lngFT_Type = "3" Then
            FT_Type = "Unknown"
        ElseIf lngFT_Type = "4" Then
            FT_Type = "FT2232C"
        End If

        VidPid = Hex(ID)
        While Len(VidPid) < 8
            VidPid = "0" + VidPid
        End While
        FT_VID_PID = VidPid

    End Function


    Function Reset_USB_Device() As Integer

        FT_Status = FT_ResetDevice(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function



    Function Purge_USB_Device_Out() As Integer

        FT_Status = FT_Purge(FT_Handle, FT_PURGE_RX)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Purge_USB_Device_In() As Integer

        FT_Status = FT_Purge(FT_Handle, FT_PURGE_TX)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_Data_Characteristics() As Integer

        FT_Status = FT_SetDataCharacteristics(FT_Handle, FT_Current_DataBits, FT_Current_StopBits, FT_Current_Parity)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_Baud_Rate() As Integer

        FT_Status = FT_SetBaudRate(FT_Handle, FT_Current_Baud)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_Baud_Rate_Divisor(ByVal intDivisor As Integer) As Integer

        FT_Status = FT_SetDivisor(FT_Handle, intDivisor)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function



    Function Set_USB_Device_Flow_Control() As Integer

        FT_Status = FT_SetFlowControl(FT_Handle, FT_Current_FlowControl, FT_Current_XOn_Char, FT_Current_XOff_Char)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Get_USB_Device_Modem_Status() As Integer

        FT_Status = FT_GetModemStatus(FT_Handle, FT_ModemStatus)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Get_USB_Device_Queue_Status() As Integer

        FT_Status = FT_GetQueueStatus(FT_Handle, FT_RxQ_Bytes)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_Characters() As Integer
        Dim Events_On As Byte
        Dim Errors_On As Byte

        If FT_Event_On Then Events_On = 1 Else Events_On = 0
        If FT_Error_On Then Errors_On = 1 Else Errors_On = 0
        FT_Status = FT_SetChars(FT_Handle, FT_Event_Value, Events_On, FT_Error_Value, Errors_On)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_Timeouts(ByVal ReadTimeOut As Integer, ByVal WriteTimeout As Integer) As Integer

        FT_Status = FT_SetTimeouts(FT_Handle, ReadTimeOut, WriteTimeout)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_RTS() As Integer

        FT_Status = FT_SetRts(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Clear_USB_Device_RTS() As Integer

        FT_Status = FT_ClrRts(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Set_USB_Device_DTR() As Integer

        FT_Status = FT_SetDtr(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Clear_USB_Device_DTR() As Integer

        FT_Status = FT_ClrDtr(FT_Handle)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Write_Data_String(ByVal StringData As String) As Integer
        Dim Write_Result As Integer
        Dim StringDataLength As Integer

        StringDataLength = Len(StringData)
        FT_Status = FT_Write_String(FT_Handle, StringData, StringDataLength, Write_Result)
        If FT_Status <> FT_OK Then
            Exit Function
        End If
    End Function


    Function Write_Data_Bytes(ByVal Write_Count As Integer) As Integer
        ' Writes Write_Count Bytes from FT_Out_Buffer to the USB device
        ' Function returns the number of bytes actually sent
        Dim Write_Result As Integer

        FT_Status = FT_Write_Bytes(FT_Handle, FT_Out_Buffer(0), Write_Count, Write_Result)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

    End Function


    Function Read_Data_String(ByVal StringData As String) As Integer
        Dim Read_Result As Integer
        Dim TempStringData As String

        TempStringData = Space(FT_RxQ_Bytes + 1)

        FT_Status = FT_Read_String(FT_Handle, TempStringData, FT_RxQ_Bytes, Read_Result)
        If FT_Status <> FT_OK Then
            Exit Function
        End If

        StringData = Trim(TempStringData)

    End Function

    Function Read_Data_Bytes(ByVal Read_Count As Integer) As Integer
        ' Reads Read_Count Bytes (or less) from the USB device to the FT_In_Buffer
        ' Function returns the number of bytes actually received  which may range from zero
        ' to the actual number of bytes requested, depending on how many have been received
        ' at the time of the request + the read timeout value.Dim Read_Result As Integer
        Dim Read_Result As Integer

        FT_Status = FT_Read_Bytes(FT_Handle, FT_In_Buffer(0), Read_Count, Read_Result)
        If FT_Status <> FT_OK Then

⌨️ 快捷键说明

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