Hello everybody, i'll have to interchange a lot of command between PC an d
my micro of EVK1100 board.
For example the PC send me command to STAR, dates of several tables, ... and
the micro has to send too about one second a command to report the situation
of the system.
In this board i'll use a lwIP with freeRTOS, and i don know exactly what is
the best form to implement the protocol, because always is online with PC.
do you use one socket everytime? or open one socket in every
comunication?. TCP or UDP protocol? the customer say me the port, and is
fixed.
Is there any api that not block the process in the recepcion? because i'll
have to do three thing:
case DATE_FROM_PC:
i'll need to read the date and store in my
SDRAM;
case COMMNAD_FROM_PC:
i'll do it this command;
case SEND_STATUS_TO_PC: (every second)
i must send a message to
report the status of the board;
Can help me this program example:
portTASK_FUNCTION( vBasicTFTPServer, pvParameters )
{
int lSocket;
int lDataLen, lRecvLen;
socklen_t lFromLen;
struct sockaddr_in sLocalAddr, sFromAddr;
portCHAR cData[SEGSIZE+sizeof(struct tftphdr)];
struct tftphdr *sHdr = (struct tftphdr *)cData;
// Set up port
// Network order in info; host order in server:
for (;;) {
// Create socket
lSocket = socket(AF_INET, SOCK_DGRAM, 0);
if (lSocket < 0) {
return;
}
memset((char *)&sLocalAddr, 0, sizeof(sLocalAddr));
sLocalAddr.sin_family = AF_INET;
sLocalAddr.sin_len = sizeof(sLocalAddr);
sLocalAddr.sin_addr.s_addr = htonl(INADDR_ANY);
sLocalAddr.sin_port = TFTP_PORT;
if (bind(lSocket, (struct sockaddr *)&sLocalAddr,
sizeof(sLocalAddr)) < 0) {
// Problem setting up my end
close(lSocket);
return;
}
lRecvLen = sizeof(cData);
lFromLen = sizeof(sFromAddr);
lDataLen = *recvfrom(lSocket, sHdr, lRecvLen, 0,
(struct sockaddr *)&sFromAddr, &lFromLen);*
vParTestSetLED( TFTP_LED , pdTRUE );
close(lSocket); // so that other servers can bind to the TFTP socket
if ( lDataLen < 0) {
} else {
switch (ntohs(sHdr->th_opcode)) {
case WRQ:
tftpd_write_file(sHdr, &sFromAddr, lFromLen);
vParTestSetLED( TFTP_LED , pdFALSE );
break;
case RRQ:
tftpd_read_file(sHdr, &sFromAddr, lFromLen);
vParTestSetLED( TFTP_LED , pdFALSE );
break;
case ACK:
case DATA:
case ERROR:
vParTestSetLED( TFTP_LED , pdFALSE );
// Ignore
break;
default:
for(;;)
{
vParTestToggleLED( TFTP_LED );
vTaskDelay(200);
}
}
}
}
}
i don want to block the this task, because in other period i'll have to send
a command of status. In this example beyond close the socket and i
think,that i need to have always the socket open and bind.
Thank you
Regards
Oscar
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users