Workbench3.0-vxworks6.6仿真测试和调试指南

    VxWorks5.5只能创建静态库(.a),VxWorks6.0之后增加了动态链接库(.so)的功能,方便了多进程使用动态库。本文继承win32和linux编程入门的一贯风格,通过简单的动态库生成步骤,并编写RTP程序进行测试,让您初步认识VxWorks6.6强大的功能,同时也让我们注意到VxWorks6.6比VxWorks5.5在使用要复杂很多。我相信通过这些简单的编程知识点,您基本掌握了VxWorks6.6调试技巧,让我们后来者不必在调试过程中去探索黑暗。本文基本使用图形来描述操作流程:一副图低得上千言万语了。

VxWorks6.0之后版本新增引入了具有完全保护功能的实时进程Real Time Process简称 RTP,首次完美的解决了内核保护与实时性和确定性之间的矛盾。用户可以根据需要动态的创建/删除 RTP实时保护进程或仅将一部分程序运行在 RTP实时保护进程中。RTP实时进程可以随时动态加载运行外部程序。每个RTP进程完全独立,程序在 RTP进程内部出现的任何错误都被限制在RTP进程内部,删除RTP实时进程时自动释放所有资源。RTP与其他多进程OS不同的是,VxWorks的RTP实时进程具有完全的静态确定性,提供保护功能的同时提供最高的实时响应确定性和快速性,并且可以提供完全的存储错误检测和存储报告功能。动态链接库和共享数据区功能也同时提供。RTP实时保护进程与VWorks原有的更高性能实时任务一起构成保护性和实时性兼备的超级设备平台. 

动态库生成

1、选择工程工作路径

Workbench3.0-vxworks6.6仿真测试和调试指南_第1张图片

2、正常打开的初始界面

       一般情况下左下角出现相似的界面,说明您的VxWorks6.6系统基本安装正常。需要注意的是系统安装了Tornado2.2会与WorkBench3.0冲突,最好要把Tornado2.2卸掉,操作系统Win7不支持两者的安装。

Workbench3.0-vxworks6.6仿真测试和调试指南_第2张图片

3、创建动态库工程

Workbench3.0-vxworks6.6仿真测试和调试指南_第3张图片

4、动态库名称

5、编译选择

       这里我们选择diab工具编译,gnu编译工具在调试c++中的 Class类有点问题,具体原因我没有去研究。

6、其余默认,按完成即可

Workbench3.0-vxworks6.6仿真测试和调试指南_第4张图片

7、添加inc和src文件夹

       A、Inc包含demo.h和stdafx.h;

       B、src包含demo.cpp和stdafx.cpp。

