RTDX(实时数据交换)

RTDX(实时数据交换)

 

RTDX提供了实时、连续了解目标系统程序运行情况的手段,它允许用户在不干扰目标系统程序运行的情况下,在主机和目标系统之间传送数据。目标系统与主机之间的RTDX实际上仍然是通过JTAG接口完成的,目标系统中的RDTX目标库和位于CCS中的RDTX主机库之间实时交换数据。

 

主机客户程序:运行在主机上利用COM接口项目表应用程序发送数据或者从目标应用程序接收数据的程序。

 

目标应用程序通过调用RTDX目标库中的函数发送数据。这些数据实际上只是放在RTDX目标库的缓冲区中,然后函数立即返回。RTDX目标库在处理器空闲时将本地缓冲区中的数据发送出去,这样就不干扰主应用程序的正常运行。RTDX主机库对外提供COM接口,可以认为是COM服务器,主机客户程序通过COM接口获取数据,并根据需要分析和显示数据。

 

同样,当主机应用程序向客户应用程序发送数据时,数据被放在RTDX主机库的缓冲区中。当RTDX主机库接收到目标应用程序要求数据的请求时,如果缓冲区中有足够的数据满足要求,数据就会发送到目标应用程序。数据被写入指定的存储器,不干扰目标应用程序运行,同时主机会通知RTDX目标库操作已经完成。

 

下面贴上DM642的DSP程序

//rtdxbios.c

 


#include <std.h>
#include <rtdx.h>
#include"target.h"   
#include<stdio.h>     
#include <log.h>
#include <tsk.h>
#include "rtdxbioscfg.h"


int arraydata[10];

  

Void reading(int n);
Void writing(int n);
Void processing(int n);
Void taskend();

Void main()
{
                        
        

Void reading(int n)
      


}


Void writing(int n)
     
       
       int status;
       n=10;
       LOG_printf(&trace,"writing");
       
       status=RTDX_write(&ochan,&arraydata,4*n);//如何传输一个文件呢?


       if ( status == 0 ) {
               LOG_printf(&trace,"ERROR: RTDX_write failed!\n");
               exit( -1 );
       }
       LOG_printf(&trace,"has been writed to thehost");
}
Void processing(int n)
{
    
 int i;
 n=10;

      
 TARGET_INITIALIZE();

 RTDX_enableInput(&ichan);
 RTDX_enableOutput(&ochan);
 LOG_printf(&trace,"begin");
 LOG_printf(&trace,"processing");
   for(i=0;i<n;i++)
    {
    arraydata[i]=i;
    }
}

    
Void taskend()
      
        while ( RTDX_writing != NULL )
        {
               #if RTDX_POLLING_IMPLEMENTATION
                   RTDX_Poll();
               #endif
        }


         
       RTDX_disableInput(&ichan);                           
       RTDX_disableOutput(&ochan);

       LOG_printf(&trace, "Program Complete!\n" );
       exit(-1);
}

 

本例程用DSP/BIOS实现,设定了四个任务线程,读函数没有操作,因为个人只想测试一下DSP通过JTAG向PC发送数据。

具体的函数参考DSP/BIOS API 手册,另外因为用到了RTDX,所以必须设置RTDX

 

RTDX(实时数据交换)

 

主机口程序用VC++6.0写的

// rtdxint.cpp : Defines the entry point for the consoleapplication.
//
#import "F:\MFC\rtdxint\rtdxint.dll"
#include "stdafx.h"

#include "rtdxint.h"
#include <iostream.h>


using namespace RTDXINTLib;

int main(int argc, char* argv[])
{
       IRtdxExpPtrrtdx;      // holds pointer to IRtdxExp interface
       shortdata;            // holds data received from target application
       longstatus;           // holds status of RTDX COM API calls
       HRESULThr;            // holds status of generic COM API calls

       // initialize COM
       ::CoInitialize( NULL );

       // instantiate the RTDX COM Object
       hr = rtdx.CreateInstance( L"RTDX" );

  cout.setf( ios::showbase);

       if ( FAILED(hr) ) {
               cerr << hex<< hr<< " - Error: Instantiation failed!\n";
               return -1;
       }

       // open a channel (ochan) for reading data
       status = rtdx->Open( "ochan", "R" );

       if ( status ) {
               cerr << hex<< status \
                    << " -  Error:Opening of channel \"ochan\" failed! \n";
               return -1;
  }

         // loop until we have read all of our messages
       do {
               // read a message
               status = rtdx->ReadI2( &data);
 
               // test status returned from ReadI2
               switch ( status ) {
                       case Success:
        //如何传输一个文件呢?
                               // display data
                               cout << data<< "\n";
                               break;
                       case Failure:
                               cerr << hex<< status \
                                    << " - Error: ReadI2 returnedfailure! \n";
                               return -1;
                       case ENoDataAvailable:
                               cout << "\n\nNo Data is currentlyavailable!\n";
                               cout << "\n\nWould you like tocontinue reading [y or n]?\n";
                               char option;
                               cin >> option;
                               if ( (option == 'y') || (option == 'Y') )
                                       break;
                               else
          return-1;
                       case EEndOfLogFile:
        
                               cout << "\n\nData ProcessingComplete!\n";
                               break;
                       default:
                               cerr << hex<< status \
                                    << " - Error: Unknown return code!\n";
                               return -1;
               }
       } while ( status != EEndOfLogFile );
 
       // close the channel
       status = rtdx->Close();
 
       // release the RTDX COM Object
       rtdx.Release();
 
       // unitialize COM
       ::CoUninitialize();
 
       return 0;
}

RTDX是通过JTAG接口实现DSP与PC的双向数据传输,JTAG接口决定了数据通信比特率很低,Kbps级别,用于实时调试还是蛮好,真要做大量数据传输就不合适了。

该实验还没有实现文件的传输,料想也差不多,但是自己实在C++与windos基础太差,现在还在学习中;以后要是做出了,会贴在这上面。学DSP好几个月了,现在感觉很好的掌握了一门语言并且很深的了解了某个系统的运作机制,对于学习DSP实在有太多的助益!


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值