#include #include #include #include "serial.h" #include "ethernet.h" #include "w5100.h" #include "socket.h" #define MAC_SIZE 6 #define IPV4_SIZE 4 int main(void) { uint8 com[4],per[14]; uint8_t mac[MAC_SIZE] = {0xA0,0xBD,0xCD,0xDD,0xED,0xFD}; uint8_t ip[IPV4_SIZE] = {172,26,145,205}; uint8_t gateway[4] = {172,26,145,254}; uint8_t mask[4] = {255,255,255,0}; int isUDP = 0; const char answer [16] = "I'm ok"; uint8 buf[16]; uint8_t addr[IPV4_SIZE]; uint16_t port; uint16 datasize; uint8_t addrpifou[IPV4_SIZE]={172,26,145,35}; uint16 size; SOCKET sUDP=0; SOCKET sTCP=1; init_printf(); ethernet_init(mac,ip,gateway,mask); if (!socket(sUDP,Sn_MR_UDP,2020,0)) { return -1; } if (!socket(sTCP,Sn_MR_TCP,2020,0)) { return -1; } while(1) { if((datasize=recvfrom(sUDP,buf,sizeof(buf),addr,&port)) == 17) { com[0]=buf[0]; com[1]=buf[1]; com[2]=buf[2]; com[3]='\0'; per[0]=buf[3]; per[1]=buf[4]; per[2]=buf[5]; per[3]=buf[6]; per[4]=buf[7]; per[5]=buf[8]; per[6]=buf[9]; per[7]=buf[10]; per[8]=buf[11]; per[9]=buf[12]; per[10]=buf[13]; per[11]=buf[14]; per[12]=buf[15]; per[13]='\0'; printf("Com : %s\n",com); printf("Per : %s\n",per); } } printf("RESET\n"); close(sTCP); close(sUDP); return 0; } //send(sTCP,(uint8*)answer, (uint16)sizeof(answer));