【发布时间】:2016-05-02 19:33:41
【问题描述】:
我希望 arduino 在进行 ajax 调用时写入文件。 ajax 工作,但它不写入文件。 ajax 处理程序中的所有其他代码都会执行。
void handle_ajax(){
int startUrlIndex= HTTP_req.indexOf("button");
int endUrlIndex = HTTP_req.indexOf(" HTTP");
String url = HTTP_req.substring(startUrlIndex, endUrlIndex);
int startButtonIndex = url.indexOf("device-") + 7;// 7 is length of device-, I really just want the number.
int endButtonIndex = url.indexOf("&");
String button = url.substring(startButtonIndex, endButtonIndex);
int startStateIndex = url.indexOf("state=") + 6; // 6 is length of state=, I really just want the number.
String state = url.substring(startStateIndex);
int device = button.toInt();
int newState = state.toInt();
dim_light(device, newState * 12);
write_config("", "text");
}
bool write_config(String line, String text){
configFile = SD.open("config.ini", FILE_WRITE);
if(configFile){
configFile.write("Dipshit");
}
configFile.close();
Serial.println("Works.");
return true;
}
【问题讨论】:
-
你有什么结果?你能在'if(configFile)'里面放一个闪烁的LED吗? SD的引脚是否可用?你用什么盾牌?请提供更多信息
-
找到了,内存的问题...再次
标签: ajax arduino sd-card arduino-uno arduino-ide