亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? filetransfermodule.bas

?? cp2102 官方usb開發(fā)包
?? BAS
字號:
Attribute VB_Name = "modFileTransfer"

Option Explicit

' Declare statements for all the functions in the SiUSBXp DLL
' NOTE: These statements assume that the DLL file is located in
'       the same directory as this project.
'       If you change the location of the DLL, be sure to change the location
'       in the declare statements also.
Public Declare Function SI_GetNumDevices Lib "SiUSBXp.dll" (ByRef lpwdNumDevices As Long) As Integer
Public Declare Function SI_GetProductString Lib "SiUSBXp.dll" (ByVal dwDeviceNum As Long, ByRef lpvDeviceString As Byte, ByVal dwFlags As Long) As Integer
Public Declare Function SI_Open Lib "SiUSBXp.dll" (ByVal dwDevice As Long, ByRef cyHandle As Long) As Integer
Public Declare Function SI_Close Lib "SiUSBXp.dll" (ByVal cyHandle As Long) As Integer
Public Declare Function SI_Read Lib "SiUSBXp.dll" (ByVal cyHandle As Long, ByRef lpBuffer As Byte, ByVal dwBytesToRead As Long, ByRef lpdwBytesReturned As Long, ByVal lpOverlapped As Long) As Integer
Public Declare Function SI_Write Lib "SiUSBXp.dll" (ByVal cyHandle As Long, ByRef lpBuffer As Byte, ByVal dwBytesToWrite As Long, ByRef lpdwBytesWritten As Long, ByVal lpOverlapped As Long) As Integer
Public Declare Function SI_SetTimeouts Lib "SiUSBXp.dll" (ByVal dwReadTimeout As Long, ByVal dwWriteTimeout As Long) As Integer
Public Declare Function SI_GetTimeouts Lib "SiUSBXp.dll" (ByRef lpdwReadTimeout As Long, ByRef lpdwWriteTimeout As Long) As Integer
Public Declare Function SI_CheckRXQueue Lib "SiUSBXp.dll" (ByVal cyHandle As Long, ByRef lpdwNumBytesInQueue As Long, ByRef lpdwQueueStatus As Long) As Integer

'Masks for the serial number and description
Public Const SI_RETURN_SERIAL_NUMBER = &H0
Public Const SI_RETURN_DESCRIPTION = &H1
Public Const SI_RETURN_LINK_NAME = &H2
Public Const SI_RETURN_VID = &H3
Public Const SI_RETURN_PID = &H4

'Masks for return values from the device
Public Const SI_SUCCESS = &H0
Public Const SI_DEVICE_NOT_FOUND = &HFF
Public Const SI_INVALID_HANDLE = &H1
Public Const SI_READ_ERROR = &H2
Public Const SI_RX_QUEUE_NOT_READY = &H3
Public Const SI_WRITE_ERROR = &H4
Public Const SI_RESET_ERROR = &H5
Public Const SI_INVALID_BUFFER = &H6
Public Const SI_INVALID_REQUEST_LENGTH = &H7
Public Const SI_DEVICE_IO_FAILED = &H8

Public Const SI_QUEUE_NO_OVERRUN = &H0
Public Const SI_QUEUE_OVERRUN = &H1
Public Const SI_QUEUE_READY = &H2

Public Const SI_MAX_DEVICE_STRLEN = 256
Public Const SI_MAX_READ_SIZE = 65536
Public Const SI_MAX_WRITE_SIZE = 4096

Public Const INVALID_HANDLE_VALUE = &HFFFF

Public Const MAX_PACKET_SIZE_WRITE = 512
Public Const MAX_PACKET_SIZE_READ = 4096

Public Const FT_READ_MSG = &H0
Public Const FT_WRITE_MSG = &H1
Public Const FT_READ_ACK = &H2
Public Const FT_MSG_SIZE = &H3

Public Const MAX_WRITE_PKTS = 1

'Variables used within the project
Global hUSBDevice  'global handle that is set when connected with the usb device
Global Status      'status, value to set when communicating with the board to determine success
Global TempString  'tempstring, contains the value of the file when performing a read

