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

📄 s4l6.bas

📁 德州仪器公司的6000系列的程序示例,可以看看实现什么功能,如果需要可以继续上传,配套有电子版说明
💻 BAS
字号:
Attribute VB_Name = "Module1"
Option Explicit
'**********************************************************************
'* S4L6.bas - (Section 4, Lesson 6) USING THE SETPROCESSOR ROUTINE
'*            This is the RTDX Host Client for Section 4, Lesson 6
'*
'* This example receives integer values 1-10 from the target
'**********************************************************************

Const Success = &H0                     ' Method call is valid
Const Failure = &H80004005              ' Method call failed
Const ENoDataAvailable = &H8003001E     ' No data was available.
                                        ' However, more data may be
                                        ' available in the future.
Const EEndOfLogFile = &H80030002        ' No data was available
                                        ' The end of the log file has
                                        ' been reached.

Sub main()
    
    Dim rtdx As Object
    Dim vardata As Variant

    Dim status As Long
    Dim i As Long
    Dim board As String
    Dim cpu As String


    On Error GoTo Error_Handler

    ' Create an instance of the RTDX COM object
    Set rtdx = CreateObject("RTDX")

    '******************************************************************
    ' Insert code from Step #4 here - to specify the board and
    '                                 processor
    '******************************************************************
    board = "C6xxx EVM (Texas Instruments)"
    cpu = "CPU_1"


    '******************************************************************
    ' Insert code from Step #5 here - to attach to the specified board
    '                                 and processor
    '******************************************************************
    status = rtdx.SetProcessor(board, cpu)
    
    If status <> Success Then
        Debug.Print "Attempt to attach to specified processor failed"
        GoTo Error_Handler
    End If

    ' Open channel ochan for reading
    status = rtdx.Open("ochan", "R")

    If status <> Success Then
        Debug.Print "Opening of channel ochan failed"
        GoTo Error_Handler
    End If

    Do
        ' read a message (32-bit integer array) from the target
        status = rtdx.ReadSAI4(vardata)
        
        Select Case (status)
            Case Success

                ' print each element in the array
                For i = LBound(vardata) To UBound(vardata)
                     Debug.Print vardata(i)
                Next i
            Case ENoDataAvailable
                Debug.Print "No data is currently available"
            Case EEndOfLogFile
                Debug.Print "End of log file has been detected"
            Case Failure
                Debug.Print "ReadSAI4 returned failure"
                Exit Do
            Case Else
                Debug.Print "Unknown return code"
                Exit Do
        End Select
    Loop Until status = EEndOfLogFile

    ' Close the channel
    status = rtdx.Close()

    ' Release the reference to the RTDX COM object
    Set rtdx = Nothing
    
    Exit Sub

Error_Handler:
Debug.Print "Error in COM method call"
Set rtdx = Nothing

End Sub

⌨️ 快捷键说明

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