MOD5282 DHCP ...
Posted: Mon Sep 22, 2008 7:01 pm
Hello,
I am working with the MOD5282 on a new project (we used to use Rabbit cores and hated them ). This project requires the unit to be capable of switching between static and dynamic IP addresssing. The initial provisioning of the unit will accomplished via the serial port, then future provisioning will most likely be accomplished via the web browser. I have most everything working on the unit, the serial port, TCP sockets (for remote automation control), the web browser. However, I am having an issue getting the MOD5282 to start up and obtain it's ethernet parameters via DHCP.
My network does have a router that is properly handing out DHCP. This has been confirmed via various PC's and other embedded devices. I have included the code block below that is run directly after "InitializeStack();" call in main. Everytime this block attempts to obtain the DHCP parameters it returns unsuccessful in that the DHCP server could not be found.
Any help would be greatly appreciated.
Thanks,
Mark
void StartEthernet()
{
//Get first interface identifier
int FirstInterface = GetFirstInterface();
//Get interface data
InterfaceBlock *ib = GetInterFaceBlock(FirstInterface);
//Check IP address for 0.0.0.0, and use DHCP if necessary
if (ib->netIP == 0)
{
iprintf("No static IP address set, attempting DHCP ...\r\n");
//The following lines of code are essentially what the GetDHCPAddress() function
//does to make the DHCP process easier.
pDHCPOfferName = "CTI RFPMU";
DhcpObj = new DhcpObject( FirstInterface );
DhcpObj->StartDHCP(); //Start DHCP
//Pend on semaphore to verify an address was obtained, waiting 30 seconds
if ( OSSemPend( &( DhcpObj->NotifySem ), 30 * TICKS_PER_SECOND ) == OS_TIMEOUT )
{
iprintf("\r\n*** WARNING ***\r\n");
iprintf("IP Address was set to 0.0.0.0, and a DHCP server could not be found.\r\n");
iprintf("Device does not have a valid IP address.\r\n");
}
else
{
iprintf("My DHCP assigned ethernet values are:\r\n");
iprintf("IP: "); ShowIP(ib->netIP); iprintf("\r\n");
iprintf("NetMask: "); ShowIP(ib->netIpMask); iprintf("\r\n");
iprintf("Gateway: "); ShowIP(ib->netIpGate); iprintf("\r\n");
iprintf("DNS: "); ShowIP(ib->netDNS); iprintf("\r\n");
iprintf("Interface Name: %s\r\n", ib->InterfaceName);
iprintf("\r\n");
bolDhcpAssigned = TRUE;
}
}
//Check DHCP flag
else if (bUseDhcp)
{
iprintf("\r\nDHCP flag set, attempting DHCP ...\r\n");
//The following lines of code are essentially what the GetDHCPAddress() function
//does to make the DHCP process easier.
pDHCPOfferName = "CTI RFPMU";
DhcpObj = new DhcpObject( FirstInterface );
DhcpObj->StartDHCP(); //Start DHCP
//Pend on semaphore to verify an address was obtained, waiting 30 seconds
if ( OSSemPend( &( DhcpObj->NotifySem ), 30 * TICKS_PER_SECOND ) == OS_TIMEOUT )
{
iprintf("\r\n*** WARNING ***\r\n");
iprintf("IP Address was set to 0.0.0.0, and a DHCP server could not be found.\r\n");
iprintf("Device does not have a valid IP address.\r\n");
}
else
{
iprintf("My DHCP assigned ethernet values are:\r\n");
iprintf("IP: "); ShowIP(ib->netIP); iprintf("\r\n");
iprintf("NetMask: "); ShowIP(ib->netIpMask); iprintf("\r\n");
iprintf("Gateway: "); ShowIP(ib->netIpGate); iprintf("\r\n");
iprintf("DNS: "); ShowIP(ib->netDNS); iprintf("\r\n");
iprintf("Interface Name: %s\r\n", ib->InterfaceName);
iprintf("\r\n");
bolDhcpAssigned = TRUE;
}
}
else
{
iprintf("My static assigned ethernet values are: ");
ShowIP(EthernetIP);
iprintf("\r\n");
bolDhcpAssigned = false;
}
}
I am working with the MOD5282 on a new project (we used to use Rabbit cores and hated them ). This project requires the unit to be capable of switching between static and dynamic IP addresssing. The initial provisioning of the unit will accomplished via the serial port, then future provisioning will most likely be accomplished via the web browser. I have most everything working on the unit, the serial port, TCP sockets (for remote automation control), the web browser. However, I am having an issue getting the MOD5282 to start up and obtain it's ethernet parameters via DHCP.
My network does have a router that is properly handing out DHCP. This has been confirmed via various PC's and other embedded devices. I have included the code block below that is run directly after "InitializeStack();" call in main. Everytime this block attempts to obtain the DHCP parameters it returns unsuccessful in that the DHCP server could not be found.
Any help would be greatly appreciated.
Thanks,
Mark
void StartEthernet()
{
//Get first interface identifier
int FirstInterface = GetFirstInterface();
//Get interface data
InterfaceBlock *ib = GetInterFaceBlock(FirstInterface);
//Check IP address for 0.0.0.0, and use DHCP if necessary
if (ib->netIP == 0)
{
iprintf("No static IP address set, attempting DHCP ...\r\n");
//The following lines of code are essentially what the GetDHCPAddress() function
//does to make the DHCP process easier.
pDHCPOfferName = "CTI RFPMU";
DhcpObj = new DhcpObject( FirstInterface );
DhcpObj->StartDHCP(); //Start DHCP
//Pend on semaphore to verify an address was obtained, waiting 30 seconds
if ( OSSemPend( &( DhcpObj->NotifySem ), 30 * TICKS_PER_SECOND ) == OS_TIMEOUT )
{
iprintf("\r\n*** WARNING ***\r\n");
iprintf("IP Address was set to 0.0.0.0, and a DHCP server could not be found.\r\n");
iprintf("Device does not have a valid IP address.\r\n");
}
else
{
iprintf("My DHCP assigned ethernet values are:\r\n");
iprintf("IP: "); ShowIP(ib->netIP); iprintf("\r\n");
iprintf("NetMask: "); ShowIP(ib->netIpMask); iprintf("\r\n");
iprintf("Gateway: "); ShowIP(ib->netIpGate); iprintf("\r\n");
iprintf("DNS: "); ShowIP(ib->netDNS); iprintf("\r\n");
iprintf("Interface Name: %s\r\n", ib->InterfaceName);
iprintf("\r\n");
bolDhcpAssigned = TRUE;
}
}
//Check DHCP flag
else if (bUseDhcp)
{
iprintf("\r\nDHCP flag set, attempting DHCP ...\r\n");
//The following lines of code are essentially what the GetDHCPAddress() function
//does to make the DHCP process easier.
pDHCPOfferName = "CTI RFPMU";
DhcpObj = new DhcpObject( FirstInterface );
DhcpObj->StartDHCP(); //Start DHCP
//Pend on semaphore to verify an address was obtained, waiting 30 seconds
if ( OSSemPend( &( DhcpObj->NotifySem ), 30 * TICKS_PER_SECOND ) == OS_TIMEOUT )
{
iprintf("\r\n*** WARNING ***\r\n");
iprintf("IP Address was set to 0.0.0.0, and a DHCP server could not be found.\r\n");
iprintf("Device does not have a valid IP address.\r\n");
}
else
{
iprintf("My DHCP assigned ethernet values are:\r\n");
iprintf("IP: "); ShowIP(ib->netIP); iprintf("\r\n");
iprintf("NetMask: "); ShowIP(ib->netIpMask); iprintf("\r\n");
iprintf("Gateway: "); ShowIP(ib->netIpGate); iprintf("\r\n");
iprintf("DNS: "); ShowIP(ib->netDNS); iprintf("\r\n");
iprintf("Interface Name: %s\r\n", ib->InterfaceName);
iprintf("\r\n");
bolDhcpAssigned = TRUE;
}
}
else
{
iprintf("My static assigned ethernet values are: ");
ShowIP(EthernetIP);
iprintf("\r\n");
bolDhcpAssigned = false;
}
}