Public Const IOBufSize = 12
Global IOBuf(IOBufSize) As Byte 'io buffer; bits are defined as follows:
'IOBuf(0) = LED1
'IOBuf(1) = LED2
'IOBuf(2) = Port
'IOBuf(3) = Analog1
'IOBuf(4) = Analog2
'IOBuf(5,6,7) = Unused
'IOBuf(8,9,10,11) = Number Of Interrupts

Public Function ConvertToVBString(Str)

    Dim NewString As String
    Dim i As Integer
    
    'for the received string array, loop until we get
    'a 0 char, or until the max length has been obtained
    'then add the ascii char value to a vb string
    i = 0
    Do While (i < SI_MAX_DEVICE_STRLEN) And (Str(i) <> 0)
        NewString = NewString + Chr$(Str(i))
        i = i + 1
    Loop
    
    ConvertToVBString = NewString
    
End Function

Public Sub WriteFileData()

    Dim Success As Boolean
    Success = True
    
    Dim FileNum As Integer
    FileNum = FreeFile

    'check if there is a valid file
    If frmMain.txtTransfer.Text <> "" Then
        Open frmMain.txtTransfer.Text For Binary As FileNum
        
        Dim FileSize As Long
        FileSize = FileLen(frmMain.txtTransfer.Text)
        
        'if the file is valid, and exists then obtain its size,
        'and prepare to write data to the board
        If FileSize > 0 Then
            Dim BytesWritten As Long
            Dim BytesRead As Long
            Dim Buf(MAX_PACKET_SIZE_WRITE) As Byte
            
            BytesWritten = 0
            BytesRead = 0
                       
            Buf(0) = FT_WRITE_MSG
            Buf(1) = FileSize And &HFF
            Buf(2) = (FileSize And &HFF00) / 256
            
            'send the board a write message
            If (DeviceWrite(Buf, FT_MSG_SIZE, BytesWritten)) Then
                If BytesWritten = FT_MSG_SIZE Then
                    Dim NumPkts As Long
                    Dim NumLoops As Long
                    Dim CounterPkts As Long
                    Dim CounterLoops As Long
                    Dim i As Integer
                    Dim ByteInFile As Long
                    
                    'send data to the board in groups of 8 packets
                    If (FileSize Mod MAX_PACKET_SIZE_WRITE) > 0 Then
                        NumPkts = (FileSize \ MAX_PACKET_SIZE_WRITE) + 1
                    Else
                        NumPkts = (FileSize \ MAX_PACKET_SIZE_WRITE)
                    End If
                    If (NumPkts Mod MAX_WRITE_PKTS) > 0 Then
                        NumLoops = (NumPkts \ MAX_WRITE_PKTS) + 1
                    Else
                        NumLoops = (NumPkts \ MAX_WRITE_PKTS)
                    End If
                    CounterPkts = 0
                    CounterLoops = 0

                    Do While (CounterLoops < NumLoops) And Success
                        i = 0
                        Do While (i < MAX_WRITE_PKTS) And (CounterPkts < NumPkts) And Success
                            'for each section of 8 packets, clear the buffer
                            'then load the next section of data to send
                            Call MemSet(Buf, 0, MAX_PACKET_SIZE_WRITE)
                            If CounterPkts < (NumPkts - 1) Then
                                Call FileRead(FileNum, Buf, MAX_PACKET_SIZE_WRITE)
                            Else
                                'check if last packet is partial
                                If (FileSize Mod MAX_PACKET_SIZE_WRITE) > 0 Then
                                    Call FileRead(FileNum, Buf, FileSize Mod MAX_PACKET_SIZE_WRITE)
                                Else
                                    Call FileRead(FileNum, Buf, MAX_PACKET_SIZE_WRITE)
                                End If
                            End If
                            BytesWritten = 0
                            Success = DeviceWrite(Buf, MAX_PACKET_SIZE_WRITE, BytesWritten)
                            CounterPkts = CounterPkts + 1
                            i = i + 1
                        Loop
                        
                        If Success Then
                            Call MemSet(Buf, 0, MAX_PACKET_SIZE_WRITE)

                            'check for ack packet after writing 8 packets
                            Do While (Buf(0) <> 255) And Success
                                Success = DeviceRead(Buf, 1, BytesRead)
                            Loop
                        End If
                        
                        CounterLoops = CounterLoops + 1
                    Loop
                Else
                    MsgBox "Incomplete Write File Size Message Sent to Device"
                    Success = False
                End If
            Else
                MsgBox "Target Device Failure While Sending File Size Information"
                Success = False
            End If
            
            Close FileNum
        Else
            MsgBox "Failed to Open File " + frmMain.txtTransfer.Text
            Success = False
        End If
    Else
        MsgBox "No File Selected"
        Success = False
    End If
        
