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

📄 s2l9.bas

📁 TMS320c6000系列dsp软件模拟器在集成开发环境CCS中应用实例
💻 BAS
字号:
Option Explicit

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

'* S2L9.bas - (Section 2, Lesson 9) REMOTE ENABLING AND DISABLING OF A

'*                                  CHANNEL

'*        This is the RTDX Host Client for Section 2, Lesson 9

'*

'* This example enables the target channel ochan, receives integer

'* value 5 from the target, and disables the channel

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



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.





Const CHANNEL_NAME = "ochan"



Sub main()

    

    Dim rtdx As Object

    

    Dim data As Long

    Dim status As Long

    Dim nummsgs As Long

    Dim i As Long



    On Error GoTo Error_Handler

    

    Set rtdx = CreateObject("RTDX")



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

    ' Insert code from Step #3 here - enable channel for target

    '                                 writes

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

    status = rtdx.EnableChannel(CHANNEL_NAME)



    If status <> Success Then

        Debug.Print "enabling of channel ochan failed"

        GoTo Error_Handler

    End If

    

    status = rtdx.Open(CHANNEL_NAME, "R")



    If status <> Success Then

        Debug.Print "Opening of channel ochan failed"

        GoTo Error_Handler

    End If



    status = rtdx.GetNumMsgs(nummsgs)

    

    If status <> Success Then

        Debug.Print "GetNumMsgs returned failure"

        GoTo Error_Handler

    End If

    

    For i = 1 To nummsgs

        status = rtdx.ReadI4(data)

        Select Case (status)

            Case Success

                Debug.Print "Value " & _

                            data & _

                            " was received from the target "

            Case ENoDataAvailable

                Debug.Print "No data is currently available"

            Case EEndOfLogFile

                Debug.Print "End of log file has been detected"

            Case Failure

                Debug.Print "ReadI4 returned failure"

                Exit For

            Case Else

                Debug.Print "Unknown return code"

                Exit For

        End Select

    Next i



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

    ' Insert code from Step #4 here - disable channel from target

    '                                 writes

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

    status = rtdx.DisableChannel(CHANNEL_NAME)



    status = rtdx.Close()

    

    If status <> Success Then

        Debug.Print "enabling of channel ochan failed"

        GoTo Error_Handler

    End If

    

    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 + -