[转帖]在vxworks中如何使用启动脚本startup script

[转帖]在vxworks中如何使用启动脚本startup script

在vxworks中如何使用启动脚本startup script
1 选择一个合适的bsp,创建一个bootable vxworks image project,包含shell startup script组件。
在usrAppInit()中添加代码
printf("/nusrAppInit/n");
这条语句的作用就是为了比较usrAppInit()和startup script谁先执行。
2 写一个demo.c,文件内容如下:
#include "vxworks.h"
void demo(void)
{
int x;
for(x=0;x<5;x++)
printf("x=%d/n",x);
}
把它加入到vxworks的工程中。这是一个简单的用户函数例子。
3 在vxworks文件所在的目录下,创建一个文件myscripts.txt,其内容为:
printf("hello/n")
demo()
routeShow()
i
为了能够调用routeShow,vxworks配置中需要包含网络调试组件。
4 启动目标机,在bootrom引导vxworks时,指定startup script参数,如:
boot device : cpm
unit number : 0
processor number : 0
host name : chenqi
file name : vxWorks
inet on ethernet (e) : 192.168.0.200
host inet (h) : 192.168.0.118
user (u) : target
ftp password (pw) : target
flags (f) : 0x0
target name (tn) : 850pc
startup script (s) : myscript.txt
5 如果一切正常,vxworks启动完毕之后,会有:
Executing startup script myscript.txt ...
printf("hello/n")
hello
value = 6 = 0x6
demo()
x=0
x=1
x=2
x=3
x=4
value = 4 = 0x4
routeShow()


ROUTE NET TABLE
Destination Gateway Flags Refcnt Use Inte**ce
--------------------------------------------------------------------
192.168.0.0 192.168.0.200 0x101 1 0 cpm0
--------------------------------------------------------------------


ROUTE HOST TABLE
Destination Gateway Flags Refcnt Use Inte**ce
--------------------------------------------------------------------
127.0.0.1 127.0.0.1 0x5 0 0 lo0
--------------------------------------------------------------------
value = 69 = 0x45 = 'E'
i(0)
Show routine of this object not configured into system.
value = 56 = 0x38 = '8'



Done executing startup script myscript.txt


usrAppInit
由此可见,startup script在usrAppInit函数之前执行。
在上述试验中,需要注意最好让vxworks文件和myscript.txt文件在同一位置。  

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值