0
我正在開發一個arduino項目,它在服務器上發出http請求並讀取http頁面內容。在循環中我有一個功能:Arduino在時間之後崩潰
String eventValue = check_for_event();
String check_for_event(){
if (client.connect(server, 80)) {
client.print("GET /check_for_event.php?q=");
client.print(class_code);
client.println(" HTTP/1.0");
client.println();
return readPage();
} else{ return "704"; }
}
String readPage(){
stringPos = 0;
memset(&inString, 0, 32);
int print_flag=0;
while(true){
if (client.available()) {
char c = client.read();
if (c == '<') {
startRead = true;
}else if(startRead){
if(c != '>'){
inString[stringPos] = c;
stringPos ++;
}else{
startRead = false;
client.stop();
client.flush();
print_flag=1;
return inString;
}
}
}
}
if(print_flag==0){return "804";}
}
這是我的代碼的一部分,我每3秒調用一次。它可以正常工作幾個小時,但突然崩潰,我不明白爲什麼。我發現崩潰在check_for_event函數的某處。
'class_code'裏有什麼?如果您的HTTP請求花費的時間超過三秒,會發生什麼? – Blazemonger
這是我在服務器數據庫中保存的用於識別arduino的代碼。秒數沒有問題,因爲我檢查是否已經超過3秒鐘來創建新的查詢。 – giorgos