CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Microchip TCP/IP Stack Question

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

Microchip TCP/IP Stack Question
PostPosted: Tue Oct 07, 2003 3:09 pm     Reply with quote

This is for the people who have used Microchip's TCP/IP stack. Ok, I have this code:

Code:

void put_page_machine(char * hostname, int8 * ptr, int16 max, int8 socket) {
   enum _put_page_state {PUT_PAGE_WAIT_FOR_TX, PUT_PAGE_WAIT_FOR_RX} put_page_state;
   tcpip_ec ret=EC_SOCKET_DISCONNECTED;

   //clean / init some variables

   TCPDiscard(socket);
   put_page_state=PUT_PAGE_WAIT_FOR_TX;

   while( (second_counter < (PUT_PAGE_TIMEOUT)) && (TCPIsConnected(socket)) ) {

      if (put_page_state==PUT_PAGE_WAIT_FOR_TX) {
         if (TCPIsPutReady(socket)) {

            //use TCPPut() to put data. 
            //This routine does not put more data than there is buffer available.

            TCPFlush(socket);
            StackTask();
           
            put_page_state=PUT_PAGE_WAIT_FOR_RX;
            ret=EC_TCPIP_RX_RESPONSE_TIMEOUT;
         }
         else {StackTask();}
      }
      else if (put_page_state==PUT_PAGE_WAIT_FOR_RX) {
                ret=EC_TCPIP_RX_TIMEOUT;

               while ((second_counter < (PUT_PAGE_TIMEOUT))&&(max)&&(!done)) {
                  if (TCPGet(socket,&c)) {

                         //Parse and save data.

                  else {
                     StackTask();
                  }
                  restart_wdt();
               }

               break;
           
         }
      restart_wdt();
   }

   if (!TCPIsConnected(socket)) {
      ret=EC_SOCKET_DISCONNECTED;
   }


            TCPDiscard(socket);
         
        //return data
}


Basically, this function talks to a CGI script on a webserver. This function sends a CGI query, and then gets the answer to the query. The program makes several queries, so it calls this function several times. The socket is opened once, this function is called a few times to make a few queries, and then the socket is closed.

My problem is that the function works 2 or 3 times, then it stops working. What I mean by stops working is that this function sends a query to the CGI script, the CGI script responds but TCPGet() never returns true. I have verified that the CGI script is responding correctly using a packet sniffer.

So, what have I done to break TCPGet() so that is returning false? Or is there possibly a bug in the TCP/IP stack and the packet gets thrown away? Any ideas?

Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 07, 2003 9:21 pm     Reply with quote

I haven't done this, but reading AN833, it says that a pre-condition
before calling TCPget() is that a call to TCPisgetready() must return TRUE.


This is from page 55 of AN833:

if ( TCPIsGetReady(httpSocket) )
{
// Fetch data
TCPGet(httpSocket, &dataByte);
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 07, 2003 10:16 pm     Reply with quote

PCM programmer wrote:
I haven't done this, but reading AN833, it says that a pre-condition
before calling TCPget() is that a call to TCPisgetready() must return TRUE.


This is from page 55 of AN833:


Have I ever told you that you are amazing? Very Happy

Anyways, back to the point... I had TCPIsGetReady() in the code but then I removed it because they call TCPIsGetReady() in TCPGet(). After some sleep, I will double check. Thanks.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 08, 2003 11:58 am     Reply with quote

PCM programmer wrote:
I haven't done this, but reading AN833, it says that a pre-condition
before calling TCPget() is that a call to TCPisgetready() must return TRUE.


Unfortunately, I was correct last night in the TCPGet() checks TCPIsGetReady() beforehand so this is not my problem. (I originally did check TCPISGetReady() before using TCPGet(), but took it out to save space when I saw that TCPGet() was doing this already).

It looks like there is a bug in the TCP/IP stack (either a compiler bug or bug in the actual stack) in that the socket loses connection after a certain time.

I will have to track down the guy who wrote the stack to see what he says.

Anyone else have any ideas?
murad772



Joined: 30 Oct 2010
Posts: 5

View user's profile Send private message

PostPosted: Mon Nov 15, 2010 2:14 am     Reply with quote

How can this function be called?
And can it used with php script?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group