End Sub

Public Function DeviceWrite(Buffer() As Byte, dwSize As Long, lpdwBytesWritten As Long) As Boolean
    Dim Stat As Integer
    Dim WriteStatus As Integer
       
    WriteStatus = SI_Write(hUSBDevice, Buffer(0), dwSize, lpdwBytesWritten, 0)
    
    If WriteStatus = SI_SUCCESS Then
        DeviceWrite = True
    Else
        DeviceWrite = False
    End If
  
End Function

Public Sub ReadFileData()

    Dim Success As Boolean
    Success = True
    
    Dim FileNum As Integer
    FileNum = FreeFile

    TempString = ""
    
    'check if there is a valid file
    If frmMain.txtReceive.Text <> "" Then
        Open frmMain.txtReceive.Text For Output As FileNum
        
        Dim BytesRead As Long
        Dim BytesWritten As Long
        Dim Buf(MAX_PACKET_SIZE_READ) As Byte
        
        Buf(0) = FT_READ_MSG
        Buf(1) = &HFF
        Buf(2) = &HFF
        
        'send the board a read message
        If (DeviceWrite(Buf, FT_MSG_SIZE, BytesWritten)) Then
            Dim FileSize As Long
            Dim CounterPkts As Long
            Dim NumPkts As Long
            
            FileSize = 0
            CounterPkts = 0
            NumPkts = 0
            Call MemSet(Buf, 0, MAX_PACKET_SIZE_READ)
            
            'determine the file size and number of packets to
            'receive from the board
            If (DeviceRead(Buf, FT_MSG_SIZE, BytesRead)) Then
                FileSize = ((Buf(1) And &HFF) Or ((Buf(2) * 256) And &HFF00))
                If (FileSize Mod MAX_PACKET_SIZE_READ) > 0 Then
                    NumPkts = (FileSize \ MAX_PACKET_SIZE_READ) + 1
                Else
                    NumPkts = (FileSize \ MAX_PACKET_SIZE_READ)
                End If
                
                'send each packet back to the board and store it in a temp
                'string via the FileWrite function
                Do While (CounterPkts < NumPkts) And Success
                    Call MemSet(Buf, 0, MAX_PACKET_SIZE_READ)
                    BytesRead = 0
                    
                    If (DeviceRead(Buf, MAX_PACKET_SIZE_READ, BytesRead)) Then
                        If (CounterPkts < (NumPkts - 1)) Then
                            Call FileWrite(FileNum, Buf, MAX_PACKET_SIZE_READ)
                        Else
                            'check to see if last packet is partial
                            If (FileSize Mod MAX_PACKET_SIZE_READ) > 0 Then
                                Call FileWrite(FileNum, Buf, (FileSize Mod MAX_PACKET_SIZE_READ))
                            Else
                                Call FileWrite(FileNum, Buf, MAX_PACKET_SIZE_READ)
                            End If
                        End If
                    Else
                        MsgBox "Failed Reading File Packet From Target Device"
                    End If
                    
                    CounterPkts = CounterPkts + 1
                Loop
            Else
                MsgBox "Target Device Failure While Sending Read File Message"
            End If
        Else
            MsgBox "Target Device Failure While Sending File Size Information"
            Success = False
        End If

        'write the entire temporary string to the output file chosen
        Print #FileNum, TempString;
               
        Close FileNum
    Else
        MsgBox "No File Selected"
        Success = False
    End If
 
End Sub

