如何在Arduino草图中使用库Ethernet2?
我有和堆栈溢出问题相同的问题 这个问题的解决方案是使用库。我下载了这个库并将文件夹“Ethernet2”放在文件夹“libraries”中。当我尝试在中使用Arduino 1.0.1时,它会产生错误 草图:如何在Arduino草图中使用库Ethernet2?,arduino,Arduino,我有和堆栈溢出问题相同的问题 这个问题的解决方案是使用库。我下载了这个库并将文件夹“Ethernet2”放在文件夹“libraries”中。当我尝试在中使用Arduino 1.0.1时,它会产生错误 草图: /* * Echo Server * * Echoes back the headers of the web request. Good for * learning how the HTTP protocol works. */ #include <Ethernet2
/*
* Echo Server
*
* Echoes back the headers of the web request. Good for
* learning how the HTTP protocol works.
*/
#include <Ethernet2.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
Server server(80);
void setup()
{
Client client(255);
Ethernet.begin(mac, ip);
Serial.begin(9600);
server.begin();
}
void loop()
{
char buf[512];
int i = 0;
Client client = server.available();
if (client) {
boolean previous_is_newline = false;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && previous_is_newline) {
buf[i] = 0;
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<pre>");
client.println(buf);
client.println("</pre>");
break;
}
if (i < 511)
buf[i++] = c;
if (c == '\n')
previous_is_newline = true;
else if (c != '\r')
previous_is_newline = false;
}
}
client.stop();
}
}
如何解决此问题?由于Arduino IDE 1.5,您可以使用库管理器安装libs-此问题不应再出现请尝试重新安装库。好像有两个文件。。。你下载了这两个软件并正确安装了吗?此外,请尝试更新到IDE的较新版本。
In file included from C:\Documents and Settings\Admin\Рабочий стол\!!! Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Arduino.h:193,
from Test_Ethernet2_echo.cpp:10:
C:\Documents and Settings\Admin\Рабочий стол\!!! Arduino\arduino-1.0.1\hardware\arduino\cores\arduino/HardwareSerial.h:58: error: conflicting return type specified for 'virtual size_t HardwareSerial::write(uint8_t)'
C:\Documents and Settings\Admin\Рабочий стол\!!! Arduino\arduino-1.0.1\libraries\Ethernet2/Print.h:36: error: overriding 'virtual void Print::write(uint8_t)'