Dear Group Members,
I am struggling to try to receive UDP multicast messages with the Atmel UC3A
lwip 1.3.2 port.
I have been successfully sending UDP multicast packets with lwip for a
couple of years using the netconn API. But now I need to receive them in a
different FreeRTOS task.
Here are the particulars: Multicast Group Address = 224.0.0.0,
destination UDP port = 55555
I've enabled the IGMP code in lwip and everything builds fine. I have coded
up several attempts to set up to receive UDP multicast packets for the above
group and port as follows:
=============================== Code snippet
================================================
(other includes here)
/* lwIP includes. */
#include "lwip/api.h"
#include "lwip/memp.h"
#include "lwip/inet.h"
#include "lwip/ip_addr.h"
#include "lwip/udp.h"
(other includes here)
my_task_function()
{
struct ip_addr s_mcast_ip_addr; // MCAST IP Address
struct netconn *conn;
int lwip_status;
err_t err;
/* Multicast Group IP address bytes are specified in MS to LS order here
*/
/* The group address is 224.0.0.0 */
IP4_ADDR(&s_mcast_ip_addr,(NetConfig_s.udp_mcast_group_addr.addr >> 24) &
0xff,
(NetConfig_s.udp_mcast_group_addr.addr >> 16) & 0xff,
(NetConfig_s.udp_mcast_group_addr.addr >> 8) & 0xff,
(NetConfig_s.udp_mcast_group_addr.addr & 0xff));
// Create a new UDP connection
conn = netconn_new(NETCONN_UDP);
// Note: the above call returns a valid pointer (non-zero)
// Bind to the multicast group address 224.0.0.0 and UDP port 55555 (is
this call needed??)
// lwip_status = netconn_bind(conn, &s_mcast_ip_addr,
NetConfig_s.udp_dest_port);
// Allow packets from ANY remote host on any port. Is this call
needed?????
// I suspect this call is not needed for UDP
// netconn_connect(conn, &s_remote_ip_addr, 0); //
what do we use for "Any UDP Port?"
err = netconn_join_leave_group (conn,
// netconn *
&s_mcast_ip_addr,
// Multicast Group Address (32-bits: 224.0.0.0)
&NetConfig_s.ip_addr, // Local interface IP address = 192.168.1.21
NETCONN_JOIN);
// We want to join this multicast group
============================================================================
=================
The code from which this snippet was taken compiles fine with no errors or
warnings.
The problem seems to be in the netconn_join_leave_group function call. It
returns err = -9 (ERR_VAL).
The first parameter, conn, is non-zero, indicating a reasonable, initialized
struct netconn pointer.
The second parameter has been checked and really is 224.0.0.0.
The third parameter is a pointer to struct ip_addr which is initialized with
the IP address of our local Ethernet interface.
As you can see, I've commented out calls to the netconn_bind and
netconn_connect functions; it's not clear whether or not these are
necessary.
Examples of using this function seem to be non-existent, hence my decision
to post a humble cry for help on the lwip forum.
Incidentally, I've patched the Atmel UC3A MACB driver to allow all broadcast
and multicast packets to be passed to lwip. However, I am not yet to the
point where this matters, given the above error scenario.
Any help would be greatly appreciated.
Thanks,
Dave Squires
-----------------------------------
SQUIRES ENGINEERING, INC.
2604 Lowell Circle
Melbourne, FL 32935-2215
phone: (321) 242-8611
website: http://www.squires-eng.com
-----------------------------------
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users