[phpBB Debug] PHP Warning: in file [ROOT]/includes/db/dbal.php on line 117: Undefined array key "cached"
[phpBB Debug] PHP Warning: in file [ROOT]/includes/db/dbal.php on line 118: Undefined array key "normal"
[phpBB Debug] PHP Warning: in file [ROOT]/includes/db/dbal.php on line 119: Undefined array key "total"
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1056: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1056: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1056: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Undefined variable $Array
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Trying to access array offset on value of type null
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Undefined variable $Array
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Trying to access array offset on value of type null
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Undefined variable $Array
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 78: Trying to access array offset on value of type null
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
MK90 • Просмотр темы - Freeduino EtherCard R1

Freeduino EtherCard R1

Обсуждение устройств на основе существующих шилдов, создание новых шилд-плат, библиотеки.

Freeduino EtherCard R1

Сообщение polyar » 21 май 2014, 20:41

Добрый день

Приобрел у вас Freeduino EtherCard R1 вместе с Freeduino Mega 2560. Разобрался как на ней поднимать web server. Подскажите, пожалуйста, скетч как отправить на локальный web сервер с IP 192.168.1.10 запрос. В интернете нашел только через ДНС имя сервера. А как отправить именно запрос вида http://192.168.1.10/sript.php?cmd=1 ? Сервер, настроен отвечать на такие запросы. Если в браузере вбить http://192.168.1.10/sript.php?cmd=1 скрипт отработает как надо. Но ардуино не хочет слать запросы.
polyar
 
Сообщения: 3
Зарегистрирован: 21 май 2014, 20:35

Re: Freeduino EtherCard R1

Сообщение ilya_dan » 22 май 2014, 08:43

А можно взглянуть на текст скетча, который надо заставить заработать?
Always yours, MK90 admin
ilya_dan
Site Admin
 
Сообщения: 175
Зарегистрирован: 11 авг 2011, 23:34
Откуда: MK90

Re: Freeduino EtherCard R1

Сообщение polyar » 22 май 2014, 10:11

Вот такой скетч, только ардуино ничего не отправляет
Когда на сервере отрабатывает скрипт приходит GET запрос
GET /?cmd=1 HTTP/1.1
Host: 192.168.1.103
Accept: */*

[code]#include <EtherCard.h>


//Дефолтовые настройки сети
static byte mac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
static byte eip[] = {192,168,1,103};
static byte sip[] = {192,168,1,10};

byte Ethernet::buffer[700];
char website[] PROGMEM = "192.168.1.10";
static BufferFiller bfill;


int stat=0;

void setup(void)
{
Serial.begin(57600);
if (!ether.begin(sizeof Ethernet::buffer, mac, 10))
Serial.println( " Status:Failed to access Ethernet controller");
else
Serial.println(" Status:Ok");

if (!ether.staticSetup(eip))
Serial.println(" Status:Failed to set IP address");

ether.copyIp(ether.hisip, sip);
}

//функция приема текстовой строки сетевой карты
static void my_callback (byte status, word off, word len) {
Ethernet::buffer[off+300] = 0;
Serial.print((const char*) Ethernet::buffer + off);


}

void loop(void)
{


if (Serial.available() > 0) {
int sread = Serial.read();
if (sread == 49){
stat++;
ether.browseUrl(PSTR("/script.php?"), "p=8", NULL, my_callback);
Serial.println(stat);
}
}


word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(pos) {

bfill = ether.tcpOffset();
char* data = (char *) Ethernet::buffer + pos;

Serial.println(data); // распечатываем запрос для отладки


bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><head><title>Test</title></head>"
"<body>Test page"

"</body></html>"));
ether.httpServerReply(bfill.position());

}
}[/code]

Скетч построен на примере что идет с библиотекой EtherCard
[code]// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

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

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

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

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

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

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

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

if (!ether.dnsLookup(website))
Serial.println("DNS failed");

ether.printIp("SRV: ", ether.hisip);
}

void loop () {
ether.packetLoop(ether.packetReceive());

if (millis() > timer) {
timer = millis() + 5000;
Serial.println();
Serial.print("<<< REQ ");
ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
}
}[/code]
polyar
 
Сообщения: 3
Зарегистрирован: 21 май 2014, 20:35

Re: Freeduino EtherCard R1

Сообщение polyar » 22 май 2014, 13:05

нашел выход, на роутере прописал A запись: [b] A home.loc 192.168.1.10[/b]
изменив стандартный скетч добавив

[b]static byte his[] ={192,168,1,10};[/b]

а setup после
if (!ether.dnsLookup(website))
Serial.println("DNS failed");

[b] ether.copyIp(ether.hisip,his); [/b]

[code]// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>
static BufferFiller bfill;
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte his[] ={192,168,1,10};
byte Ethernet::buffer[700];
static uint32_t timer;

const char website[] PROGMEM = "home.loc";

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

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

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

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

if (!ether.dnsLookup(website))
Serial.println("DNS failed");

ether.copyIp(ether.hisip,his);
ether.printIp("SRV: ", ether.hisip);
}

void loop () {
//ether.packetLoop(ether.packetReceive());
word len = ether.packetReceive();
word pos = ether.packetLoop(len);

if(pos) {
//Убрать -->>>
bfill = ether.tcpOffset();
char* data = (char *) Ethernet::buffer + pos;

Serial.println(data); // распечатываем запрос для отладки


bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><head><title>iHome </title></head>"
"<body>LED Status: "

"</body></html>" ));
ether.httpServerReply(bfill.position());

}

if (millis() > timer) {
timer = millis() + 5000;
Serial.println();
Serial.print("<<< REQ ");
ether.browseUrl(PSTR("/script.php"), "?jh=0", website, my_callback);
}
}[/code]
polyar
 
Сообщения: 3
Зарегистрирован: 21 май 2014, 20:35


Вернуться в Shield-платы

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

cron