Arduino - ENC28J60 - EtherCard.h - kompilyatsiya xatosi - "homePage ()" so'zi "extern" va keyinchalik "statik" [- fermissive]

  • Arduino Uno
    • ENC28J60
    • EtherCard.h

Men ushbu misolni kompilyatsiya qilish va ishga tushirishga harakat qilaman. Lekin men bu xatoni olaman.

"exit status 1" so'zi homePage() "extern" va keyinroq e'lon qilindi   "statik" [ishlamaydigan] "

#include 

static byte mymac[] = {0x65,0x77,0x33,0x2D,0x30,0x66};
static byte myip[] = {192,168,0,99};

byte Ethernet::buffer[500];
BufferFiller bfill;

static word homePage() { 
  bfill = ether.tcpOffset();
  bfill.emit_p( PSTR ( 
    "HTTP/1.0 503 test page\r\n"
    "Content-Type: text/html\r\n"
    "Retry-After: 600\r\n"
    "\r\n"
    "<html>"
    "<head><title>"
    "Arduino test page"
    "</title></head>"
    "<body>"
    "

Test

" 
    "
Test" "</body>" "</html>" )) ; return bfill.position(); } void setup() { //put your setup code here, to run once: Serial.begin(57600); Serial.println("TEST"); Serial.println(); Serial.print("Status: "); if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) { Serial.println( "Failed to access Ethernet controller"); } else { Serial.println( "Ethernet controller OK!"); ether.staticSetup(myip); ether.dhcpSetup(); } Serial.println(); ether.printIp("My IP: ", ether.myip); ether.printIp("GW IP: ", ether.gwip); ether.printIp("DNS IP: ", ether.dnsip); } void loop() { //put your main code here, to run repeatedly: word pos = ether.packetLoop(ether.packetReceive()); if (pos){ for (int i=pos;Ethernet::buffer[i]; i++) { Serial.print((char)Ethernet::buffer[i]); Serial.println(); ether.httpServerReply(homePage()); } } }

Kod yoki kutubxonada biror narsa bormi? Misol tarmoqdan ko'chirildi. Kutubxona yangilandi.

Bu muammo bilan menga yordam berishi mumkinmi? Uni qanday tuzatish mumkin?

0
bu qatorda: bayt chekilgan :: bufer [500]; va boshqalar bu kodni C ++ emas, balki tasdiqlashini tasdiqlang. Iltimos, 'c' yorlig'ini olib tashlang.
qo'shib qo'ydi muallif user3629249, manba
static modifierini homePage() funktsiyasining deklaratsiyasidan olib tashlashingiz mumkin.
qo'shib qo'ydi muallif user3629249, manba
muammo ba'zi nom faylida bo'lishi kerak. chunki barcha kodlangan kod ether.httpServerReply (homePage ()) ga qo'ng'iroqni biladi; manzilini ko'rsatmoqda. Eslatma: static ning maqsadini engish juda mo'rt
qo'shib qo'ydi muallif user3629249, manba
muammo ba'zi nom faylida bo'lishi kerak. chunki barcha kodlangan kod ether.httpServerReply (homePage ()) ga qo'ng'iroqni biladi; manzilini ko'rsatmoqda. Eslatma: static ning maqsadini engish juda mo'rt
qo'shib qo'ydi muallif user3629249, manba
EtherCard.h funksiyasi haqida nima desa bo'ladi (va bu funktsiyani eslatmaslik kerak): homePage() ?
qo'shib qo'ydi muallif user3629249, manba
EtherCard.h funksiyasi haqida nima desa bo'ladi (va bu funktsiyani eslatmaslik kerak): homePage() ?
qo'shib qo'ydi muallif user3629249, manba
Net'dan qaerdan ko'chirildi?
qo'shib qo'ydi muallif user3629249, manba
Net'dan qaerdan ko'chirildi?
qo'shib qo'ydi muallif user3629249, manba
Ushbu kod uchun nom fayl bormi? homePage() uchun protetib turadimi? Bu aniq ifodani tashqi sifatida ifodalaydi.
qo'shib qo'ydi muallif Unimportant, manba

7 javoblar

homePage funktsiyasi nomda static funksiyasi mavjud bo'lmagan holda e'lon qilindi.

However then it is defined with the storage class specifier static

static word homePage() { 
//...

va derleyici bu ziddiyat haqida xabar beradi.

Funktsiya ta'rifida saqlash kodi identifikatori static ni olib tashlashingiz mumkin deb o'ylayman.

Yana bir yondashuv, nomdan oldin saqlash kodi spesifikatori static bilan funktsiya deklaratsiyasini joylashtirishdir. Bunday holda funktsiya ichki aloqaga ega bo'ladi.

0
qo'shib qo'ydi

homePage funktsiyasi nomda static funksiyasi mavjud bo'lmagan holda e'lon qilindi.

However then it is defined with the storage class specifier static

static word homePage() { 
//...

va derleyici bu ziddiyat haqida xabar beradi.

Funktsiya ta'rifida saqlash kodi identifikatori static ni olib tashlashingiz mumkin deb o'ylayman.

Yana bir yondashuv, nomdan oldin saqlash kodi spesifikatori static bilan funktsiya deklaratsiyasini joylashtirishdir. Bunday holda funktsiya ichki aloqaga ega bo'ladi.

0
qo'shib qo'ydi

Ehtimol, arduino gui tomonidan qo'llanilgan vositalardagi o'zgarishlar oldinroqdan ko'ra kamroq tolerant va kutubxona yangilangan.

Sizning kutubxonangiz eskirgan ko'rinadi, github repo-dagi ota-sahifa uchun qidiruv faqatgina 3 ta faylni ochib beradi, ularning hammasi misol.

https://github.com/jcw/ethercard/search?utf8=%E2%9C%93&q=homepage

https://github.com/jcw/ethercard dan yangilash tavsiya qilamiz.

0
qo'shib qo'ydi

Ehtimol, arduino gui tomonidan qo'llanilgan vositalardagi o'zgarishlar oldinroqdan ko'ra kamroq tolerant va kutubxona yangilangan.

Sizning kutubxonangiz eskirgan ko'rinadi, github repo-dagi ota-sahifa uchun qidiruv faqatgina 3 ta faylni ochib beradi, ularning hammasi misol.

https://github.com/jcw/ethercard/search?utf8=%E2%9C%93&q=homepage

https://github.com/jcw/ethercard dan yangilash tavsiya qilamiz.

0
qo'shib qo'ydi

Iltimos, taqdim qilgan kodni tekshiring. Jean-Claude Wipper's Github sahifasida taqdim etilgan eskiz bilan bir xildir. " ether.begin " funktsiyasiga har doim ham Chip Select Pin ni berishim kerak, yoki mening ENC28J60 javob bermaydi.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30  http://opensource.org/licenses/mit-license.php
// Connection Diagram: http://i.stack.imgur.com/SvG7J.jpg

#include 

#define STATIC 1 //set to 1 to disable DHCP (adjust myip/gwip values below)
#define CS_PIN 10

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500];//tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "

This service is currently unavailable

"
    "
" "The main server is currently off-line.
" "Please try again later." "
" "</body>" "</html>" ; void setup(){ Serial.begin(9600); Serial.println("\n[backSoon]"); if (ether.begin(sizeof Ethernet::buffer, mymac, CS_PIN) == 0) Serial.println( "Failed to access Ethernet controller"); #if STATIC ether.staticSetup(myip, gwip); #else if (!ether.dhcpSetup()) Serial.println("DHCP failed"); #endif ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); } void loop(){ //wait for an incoming TCP packet, but ignore its contents if (ether.packetLoop(ether.packetReceive())) { memcpy_P(ether.tcpOffset(), page, sizeof page); ether.httpServerReply(sizeof page - 1); } }

Yuklab olish:

Arduino EtherCard kutubxonasi


Essential Task
Before uploading your sketch, you first need to connect your ENC28J60 module to your PC using LAN cable or you can also connect to your router. Now the main part comes. The variable "gwip" must match with your gateway IP address.

  • If you have connected with your PC, find your PC > Ethernet's IP address which may be look like "169.254.x.x":
    enter image description here

  • If you have connected to your router, place router's IP in "gwip".

Gateway IP-ni olganingizdan so'ng, uni "gwip" o'zgaruvchiga yozing va sketchni yuklang :)

0
qo'shib qo'ydi

Iltimos, taqdim qilgan kodni tekshiring. Jean-Claude Wipper's Github sahifasida taqdim etilgan eskiz bilan bir xildir. " ether.begin " funktsiyasiga har doim ham Chip Select Pin ni berishim kerak, yoki mening ENC28J60 javob bermaydi.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30  http://opensource.org/licenses/mit-license.php
// Connection Diagram: http://i.stack.imgur.com/SvG7J.jpg

#include 

#define STATIC 1 //set to 1 to disable DHCP (adjust myip/gwip values below)
#define CS_PIN 10

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500];//tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "

This service is currently unavailable

"
    "
" "The main server is currently off-line.
" "Please try again later." "
" "</body>" "</html>" ; void setup(){ Serial.begin(9600); Serial.println("\n[backSoon]"); if (ether.begin(sizeof Ethernet::buffer, mymac, CS_PIN) == 0) Serial.println( "Failed to access Ethernet controller"); #if STATIC ether.staticSetup(myip, gwip); #else if (!ether.dhcpSetup()) Serial.println("DHCP failed"); #endif ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); } void loop(){ //wait for an incoming TCP packet, but ignore its contents if (ether.packetLoop(ether.packetReceive())) { memcpy_P(ether.tcpOffset(), page, sizeof page); ether.httpServerReply(sizeof page - 1); } }

Yuklab olish:

Arduino EtherCard kutubxonasi


Essential Task
Before uploading your sketch, you first need to connect your ENC28J60 module to your PC using LAN cable or you can also connect to your router. Now the main part comes. The variable "gwip" must match with your gateway IP address.

  • If you have connected with your PC, find your PC > Ethernet's IP address which may be look like "169.254.x.x":
    enter image description here

  • If you have connected to your router, place router's IP in "gwip".

Gateway IP-ni olganingizdan so'ng, uni "gwip" o'zgaruvchiga yozing va sketchni yuklang :)

0
qo'shib qo'ydi

Iltimos, taqdim qilgan kodni tekshiring. Jean-Claude Wipper's Github sahifasida taqdim etilgan eskiz bilan bir xildir. " ether.begin " funktsiyasiga har doim ham Chip Select Pin ni berishim kerak, yoki mening ENC28J60 javob bermaydi.

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30  http://opensource.org/licenses/mit-license.php
// Connection Diagram: http://i.stack.imgur.com/SvG7J.jpg

#include 

#define STATIC 1 //set to 1 to disable DHCP (adjust myip/gwip values below)
#define CS_PIN 10

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500];//tcp/ip send and receive buffer

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "

