调用select函数时出现如下错误
Undefined instruction
Exception address: 0x0005c1e0
Current Processor Status Register: 0x20000013
Task: 0xff45c8 "tTffsPTask"
哪位大侠指点一下!谢谢!
确定是执行到select那一句挂掉的吗?
设断点跟一下~
代码贴点出来吧
确定!
代码如下
static STATUS RecvDataWithTimeOut(UINT16 datacount,UINT16 timeoutvalue)
{
UINT16 bytesRead;
UINT32 i = 0;
struct timeval timeout;
int selectnum;
struct fd_set readFds; /* 串口bit mask of fds to read from */
int width; /* number of fds on which to pend */
timeout.tv_sec = timeoutvalue;
timeout.tv_usec = 0;FD_ZERO (&readFds);
FD_ZERO (&readFds);
FD_SET (comm2Fd, &readFds);
width = comm2Fd + 1;
FD_ISSET (comm2Fd, &readFds);
FOREVER
{
printf("select start!!!\n");
if(timeoutvalue==0)
selectnum = select (width, &readFds, NULL, NULL, NULL);
printf("select over!!!\n");
else
selectnum = select (width, &readFds, NULL, NULL, &timeout);
if (selectnum == ERROR)
{
#ifdef DEBUG_PRINT
printErr("ERROR:An select error has occurred in received data from COM2!\n");
#endif
return ERROR;
}
else if(selectnum == 0)
{
#ifdef DEBUG_PRINT
printErr("ERROR:An timeout error has occurred in received data from COM2!\n");
#endif
return ERROR;
}
if (FD_ISSET (comm2Fd, &readFds))
{
bytesRead = fioRead(comm2Fd,szBuf,datacount);
/*#ifdef DEBUG_PRINT
printf("bytesRead = %d, datacount = %d, szBuf[0] = %x\n",bytesRead,datacount,szBuf[0]);
#endif*/
return bytesRead;
}
}
}
现在 select start!!!能打印出来
select over!!!打印不出来就死了!!
大侠,判断以下
..\temp.c: In function `RecvDataWithTimeOut':
..\temp.c:75: `comm2Fd' undeclared (first use in this function)
..\temp.c:75: (Each undeclared identifier is reported only once
..\temp.c:75: for each function it appears in.)
..\temp.c:85: parse error before `else'
..\temp.c:105: `szBuf' undeclared (first use in this function)
这段代码能编译通过?
if(timeoutvalue==0)
selectnum = select (width, &readFds, NULL, NULL, NULL);
printf("select over!!!\n");
else
selectnum = select (width, &readFds, NULL, NULL, &timeout);
不好意思,昨天着急打错了,但是跟踪加的位置是没错的,请各位大侠原谅,
代码如下
static STATUS RecvDataWithTimeOut(UINT16 datacount,UINT16 timeoutvalue)
{
UINT16 bytesRead;
UINT32 i = 0;
struct timeval timeout;
int selectnum;
struct fd_set readFds; /* 串口bit mask of fds to read from */
int width; /* number of fds on which to pend */
timeout.tv_sec = timeoutvalue;
timeout.tv_usec = 0;FD_ZERO (&readFds);
FD_ZERO (&readFds);
FD_SET (comm2Fd, &readFds);
width = comm2Fd + 1;
FD_ISSET (comm2Fd, &readFds);
FOREVER
{
printf("select start!!!\n");
if(timeoutvalue==0)
{
selectnum = select (width, &readFds, NULL, NULL, NULL);
printf("select over!!!\n");
}
else
selectnum = select (width, &readFds, NULL, NULL, &timeout);
if (selectnum == ERROR)
{
#ifdef DEBUG_PRINT
printErr("ERROR:An select error has occurred in received data from COM2!\n");
#endif
return ERROR;
}
else if(selectnum == 0)
{
#ifdef DEBUG_PRINT
printErr("ERROR:An timeout error has occurred in received data from COM2!\n");
#endif
return ERROR;
}
if (FD_ISSET (comm2Fd, &readFds))
{
bytesRead = fioRead(comm2Fd,szBuf,datacount);
/*#ifdef DEBUG_PRINT
printf("bytesRead = %d, datacount = %d, szBuf[0] = %x\n",bytesRead,datacount,szBuf[0]);
#endif*/
return bytesRead;
}
}
}
现在 select start!!!能打印出来
select over!!!打印不出来就死了!!
大侠,判断以下
再详细介绍一下,这段代码是ARM通过串口接收单片机信息的代码,整个系统有ABCDE五个用户任务,其中ABC任务同一个优先级,DE任务同一个优先级但比ABC任务优先级低,这段代码为A任务调用,B与DE属于死循环任务,整个任务调度依靠VXWORKS默认任务调度机制,可是现在发现,该系统会发生不可预期的死机现象,表现有时是低优先级任务DE挂起,有时甚至连0优先级的异常处理任务以及FLASH驱动任务都挂起了,加跟踪后几乎每次都是死机在执行printf("select start!!!\n");之后,printf("select over!!!\n"); 执行不出来,并且有时会出现如下错误:
Undefined instruction
Exception address: 0x0005c1e0
Current Processor Status Register: 0x20000013
Task: 0xff45c8 "tTffsPTask"
我的问题是,我的这段代码是否正确?能否判定是调用select函数的问题?select函数是否有什么需要注意的地方?
我现在把BCDE任务全部砍掉,只留A任务在跑,这时A任务会有定期的(大概一分钟一次的)由单片机主动访问ARM,由ARM执行IIC驱动得到其他芯片数据,并返回给单片机的动作。可是这样依然会发生不定期的死机。单片机的型号是W78E516B会有什么问题吗?ARM的型号是三星S3C4510B01-QERO,这款ARM的IIC是否有问题?
comm2Fd这个值没有问题的话,这段代码应该没有问题。
应该是其他的问题
谢谢!怎么验证comm2Fd这个值呢?另外能帮我看看下面这段代码是否有时序问题吗?谢谢!
void usrRoot (char *pMemPoolStart, unsigned memPoolSize)
{
usrKernelCoreInit (); /* core kernel facilities */
memPartLibInit (pMemPoolStart, memPoolSize); /* core memory partition manager */
memInit (pMemPoolStart, memPoolSize); /* full featured memory allocator */
sysClkInit (); /* System clock component */
usrIosCoreInit (); /* core I/O system */
usrKernelExtraInit (); /* extended kernel facilities */
usrIosExtraInit (); /* extended I/O system */
selectInit (); /* select */
usrToolsInit (); /* software development tools */
cplusLibInit (); /* C++ runtime support */
usrAppInit (); /* call usrAppInit() (in your usrAppInit.c project file) after startup. */
}
我看网上有些例子selectInit ();是这样写的selectInit (NUM_FILES);,有什么含义?和我现在的有什么不同吗?
我很菜,帮帮忙!
comm2Fd不是你给赋值的吗?
shell下敲iosFdShow命令查看fd列表
另外把comm2Fd打印出来
看是否在fd列表中。。。
谢谢,我还有个问题想请教,请问还是这个系统,如果单片机通过串口主动与ARM通讯,ARM返回信息,当ARM正在Write的同时,前面板又send了,请问,这样对ARM会不会有影响?单片机通过串口与ARM通讯的任务优先级是100。
是说单片机和arm之间用一根串口线连接
双方同时往串口写东西吗?
应该没有问题,串口是一根读的数据线一根写的数据线,互相之间不会影响到
select中没有指定超时时间,所以一直处于等待状态!