Hi Daniel, I tested the listener modules with different setting as you mentioned, and nothing worked.
Finally I found the problem in different configuration file which is sys_arch.c. Of course I changed the configuration in lwipopts.h, but some of them in lwipopts.h seem like not affecting that much. My problem was netconn was not properly allocated. I am not sure still how nicely debug programs based on lwip+safeRTOS, but they seem like not giving me that much options, so I tried to print out a certain message on LCD for debugging. What I did in sys_arch.c is change SYS_SEM_MAX, SYS_MBOX_MAX. There are simple 5 tasks running together with listener task in my test project, and I guess each task uses their own SEM and MBOX as they get into active. I just changes the MAX # in sys_arch.c to above # of tasks running on safeRTOS. In addition, I changed DEFAULT_UDP_RECVMBOX_SIZE as well since I used DHCP option in lwipopts.h to get IP from server in my test project. However, based on my analysis, even though LWIP_TCP is set, it seems like not affecting because a couple of definitions are redefined in opt.h in case of commenting out definitions in lwipopts.h. Moreover, netconn_alloc() in api_msg.c(lwip1.3.2) seems like not allowing to use two different protocols like using UDP and TCP together. Only one type of protocol among other that filtered by switch~case for the first time is returned by netconn_alloc() since detecting UDP is prior to TCP in codes. *My project may need both protocols(UDP+TCP), and I wonder how both are used in different scenario??.* I am not sure yet, but it won't allow to use mixed protocols based on the behavior of the function. I appreciate your help, Jin On Tue, Sep 24, 2013 at 4:49 AM, Darius Babrauskas <[email protected]> wrote: > ** > It looks, that not defined UDP bufs. > In your lwipopts.h commented out: > //#define LWIP_UDP 1 > #define LWIP_UDP 1 > //#define MEMP_NUM_UDP_PCB 4 > #define MEMP_NUM_UDP_PCB 5 > > Need uncomment ---------- ARP options ---------- > > You not using tcp, so comment > #define LWIP_TCP 0 > #define MEMP_NUM_TCP_PCB 0// default is 5 > > > Read opt.h for more information... > > ----- Original Message ----- > *From:* Jin Won Seo <[email protected]> > *To:* Mailing list for lwIP users <[email protected]> > *Sent:* Friday, September 20, 2013 8:07 PM > *Subject:* Re: [lwip-users] lwip bind fail > > Thanks, > > It's my misunderstanding. Telnet doesn't let me check if UDP Server's IP > port is alive. > > Anyhow, I can't still figure the main problem out. > > Why is lwip_socket() not working? > > socket_fd = lwip_socket(AF_INET, SOCK_DGRAM, 0) always return -1. > > I put a debugging codes to see get a connection in lwip_socket() in > sockets.c > > if (!conn) { > DisplayString(115, 180 - 10, " ENOBUFS (could not create netconn) > "); > LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create > netconn)\n")); > set_errno(ENOBUFS); > return -1; > } > > and display "ENOBUFS...." on LCD. > > lwip_socket_init() is called in different task, which is *lwip_task*, and > *listener task* sets up socket and receives packets. > > lwip_task init lwip and calls lwip_socket_init() > > // Initialize lwIP. > // > //*get client IP and use it to set up socket later on * > lwIPInit(pucMAC, 0, 0, 0, IPADDR_USE_DHCP); > > // > // Setup the remaining services inside the TCP/IP thread's context. > // > tcpip_callback(SetupServices, 0);//* lwip_socket_init() is called in > SetupServices().* > > I was suspicious about lwipopts.h, so kept changing definition and tested > to see if I missed one of definition in the header file. However, it still > doesn't work. > > I attached my lwipopts.h. > > Thanks, > Jin > > > On Thu, Sep 19, 2013 at 10:53 PM, Darius Babrauskas <[email protected]>wrote: > >> ** >> >> >>Also I directly attempts to access the listener using telnet >> command(telnet 192.2.0.208 5701), but the below error message comes out >> Telnet using TCP protocol. Your server type are UDP. Connection not >> possible. >> >> ----- Original Message ----- >> *From:* Jin Won Seo <[email protected]> >> *To:* Mailing list for lwIP users <[email protected]> >> *Sent:* Friday, September 20, 2013 12:41 AM >> *Subject:* Re: [lwip-users] lwip bind fail >> >> Hi, >> >> I put a debugging code to see what error no spits out. >> >> if (!conn) { >> DisplayString(115, 180 - 10, " ENOBUFS (could not create netconn) >> "); >> LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create >> netconn)\n")); >> set_errno(ENOBUFS); >> return -1; >> } >> >> " ENOBUFS (could not create netconn) " was displayed on LCD. The meaning >> of ENOBUFS is /* No buffer space available */ >> >> I think it just says that no connection is made up. >> >> I don't know what makes this happened, but I feel like something to do >> with configuration to use lwip-socket since not even lwip-socket conn is >> assigned. >> >> Anyone knows about this? >> >> >> >> On Thu, Sep 19, 2013 at 11:42 AM, Jens Nielsen <[email protected]> wrote: >> >>> Hi >>> >>> Did you check the value of socket_fd? lwip_socket() returns -1 on error >>> but your code tests for == 0 >>> >>> Also check the value of errno after your call, that might give you a hint >>> >>> BR /Jens >>> >>> >>> >>> On 2013-09-19 20:19, Jin Won Seo wrote: >>> >>> Hi all, >>> >>> I posted my issue but I fell like not describing the problem in detail. >>> So I re-post it with detail information. >>> >>> I am testing listener modules using LM3S9B96, lwip1.3.2, safeRTOS, >>> StellarisWare 10636, ccs 5.4.x. >>> >>> The listener task running on safeRTOS basically receives message from >>> server daemon in Unix using socket(UDP). >>> >>> As the server daemon sends messages, the listener seems like not getting >>> anything from the server >>> >>> Also I directly attempts to access the listener using telnet >>> command(telnet 192.2.0.208 5701), but the below error message comes out >>> >>> "telnet : Unable to connect to remote host: Connection refused" >>> >>> My test scenario is : >>> >>> 1. Get an IP from Server(Unix) using DHCP >>> >>> // >>> // Initialize lwIP. >>> // >>> lwIPInit(pucMAC, 0, 0, 0, *IPADDR_USE_DHCP*); >>> >>> // >>> // Setup the remaining services inside the TCP/IP thread's context. >>> // >>> tcpip_callback(*SetupServices*, 0); >>> >>> 2. Init lwip socket in SetupServices(). >>> >>> lwip_socket_init(); >>> >>> 3. Create listener task to receive packets from server daemon(UDP). >>> >>> int socket_fd; >>> struct sockaddr_in sa, ra;//sa = sender addr, ra= receiver addr >>> NET_MSG *sMsg; >>> int length; >>> >>> u32_t size; >>> size = sizeof(sa); >>> >>> // addr_setup(); >>> // portTickType xTime1, xTime2; >>> >>> // Setup the local address. >>> memset((char *) &ra, 0, sizeof(ra)); >>> ra.sin_family = AF_INET; >>> ra.sin_len = sizeof(ra); >>> // ra.sin_addr.s_addr = lwIPLocalIPAddrGet(); >>> ra.sin_addr.s_addr = inet_addr("192.2.0.208"); >>> ra.sin_port = htons(S_PORT);//#define S_PORT 5701 >>> >>> //setup the destination address >>> memset((char *) &sa, 0, sizeof(sa)); >>> sa.sin_family = AF_INET; >>> sa.sin_len = sizeof(sa); >>> sa.sin_addr.s_addr = inet_addr("192.2.0.3");// for test, hard-corded >>> // sDestAddr.sin_addr.s_addr = chgd_in_addr(); >>> sa.sin_port = htons(S_PORT); >>> >>> while((socket_fd = *lwip_socket*(AF_INET, SOCK_DGRAM, 0)) == 0) >>> { >>> *DisplayString(115, 210 - 10, " lwip socket error... ");* >>> //xTaskDelay(CHGD_OPEN_TIME); >>> xTaskDelay(SECONDS(5));//arbitrary time for test >>> } >>> >>> //bind socket to the local address and port >>> if*(lwip_bind*(socket_fd, (struct sockaddr *) &ra, sizeof(ra)) == >>> -1) >>> { >>> lwip_close(socket_fd); >>> *DisplayString(115, 190 - 10, " bind error... ");*//Display >>> message on LCD in LM3S9B96 >>> } >>> >>> while(1) >>> { >>> >>> //receive from server >>> length = lwip_recvfrom(socket_fd, (char *) msg_buf, >>> sizeof(msg_buf), >>> MSG_DONTWAIT, (struct sockaddr *)&sa, &size); >>> >>> if(length > 0) >>> { >>> sMsg = (NET_MSG *) (msg_buf); >>> mon_cmd_do(socket_fd, &sa, sMsg, length); >>> } >>> >>> lwip_close(socket_fd); >>> xTaskDelay(1);// 1ms tick delay >>> } >>> >>> >>> As the program is executed, it seems like not binding socket properly >>> since "*bind error..." *is displayed on LCD. >>> >>> Here is my *lwipopts.h* >>> >>> #define SYS_LIGHTWEIGHT_PROT 1 // default is 0 >>> #define NO_SYS 0 // default is 0 >>> #if !NO_SYS >>> #define RTOS_SAFERTOS 1 >>> #define RTOS_FREERTOS 0 >>> #endif /* !NO_SYS */ >>> >>> #define MEMP_NUM_PBUF 64 >>> #define MEMP_NUM_TCP_PCB 40 >>> #define MEMP_NUM_TCP_SEG 48 >>> #define MEMP_NUM_SYS_TIMEOUT 10 >>> #define PBUF_POOL_SIZE 64 >>> >>> #define IP_REASSEMBLY 0 // default is 1 >>> #define IP_FRAG 0 // default is 1 >>> >>> #define LWIP_DHCP 1 >>> >>> #define LWIP_AUTOIP 1 // default is 0 >>> #define LWIP_DHCP_AUTOIP_COOP ((LWIP_DHCP) && (LWIP_AUTOIP)) >>> // default is 0 >>> #define LWIP_DHCP_AUTOIP_COOP_TRIES 5 // default is 9 >>> >>> >>> #define TCP_WND 4096 // default is 2048 >>> #define TCP_MSS 1500 // default is 128 >>> //#define TCP_CALCULATE_EFF_SEND_MSS 1 >>> #define TCP_SND_BUF (6 * TCP_MSS) >>> // default is 256 >>> #define TCP_SND_QUEUELEN (MEMP_NUM_TCP_SEG) >>> >>> #define PBUF_LINK_HLEN 16 // default is 14 >>> #define PBUF_POOL_BUFSIZE 256 >>> // default is >>> LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN) >>> #define ETH_PAD_SIZE 2 // default is 0 >>> >>> #define TCPIP_THREAD_NAME "tcpip_thread" >>> #define TCPIP_THREAD_STACKSIZE 1024 >>> #define TCPIP_THREAD_PRIO 3 >>> #define TCPIP_MBOX_SIZE 32 >>> >>> #define LWIP_NETCONN 1 // default is 1 >>> >>> >>> //***************************************************************************** >>> // >>> // ---------- Socket Options ---------- >>> // >>> >>> //***************************************************************************** >>> #define LWIP_SOCKET 1 // default is 1 >>> #define LWIP_COMPAT_SOCKETS 0 >>> #define LWIP_POSIX_SOCKETS_IO_NAMES 0 >>> #define LWIP_TCP_KEEPALIVE 0 >>> #define LWIP_SO_RCVTIMEO 0 >>> #define LWIP_SO_RCVBUF 0 >>> #define SO_REUSE 0 >>> >>> #define LWIP_PROVIDE_ERRNO 1 //Add for lwip >>> socket errors >>> >>> #define LWIP_STATS_LARGE 1 >>> >>> #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_OFF >>> >>> #define LWIP_DBG_TYPES_ON >>> (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH) >>> >>> So far I don't see any clues to figure this out. >>> >>> If anyone can help me out, I will appreciate that. >>> >>> Thank, >>> >>> Jin >>> >>> >>> >>> _______________________________________________ >>> lwip-users mailing >>> [email protected]https://lists.nongnu.org/mailman/listinfo/lwip-users >>> >>> >>> >>> _______________________________________________ >>> lwip-users mailing list >>> [email protected] >>> https://lists.nongnu.org/mailman/listinfo/lwip-users >>> >> >> ------------------------------ >> >> _______________________________________________ >> lwip-users mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/lwip-users >> >> >> _______________________________________________ >> lwip-users mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/lwip-users >> > > ------------------------------ > > _______________________________________________ > lwip-users mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/lwip-users > > > _______________________________________________ > lwip-users mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/lwip-users >
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