This service is currently unavailable

"
    "
" "The main server is currently off-line.
" "Please try again later." "
" "</body>" "</html>" ; void setup(){ Serial.begin(9600); Serial.println("\n[backSoon]"); if (ether.begin(sizeof Ethernet::buffer, mymac, CS_PIN) == 0) Serial.println( "Failed to access Ethernet controller"); #if STATIC ether.staticSetup(myip, gwip); #else if (!ether.dhcpSetup()) Serial.println("DHCP failed"); #endif ether.printIp("IP: ", ether.myip); ether.printIp("GW: ", ether.gwip); ether.printIp("DNS: ", ether.dnsip); } void loop(){ //wait for an incoming TCP packet, but ignore its contents if (ether.packetLoop(ether.packetReceive())) { memcpy_P(ether.tcpOffset(), page, sizeof page); ether.httpServerReply(sizeof page - 1); } }

Yuklab olish:

Arduino EtherCard kutubxonasi


Essential Task
Before uploading your sketch, you first need to connect your ENC28J60 module to your PC using LAN cable or you can also connect to your router. Now the main part comes. The variable "gwip" must match with your gateway IP address.

  • If you have connected with your PC, find your PC > Ethernet's IP address which may be look like "169.254.x.x":
    enter image description here

  • If you have connected to your router, place router's IP in "gwip".

Gateway IP-ni olganingizdan so'ng, uni "gwip" o'zgaruvchiga yozing va sketchni yuklang :)

0
qo'shib qo'ydi