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

RL-ARM udp_send() issue

Hi all,

I hope someone will be able to help me with my issue. I am trying to send out an UDP packet but without any luck. The only instance when I send out the packet succesfully is when I first recieve an UDP packet and then send a reply to the same address as if the function first needed to know the way through network. But I need to send out a packet and then wait for the reply and I cannot figure out how to make this work.
I have implemented the function that sends the packets just like mentioned in the examples including the check for successfull addres obtain from DHCP but no luck.
Anyone please tell me where I am making a mistake.

Thanks,
Radovan.

Parents
  • I am afraid there is nothing wrong with the socket initialisation. Socket recieves data but I have problem sending data out. The only instance when I manage to send out the data is when I first recieve them from PC and then reply to the same address. Otherwise all attempts to send out UDP packet end up in an error.

    My aim is to sned out an UDP packet with NTP request and wait for reply with time information.

    Below is the code part for socket initialisation and the function where data is sent out.

    init_TcpNet (); udp_soc = udp_get_socket (0, UDP_OPT_SEND_CS | UDP_OPT_CHK_CS, udp_callback); if (udp_soc != 0) { udp_open (udp_soc, 200); }

    This is followed by the timer_poll() and main_TcpNet() endless loop.

    Function to send data out:

    unsigned char udp_msg[] = {"\111\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; U8 remip[4] = {192,168,1,154}; U8* sendbuf; U16 len;

    if (mem_test (localm[NETIF_ETH].IpAdr, 0, 4) == __TRUE) {
    // IP address not yet assigned by DHCP. printf(" return "); return; }

    len = strlen(udp_msg); sendbuf = udp_get_buf(len); str_copy(sendbuf, udp_msg); printf(" Alokace %d %d %d",sendbuf, sendbuf[0], udp_msg[0]); answer = udp_send(udp_soc, remip, 200, sendbuf, len);

Reply
  • I am afraid there is nothing wrong with the socket initialisation. Socket recieves data but I have problem sending data out. The only instance when I manage to send out the data is when I first recieve them from PC and then reply to the same address. Otherwise all attempts to send out UDP packet end up in an error.

    My aim is to sned out an UDP packet with NTP request and wait for reply with time information.

    Below is the code part for socket initialisation and the function where data is sent out.

    init_TcpNet (); udp_soc = udp_get_socket (0, UDP_OPT_SEND_CS | UDP_OPT_CHK_CS, udp_callback); if (udp_soc != 0) { udp_open (udp_soc, 200); }

    This is followed by the timer_poll() and main_TcpNet() endless loop.

    Function to send data out:

    unsigned char udp_msg[] = {"\111\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}; U8 remip[4] = {192,168,1,154}; U8* sendbuf; U16 len;

    if (mem_test (localm[NETIF_ETH].IpAdr, 0, 4) == __TRUE) {
    // IP address not yet assigned by DHCP. printf(" return "); return; }

    len = strlen(udp_msg); sendbuf = udp_get_buf(len); str_copy(sendbuf, udp_msg); printf(" Alokace %d %d %d",sendbuf, sendbuf[0], udp_msg[0]); answer = udp_send(udp_soc, remip, 200, sendbuf, len);

Children