[cpp]  view plain copy
  1. stdafx.h  
  2. // stdafx.h : include file for standard system include files,  
  3. //  or project specific include files that are used frequently, but  
  4. //      are changed infrequently  
  5. //  
  6.   
  7. #if !defined(AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_)  
  8. #define AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_  
  9.   
  10. #if _MSC_VER > 1000  
  11. #pragma once  
  12. #endif // _MSC_VER > 1000  
  13.   
  14. #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers  
  15.   
  16. #include <stdio.h>  
  17.   
  18. // TODO: reference additional headers your program requires here  
  19.   
  20. //{{AFX_INSERT_LOCATION}}  
  21. // Microsoft Visual C++ will insert additional declarations immediately before the // previous line.  
  22.   
  23. #endif // !defined(AFX_STDAFX_H__E5CE9468_AAF9_46A6_979B_9C125F6E9D00__INCLUDED_)  
  24.   
  25. stdafx.cpp  
  26. // stdafx.cpp : source file that includes just the standard includes  
  27. //  libdemo.pch will be the pre-compiled header  
  28. //  stdafx.obj will contain the pre-compiled type information  
  29.   
  30. #include "stdafx.h"  
  31.   
  32. // TODO: reference any additional headers you need in STDAFX.H  
  33. // and not in this file  
  34.   
  35. demo.h  
  36. #ifndef _DEMO_H_  
  37. #define _DEMO_H_  
  38.   
  39. // The following ifdef block is the standard way of creating macros which make exporting   
  40. // from a DLL simpler. All files within this DLL are compiled with the AE_DEMO_EXPORTS  
  41. // symbol defined on the command line. this symbol should not be defined on any project  
  42. // that uses this DLL. This way any other project whose source files include this file see   
  43. // AE_DEMO_ENTRY functions as being imported from a DLL, wheras this DLL sees symbols  
  44. // defined with this macro as being exported.  
  45. #ifdef WIN32  
  46. #ifdef AE_DEMO_EXPORTS  
  47. #define AE_DEMO_ENTRY __declspec(dllexport)  
  48. #else  
  49. #define AE_DEMO_ENTRY __declspec(dllimport)  
  50. #endif  
  51. #else  
  52. #define AE_DEMO_ENTRY  
  53. #endif  
  54.   
  55. // This class is exported from the libdemo.dll  
  56. class AE_DEMO_ENTRY CTest   
  57. {  
  58. public:  
  59.     CTest();  
  60.     virtual ~CTest();  
  61. public:  
  62.     int Add(int a, int b);  
  63. protected:  
  64.     int m_nCount;  
  65. };  
  66.   
  67. extern AE_DEMO_ENTRY int nTest;  
  68.   
  69. AE_DEMO_ENTRY int fnTest();  
  70.   
  71. #endif // _DEMO_H_  
  72.   
  73. demo.cpp  
  74. #include "stdafx.h"  
  75. #include "demo.h"  
  76.   
  77. // This is an example of an exported variable  
  78. AE_DEMO_ENTRY int nTest = 0x64;  
  79.   
  80. // This is an example of an exported function.  
  81. AE_DEMO_ENTRY int fnTest()  
  82. {  
  83.     return 64;  
  84. }  
  85.   
  86. // This is the constructor of a class that has been exported.  
  87. // see demo.h for the class definition  
  88. CTest::CTest()  
  89. {   
  90. }  
  91.   
  92. CTest::~CTest()  
  93. {   
  94. }  
  95.   
  96. int CTest::Add(int a, int b)  
  97. {  
  98.     return (a + b);  
  99. }  

8、添加inc路径

Workbench3.0-vxworks6.6仿真测试和调试指南_第5张图片

9、刷新工程

       如图所示,按鼠标右键刷新工程,inc和src即可添加到工程中去。

Workbench3.0-vxworks6.6仿真测试和调试指南_第6张图片

10、编译工程

       从右键菜单中选择“build project”完成编译,把编译好的动态库 libdemo.so拷贝到

$(FEPHOME)/bin下,方便后面的使用。

       注意:FEPHOME环境编译=c:/openSUSE3000/fep中的斜杠是反的。

动态库调用

       VxWorks6.6调用比较麻烦,需要很多配置。

1、创建工程

Workbench3.0-vxworks6.6仿真测试和调试指南_第7张图片

2、编译选择

3、默认完成

Workbench3.0-vxworks6.6仿真测试和调试指南_第8张图片

4、编译属性

Workbench3.0-vxworks6.6仿真测试和调试指南_第9张图片

5、编译属性-linker

6、选中Create a dynamic executable

Workbench3.0-vxworks6.6仿真测试和调试指南_第10张图片

7、设置LIBPATH和LIBS

Workbench3.0-vxworks6.6仿真测试和调试指南_第11张图片

8、包含路径

       这里包含$(FEPHOME)/code/include,因为libdemo.h需要放在这里,它是一个隐式调用的方式。

Workbench3.0-vxworks6.6仿真测试和调试指南_第12张图片
 

以上设置好即可编译,编译方式如上比较简单。把编译好的动态库 testdemo.vxe拷贝到$(FEPHOME)/bin下,方便后面的使用。

9、启动仿真

Workbench3.0-vxworks6.6仿真测试和调试指南_第13张图片

10、调试

       因为动态链接库是给RTP使用的,我们只能选择Debug RTP On Target在目标机上运行。

Workbench3.0-vxworks6.6仿真测试和调试指南_第14张图片

11、设置运行程序路径

 

12、执行Debug

       执行上面的Debug按钮之后,将出现如下的画面。

Workbench3.0-vxworks6.6仿真测试和调试指南_第15张图片

13、F6单步执行

       调试可以按F6单步执行,右上角的工具栏上也有该功能项按钮。选择中间的Console控制台TA B栏,我们可以看到输出结果了。Workbench3.0-vxworks6.6仿真测试和调试指南_第16张图片

14、执行后的仿真器

SHELL调用

1、首先看看仿真器的虚拟路径

2、在仿真器中执行testdemo.vxe

你可能感兴趣的:(编程,测试,存储,Build,insert,工具)