[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Weird behavior of lwIP with C functions
From: |
Louis Filasky |
Subject: |
[lwip-users] Weird behavior of lwIP with C functions |
Date: |
Tue, 10 Jul 2007 19:25:05 +0200 |
Hi,
Thanks again everyone for your help so far. Still, the more I feel like I get to understand how lwIP works, the more I encounter some weird problems.
The Virtex II Pro, being the server; receives data from a java client.
The thing is that we have weird behavior. Code that work with Xilinx 9.1 won t work with 8.2 or code that work with dhcp enabled wont work without it.
That includes the use of function such as atoi, strtol, memcpy or sprintf.
I am really confused here, here is the code below. I started it all over again to determine the cause of those crashes. Actually the server works but whenever I send
a command to the server, it will crash/restart the server...
void processCommand(struct pbuf* p,struct tcp_pcb *pcb, struct connection_state *cs) {
char *commandLine, *commandType, *data1, *data2, *response, *end;
char* memory =(char*)XPAR_DDR_512MB_64MX64_RANK2_ROW13_COL10_CL2_5_MEM1_BASEADDR;
long int i;
char test[10]="1";
//Allocate memory and copy the entire content of the command line received in pbuf->payload:
commandLine=(char*)malloc((p->tot_len)*sizeof(char));
sprintf(commandLine, "%s", p->payload);
//Take care of the garbage after the command line.
commandLine=strtok(commandLine, "\r\n");
//Get the command type.
commandType=strtok(commandLine, " ");
if(strncmp(commandType, "PROC",4)==0) {
//If "PROC" type command, only 1 argument is expected:
data1=strtok(NULL, " ");
xil_printf("Command Type: %s / %s.\r\n", commandType, data1);
//Send control signal to register 0 of custom logic
//*(customLogicPtr) = (Xuint8)(atoi(data1));
xil_printf("Video processing #%s running.\r\n", data1);
response=(char*)malloc((strlen("PROC command.\n")+1)*sizeof(char));
sprintf(response, "%s", "PROC command.\n");
}
else if(strncmp(commandType, "SEND",4)==0) {
//If "SEND" type command, 2 arguments are expected:
data1=strtok(NULL, " ");
data2=strtok(NULL, " ");
xil_printf("Command Type: %s / %s / %s.\r\n", commandType, data1, data2);
//Then copy the data at the corresponding address:
i=atol(test);
xil_printf("Number: %d\r\n", (int)i);
//memcpy(memory+i, data2, strlen(data2));
//Print information on the server terminal and store the response to be sent to the client:
response=(char*)malloc((strlen("youhou\n")+1)*sizeof(char));
//xil_printf("Data sent to server: %s at address: %s.\r\n",data2,data1);
sprintf(response, "%s", "youhou\n");
//response[strlen(data2)]='\n';
//response[strlen(data2)+1]='\0';
}
xil_printf("response: %s\r",response);
cs->data = ""> cs->left = strlen(response);
send_data(pcb, cs);
free(commandLine);
free(response);
}
Thanks for your help, because I m really starting to be desperate...
Antoine.
Besoin d'un e-mail ? Créez gratuitement un compte Windows Live Hotmail et bénéficiez de 2 Go de stockage ! Windows Live Hotmail
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] Weird behavior of lwIP with C functions,
Louis Filasky <=