This is a non working version of my ethernet with sd card, i do not know why
Dependencies: SDFileSystem mbed
Fork of eth_v13 by
Revision 4:01cb86c138d8, committed 2014-03-27
- Comitter:
- hggerdd
- Date:
- Thu Mar 27 21:58:15 2014 +0000
- Parent:
- 3:79dc3337d9da
- Commit message:
- a
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Thu Mar 27 21:58:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/hggerdd/code/SDFileSystem/#d92869573b15
--- a/html.h Fri Mar 21 00:18:33 2014 +0000 +++ b/html.h Thu Mar 27 21:58:15 2014 +0000 @@ -1,26 +1,23 @@ #ifndef HTML_H_ #define HTML_H_ -/* -const char html_head[] = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n" \ - "<html>\r\n<body>\r\n" \ - "<title>Karl's W5100 web server (ATmega644p)</title>\r\n" \ - "<h2>Karl's ATmega644p web server using Wiznet W5100 chip</h2>\r\n"; -*/ - -const char html_head[] = "<html>\r\n<body>\r\n" \ - "<title>Karl's W5100 web server (ATmega644p)</title>\r\n" \ - "<h2>Karl's ATmega644p web server using Wiznet W5100 chip</h2>\r\n"; +const char html_head[] = "<html><meta http-equiv=\"refresh\" content=\"5\">\r\n<body>\r\n" \ + "<title>Webserver </title>\r\n" \ + "<h2>Webserver using Wiznet W5100 chip</h2>\r\n"; const char html_foot[] ="<br /><hr></html>\r\n"; +/* html Tabelle */ +const char html_table_head[] = "<table border=\"1\">"; +const char html_table_foot[] = "</table>"; + const char c_HTTP_200_OK[] = "HTTP/1.0 200 OK\r\n"; const char c_HTTP_404_NotFound[] = "HTTP/1.0 404 Not Found\r\n"; /* Cache Control */ const char c_HTTP_CacheControl_NoCache[] = "Pragma: no-cache\r\nExpires: Fri, 01 Jan 1990 00:00:00 GMT\r\nCache-Control: no-cache, must-revalidate\r\n"; - +const char http_refresh[] = "<head><meta http-equiv=\"refresh\" content=\"5\"></head>"; /* Content Types */ const char c_HTTP_Content_HTML[] = "Content-Type: text/html\r\n"; const char c_HTTP_Content_Javascript[] = "Content-Type: text/javascript\r\n"; @@ -38,7 +35,7 @@ /* File Extensions */ const char c_HTTP_FileExtension_Htm[] = "htm"; -const char c_HTTP_FileExtension_Js[] = "js"; +const char c_HTTP_FileExtension_Js[] = "js"; const char c_HTTP_FileExtension_Bmp[] = "bmp"; const char c_HTTP_FileExtension_Ico[] = "ico"; const char c_HTTP_FileExtension_Jpg[] = "jpg";
--- a/httpServer.cpp Fri Mar 21 00:18:33 2014 +0000 +++ b/httpServer.cpp Thu Mar 27 21:58:15 2014 +0000 @@ -36,7 +36,7 @@ // Größe des Empfangspuffers einlesen int size = tcpSocket.getRxSize(); -counter++; + counter++; pc.printf("\n\n!! Was empfangen (%d)(%d)\n\n", _port, size); @@ -54,7 +54,7 @@ // Erkenne die Anfrage ptrToken = strtok(NULL, " /&\r\n"); - if (strncmp(ptrToken, "heiko", strlen("heiko")) == 0) { + if (strncmp(ptrToken, "test", strlen("test")) == 0) { tcpSocket.send(c_HTTP_200_OK, strlen(c_HTTP_200_OK)); tcpSocket.send(c_HTTP_CacheControl_NoCache, strlen(c_HTTP_CacheControl_NoCache)); tcpSocket.send(c_HTTP_Content_HTML, strlen(c_HTTP_Content_HTML)); @@ -65,18 +65,27 @@ } else if (strncmp(ptrToken, "zeit", strlen("zeit")) == 0) { tcpSocket.send(c_HTTP_200_OK, strlen(c_HTTP_200_OK)); tcpSocket.send(c_HTTP_CacheControl_NoCache, strlen(c_HTTP_CacheControl_NoCache)); + tcpSocket.send(http_refresh, strlen(http_refresh)); + tcpSocket.send(c_HTTP_Content_HTML, strlen(c_HTTP_Content_HTML)); tcpSocket.send(c_HTTP_EmptyLine, strlen(c_HTTP_EmptyLine)); tcpSocket.send(html_head, strlen(html_head)); - - sprintf(buf, "Zaehler : %d \r\n\r\n", counter); + + //sprintf(buf, "Zaehler : %d \r\n\r\n", counter); + + tcpSocket.send(html_table_head, strlen(html_table_head)); - for (int i=0; i<1000; i++) tcpSocket.send(buf, strlen(buf)); - + for (int i=0; i<10; i++) { + //sprintf(buf, "Zaehler : %d, %d \r\n\r\n", counter, i); + sprintf(buf, "<tr><th>%d</th><th>%d</th><th>%d</th></tr>", counter, i, counter*counter); + tcpSocket.send(buf, strlen(buf)); + } + + tcpSocket.send(html_table_foot, strlen(html_table_foot)); tcpSocket.send(html_foot, strlen(html_foot)); - - + + } else { tcpSocket.send(c_HTTP_404_NotFound, strlen(c_HTTP_404_NotFound)); tcpSocket.send(c_HTTP_CacheControl_NoCache, strlen(c_HTTP_CacheControl_NoCache));
--- a/main.cpp Fri Mar 21 00:18:33 2014 +0000 +++ b/main.cpp Thu Mar 27 21:58:15 2014 +0000 @@ -5,6 +5,9 @@ #include "html.h" #include "sstream" #include "httpServer.h" +//#include "SDFileSystem.h" + +#include "test.h" extern W5100Class W5100; @@ -19,6 +22,9 @@ httpServer webServer(0); +#ifdef SDCARD_ +SDFileSystem sd(D4, D5, D3, D2, "sd"); +#endif int main() { IpAddr localhost(192,168,1,68); @@ -53,9 +59,24 @@ pc.printf("Sendetimer starten.\n"); // sendStatusTimer.start(); +#ifdef SDCARD_ + pc.printf("sd.disk_status = %x", sd.disk_status()); + + + mkdir("/sd/mydir", 0777); + + FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); + if(fp == NULL) { + printf("Could not open file for write\n"); + } else { + fprintf(fp, "Hello fun SD Card World!"); + fclose(fp); + } +#endif + // TCP starten und regelmäßig bedienen webServer.start(80); - tickTCP.attach(&webServer, &httpServer::poll, 0.5); + tickTCP.attach(&webServer, &httpServer::poll, 0.1); while(1) { /*