This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sending UDP Data, Serial Link

Hi there!

Im having some troubles implementing a DHCP server on a microcontroller.

System Overview:
-Webserver (RL-ARM) running on MCBSTM32E
-MCBSTM32E connected over UART with a WLAN module (SLIP).
-WLAN module creates an ad-hoc network
-Laptop is connected to WLAN module

First, I did get the DHCP server running on the MCBSTM32C development board which has an ethernet interface.

Then I tried to port the DHCP server to the MCBSTM32E. I receive the incoming DHCP_DISCOVER messages and the microcontroller seems to send the SLIP packets but I can't see any incoming UDP data on Packetyzer (running on my laptop). (btw I disable the firewall on my laptop.)

To find the problem I simplified the whole thing and used the udp_send function to send some data to an UDP port ("Hello", port 1333). I did receive the data but only after sending a PING to module and even then only at random. It seemed like a timing or a socket allocation problem. I tried various configurations but without a conclusive answer.

My code:

TCP Task

__task void task_tcp (void) {
        while (1)
        {
           main_TcpNet();
           dhcp_server();
           os_tsk_pass();
        }
}


DHCP Server

void dhcp_server (){
  if (udp_soc == 0)
  {
        udp_soc = udp_get_socket (0, UDP_OPT_SEND_CS | UDP_OPT_CHK_CS, udp_callback);
        udp_open (udp_soc, 67);  /*open port*/
  }
}


UDP Callback

U16 udp_callback (U8 socket, U8 *remip, U16 remport, U8 *buf, U16 len) {

  /*udp inits*/
  U8 remoteip[4] = {255,255,255,255};
  U8* sendbuf;
  unsigned char udp_msg[302];   //302 Bytes

  ...

  if(buf[0]==0x01)              //check if bootp boot request
  {
          ...
        if(buf[242]==0x01)         //check if dhcp discover
        {
                ...

                //send message
                len = 256;
                sendbuf = udp_get_buf (len); //

                for(index=0;index<256;index++)
                {
                        sendbuf[index] = udp_msg[index];
                }

                udp_send (udp_soc, remoteip, 68, sendbuf, len);
        }
        else if(buf[242]==0x03)   //check if dhcp request
        {
             ...
                //send message
                len = 268;
                sendbuf = udp_get_buf (len);
                for(index=0;index<268;index++)
                {
                        sendbuf[index] = udp_msg[index];
                }
                udp_send (udp_soc, remoteip, 68, sendbuf, len);
        }
  }

  return (0);
}

Has anyone encountered a similar problem?

Thanks,
Christian

0