17.05.2020, 17:18
|
|
Прохожий
Регистрация: 17.05.2020
Сообщений: 2
Сказал спасибо: 0
Сказали Спасибо 0 раз(а) в 0 сообщении(ях)
|
Симуляция веб-сервера в Proteus
Необходимо симулировать web-server в Proteus для моделирования "умного" дома. Делал по примеру http://2embeddedrobotics.blogspot.co...d-arduino.html
Версия Proteus 8 Professional. Virtual Network Driver установлен.
Использую Arduino UNO и ENC28J60.
Код пишу в Arduino IDE версии 1.8.12.
Вот код: // Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 ‹jc@wippler.nl›
//
// License: GPLv2
#include ‹EtherCard.h›
#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)
#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›"
"‹h3›This service is currently unavailable‹/h3›"
"‹p›‹em›"
"The main server is currently off-line.‹br /›"
"Please try again later."
"‹/em›‹/p›"
"‹/body›"
"‹/html›"
;
void setup(){
Serial.begin(57600);
Serial.println("\n[backSoon]");
// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 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);
}
} Потом код компилирую и hex файл указываю в плате arduino в программе proteus. Запускаю и на терминал выводится только [backSoon], а должен еще и ip.
Последний раз редактировалось tolstj; 17.05.2020 в 17:44.
Причина: РЕШЕНО
|
|
|
|
17.05.2020, 17:43
|
|
Прохожий
Регистрация: 17.05.2020
Сообщений: 2
Сказал спасибо: 0
Сказали Спасибо 0 раз(а) в 0 сообщении(ях)
|
Re: Симуляция веб-сервера в Proteus
Проблема решена:
Поменял контакт 8 на 10.
Переписаны строчки под IP адрес Virtual Network и отключен DHCP:
Было:
#define STATIC 0
static byte myip[] = { 192,168,1,200 };
static byte gwip[] = { 192,168,1,1 };
Стало:
#define STATIC 1
static byte myip[] = { 192,168,95,6 };
static byte gwip[] = { 192,168,95,1 };
ip адрес взят из cmd -› ipconfig /all
Microsoft KM-TEST Loopback Adapter
Последний раз редактировалось tolstj; 17.05.2020 в 18:50.
|
|
|
|
Ваши права в разделе
|
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
HTML код Выкл.
|
|
|
Часовой пояс GMT +4, время: 11:24.
|
|