首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

嵌入式操作系统VxWorks中文FAQ 10

嵌入式操作系统VxWorks中文FAQ 10

int teststdio()
{
char buffer[10];
char *tn = "tmpxxx"; //是不是这里的问题?
FILE *pf = NULL;
int result = 0;
/*fpos_t fp1;
long off;*/

/* opening a file for both reading and writing */
result += ASSERT((pf = fopen(tn, "w+")) != NULL);

/* closing the file */
result += ASSERT(fclose(pf) == 0);

/* reopening the file and attaching the standard input stream to the file */
result += ASSERT(freopen(tn, "r", stdin) == stdin);
.....
/


A:char *tn = "tmpxxx"; //是不是这里的问题?
你没指定文件所在的设备,
simNT环境里,一般设备为"host:"
所以格式为char *tn="host:/myFile";
(by wys205)

6.9 Task related items
6.10 Time/timer related items
6.11 Wind Web Server related items
6.12 Zinc/windML related items
6.13 Other items
6.14 VxWorks AE issues


6.15 I/O 操作
6.15.1 查看serial device的状态,又是异常!
文件如下,注释有它的说明,编译后,在shell输入:
-> pDevHdr = iosDevFind ("/tyCo/0",0)
Exception number 0: Task: 0x4bbc8e8 (t1)

General Protection Fault
Program Counter: 0x0041eba5
Status Register: 0x00010202

还是想得到各位兄台的指点,谢谢!
......
void tyShow
(
TY_DEV * pTyDev
)
{
/* read - ring buffer and semaphores */
printf ("Address of pTyDev->rdBuf = 0x%08x.\n", &pTyDev->rdBuf);
printf ("Address of pTyDev->rdSyncSem = 0x%08x.\n", &pTyDev->rdSyncSem);
printf ("Address of pTyDev->mutexSem = 0x%08x.\n\n", &pTyDev->mutexSem);

/* rdState */
printf ("pTyDev->rdState.xoff = 0x%02x.\n", pTyDev->rdState.xoff);
printf ("pTyDev->rdState.pending = 0x%02x.\n", pTyDev->rdState.pending);
printf ("pTyDev->rdState.canceled = 0x%02x.\n", pTyDev->rdState.canceled);
printf ("pTyDev->rdState.canceled = 0x%02x.\n", pTyDev->rdState.canceled);

/* write - ring buffer and semaphores */
printf ("Address of pTyDev->wrtBuf = 0x%08x.\n", &pTyDev->wrtBuf);
printf ("Address of pTyDev->wrtSyncSem = 0x%08x.\n\n", &pTyDev->wrtSyncSem);

.....

A:
->buf=malloc(100)
->pDevHdr=iosDevFind("/tyCo/0", buf)
(by vxfree)


7.其它 FAQ
7.1
7.1.1 各位大侠: 我的程序写好了,系统如何启动我的应用程序。tornado 2 帮助里有这一段:
Linking the application with VxWorks is really a two-step process. You must add an entry point
to the application in usrConfig.c, and you must modify the makefile to link the application
statically with VxWorks.

To start your application during system initialization, add code to the usrRoot( ) routine in
usrConfig.c. You can call application initialization routines, create additional I/O devices,
spawn application tasks, and so on, just as you do from the Tornado shell during development.
An example is provided in usrConfig.c. This file includes and initializes a simple demo if the
preprocessor constant INCLUDE_DEMO is defined in one of the configuration files. In that
situation, usrRoot( ) spawns usrDemo( ) as a task as the last step in booting the system. You
can simply insert the appropriate initialization of your application after the conditional
code to start the demo. For example:

/* spawn demo if selected */
#if defined(INCLUDE_DEMO)
taskSpawn ("demo", 20, 0, 2000, (FUNCPTR)usrDemo, 0,0,0,0,0,0,0,0,0,0);
#endif
taskSpawn ("myMod", 100, 0, 20000, (FUNCPTR)myModEntryPt,
0,0,0,0,0,0,0,0,0,0);
To include your application modules in the bootable system image, add the names of the
application object modules (with the .o suffix) to MACH_EXTRA in Makefile. For example, to
link the module myMod.o, add a line like the following:

MACH_EXTRA = myMod.o
...
Building the system image with the application linked in is the final part of this step. In
the target directory, execute the following command:

make vxWorks

按上面的步骤,我用tornado 2的rebuild All命令生成vxWorks,考到硬盘里通过bootrom.sys
启动vxWorks;vxWorks启动了,可我的应用没有。各位大侠,如何启动应用程序呢? 请指点。
小弟非常感谢!
※ 作 者: zhangjiaxue 02-8-21 18:09:18 ※

Re:哪位大侠做过把应用绑定到vxWorks系统去 <--- 〖回复该帖子〗

1).在启动系统时启动用户定制的任务
假设有一个MultiTask.c的程序,该程序使用消息队列来传递不同task之间的消息,其中:主task为Init,
负责建立两个从task,监控和传递推出消息,并释放从进程需要的资源。
将此文件加入到制作vxworks的工程中(注意这里的MultiTask.c同样不能放在带空格的路径下),
修改usrAppInit.c,在开头加入:
extern void Init(void);
在函数结束前加入:
Init();
重新编译生成vxworks,重启目标机,可以看到任务自动执行。

2).关于usrconfig.c
有些帮助文件中提到可以修改c:\tornado\target\config\all\usrconfig.c中的usrRoot函数来改变启动画
面和启动用户任务。但在vxworks的faq中提到:"Tornado2.0不使用usrconfig.c,而是用
target\config\comps下的 configulettes,如果需要使用usrconfig,必须"make"
c:\tornado\target\config\pentiumpro下的makefile文件。事实上,在帮助文件里大量地提到了修改
usrconfig,例如在不通过网络而是从rom启动vxworks,使用flash ram等。
实际上就tornado2.0来说,分为两种情况:
<1>用户自己建立的bootable image
这时不使用usrconfig,用户通过对工程可视化的修改,就可以裁减内核。如果在project里面去掉了默认
的dependence,可以看到target\config\comps下的一些*.c,*.h文件其实是被引用的。通过对它们的修改,
可以起到类似于修改usrconfig.c的作用,编译时使用的是系统自动在工程所在目录下产生的makefile,
对这个makefile的修改将不会产生作用。
<2>系统默认的bootable image
这时使用安装时自带usrconfig。用于通过对configAll.h和config.h中define或undef宏INCLUDE_XXX来
裁减内核。这时对启动化面的修改是通过对usrconfig.c的修改实现的。用户定制任务如下实现。: 在
#else
#if defined(INCLUDE_DEMO) /* create demo w/o shell */
taskSpawn ("demo", 20, 0, 2000, (FUNCPTR)usrDemo, 0,0,0,0,0,0,0,0,0,0);
#endif /* mips cpp no elif */
#endif /* INCLUDE_SHELL */
后面添加
taskSpawn("tInit", 1, 0, 10000, (FUNCPTR)Init, 0,0,0,0,0,0,0,0,0,0);
这里使用的是c:\tornado\target\config\bspname下的makefile。
定制任务还需要在makefile里添加:
MACH_EXTRA = MultiTask.o
这个MultiTask.o是在另外一个downloadable application project里编译产生的。这个project里仅含有
一个MultiTask.c,将MultiTask.o拷贝到c:\tornado\target\config\bspname下供makefile使用。可以参
照下面vxWorks.st_rom的产生方法产生一个可以standalone的vxWorks.st,也可以在tornado集成环境中选
择toolsèoptionsèprojectèshow Tornado1.0.1 menu items(如果安装时选择使用tornado1.0,则这个选项
默认被选中),然后选择builtèstandard bsp buildsèpcPentiumPro、vxWorks.st,这两种方法生成的
vxWorks.st都在c:\tornado\target\config\bspname目录下。

7.2
7.2.1 请教帮主c and c++,tornado支持c and c++ ,但当我用c++写好程序test.cpp,然后想在usrAppinit.c
中调用我写好的myFuc();时,不能编译通过。但我把test.cpp改成test.c后则可以通过。这是为什么?
A:文件后缀为.cpp时编译器会认为是C++文件,这样有些定义类型为C的函数在编译或下载时不被认可。
解决方法是把这些不被认可的C类型函数用语句extern "C"说明一下为C函数就行了
返回列表