LwIP adaptation for Fujitsu MB90f497 and CS8900A Ethernet driver

源代码在线查看: test_tcp.c

软件大小: 179 K
上传用户: setixp
关键词: adaptation Ethernet Fujitsu driver
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				#include "lwip\tcp.h"
				#include "lwip\lcd.h"
				err_t test_accept(void *arg, struct tcp_pcb *newpcb, err_t err);
				err_t test_recv (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
				err_t test_poll(void *arg, struct tcp_pcb *pcb);
				
				 static err_t
				 test_sent(void *arg, struct tcp_pcb *pcb, u16_t len);
				
				void test_err (void *arg, err_t err);
				
				static char Sent=0;
				
				
				
				err_t test_recv (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) {
				//struct pas_states *es;
				//int ptr;
				Put_String("\nRecived:");
				//	es=arg;
					if(err==ERR_CLSD) Put_String("Error: Close ");
					if(err==ERR_ABRT) Put_String("Error: Abort ");
					if(err==ERR_RST) Put_String("Error: Reset ");
				
					if(err==ERR_OK && arg!=NULL) {
					 //  Put_String("rbuf add ");
					//	rbuf_add(es->rbuf,p);
						tcp_recved(pcb,p->len);
						pbuf_free(p);
					}
				
					if(err==ERR_OK && arg==NULL) { 
					//	Put_String("no data ");
					//	tcp_close(pcb);
					}
				
					//pas_write(es,"Asynhronus State Protocol for Aquaco ",37);
				return ERR_OK;
				
				}
				
				
				
				 static void
				 send_buf(struct tcp_pcb *pcb)
				 /* [][^][v][top][bottom][index][help] */
				 {
				//     Put_String("test: send_buf\n");	
				     tcp_write(pcb,"Hello from test",15,1);
				 }
				
				
				 static err_t
				 test_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
				 {
				  	
				 //  struct pas_states *es;
				 //  es=arg;	
				//	   if(es != NULL && es->pb != NULL) {	
				//	             Put_String("Send_buf:");
						     send_buf(pcb);
				//	   } else if(es->pb==NULL && es != NULL) es->Sent=1; 
				   return ERR_OK;
				 }
				
				
				
				
				
				err_t test_poll(void *arg, struct tcp_pcb *pcb) {                
				//struct pas_states *es;                                          
				//es=arg;                                                    
				//                Put_String("Pool ");                      
				/*	Put_String("TCP state: ");                           
					if(pcb->state==CLOSED) Put_String("Closed\n");
					if(pcb->state==SYN_SENT) Put_String("SYN-SENT\n");
					if(pcb->state==SYN_RCVD) Put_String("SYN-RCVD\n");
					if(pcb->state==ESTABLISHED) Put_String("ESTABLISHED\n");
					if(pcb->state==FIN_WAIT_1) Put_String("FIN_WAIT_1\n");
					if(pcb->state==FIN_WAIT_2) Put_String("FIN_WAIT_2\n");
					if(pcb->state==CLOSE_WAIT) Put_String("CLOSE_WAIT\n");
					if(pcb->state==CLOSING) Put_String("CLOSING\n");
					if(pcb->state==LAST_ACK) Put_String("LAST_ACK\n");
					if(pcb->state==TIME_WAIT) Put_String("TIME_WAIT\n");*/
				
				        if(pcb->state==CLOSE_WAIT) tcp_close(pcb);
				        if(Sent) {
						Sent=0; 
						test_sent(arg,pcb,0);
					}
				return ERR_OK;
				}
				
				
				void test_err (void *arg, err_t err) {
				struct pas_states *es=arg;
					Put_String("Error: ");
					if(err==ERR_CLSD) Put_String("Error: Close ");
					if(err==ERR_ABRT) Put_String("Error: Abort ");
					if(err==ERR_RST) Put_String("Error: Reset ");
					
				}
				
				
				err_t test_accept(void *arg, struct tcp_pcb *newpcb, err_t err) {
				
				/* 			

相关资源