Public Function DeviceRead(Buffer() As Byte, dwSize As Long, lpdwBytesRead As Long) As Boolean

    Dim Stat As Integer
    Dim ReadStatus As Integer
    Dim BytesInQueue As Long
    BytesInQueue = 0
    
    ReadStatus = SI_Read(hUSBDevice, Buffer(0), dwSize, lpdwBytesRead, 0)
   
    If ReadStatus = SI_SUCCESS Then
        DeviceRead = True
    Else
        DeviceRead = False
    End If
    
End Function

Public Sub MemSet(Buffer() As Byte, Value As Byte, Amount As Long)
    
    'this function sets all elements of on array to 0
    Dim i
    
    For i = 0 To (Amount - 1)
        Buffer(i) = Value
    Next
    
End Sub

Public Sub FileRead(FileNum As Integer, Buffer() As Byte, NumberOfBytes As Long)

    'this function converts the characters of a text file to bytes of
    'binary data to send out
    Dim i
    Dim Tmp
            
    For i = 0 To NumberOfBytes - 1
        If (Not EOF(FileNum)) Then
            Tmp = Input(FileNum, 1)
            If Tmp <> "" Then
                Buffer(i) = Asc(Tmp)
            Else
                Buffer(i) = 0
            End If
        End If
    Next
    
End Sub

Public Sub FileWrite(FileNum As Integer, Buffer() As Byte, NumberOfBytes As Long)

    'this function puts all the characters from the buffer in a temp
    'string to be dumped into a file after everything has been read
    Dim i
    
    For i = 0 To NumberOfBytes - 1
        TempString = TempString + Chr(Buffer(i))
    Next
    
