<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=47&amp;t=15457&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2016-05-26T19:31:47+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=47&amp;t=15457&amp;mode</id>
<entry>
<author><name><![CDATA[ANT]]></name></author>
<updated>2016-05-26T19:31:47+01:00</updated>
<published>2016-05-26T19:31:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161139#p161139</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161139#p161139"/>
<title type="html"><![CDATA[Re: Arduino + czytnik kart microSD + serwer WWW]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161139#p161139"><![CDATA[
Witam,<br /><br />Kiedyś się tym bawiłem i nawet opisywałem to na forum lecz niestety tak na szybko nie mogę tego znaleźć...<br />Podaję natomiast kod znaleziony w moich czeluściach z którego korzystałem.<br />Może się przyda...<br /><br />[syntax=cpp]/* Serwer 31.<br /> Załadowanie strony z karty SD.<br /> */<br /><br />//Załadowanie bibliotek.<br />#include &lt;SPI.h&gt;<br />#include &lt;Ethernet.h&gt;<br />#include &lt;SD.h&gt;<br />#include &lt;EEPROM.h&gt;<br /><br />#define REQ_BUF_SZ   20<br /><br />//Ustawienia serwera.<br />byte mac&#91;&#93; = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };<br />IPAddress ip( 192, 168, 1, 100 ); <br />EthernetServer server(80);  <br /><br />//Ustawienia zmiennych.<br />File webFile;<br />File myFile;<br />char HTTP_req&#91;REQ_BUF_SZ&#93; = { 0 }; <br />char req_index = 0;  <br />int licz;<br />int led = 8;<br /><br />//Ustawienia programu.<br />void setup()<br />{<br />  //Ustawienie pinu nr 8 do obsługi diody LED.<br />  pinMode(led, OUTPUT);<br />  digitalWrite(led, LOW);<br /><br />  //Ustawienie pinu nr 10.<br />  pinMode(10, OUTPUT);<br />  digitalWrite(10, HIGH);<br /><br />  //Uruchomienie monitora szeregowego.<br />  Serial.begin(9600);      <br /><br />  //-------------------------------Sprawdzenie karty SD-----------------------------------<br />  Serial.println(&quot;Inicjacja karty SD...&quot;);<br />  if (!SD.begin(4)) <br />  {<br />    Serial.println(&quot;Blad inicjacji karty SD!&quot;);<br />    return;    <br />  }<br />  Serial.println(&quot;Karta SD zainicjowana!&quot;);<br />  if (!SD.exists(&quot;index.htm&quot;)) <br />  {<br />    Serial.println(&quot;Blad - brak pliku: index.htm&quot;);<br />    return; <br />  }<br />  Serial.println(&quot;Plik: index.htm - znaleziony!&quot;);<br />  //--------------------------------------------------------------------------------------<br /><br />  //Uruchomienie serwera.<br />  Ethernet.begin(mac, ip);  <br />  server.begin();    <br /><br />  //Odczytanie licznika z pamięci EEPROM.<br />  licz = EEPROM.read(0); <br />}<br /><br />//Pętla główna programu.<br />void loop()<br />{<br />  //Wygaszenie diody LED.<br />  digitalWrite(led, LOW);<br />  <br />  EthernetClient client = server.available(); <br /><br />  if (client) <br />  { <br />    //Zaświecenie diody LED.<br />    digitalWrite(led, HIGH);<br />    <br />    boolean currentLineIsBlank = true;<br />    while (client.connected()) <br />    {<br /><br />      if (client.available()) <br />      {   <br />        char c = client.read(); <br />        if (req_index &lt; (REQ_BUF_SZ - 1)) <br />        {<br />          HTTP_req&#91;req_index&#93; = c;      <br />          req_index++;<br />        }<br /><br />        Serial.print(c);<br /><br />        if (c == '\n' &amp;&amp; currentLineIsBlank) <br />        {<br />          if (StrContains(HTTP_req, &quot;GET / &quot;)<br />            || StrContains(HTTP_req, &quot;GET /index.htm&quot;)) <br />          {<br />            client.println(&quot;HTTP/1.1 200 OK&quot;);<br />            client.println(&quot;Content-Type: text/html&quot;);<br />            client.println(&quot;Polaczenie: zamkniete!&quot;);<br />            client.println();<br />            webFile = SD.open(&quot;index.htm&quot;);  <br />          }<br /><br />          //--------------------------------obrazek chip-----------------------------<br />          else if (StrContains(HTTP_req, &quot;GET /chip.jpg&quot;)) <br />          {<br />            webFile = SD.open(&quot;chip.jpg&quot;);<br />            if (webFile) <br />            {<br />              client.println(&quot;HTTP/1.1 200 OK&quot;);<br />              client.println();<br />            }<br />          }<br /><br />          //------------------------------------licznik--------------------------------<br />          else if (StrContains(HTTP_req, &quot;GET /licznik.txt&quot;)) <br />          {<br />            webFile = SD.open(&quot;licznik.txt&quot;);<br />            if (webFile) <br />            {<br />              client.println(&quot;HTTP/1.1 200 OK&quot;);<br />              client.println();<br />            }<br />          }<br /><br />          //--------------------------------------------------------------------------<br />          if (webFile) <br />          {<br />            while(webFile.available()) <br />            {<br />              client.write(webFile.read()); <br />            }<br />            webFile.close();<br />          }<br /><br />          req_index = 0;<br />          StrClear(HTTP_req, REQ_BUF_SZ);<br />          break;<br />        }<br /><br />        if (c == '\n') <br />        {<br />          currentLineIsBlank = true;<br />        } <br />        else if (c != '\r') <br />        {<br />          currentLineIsBlank = false;<br />        }<br />      } <br />    } <br /><br />    delay(1);    <br />    client.stop(); <br />  }<br />}<br /><br />//-----------------------------------------------------------------------<br />void StrClear(char *str, char length)<br />{<br />  for (int i = 0; i &lt; length; i++) <br />  {<br />    str&#91;i&#93; = 0;<br />  }<br />}<br /><br />//-----------------------------------------------------------------------<br />char StrContains(char *str, char *sfind)<br />{<br />  char found = 0;<br />  char index = 0;<br />  char len;<br /><br />  len = strlen(str);<br /><br />  if (strlen(sfind) &gt; len) <br />  {<br />    return 0;<br />  }<br />  while (index &lt; len) <br />  {<br />    if (str&#91;index&#93; == sfind&#91;found&#93;) <br />    {<br />      found++;<br />      if (strlen(sfind) == found) <br />      {<br />        return 1;<br />      }<br />    }<br />    else <br />    {<br />      found = 0;<br />    }<br />    index++;<br />  }<br /><br />  return 0;<br />}[/syntax]<br />Pozdr.<br /><br />Sorki, za źle wklejony wcześniej listing. Dawno się nie udzielałem na forum i się zapomniało <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=5883">ANT</a> — 26 maja 2016, o 19:31</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[ramcin]]></name></author>
<updated>2016-05-26T08:41:52+01:00</updated>
<published>2016-05-26T08:41:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161112#p161112</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161112#p161112"/>
<title type="html"><![CDATA[Arduino + czytnik kart microSD + serwer WWW]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=15457&amp;p=161112#p161112"><![CDATA[
Witam,<br />Panowie jak najłatwiej umieścić na karcie SD plik html ze stroną internetową, aby następnie uC z karty SD odczytywał tę stronę i przez moduł ethernetowy to wszystko działało. W tym momencie stronę HTML mam na uC ale ma on małą pamięć dlatego chciałbym, żeby strona znajdowała się na karcie SD, a uC wyciągał z niej ten plik + jakieś obrazki itp. Da rade coś takiego zrobić? Może ktoś coś takiego robił i chciałby się podzielić?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6229">ramcin</a> — 26 maja 2016, o 08:41</p><hr />
]]></content>
</entry>
</feed>