我想用muxSend()来发送一个自己填充的数据帧,其中由于对M_BLK_ID pMblk结构不是很了解,我也只是通过WindRiver提供的文档已经一些头文件来猜测着填充pMblk的各个成员。整个程序的主要步骤如下:
STATUS muxSendData() //The entry of the program
{
int j;
char *ifname = "motfec";//网络接口名
int unit = 0;
M_BLK_ID pMblk = (M_BLK_ID)malloc(1 * sizeof(M_BLK));
unsigned char PktHeader[] =
{ 0x00,0x10,0x4b,0x08,0xca,0x1c, //目的MAC
0x08,0x00,0x3e,0x32,0x53,0x22,//源MAC
0x81,0x00,//协议类型
0x20,0x01,//其他字段
0x00,0x52
};
struct ifnet *pIfnet; //Pointer to your network interface's ifnet struct
monitorSendBindCookie = muxBind ("motfec", 0, NULL,
NULL, NULL, NULL, MUX_PROTO_SNARF, NULL, NULL);
if(monitorSendBindCookie == NULL)
{
logMsg("monitor SendBindCookie:Can't bind to %s%d!\n",ifname,unit);
return(ERROR);
}
logMsg("Data Monitor By Mux:%s%d Bind OK!!\n",ifname,unit);
//bzero ((unsigned char *)&pMblk,sizeof(M_BLK));
pMblk->mBlkHdr.mNext = NULL;
pMblk->mBlkHdr.mNextPkt = NULL;
pMblk->mBlkHdr.mData = PktHeader;
pMblk->mBlkHdr.mLen = 82;
pMblk->mBlkHdr.mType = MT_DATA;
pMblk->mBlkHdr.mFlags = M_FORWARD;
pMblk->mBlkHdr.reserved = 0x8100;
// get the ifnet pointer of your network interface
pIfnet = ifunit ("motfec0");
if (pIfnet == (struct ifnet *) NULL)
{
printf ("ifunit failed\n");
return (ERROR);
}
pMblk->mBlkPktHdr.rcvif = pIfnet;
pMblk->mBlkPktHdr.len = 82;
pMblk->pClBlk = g_pMblk->pClBlk;
for(j = 0; j < 5; j++)
{
muxSend(monitorSendBindCookie,pMblk);
}
printf("Over");
return (OK);
}
问题:
当我运行后,系统只发了2个帧(我总共需要发5个帧),VxWorks下的tNetTask就被SUSPEND+I了,只能重启后才能重新唤起tNetTask。
错误提示信息是:
data access
Exception current instruction address: 0x0005ab10
Machine Status Register: 0x00009030
Data Access Register: 0x0010da94
Condition Register: 0x40000043
Data storage interrupt Register: 0x00000084
Task: 0x1fa75b8 "tNetTask"
需要大家的帮助,谢谢大家了!!!!
我的运行平台是:
Tornado 2.2
VxWorks 5.5
[align=right][color=#000066][此贴子已经被作者于2005-9-9 10:09:43编辑过][/color][/align]