【发布时间】:2011-12-20 17:38:05
【问题描述】:
我需要解析大量数据。当我的意思很多时,我说的是大约 5,000 到 10,000 个字符。现在,我的代码可以处理 285 条数据。我正在使用 Arduino 原型平台。这是我的loop() 在我的sketch:
void loop() {
if (client.available()) {
char inChar = client.read();
currentLine += inChar;
if (inChar == '\n') { currentLine = ""; }
if (currentLine.endsWith("[start]")) {
readingData = true;
theData = "";
}
if (readingData) {
if (inChar != '[') {
theData += inChar;
//Serial.println("something!");
}
else {
readingData = false;
int count = theData.length()-0;
theData = theData.substring(1, count);
Serial.println(theData);
doAction(100,count,theData);
client.stop();
}
}
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
我应该将其拆分为 20 多个字符串并将它们放入一个数组中吗?我不确定我的 2KB RAM 是否能够处理。
【问题讨论】:
-
你的 10000 个字符从何而来?这甚至不太可能适合 AVR 的内存 IIRC。
-
@JamWaffles:来自远程 URL,它将打开/关闭我面包板上的一系列 LED。
-
我无法理解您如何需要 10k 个字符来控制某些 LED。正如 Basile 所说,AVR 没有足够的 RAM,因此您需要将您的字符串分成块并将它们发送到例如 1KB 的部分中。
-
最终它将控制圣诞灯。如果一首歌曲是 300 节拍(大约 2-3 分钟),那么使用我的代码将是大约 5,000 个字符...