mouns
Joined: 16 Apr 2008 Posts: 1
|
UDP protocol : send from PC to PIC 18F4620 |
Posted: Fri Apr 18, 2008 9:08 am |
|
|
hello,
I try to send UDP packets from a PC, i send this frame thanks to a software that i developed and it works correctly.
When i send the frames i switch the network thank to ethereal and none UDP frame are displayed.
i join my souce code.
I have a good connexion but i don't receive datas .
#define UDP_SOURCE_PORT 3000
#define UDP_DESTINATION_PORT 3001
#define UDP_NUM_LISTEN_SOCKETS 2
#define STACK_USE_UDP 1
#define MAX_SOCKETS 6
#define MAX_UDP_SOCKETS 4
#include "ccstcpip.h"
#include "tcpip\udp.h"
void main(void) {
MAC_ADDR mac_dest; //Variable structurée pour l'affectation de l'adresse MAC du destinataire
static UDP_SOCKET MySocket=INVALID_UDP_SOCKET;
NODE_INFO remote;
int i,len;
char *Transmission_OK;
char *Transmission_Failed;
char *reception;
char c;
Transmission_OK ="Data progress..."; //Status de la transmission
Transmission_Failed="Data progress failed"; //Status de la transmission
init_user_io();
MACAddrInit();
IPAddrInit(); //Initialisation de l'adresse IP
//MACInit(); //Initialisation de l'adresse MAC
// Adress MAC de destination prise en compte
/*mac_dest.v[0]=0xFF;
mac_dest.v[1]=0xFF;
mac_dest.v[2]=0xFF;
mac_dest.v[3]=0xFF;
mac_dest.v[4]=0xFF;
mac_dest.v[5]=0xFF; */
lcd_init(); // Initialisation du LCD
//TickInit(); //Initialisation des composant TCP/IP
StackInit();
printf(lcd_putc,"Test UDP V1.0"); delay_ms(2000);lcd_putc('\n');
i=0;
//UDPInit();
MySocket=UDPOpen(UDP_SOURCE_PORT,NULL,0);
if(MySocket==INVALID_UDP_SOCKET) {printf(lcd_putc,"Echec Connexion");
delay_ms(2000);break;}
else{
printf(lcd_putc,"Connexion OK"); delay_ms(2000);
while(TRUE) {
lcd_putc('\f');
if (UDPIsGetReady(MySocket)){
// reception du paquet envoyé par le PC
while(UDPGet(&c)){
reception[i]=c;
i++;
printf(lcd_putc,reception);
}
UDPDiscard();
}
else printf(lcd_putc,"Echec reception");
//Fermeture de la connection
UDPClose(MySocket);
delay_ms(1000);
StackTask();
}
}
}
thank you
Best regards |
|