lpc2148+lwip1.3.0+enc28j60的tcp数据发送问题和debug问题
本帖最后由 xl_1120 于 2013-5-13 20:47 编辑最近在搞无操作系统的lwip移植,之前还算顺利,能够把数据收发解决,实现ping,udp的收发,但是在解决tcp连接时出了问题,一直解决不掉,问题是这样的,当我发送tcp数据在50字节以下,收发都正常,到了大于50字节后,数据就无法发送出去了,抓包发现,tcp连接已建立,就是不发送数据,增加MEMP_NUM_TCP_PCB 16 /* 同时建立激活的TCP连接的数目,数据能够发送8帧左右停止,过一会继续发送,抓包发现开发板在发送数据后没有发送标志位FIN的一条报文。
#include <includes.h>
#include "ethernetif.h"
#include "time.h"
//#include "tcpip.h"
/*********************************************************************************************************
CONSTANTS 常量定义
*********************************************************************************************************/
const static int8 TCP_TestData[]="12345678901234567890123456789123465678901234567890123456789012345678901234567890\r\n";
voidDelay(unsigned longulVal)
{
while ( --ulVal!=0 );
}
err_t TcpCli_Connected(void *arg,struct tcp_pcb *pcb,err_t err)
{
#if 1
tcp_write(pcb,strbuf,sizeof(strbuf),1); //发送数据
tcp_close(pcb);
tcp_recv(pcb,tcp_data);
// tcp_abort(pcb);
// tcp_recv(pcb,tcp_recved err_t(* recv)(void * arg,struct tcp_pcb * tpcb,struct pbuf * p,err_t err))
return ERR_OK;
#endif
}
void TCP_Client_Init()
{
struct tcp_pcb *Clipcb;
struct ip_addr ipaddr;
s8_t ret;
IP4_ADDR(&ipaddr,192,168,0,26);
Clipcb = tcp_new(); // 建立通信的TCP控制块(Clipcb)
tcp_bind(Clipcb,IP_ADDR_ANY,4096); // 绑定本地IP地址和端口号
ret=tcp_connect(Clipcb,&ipaddr,1026,TcpCli_Connected);
//tcp_accept(Clipcb,tcp_data_rev); /* 设置有连接请求时的回调函数 */
}
int main()
{
targetInit();
lwipInit();
Delay(1000000UL);
time0_enable();
time1_enable();
while(1)
{
TCP_Client_Init();
Delay(1000000UL);
Delay(1000000UL);
Delay(1000000UL);
}
}
还有一个问题就是debug信息无法开启,debug.h中的定义:
#define LWIP_DEBUG//20130510 xl add
#ifdef LWIP_DEBUG
/** print debug message only if debug message type is enabled...
*AND is of correct type AND is at least LWIP_DBG_LEVEL
*/
#define LWIP_DEBUGF(debug,x) do { \
if ( \
((debug) & LWIP_DBG_ON) && \
((debug) & LWIP_DBG_TYPES_ON) && \
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
LWIP_PLATFORM_DIAG(x); \
if ((debug) & LWIP_DBG_HALT) { \
while(1); \
} \
} \
} while(0)
#else/* LWIP_DEBUG */
#define LWIP_DEBUGF(debug,x)
#endif /* LWIP_DEBUG */
cc.h中的定义:
#if 1
/* 这个串口格式化输出要自己实现 */
extern void RS232_Printf(char *fmt,...);
#define lwip_printf RS232_Printf
//#define LWIP_PLATFORM_ASSERT(expr) { lwip_printf x; }
#define LWIP_PLATFORM_DIAG(x) { RS232_Printf ("\"%s\"",(x));}
#define LWIP_DEBUG
#endif
编译就会出错(应该是有不能识别的字符,可是不知道在哪里,数量非常多):
lwip-1.3.0\src\netif\etharp.c(179): error:#18: expected a ")"
lwip-1.3.0\src\netif\etharp.c(179): warning:#174-D: expression has no effect
lwip-1.3.0\src\netif\etharp.c(179): warning:#174-D: expression has no effect
lwip-1.3.0\src\netif\etharp.c(179): error:#65: expected a ";"
lwip-1.3.0\src\netif\etharp.c(187): error:#18: expected a ")"
lwip-1.3.0\src\netif\etharp.c(187): warning:#174-D: expression has no effect
lwip-1.3.0\src\netif\etharp.c(187): warning:#174-D: expression has no effect
lwip-1.3.0\src\netif\etharp.c(187): error:#65: expected a ";"
lwip-1.3.0\src\netif\etharp.c(290): error:#18: expected a ")"
lwip-1.3.0\src\netif\etharp.c(290): warning:#174-D: expression has no effect
lwip-1.3.0\src\netif\etharp.c(290): error:#65: expected a ";"
lwip-1.3.0\src\netif\etharp.c(298): error:#18: expected a ")"
lwip-1.3.0\src\netif\etharp.c(298): warning:#174-D: expression has no effect
页:
[1]