我有一个应用程序模块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;
}
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
多组DCTODC电源方案被打赏50分 | |
【我踩过的那些坑】STM32cubeMX软件的使用过程中的“坑”被打赏50分 | |
新手必看!C语言精华知识:表驱动法被打赏50分 | |
【我踩过的那些坑】杜绑线问题被打赏50分 | |
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 |