Way of getting IP number of headless device?

Hi All,

I just wonder if some has an easy way of finding the IP number of a headless device?

I have a headless device running WEC2013 on a Colibri module.
Default it uses DHCP so connecting it to the network would give the device an IP.
I need this IP to Debug the application.

Someway of getting the IP:
1: Auto launch Remote Display from USB driver and see the actual IP number
2: Make a static IP configuration with an USB drive. (Have to remember to undo the config after end usage)
3: Launch the bootloader and activate image download. The IP acquired here would probably be the same it gets in WEC2013!

Anyone has some other tricks?

Thomas

Hello Thomas,

I use advanced Ip Scanner on my PC to find Colibri modules on my network : http://www.advanced-ip-scanner.com.

Perhaps it could be a good solution for you.
Regards,
Aurélien.

This is some code I used to read local IP address:

PIP_ADAPTER_ADDRESSES       adapter_addresses;
DWORD					    size = 0;

if (WSAStartup(MAKEWORD(1, 1), &WsaData) != 0)
{
	_tprintf(TEXT("WSAStartup failed (error %ld)\n"), GetLastError());
	return 0;
}

for (;;)
{
	IP_ADAPTER_INFO*		adapterinfo = NULL;
	IP_ADAPTER_INFO*		adapter = NULL;
	DWORD					err;

	GetAdaptersInfo(NULL, &size);

	adapterinfo = (IP_ADAPTER_INFO*)malloc(size);

	if ((err = GetAdaptersInfo(adapterinfo, &size)) != ERROR_SUCCESS)
	{
		_tprintf(TEXT("GetAdaptersInfo failed (error %ld)\n"), err);
		free(adapterinfo);
		Sleep(1000);
		continue;
	}

	for (adapter = adapterinfo; adapter != NULL; adapter = adapter->Next)
	{
		if (stricmp(adapter->AdapterName, "ENET1") && stricmp(adapter->AdapterName, "ENET2"))
			continue;

		if (!stricmp(adapter->IpAddressList.IpAddress.String, "0.0.0.0"))
		{
			_tprintf(TEXT("Waiting for a valid IP\n"), err);
			Sleep(5000);
			continue;
		}

		printf("ip address: %s\r\n", adapter->IpAddressList.IpAddress.String);
		break;
	}

	free(adapterinfo);

	if (adapter)
		break;
}

You can build this as an application and eventually replace _tprintf with RETAILMSG if you don’t have a screen and prefer output on the serial console.
The application tries to read the IP and waits until one is available so you can put it in the autorun folder on your flashdisk or on the same folder on removable media and just plug it in when you need to read the address.