我有一个应用程序模块sample.out。要是将它和VxWorks做在一起,在ursAppInit.c中添加一个taskSpawn函数,就可以实现vxWorks启动之后,自动发起一个任务,运行sample.out。但这样做生成的VxWorks会很大,我听说可以在usrAppInit.c中调用别的函数,可以将vxWorks和sample.out分开,vxworks启动之后,手动输入sample.out,系统会到c盘根目录下找sample.out,然后运行,请问这个怎么实现?

试试这个代码,应该可以load 吧!
#include <vxWorks.h>
#include <stdio.h>
#include <ioLib.h>
#include <loadLib.h>
#include <symLib.h>
#include <taskLib.h>
#include <moduleLib.h>
#include <nfsLib.h>
#include <nfsDrv.h>
#include <netDrv.h>
extern SYMTAB_ID sysSymTbl;
int loadTest()
{
int fd = ERROR;
int status = ERROR ;
MODULE_ID hModule;
FUNCPTR taskEntry = NULL;
SYM_TYPE * pType;
fd = open("/tffs/project0.out",O_RDONLY,0644);
if (fd==ERROR)
{
printf("can not open file.\n");
return ERROR;
}
else
{
printf(" file opened.\n");
}
printf("before loadModule\n");
if ((hModule=loadModule( fd,LOAD_GLOBAL_SYMBOLS))==NULL)
{
printf("loadModule error = 0x%x.\n",errno);
return ERROR;
}
close(fd);
status = symFindByName(sysSymTbl,"hello",(char **)&taskEntry,pType);
if (status==ERROR)
{
printf("symFindByName error=%d\n", errno);
return ERROR;
}
else
{
printf("taskEntryr=0x%x, type=%d\n.",(int)taskEntry,(int)*pType);
}
status = taskSpawn("test",100,0,30000,taskEntry,0,0,0,0,0,0,0,0,0,0);
if (status==ERROR)
{
printf("taskSpawn error=%d\n",errno);
return ERROR;
}
return OK;
}
回复
打赏帖 | |
---|---|
【S32K146】S32DS watchdog 配置使用被打赏20分 | |
【Zephyr】使用 IAR 调试 Zephyr 镜像被打赏20分 | |
【Zephyr】MCXN947 Zephyr 开发入门适配shell被打赏20分 | |
【我要开发板】6.联合MATLAB记录数据被打赏50分 | |
【瑞萨RA2E1开发板】:使用ADC功能实现位移传感器采集方案被打赏20分 | |
【nRF7002DK】基于sht30的温湿度计被打赏20分 | |
【nRF7002DK】日志打印被打赏20分 | |
【换取手持示波器】RGB屏幕移植ARM-2D库被打赏35分 | |
【分享开发笔记,赚取电动螺丝刀】分享一下如何解决瑞萨RA2E1使用printf编译报错问题被打赏27分 | |
rtthread硬件加密-5hash加密分析被打赏10分 |