Jump to content
Sign in to follow this  
khm

Ethernet Hanging

Recommended Posts

Hi , I have written a code for ethernet client using TM4c1294NCPDT launchpad and I am sending data to a server at api.pushingbox.com. The code sends data to the server after every 15 seconds, It works all the time, however sometimes suddenly the ethernet data transfer hangs, the microcontroller does not hang. Below is the void loop() I have used.Please help.
 

void loop(){ 


   kemasData(); //packing GET query with data
   Serial.println("connecting...");
   if (client.connect(server, 80)) {
     sendData();  
//     koneksi = true; //connected = true
     u.count++;
        Serial.println(length);
       length = 0;
   EEPROM.write(0,u.b[0]);
   EEPROM.write(1,u.b[1]);
          Serial.println("conn serv");


   }
   else{
     Serial.println("connection failed");
   }
  // loop
  while(client.connected()){


    while (client.available()) {
 char c = client.read(); //save http header to c
 Serial.print(c); //print http header to serial monitor


    }
   
   
    //Serial.print("-");


  }
  if (!client.connected()) {


 Serial.println();
 Serial.println("disconnecting.");
          Serial.print("Count :");
          Serial.println(u.count); //print sent value to serial monitor
          client.stop();
          Serial.println("Client Stopped");
//          koneksi = false; 
          Serial.println("koneksi = false");
          data = ""; //data reset
    }
  delay(15000); // interval
}
 
When I check the serial port the code hangs at conn serv printed above.
Edited by bluehash
[ADMIN] Please use code tags <> next time.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...