首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

seuafu2005 你好,麻烦进来看看[求助]

seuafu2005 你好,麻烦进来看看[求助]

看您前面的帖子说到:


据我所知freescale有一个manyhops的demo,实现mesh的功能


能够告诉我如何得到这个demo么。我想看看

jimmytan 您好 我的地址tianandy_tom@yahoo.com.cn
万分感谢
你说的星型是802.15.4 EVK 1.063里面那个MyStarNetworkApp.mpc么
jimmytan 您好 关于星型网的一些问题我发送到你邮箱了,希望您能看看,在这里再贴一下,下面是星型网协调器程序中发送数据的函数
void App_TransmitData(void)
{
uint8_t msduLength = 0;
uint8_t morePackets = 1;
uint8_t deviceAddress = 0x01;
uint8_t ret;
static uint8_t dataBuffer[DEFAULT_DATA_LENGTH]; /* Prevent slow allocation on stack */

/* We transmit only if at least one device is associated. */
if(addressesMap == 0)
return;

/* Send packets only if we can send info to all End Devices */
if(numPendingPackets > 0)
{
if(packetDropped > 0)
{
Uart_Print("Packet dropped.\n");
packetDropped = 0;
}
return;
}

/* Get data to be transmitted from one source */
/* Try first the LED counter */
if(counterLEDsModified)
{
counterLEDsModified = FALSE;
packetDropped = FALSE;
dataBuffer[0] = counterLEDs & 0x0F;
msduLength = 1;
}
else
{
/* Else try to get data from the UART. */
msduLength = Uart_PollMessage(dataBuffer);
}

/* For every device associated, if there is still room in the queue
allocate and send a packet */
if(msduLength != 0)
{
/* Find the first associated end device. We have at least one.*/
while((deviceAddress & addressesMap) == 0)
{
deviceAddress = deviceAddress << 1;
}
/* Transmit packets to the devices */
do
{
morePackets = 0;
if (numPendingPackets < MAX_PENDING_DATA_PACKETS && NULL == pPacket)
{
pPacket = MSG_Alloc(sizeof(nwkToMcpsMessage_t) - 1 + DEFAULT_DATA_LENGTH);
if (pPacket != NULL)
{
/* Create an MCPS-Data Request message containing the data. */
pPacket->msgType = gMcpsDataReq_c;
/* Copy data to be sent to packet */
memcpy(pPacket->msgData.dataReq.msdu, (void *)dataBuffer, msduLength);
/* Create the header using device information stored when creating
the association response. In this simple example the use of short
addresses is hardcoded. In a real world application we must be
flexible, and use the address mode required by the given situation. */
pPacket->msgData.dataReq.dstAddr[0] = deviceAddress;
pPacket->msgData.dataReq.dstAddr[1] = 0;
memcpy(pPacket->msgData.dataReq.srcAddr, (void *)shortAddress, 2);
memcpy(pPacket->msgData.dataReq.dstPanId, (void *)panId, 2);
memcpy(pPacket->msgData.dataReq.srcPanId, (void *)panId, 2);
pPacket->msgData.dataReq.dstAddrMode = gAddrModeShort_c;
pPacket->msgData.dataReq.srcAddrMode = gAddrModeShort_c;
pPacket->msgData.dataReq.msduLength = msduLength;
/* Request MAC level acknowledgement, and
indirect transmission of the data packet */
pPacket->msgData.dataReq.txOptions = gTxOptsAck_c | gTxOptsIndirect_c;
/* Give the data packet a handle. The handle is
returned in the MCPS-Data Confirm message. */
pPacket->msgData.dataReq.msduHandle = msduHandle++;
/* Add the packet to tracking list in the purger module. */
ret = Purger_Track(pPacket->msgData.dataReq.msduHandle, 0, deviceAddress, counterLEDs);
/* Send the Data Request to the MCPS */
NR MSG_Send(NWK_MCPS, pPacket);
/* Prepare for another data buffer */
pPacket = NULL;
numPendingPackets++;
/* Move to next associated device */
do
{
deviceAddress = deviceAddress << 1;
}
while(((deviceAddress & addressesMap) == 0) && (deviceAddress < 0x10));
/* Continue if we haven't passed the last possible device address. */
morePackets = deviceAddress < 0x10;
}
else
{
Uart_Print("Packet NULL.\n");
}
}
}
while (morePackets);
}
}
就是星型网络中协调器发送数据的函数,从代码看是支持四个END Device,其地址为01,02,04,08。协调器往end device中发送数据,但是当连接上第4个时候,向第4个end device发送数据时候会出现 Packet NULL。前面3个都能正常发送数据的
help!!!
首先感谢jimmytan的帮助,我用的是MyStarNetworkApp.mpc这个程序,确认第四个是连上网络了。但是四个 device的程序中除了预定义的数据,其他都是一摸一样的,为什么前3个不会polling时间长,而最后一个出现polling时间过长呢?

[此贴子已经被作者于2006-10-10 11:20:47编辑过]

jimmytan不知道您现在有没有那个Mystarnetworkapp.mpc的代码?可以看一下么.一部分函数确实也不能看出什么
我发送给您吧 呵呵
jimmytan你好 demo程序已经发送过来 是5个分割文件 请查看
如果这个demo中协调器发送数据不用indirect模式发送呢?
这个问题卡住很久了   help啊
jimmytan你好 刚刚改长了EXPIRE_INTERVAL 发现还是存在如下现象
Packet NULL.

AllInfoModeevice address: 0002:C6:I am from device A!

AllInfoModeevice address: 0004:A2:I am from device C!

AllInfoModeevice address: 0001:F0:I am from device B!
我能跟您打电话祥说一下么?谢谢
从串口输出信息Packet Null来看似乎是分配地址失败阿
是内存空间分配不够么?
返回列表