MOD54415 UDP packet formation issue
Posted: Thu Apr 25, 2013 6:38 am
Hey all, having a little trouble with a UDP packet. This is my main while loop and it works correctly, but it's messy and it doesn't seem like it should:
while(1)
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
if (enabled == true)
{
siprintf (buffer, "System Running - main while loop \r\n");
pkt.AddData(buffer);
// send out the data:
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf ("System enabled mode. \r\n");
}
OSTimeDly(TICKS_PER_SECOND / 10); // five second delay to give time to examine incoming UDP packet...
for (int i = 0; i < 32; i++)
{
buffer = 0; //zero the buffer
}
} //end if
else
{
siprintf (buffer, "system idle - main while loop \r\n");
{ // send out the data:
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf("System idle mode. \r\n");
}
OSTimeDly(2*TICKS_PER_SECOND); // two second delay to give time to examine incoming UDP packet...
}//end else
}//end while(1)
I tried cleaning it up a bit, but it only crashes when I do:
while(1)
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
if (enabled == true)
{
siprintf (buffer, "System Running - main while loop \r\n");
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf ("System enabled mode. \r\n");
OSTimeDly(TICKS_PER_SECOND / 10); // five second delay to give time to examine incoming UDP packet...
for (int i = 0; i < 32; i++)
{
buffer = 0; //zero the buffer
}
} //end if
else
{
siprintf (buffer, "system idle - main while loop \r\n");
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf("System idle mode. \r\n");
OSTimeDly(2*TICKS_PER_SECOND); // two second delay to give time to examine incoming UDP packet...
}//end else
}//end while(1)
Anyone have any idea? Sorry, can't post any more code than this - sensitive nature. But I'll do what I can if anyone needs any more...
while(1)
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
if (enabled == true)
{
siprintf (buffer, "System Running - main while loop \r\n");
pkt.AddData(buffer);
// send out the data:
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf ("System enabled mode. \r\n");
}
OSTimeDly(TICKS_PER_SECOND / 10); // five second delay to give time to examine incoming UDP packet...
for (int i = 0; i < 32; i++)
{
buffer = 0; //zero the buffer
}
} //end if
else
{
siprintf (buffer, "system idle - main while loop \r\n");
{ // send out the data:
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf("System idle mode. \r\n");
}
OSTimeDly(2*TICKS_PER_SECOND); // two second delay to give time to examine incoming UDP packet...
}//end else
}//end while(1)
I tried cleaning it up a bit, but it only crashes when I do:
while(1)
{
UDPPacket pkt;
pkt.SetSourcePort(portnum);
pkt.SetDestinationPort(portnum);
if (enabled == true)
{
siprintf (buffer, "System Running - main while loop \r\n");
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf ("System enabled mode. \r\n");
OSTimeDly(TICKS_PER_SECOND / 10); // five second delay to give time to examine incoming UDP packet...
for (int i = 0; i < 32; i++)
{
buffer = 0; //zero the buffer
}
} //end if
else
{
siprintf (buffer, "system idle - main while loop \r\n");
pkt.AddData(buffer);
pkt.AddDataByte(0);
pkt.Send(ipaddr);
iprintf("System idle mode. \r\n");
OSTimeDly(2*TICKS_PER_SECOND); // two second delay to give time to examine incoming UDP packet...
}//end else
}//end while(1)
Anyone have any idea? Sorry, can't post any more code than this - sensitive nature. But I'll do what I can if anyone needs any more...