Sign in to follow this  
Followers 0
khm

Ethernet Hanging

1 post in this topic

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0