Discussion Forum

RL-ARM udp_send() issue

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Radovan Burhan
Posted
23-Nov-2009 20:53 GMT
Toolset
ARM
New! 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.

Read-Only
Author
Franc Urbanc
Posted
24-Nov-2009 10:22 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Take a look at the LEDSwitch and LEDClient examples. Enable the UDP port for communication.

Read-Only
Author
Radovan Burhan
Posted
24-Nov-2009 10:48 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

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);

Read-Only
Author
Franc Urbanc
Posted
24-Nov-2009 10:51 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Of course, strlen on a string containing zero bytes will fail.

Read-Only
Author
Radovan Burhan
Posted
24-Nov-2009 10:57 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

That string is not empty. If I enter a text like "Hello world" inside the result is the same. If it was due to the zero string length I could never send the packet out. And as I wrote before I manage to send it out when I first recieve a packet from a certain address and then reply to the same address.

Read-Only
Author
Franc Urbanc
Posted
24-Nov-2009 11:04 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Use a debug version, enable UDP debug to Full debug and watch the debug print. You will see what is happening from the debug log.

Read-Only
Author
Radovan Burhan
Posted
24-Nov-2009 11:08 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Where do I set this? I am not quite sure what you mean by UDP debug and Full debug.

Read-Only
Author
Franc Urbanc
Posted
24-Nov-2009 11:11 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Take a look at the LEDClient example. There is a target defined for Debug. Check there how it is configured and do the same. In the Net_Debug.c enable UDP debugging to Full debug.

Read-Only
Author
Radovan Burhan
Posted
24-Nov-2009 12:04 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Thank you for the debug hint. There seems to be the problem on Ethernet layer:

ETH ERR: Unresolved MAC for IP: 192.168.1.154

This is the error I got.

Read-Only
Author
Radovan Burhan
Posted
25-Nov-2009 09:54 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

Dear Franc,

can you tell me what to do in case of this error?

ETH ERR: Unresolved MAC for IP: 192.168.1.154

This is the reason why replying worked. The processor knew the MAC of the sending IP.

Read-Only
Author
Franc Urbanc
Posted
25-Nov-2009 12:42 GMT
Toolset
ARM
New! RE: RL-ARM udp_send() issue

http://www.keil.com/support/man/docs/rlarm/rlarm_tn_using_udp_arpempty.htm

Next Thread | Thread List | Previous Thread Start a Thread | Settings