How the dhcp is set up

I am looking at C:\Keil_v5\Boards\Keil\MCB4300\RL\TCPNet\FTP_Demo\FTP_Demo.uvproj

The main code looks like below

extern LOCALM localm[];                       /* Local Machine Settings      */
#define MY_IP localm[NETIF_ETH].IpAdr

int main (void) {
  /* Main Thread of the TcpNet */

  init ();

  init_display ();

  init_TcpNet ();

  finit (NULL);

  dhcp_tout = DHCP_TOUT;

  while (1) {

    timer_poll ();

    main_TcpNet ();

    dhcp_check ();

    blink_led ();

  }

}

Under dhcp_check() function, we are checking the MY_IP, whether it got the IP address after init_TcPNet() and main_TcpNet() are called in the main().

static void dhcp_check () {

  /* Monitor DHCP IP address assignment. */

  if (tick == __FALSE || dhcp_tout == 0) {

    return;

  }
  if (mem_test (&MY_IP, 0, IP_ADRLEN) == __FALSE && !(dhcp_tout & 0x80000000)) {

    /* Success, DHCP has already got the IP address. */

    dhcp_tout = 0;

    sprintf((char *)lcd_text[0],"IP address:");

    sprintf((char *)lcd_text[1],"%d.%d.%d.%d", MY_IP[0], MY_IP[1],
                                               MY_IP[2], MY_IP[3]);

    LCDupdate = __TRUE;

    return;

  }

}

I do not even see localm or MY_IP being passed as a parameter. Is localm declared as a global variable in the library and as a result of one of the calls (like init_TcpNet() or main_TcpNet()) localm (and MY_IP is getting modified?

Can someone please explain.. its confusing me a lot.

Parents
  • Hello Niaz,

    looking at your directory structure, I see two problems:
    - C:\Keil_v5\... tells me that you have MDK Version 5 installed
    - ..\Boards\Keil\MCB... tells me that you are looking at an example for the old version 4 middleware. Can you try to separate the two things? I would recommend to use the Middleware that comes with Version 5. In the Manage Run-Time Environment window, you will find it. Also, there are the links to the integrated documentation that should help you from there.

    Kind regards,

    Christopher

Reply
  • Hello Niaz,

    looking at your directory structure, I see two problems:
    - C:\Keil_v5\... tells me that you have MDK Version 5 installed
    - ..\Boards\Keil\MCB... tells me that you are looking at an example for the old version 4 middleware. Can you try to separate the two things? I would recommend to use the Middleware that comes with Version 5. In the Manage Run-Time Environment window, you will find it. Also, there are the links to the integrated documentation that should help you from there.

    Kind regards,

    Christopher

Children
More questions in this forum