极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 15834|回复: 3

28j60用ethercard库,示例都无法完成。求助!

[复制链接]
发表于 2012-9-27 12:18:00 | 显示全部楼层 |阅读模式
本帖最后由 坤遠遊森林 于 2012-9-28 15:27 编辑
  1. // Demo using DHCP and DNS to perform a web client request.
  2. // 2011-06-08 <[email][email protected][/email]> [url]http://opensource.org/licenses/mit-license.php[/url]

  3. #include <EtherCard.h>

  4. // ethernet interface mac address, must be unique on the LAN
  5. static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

  6. byte Ethernet::buffer[700];
  7. static uint32_t timer;

  8. char website[] PROGMEM = "www.google.com";

  9. // called when the client request is complete
  10. static void my_callback (byte status, word off, word len) {
  11.   Serial.println(">>>");
  12.   Ethernet::buffer[off+300] = 0;
  13.   Serial.print((const char*) Ethernet::buffer + off);
  14.   Serial.println("...");
  15. }

  16. void setup () {
  17.   Serial.begin(57600);
  18.   Serial.println("\n[webClient]");

  19.   if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
  20.     Serial.println( "Failed to access Ethernet controller");
  21.   if (!ether.dhcpSetup())
  22.     Serial.println("DHCP failed");

  23.   ether.printIp("IP:  ", ether.myip);
  24.   ether.printIp("GW:  ", ether.gwip);  
  25.   ether.printIp("DNS: ", ether.dnsip);  

  26.   if (!ether.dnsLookup(website))
  27.     Serial.println("DNS failed");
  28.    
  29.   ether.printIp("SRV: ", ether.hisip);
  30. }

  31. void loop () {
  32.   ether.packetLoop(ether.packetReceive());
  33.   
  34.   if (millis() > timer) {
  35.     timer = millis() + 5000;
  36.     Serial.println();
  37.     Serial.print("<<< REQ ");
  38.     ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
  39.   }
  40. }
复制代码


跑webclient这个示例。下载到板上,28j60的两个灯都不亮。
串口监视是这样的。。求助啊!!



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2012-9-27 12:31:45 | 显示全部楼层
我也一直很郁闷
回复 支持 反对

使用道具 举报

发表于 2012-9-27 17:39:27 | 显示全部楼层
请详细说接线和arduino种类,这个库绝没问题的
回复 支持 反对

使用道具 举报

发表于 2012-9-28 14:27:26 | 显示全部楼层
亲~!请修改您的波特率~!
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-3 17:32 , Processed in 0.043049 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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