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 Interface
--------------------------------------------------------------------
192.168.0.0 192.168.0.200 0x101 1 0 cpm0
--------------------------------------------------------------------
ROUTE HOST TABLE
Destination Gateway Flags Refcnt Use Interface
--------------------------------------------------------------------
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文件在同一位置。
我要赚赏金打赏帖 |
|
|---|---|
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
| 【分享开发笔记,赚取电动螺丝刀】墨水屏文本显示器被打赏¥25元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取磁力计iis2mdc被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取LPS22HH气压、温度被打赏¥19元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX读取STTS751温度被打赏¥17元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX软件读取HTS221温湿度被打赏¥22元 | |
| M5PAPERESP32EINKDEVKIT评测|使用MicroPython开发M5Paper被打赏¥15元 | |
| OK1126B-S开发板下以导航按键控制云台/机械臂姿态调整被打赏¥29元 | |
| 【树莓派5】便携热成像仪被打赏¥36元 | |
| 【树莓派5】环境监测仪被打赏¥35元 | |
我要赚赏金
