极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10587|回复: 1

求助EtherCard.h代码编译不过

[复制链接]
发表于 2015-3-26 21:28:14 | 显示全部楼层 |阅读模式
这个教程关于EtherCard
源代码地址
在arduino1.6.1环境下编译不过
错误提示web1.ino:4:16: error: variable 'website' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
以下是代码

#include <EtherCard.h>

static byte mymac[] = { 0x78, 0x2B, 0xCB, 0xDC, 0x99, 0x15 };
char website[] PROGMEM =("www.lucadentella.it");就是这行代码编译不过。

byte Ethernet::buffer[700];
static uint32_t timer;

static void response_callback(byte status, word off, word len) {

        Serial.print((const char*)Ethernet::buffer + off + 207);
}

void setup() {

        Serial.begin(57600);
        Serial.println("Client Demo");
        Serial.println();

        if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
                Serial.println("Failed to access Ethernet controller");
        else
                Serial.println("Ethernet controller initialized");
        Serial.println();

        if (!ether.dhcpSetup())
                Serial.println("Failed to get configuration from DHCP");
        else
                Serial.println("DHCP configuration done");

        ether.printIp("IP Address:\t", ether.myip);
        ether.printIp("Netmask:\t", ether.netmask);
        ether.printIp("Gateway:\t", ether.gwip);
        Serial.println();

        if (!ether.dnsLookup(website))
                Serial.println("DNS failed");
        else
                Serial.println("DNS resolution done");
        ether.printIp("SRV IP:\t", ether.hisip);
        Serial.println();
}

void loop() {

        ether.packetLoop(ether.packetReceive());

        if (millis() > timer) {
                timer = millis() + 5000;
                ether.browseUrl(PSTR("/demo/"), "aphorisms.php", website, response_callback);
        }
}
希望大家可以帮忙看下,多谢了




回复

使用道具 举报

发表于 2015-3-26 23:47:27 | 显示全部楼层
不是已經寫得很清楚了嗎?

variable 'website' must be const in order to be put into read-only section by means of '__attribute__((progmem))'


加個 const 就可以了.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-18 06:24 , Processed in 0.034174 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表