VxWorks入门教程12:程序运行-启动后

系列索引:VxWorks入门教程索引

上一篇:VxWorks入门教程11:程序运行-调试版

本文介绍如何在VxWorks系统中运行程序。就是在VxWorks启动后的系统命令行中运行程序。

通用工程

先新建一个可下载工程(Downloadable Kernel Module Project)

new project

设置工程名称

name

设置编译选项为gnu

option

设置编译目标为:

target

创建好的新工程为

project

添加一个新源码文件到工程中

new file

设置文件名

name

添加完成后,文件内容为空

file

hello world

添加代码

1
2
3
4
5
6
7
#include <stdio.h>

int first_test(void)
{
printf("hello world!\n");
return 0;
}

标准的C程序,函数名要记住,后续会用到。

编译结果为:

result

可以用

1
ls

列出硬盘中的所有文件。

加载程序

1
ld 1,0,"hello.out"

查看是否加载成功

1
moduleShow

执行程序,在命令行中输入程序的函数名作为执行入口

1
first_test

效果为:

result1

输出数组值

源码为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<vxworks.h> 
#include<stdio.h>
#include<stdlib.h>
int test()
{
int i = 1;

while(1)
{
printf ("%d\t",i);
if(i%10==0&&i!=0)
printf("\n");
i++;
if(i==101)
break;
}
printf("\n");
return 0;
}

加载模块,然后执行

1
2
ld (1) < hello.out
test

执行效果为:

array

完整的配置文件、测试工程、源码和编译结果在VxWorks_Freshman的7中。

下一篇:VxWorks入门教程13:程序运行-启动时


VxWorks入门教程12:程序运行-启动后
https://feater.top/vxworks/run-application-in-vxworks-system/
作者
JackeyLea
发布于
2021年10月15日
许可协议