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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mainform.vb

?? usb mass storage固件代碼usbwiz_demo
?? VB
?? 第 1 頁 / 共 2 頁
字號:
Option Explicit On
Option Strict On
Imports System.IO.Ports
Imports System.Text


Public Class MainForm

    ' Demonstrates communications between a USBwiz-OEM board and a USB flash drive
    '  attached to the USBwiz-OEM.
    ' The Visual-Basic application functions as host software that sends commands 
    ' to the host controller in the USBwiz.
    ' Why use a PC to control the USB host controller on the USBwiz-OEM?
    ' The PC interface makes it easy to experiment with the code. 
    ' When the code is working, you can port it to any microcontroller with a UART port.

    ' I used a DLP Electronics DLP-USB232M module to interface the USBwiz's asynchronous serial
    ' port to a USB port on a PC. You can instead use a MAX233 or similar chip to connect the 
    ' USBwiz to an RS-232 port or a USB/RS-232 converter on a PC.

    ' Connections:
    ' USBwiz-OEM  DLP-USB232M

    '     1-----------23
    '     2-----------24
    '     6-----------21
    '     7-----------22

    ' USBwiz-OEM
    ' Connect pins 13, 14, 17, 18 to +5V.
    ' Connect pins 15, 16 to GND.

    ' DLP-USB232M
    ' Connect pins 3, 10, 11, 14 to +5V.
    ' Connect pins 2, 5, 7, 19 to GND.

    ' Use a regulated +5V supply.
    ' Attach a flash drive to the bottom USB connector on the USBwix-OEM.

    ' For more about the USBwiz, go to ghielectronics.com.
    ' For more about USB and mass storage, go to Lvr.com.
    ' Send error reports, comments, etc. to jan@Lvr.com

    ' By Jan Axelson
    ' Version 0.9

    Friend enumerated As Boolean
    Friend portChange As Boolean
    Friend previousPortIndex As Integer
    Friend receiveBuffer As String
    Friend selectedPort As New System.IO.Ports.SerialPort
    Friend selectedPortIndex As Integer


    Dim previousTime As Date
    Dim timeOfTransfer As String
    Dim transferInProgress As Boolean

    '******************************************************************************************
    ' Variables used in USBwiz commands.
    ' See the USBwiz manual for more info.

    Dim deviceHandle As String = "0"
    Dim fileHandle As String = "0"         ' Valid values: 0, 1, 2, 3.
    Dim fileName As String = "test.txt"    ' The file to write to and read.
    Dim fileSystem As String = "0"         ' Valid values: 0, 1, 2.

    ' Used by the RF command if the file being read is shorter than the requested data.
    Dim fillerSymbol As String = " "

    Dim lun As String = "0"                ' Many drives have only LUN 0.
    Dim massStorageHandle As String = "0"
    Dim usbPort As String = "0"            ' Port 0 is the bottom connector on the USBwiz-OEM board.

    '******************************************************************************************

    ' USBwiz success code.
    Const Success As String = "!00"

    'Used in error messages.
    Const ModuleName As String = "USBwiz Demo"

    Private Sub btnEnumerateDrive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnumerateDrive.Click

        ' Enumerate the drive and assign handles.

        InitializeDriveCommunications()
    End Sub

    Private Sub btnReadFromFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFromFile.Click

        ' Read from a file on the flash drive.

        ReadFromFile()

    End Sub

    Private Sub btnWriteToFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnWriteToFile.Click

        'Write to a file on the flash drive.

        WriteToFile()

    End Sub
    Private Sub CloseComPort()
        If (Not IsNothing(selectedPort)) Then
            If selectedPort.IsOpen Then
                selectedPort.Dispose()
            End If
        End If
    End Sub

    Private Sub CloseDeviceHandle()

        ' Purpose    : close the device handle.
        '              The application will need to re-enumerate the device to resume communicating.

        Dim command As String
        Dim response As String

        txtMonitor.AppendText("Closing the device handle." + vbCrLf)

        If Enumerated Then
            command = "UR " + deviceHandle
            response = SendCommandToUsbwiz(command)
        End If

        enumerated = False
        transferInProgress = False

    End Sub

    Private Function DisplayDateAndTime() As String

        ' Purpose    : get and format the current date and time.

        ' Returns    : the data and time.

        Dim DateAndTime As Date = DateTime.Now
        Dim DateAndTimeString As String = ""

        DateAndTimeString = DateAndTime.ToString("G")

        Return DateAndTimeString

    End Function

    Private Sub DisplayFailureMessage(ByVal command As String, ByVal response As String)

        ' Purpose    : display a failure message in a text box.

        ' Accepts    : command - the command that failed
        '              response - the response code 

        txtMonitor.AppendText _
        ("Failed executing command " + command + " with response = " + response + "." + vbCrLf)

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Show()

        MyMainForm = Me
        MyPortSettings = New PortSettings

        transferInProgress = False

        InitializeDisplayElements()
        MyPortSettings.InitializePortSettings()

    End Sub

    Private Function ReadFileContents(ByRef receivedData As String, ByRef bytesRead As Integer, ByVal bytesToRead As Integer) As String

        ' Purpose    : Gets the requested number of bytes from the receive buffer.

        ' Accepts    : receivedData - a string to hold the received bytes.
        '              bytesRead - the number of bytes returned.
        '              bytesToRead - the number of bytes requested. 

        ' Returns    : USBwiz response code

        Dim byteBuffer() As Byte
        Dim incomingData As String = ""
        Dim newData As String = ""
        Dim response As String = ""
        Dim totalBytesRead As Integer

        ' Set the size of the buffer to match the number of bytes to read.
        ReDim byteBuffer(bytesToRead - 1)

        Do
            ' Read the port until we have the requested number of bytes or a timeout.
            bytesRead = selectedPort.Read(byteBuffer, 0, bytesToRead - totalBytesRead)

            ' Keep track of how many bytes have been read.
            totalBytesRead = totalBytesRead + bytesRead

            ' Save the data read as a string.
            newData = Encoding.Default.GetString(byteBuffer, 0, bytesRead)

            ' Append the new data to any previously read data.
            receivedData = receivedData + newData

        Loop Until (totalBytesRead >= bytesToRead)

        'The USBwiz follows the requested data with the number of valid bytes returned.
        response = ReadDataFromUsbwiz(CStr(bytesRead))

        Return response

    End Function

    Private Sub InitializeDisplayElements()

        ' Purpose    : initialize elements on the main form.

        ' Textbox elements:
        txtMonitor.Multiline = True
        txtMonitor.ScrollBars = ScrollBars.Vertical
        txtMonitor.AcceptsReturn = True
        txtMonitor.AcceptsTab = True
        txtMonitor.WordWrap = True
        txtMonitor.Multiline = True

    End Sub

    Private Sub InitializeDriveCommunications()

        ' Purpose    : Send commands to the USBwiz to enumerate a drive and mount a file system.

        Dim command As String = ""
        Dim freeMedia As String = ""
        Dim response As String = ""
        Dim maxLun As String = ""
        Dim mediaSize As String = ""
        Dim mediaStatistics As String = ""
        Dim stringIndex As Integer

        Try
            transferInProgress = True
            txtMonitor.Clear()

            ' Open the COM port if necessary.

            If portChange Then

                ' The user has changed the selected COM port.
                portChange = False

                ' If a previously opened port is open, close it.
                CloseComPort()

                ' Open the new selected port.
                OpenComPort()
            Else
                If Not (IsNothing(selectedPort)) Then
                    If Not (selectedPort.IsOpen) Then

                        ' A port has been initialized but the port isn't open.
                        OpenComPort()
                    End If
                Else
                    ' A port hasn't been initialized or opened.
                    OpenComPort()
                End If
            End If

            enumerated = False

            ' Close the device handle if one was open.
            ' Returns success even if no handle was open.
            command = "UR " + deviceHandle
            response = SendCommandToUsbwiz(command)

            If (Not IsNothing(selectedPort)) Then
                If selectedPort.IsOpen Then

                    ' The port exists and is open.
                    command = "UI " + usbPort + ">" + deviceHandle
                    txtMonitor.AppendText _
                    ("Enumerating and assigning a device handle to the USB drive: " + command + vbCrLf)
                    response = SendCommandToUsbwiz(command)

                    If (response = Success) Then
                        command = "UM " + deviceHandle + ">" + massStorageHandle
                        txtMonitor.AppendText _
                        ("Registering the drive's device handle to a mass-storage handle: " + command + vbCrLf)
                        response = SendCommandToUsbwiz(command)

                        If (response = Success) Then
                            response = ReadDataFromUsbwiz(maxLun)
                            txtMonitor.AppendText("Max LUN = " + maxLun.Trim("$"c) + vbCrLf)

                            If (response = Success) Then
                                command = "AM U" + massStorageHandle + "<" + lun
                                txtMonitor.AppendText _
                                ("Attaching to a LUN of the USB drive: " + command + vbCrLf)
                                response = SendCommandToUsbwiz(command)

                                If (response = Success) Then
                                    command = "MU " + fileSystem + ">U" + massStorageHandle
                                    txtMonitor.AppendText _
                                    ("Mounting a file system on the mass-storage handle: " + command + vbCrLf)
                                    response = SendCommandToUsbwiz(command)

                                    If (response = Success) Then
                                        enumerated = True
                                        txtMonitor.AppendText _
                                        ("Ready to communicate with the drive." + vbCrLf)

                                        command = "MS"
                                        txtMonitor.AppendText _
                                        ("Requesting media statistics: " + command + vbCrLf)
                                        response = SendCommandToUsbwiz(command)
                                        response = ReadDataFromUsbwiz(mediaStatistics)

                                        ' Remove the first "$" in the response.
                                        mediaStatistics = mediaStatistics.Trim("$"c)

                                        ' Get the location of the second "$".
                                        stringIndex = mediaStatistics.IndexOf("$"c)

                                        ' Media size is everything up to the second "$".
                                        mediaSize = mediaStatistics.Substring(0, stringIndex - 1)
                                        txtMonitor.AppendText("Media size = " + CStr(Convert.ToInt32(mediaSize, 16)) + " bytes." + vbCrLf)

                                        ' Free media is what follows the second "$".
                                        freeMedia = mediaStatistics.Trim("$"c)
                                        freeMedia = mediaStatistics.Substring(stringIndex + 1, 8)
                                        txtMonitor.AppendText("Free media = " + CStr(Convert.ToInt32(freeMedia, 16)) + " bytes." + vbCrLf)
                                    Else
                                        DisplayFailureMessage(command, response)
                                    End If
                                Else
                                    DisplayFailureMessage(command, response)
                                End If
                            Else
                                DisplayFailureMessage(command, response)
                            End If
                        Else
                            DisplayFailureMessage(command, response)
                        End If
                    Else
                        DisplayFailureMessage(command, response)
                    End If
                Else
                    txtMonitor.AppendText("Unable to open the COM port.")
                End If
            Else
                txtMonitor.AppendText("The selected COM port doesn't exist.")
            End If

        Catch ex As TimeoutException
            txtMonitor.AppendText("Timeout" + vbCrLf)
            CloseDeviceHandle()

        Catch ex As InvalidOperationException
            txtMonitor.AppendText("Invalid operation" + vbCrLf)
            CloseDeviceHandle()
        Finally
            transferInProgress = False
        End Try

    End Sub

    Private Sub MainForm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

        CloseDeviceHandle()
        CloseComPort()
    End Sub

    Private Sub OpenComPort()

        ' Purpose    : open a COM port for communicating.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产免费成人在线视频| av电影一区二区| 国产精品一区专区| 92国产精品观看| 欧美日韩一区国产| 精品福利在线导航| 中文字幕日本不卡| 日韩精品国产欧美| 国产露脸91国语对白| 91网页版在线| 精品理论电影在线观看| 最新不卡av在线| 日韩不卡手机在线v区| 免费人成黄页网站在线一区二区| 成人性生交大片免费看中文网站| 色婷婷激情综合| 欧美va亚洲va香蕉在线| 悠悠色在线精品| 久久99精品久久久久久动态图 | 在线观看不卡视频| 欧美电影免费观看高清完整版| 日韩精品一区二| 亚洲精品第1页| 国产乱码精品一区二区三区av| 欧美日韩国产区一| 国产精品国产三级国产普通话99| 日本视频在线一区| 欧洲一区二区av| 中文字幕成人网| 午夜久久福利影院| 欧美三级资源在线| 国产精品国产a级| 久久99精品国产| 亚洲精品在线观看视频| 亚洲大片精品永久免费| 白白色 亚洲乱淫| 国产精品的网站| 韩国一区二区视频| 欧美一区二区三区四区视频| 日本视频一区二区| 在线91免费看| 亚洲综合免费观看高清完整版 | 国产欧美日韩中文久久| 日韩1区2区3区| 欧美色精品天天在线观看视频| 中文字幕第一区| 国产美女久久久久| 日韩精品一区二区三区视频在线观看 | 国产日韩欧美一区二区三区综合| 日日噜噜夜夜狠狠视频欧美人| 在线看日韩精品电影| 亚洲视频电影在线| 成人午夜视频在线观看| 国产亚洲欧美在线| 国产成+人+日韩+欧美+亚洲| 91成人免费在线视频| 亚洲黄色免费电影| 91国在线观看| 亚洲123区在线观看| 日本久久精品电影| 亚洲午夜精品久久久久久久久| 日本精品视频一区二区| 亚洲线精品一区二区三区八戒| 欧美优质美女网站| 丝袜亚洲另类欧美综合| 91精品国产综合久久婷婷香蕉| 日韩电影在线观看一区| 日韩精品一区二区三区老鸭窝| 天天av天天翘天天综合网 | 日韩欧美成人一区二区| 美女精品自拍一二三四| 精品国产伦一区二区三区免费| 久久不见久久见免费视频1| 精品国产电影一区二区| 国产成人综合在线播放| 中文字幕在线观看不卡| 欧美色精品在线视频| 日本成人在线网站| 国产欧美日韩激情| 在线观看av不卡| 麻豆91免费观看| 久久亚洲春色中文字幕久久久| 风间由美性色一区二区三区| 中文字幕的久久| 337p亚洲精品色噜噜| 丰满亚洲少妇av| 天天射综合影视| 久久嫩草精品久久久精品一| 色综合激情五月| 日本sm残虐另类| 国产精品国产三级国产普通话99 | 日韩和欧美一区二区三区| 精品国产一二三| 色综合久久久久综合体| 日本成人在线电影网| 国产偷国产偷亚洲高清人白洁| 欧美在线不卡一区| 成人精品视频一区二区三区 | 日韩欧美在线123| 欧美午夜精品一区二区蜜桃| 成人sese在线| 国产成人精品1024| 国内久久精品视频| 久久99热狠狠色一区二区| 肉肉av福利一精品导航| 亚洲一区在线视频观看| 亚洲九九爱视频| 亚洲欧洲国产日韩| 中文字幕亚洲一区二区av在线 | 国产成人免费视频精品含羞草妖精| 日韩精品一二三四| 日韩高清在线一区| 天堂蜜桃91精品| 亚洲成人在线观看视频| 亚洲高清中文字幕| 亚洲一级电影视频| 亚洲国产日韩在线一区模特 | 日本一二三四高清不卡| 国产亚洲欧美在线| 国产精品嫩草影院av蜜臀| 久久久高清一区二区三区| 中文字幕av一区二区三区免费看 | 亚洲成人激情av| 亚洲成人av免费| 午夜伊人狠狠久久| 日韩主播视频在线| 久久99精品国产91久久来源| 国产乱码精品一区二区三区av| 国产麻豆精品久久一二三| 懂色中文一区二区在线播放| 成人一区在线观看| 99国产精品久久久久久久久久久| 91小视频免费观看| 欧美精品视频www在线观看| 8v天堂国产在线一区二区| 日韩视频在线你懂得| 久久色.com| 亚洲精品国产一区二区三区四区在线 | 日韩在线a电影| 国产毛片精品视频| 99在线热播精品免费| 欧美伊人久久久久久久久影院 | 欧美性生交片4| 欧美一区二区久久| 国产欧美va欧美不卡在线| 亚洲欧美日韩电影| 日本视频免费一区| 国产乱子伦视频一区二区三区| av一区二区三区| 91精品在线麻豆| 国产精品美女久久久久久久久| 亚洲综合999| 国产大陆精品国产| 欧美在线一二三四区| 2024国产精品| 亚洲影院久久精品| 国产成人日日夜夜| 在线综合视频播放| 亚洲欧美在线高清| 美腿丝袜亚洲一区| 在线观看网站黄不卡| 久久日韩精品一区二区五区| 亚洲一区二区三区三| 国产精品综合久久| 欧美一区二区三区小说| 中文字幕日韩av资源站| 激情综合亚洲精品| 欧美日韩精品系列| 亚洲欧美日韩系列| 国产成人一级电影| 欧美一区二区美女| 亚洲国产色一区| 色网站国产精品| 国产日产欧美一区二区视频| 五月综合激情网| 色婷婷激情综合| 国产精品国模大尺度视频| 精一区二区三区| 日韩色视频在线观看| 亚洲一本大道在线| 日本电影欧美片| 日韩码欧中文字| 成人福利电影精品一区二区在线观看| 日韩一级大片在线观看| 亚洲国产中文字幕| 欧美午夜精品理论片a级按摩| 日韩理论电影院| 成人高清免费观看| 国产欧美日韩视频一区二区| 国产综合色在线| 久久这里只精品最新地址| 久久成人免费日本黄色| 日韩欧美国产午夜精品| 婷婷亚洲久悠悠色悠在线播放| 91国产成人在线| 亚洲高清一区二区三区| 欧美色成人综合| 天天综合色天天综合色h| 欧美高清你懂得| 麻豆精品视频在线观看视频|