End Sub

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线视频欧美精品| 国产精品福利在线播放| 亚洲国产精品v| 视频一区二区三区中文字幕| 国产成人av一区二区三区在线| 欧美日韩一卡二卡三卡| 中文字幕精品—区二区四季| 免费在线看成人av| 欧美最猛黑人xxxxx猛交| 国产欧美日韩不卡免费| 老司机午夜精品| 欧美日韩在线观看一区二区 | 亚洲综合色婷婷| 国产黄色成人av| 精品久久久影院| 日韩国产欧美三级| 欧美日韩一级片在线观看| 亚洲欧美自拍偷拍色图| 国产高清精品在线| 欧美xxxxx牲另类人与| 免费美女久久99| 91精品国产福利在线观看| 亚洲成人手机在线| 欧美色涩在线第一页| 亚洲一区二区三区精品在线| 99综合影院在线| 136国产福利精品导航| 成人aaaa免费全部观看| 中文字幕一区二区三区色视频| 国产精品亚洲综合一区在线观看| 26uuu欧美| 国产一级精品在线| 久久久久国产精品免费免费搜索| 国产乱码精品一品二品| 久久九九久久九九| www.成人在线| 综合久久综合久久| 91猫先生在线| 亚洲国产欧美在线| 欧美一级久久久久久久大片| 久久不见久久见中文字幕免费| 欧美成人性福生活免费看| 国产乱国产乱300精品| 中文字幕亚洲区| 在线亚洲一区观看| 婷婷成人综合网| 日韩欧美的一区| 国产成人精品免费看| 亚洲欧美日韩国产综合| 欧美日本韩国一区| 国产麻豆视频精品| 亚洲摸摸操操av| 91麻豆精品国产| 国产精品资源在线看| 亚洲人精品一区| 91精品欧美福利在线观看| 国产精品一区二区你懂的| 亚洲丝袜另类动漫二区| 欧美精品日韩精品| 国产精品一区二区在线观看不卡| 中文字幕一区二区三区不卡| 欧美日韩三级视频| 国产传媒一区在线| 亚洲aⅴ怡春院| 国产亚洲综合av| 欧美三级三级三级| 国产一二三精品| 亚洲成a人片在线观看中文| 精品国产一二三| 91免费看视频| 久久国产人妖系列| 亚洲综合小说图片| 国产亚洲va综合人人澡精品| 色吧成人激情小说| 国产精品一区二区在线播放| 五月天激情综合网| 中文字幕精品一区二区精品绿巨人| 欧美日韩国产一级| 不卡av在线免费观看| 韩国欧美一区二区| 亚洲国产中文字幕在线视频综合| 久久久久久久精| 欧美一区二区三区视频在线观看| 成人永久免费视频| 美日韩黄色大片| 亚洲chinese男男1069| 国产精品久久久久天堂| 欧美tk—视频vk| 欧美日韩国产天堂| 91视视频在线观看入口直接观看www | 国产精品私人自拍| 日韩一区二区在线免费观看| 91视频观看视频| 国产精品香蕉一区二区三区| 免费高清在线视频一区·| 亚洲午夜一二三区视频| 中文字幕在线不卡一区 | 亚洲免费观看高清完整版在线观看熊 | 夜夜亚洲天天久久| 国产精品乱人伦一区二区| 日韩欧美一区二区不卡| 91精品国产综合久久久久久久| 一本久久a久久精品亚洲| 夫妻av一区二区| 国产成人在线免费| 国产成人综合在线观看| 国产精品99久久久久久宅男| 久久99精品久久久| 精品制服美女久久| 国模套图日韩精品一区二区| 精品在线播放免费| 国内精品免费在线观看| 国产一区二区三区蝌蚪| 国产精品一区二区你懂的| 丁香网亚洲国际| aa级大片欧美| 色综合久久88色综合天天6| 色婷婷久久一区二区三区麻豆| av网站一区二区三区| 97超碰欧美中文字幕| 在线观看亚洲a| 欧美电影一区二区| 精品久久久久久久久久久久久久久 | 日本一区二区免费在线| 国产午夜精品一区二区| 中文字幕乱码一区二区免费| 成人免费在线视频| 亚洲精品一二三四区| 性做久久久久久久久| 久久99精品久久久久久动态图| 国产一区二区伦理片| www..com久久爱| 欧美伦理影视网| 日韩欧美国产系列| 国产精品素人一区二区| 一区二区免费在线播放| 日本麻豆一区二区三区视频| 国产剧情一区在线| 色噜噜狠狠一区二区三区果冻| 欧美日韩激情一区| 精品粉嫩超白一线天av| 日韩一区在线免费观看| 青青草精品视频| 国产成人精品免费| 精品视频1区2区| 国产欧美一区视频| 亚洲一区二区在线观看视频 | 日本欧美韩国一区三区| 国产91精品久久久久久久网曝门 | 99在线精品免费| 欧美男男青年gay1069videost | 日韩色在线观看| 中文字幕精品三区| 日韩国产欧美三级| 不卡大黄网站免费看| 日韩欧美国产综合在线一区二区三区 | 欧美精品一区二区三区视频| 亚洲嫩草精品久久| 国精品**一区二区三区在线蜜桃| 91久久国产最好的精华液| 精品久久久久久久久久久久久久久久久| 亚洲视频在线观看三级| 狠狠色丁香久久婷婷综合丁香| 一本色道久久综合精品竹菊| 26uuu亚洲婷婷狠狠天堂| 亚洲成人资源网| 99精品国产视频| 国产午夜精品在线观看| 免费在线观看成人| 欧美视频一区二| 亚洲同性同志一二三专区| 国产真实精品久久二三区| 欧美日韩成人高清| 亚洲精品日产精品乱码不卡| 精品在线播放午夜| 日韩一二在线观看| 亚洲国产精品久久艾草纯爱| 91免费国产在线观看| 中文字幕免费一区| 国产精品一区三区| 久久美女高清视频| 精品一区二区三区欧美| 8v天堂国产在线一区二区| 亚洲一区二区三区四区在线免费观看 | 在线视频中文字幕一区二区| 中文字幕 久热精品 视频在线| 久久精品国产秦先生| 欧美一区二区三区精品| 亚洲成av人影院| 欧美久久一二区| 日韩精品乱码免费| 欧美精品亚洲一区二区在线播放| 亚洲无人区一区| 欧美日韩专区在线| 亚洲a一区二区| 91精品视频网| 欧美aaa在线| 精品福利在线导航| 国产成人三级在线观看| 中文字幕+乱码+中文字幕一区|