INFO: Dieses Forum nutzt Cookies...
Cookies sind für den Betrieb des Forums unverzichtbar. Mit der Nutzung des Forums erklärst Du dich damit einverstanden, dass wir Cookies verwenden.

Es wird in jedem Fall ein Cookie gesetzt um diesen Hinweis nicht mehr zu erhalten. Desweiteren setzen wir Google Adsense und Google Analytics ein.

Antwort schreiben 
 
Themabewertung:
  • 0 Bewertungen - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Ethernet-WebServer: Button-Belegung
07.06.2015, 15:01
Beitrag #17
RE: Ethernet-WebServer: Button-Belegung
Richtig,
das Problem tritt schon auf ohne Button-Drücken.
Ich habe nun den Aufruf freeRam(); hinter die Serial.println Zeilen gepackt und die Funktion hinter die anderen Funktionen.

Ergebnis im Serial Monitor:

server is at 192.168.178.45
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.
GET / HTTP/1.1
Host: 4711engel.ddns.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:02
Beitrag #18
RE: Ethernet-WebServer: Button-Belegung
Ok, das ist das letzte Mal: Wo ist Dein Coding?
Außerdem: Ich sehe nicht, dass das Ergebnis von freeRam ausgegeben wird.

Falls ich mit einer Antwort helfen konnte, wuerde ich mich freuen, ein paar Fotos oder auch ein kleines Filmchen des zugehoerigen Projekts zu sehen.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:07
Beitrag #19
RE: Ethernet-WebServer: Button-Belegung
He,
ich danke dir für die Hilfe, aber Druck hilft da auch nicht weiter.

Hier das Coding:

Code:
/*--------------------------------------------------------------
          Arduino Ethernet Camera
Take a picture using the adafruit_vc0706 , save it on SD-Card
and print it over ethernet on a internet browser
                  Ulrich Engel
  CoAuthor:       W.A. Smith, http://startingelectronics.org
--------------------------------------------------------------*/

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Adafruit_VC0706.h>
#include <SoftwareSerial.h>  

// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   20
#define chipSelect 4

// MAC address from Ethernet shield sticker under board
byte mac[] = {0x90, 0xA2, 0xDA, 0x0F, 0x1E, 0x28};
IPAddress ip(192, 168, 178, 45); // IP address, may need to change depending on network
byte gateway[] = { 192, 168, 178, 1 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

//*************************** void setup ********************************

void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
// Open serial communications:
  Serial.begin(9600);

// start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());  

    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
}

// **************  void loop  ***********************

void loop()
{
  EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)

               if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }

                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
                        client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("index.htm");        // open web page file
                    }

                    if (StrContains(HTTP_req, "GET /IMAGE.JPG")) {
                        webFile = SD.open("IMAGE.JPG");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();
                        }
                    }
          
          
          
               if (StrContains(HTTP_req, "GET /TakingPicture")) {
                              client.println("HTTP/1.1 200 OK");
                              client.println("Content-Type: text/html");
                             client.println("Connnection: close");
                             client.println();  
                        
                          Serial.println("Button -Take a Picture- pressed!");                        
                        
                            
                          Serial.println("VC0706 Camera snapshot test");
                          Serial.println("");

   freeRam();      
/*                        
                              // Try to locate the camera
                             if (cam.begin()) {
                                 Serial.println("Camera Found:");
                              } else {
                                 Serial.println("No camera found?");
                                 return;
                               }

                               // Existing image remove
                         //      SD.remove("IMAGE.JPG");

                               // Set the picture size - you can choose one of 640x480, 320x240 or 160x120
                                  //cam.setImageSize(VC0706_640x480);        // biggest
                                  cam.setImageSize(VC0706_320x240);        // medium
                                  //cam.setImageSize(VC0706_160x120);          // small

                               // You can read the size back from the camera (optional, but maybe useful?)
                                  uint8_t imgsize = cam.getImageSize();
                                  if (imgsize == VC0706_640x480) Serial.println("640x480");
                                  if (imgsize == VC0706_320x240) Serial.println("320x240");
                                  if (imgsize == VC0706_160x120) Serial.println("160x120");

                                  Serial.println("Snap in 3 secs...");
                                    delay(3000);

                                   if (! cam.takePicture())
                                       Serial.println("Failed to snap!");
                                    else
                                       Serial.println("Picture taken!");
  
                                    // Create an image with the name IMAGE.JPG
                                       char filename[10];
                                       strcpy(filename, "IMAGE.JPG");
                                    // Open the file for writing
                                       File imgFile = SD.open(filename, FILE_WRITE);

                                    // Get the size of the image (frame) taken  
                                       uint16_t jpglen = cam.frameLength();
                                       Serial.print("Storing ");
                                       Serial.print(jpglen, DEC);
                                       Serial.print(" byte image.");

                                       int32_t time = millis();
                                       pinMode(4, OUTPUT);
                                       // Read all the data up to # bytes!
                                       byte wCount = 0; // For counting # of writes
                                     while (jpglen > 0) {
                                       // read 32 bytes at a time;
                                       uint8_t *buffer;
                                       uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
                                       buffer = cam.readPicture(bytesToRead);
                                       imgFile.write(buffer, bytesToRead);
                                       jpglen -= bytesToRead;
                                      }
                                       imgFile.close();
                                       time = millis() - time;
                                       Serial.println("done!");
                                       Serial.print(time); Serial.println(" ms elapsed");
                        
                                      webFile = SD.open("index.htm");       // open web page file
  */                                    
                                   }
        
      
          
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                }
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}

/**********************StrClear *********************/

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

/**********************StrContains *********************/

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}




// *********************
int freeRam ()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
};
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:11
Beitrag #20
RE: Ethernet-WebServer: Button-Belegung
Hi,
das hat mit Druck nichts zu tun, es macht einfach keinen Spaß.
Ruf bitte freeRam genau da auf, wo ich es im letzten Post gesagt habe. Dort wo Du es aufrufst, wird es nicht durchlaufen. Außerdem hatte ich gesagt, dass Du das Ergebnis über Serial ausgeben sollst.
Gruß,
Thorsten

Falls ich mit einer Antwort helfen konnte, wuerde ich mich freuen, ein paar Fotos oder auch ein kleines Filmchen des zugehoerigen Projekts zu sehen.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:16
Beitrag #21
RE: Ethernet-WebServer: Button-Belegung
Hier ist der Code mit freeRam()

Code:
/*--------------------------------------------------------------
          Arduino Ethernet Camera
Take a picture using the adafruit_vc0706 , save it on SD-Card
and print it over ethernet on a internet browser
                  Ulrich Engel
  CoAuthor:       W.A. Smith, http://startingelectronics.org
--------------------------------------------------------------*/

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Adafruit_VC0706.h>
#include <SoftwareSerial.h>  

// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   20
#define chipSelect 4

// MAC address from Ethernet shield sticker under board
byte mac[] = {0x90, 0xA2, 0xDA, 0x0F, 0x1E, 0x28};
IPAddress ip(192, 168, 178, 45); // IP address, may need to change depending on network
byte gateway[] = { 192, 168, 178, 1 };
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server(80);  // create a server at port 80
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer


SoftwareSerial cameraconnection = SoftwareSerial(2, 3);
Adafruit_VC0706 cam = Adafruit_VC0706(&cameraconnection);

//*************************** void setup ********************************

void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
    
// Open serial communications:
  Serial.begin(9600);

// start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();

  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());  

    
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
    
}

// **************  void loop  ***********************

void loop()
{
  EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)

               if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }

                // print HTTP request character to serial monitor
                Serial.print(c);
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
    freeRam();
            
                                   client.println("HTTP/1.1 200 OK");
                        client.println("Content-Type: text/html");
                        client.println("Connnection: close");
                        client.println();
                        webFile = SD.open("index.htm");        // open web page file
                    }

                    if (StrContains(HTTP_req, "GET /IMAGE.JPG")) {
                        webFile = SD.open("IMAGE.JPG");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();
                        }
                    }
          
          
          
               if (StrContains(HTTP_req, "GET /TakingPicture")) {
                              client.println("HTTP/1.1 200 OK");
                              client.println("Content-Type: text/html");
                             client.println("Connnection: close");
                             client.println();  
                        
                          Serial.println("Button -Take a Picture- pressed!");                        

  
                            
                          Serial.println("VC0706 Camera snapshot test");
                          Serial.println("");

/*                      
                              // Try to locate the camera
                             if (cam.begin()) {
                                 Serial.println("Camera Found:");
                              } else {
                                 Serial.println("No camera found?");
                                 return;
                               }

                               // Existing image remove
                         //      SD.remove("IMAGE.JPG");

                               // Set the picture size - you can choose one of 640x480, 320x240 or 160x120
                                  //cam.setImageSize(VC0706_640x480);        // biggest
                                  cam.setImageSize(VC0706_320x240);        // medium
                                  //cam.setImageSize(VC0706_160x120);          // small

                               // You can read the size back from the camera (optional, but maybe useful?)
                                  uint8_t imgsize = cam.getImageSize();
                                  if (imgsize == VC0706_640x480) Serial.println("640x480");
                                  if (imgsize == VC0706_320x240) Serial.println("320x240");
                                  if (imgsize == VC0706_160x120) Serial.println("160x120");

                                  Serial.println("Snap in 3 secs...");
                                    delay(3000);

                                   if (! cam.takePicture())
                                       Serial.println("Failed to snap!");
                                    else
                                       Serial.println("Picture taken!");
  
                                    // Create an image with the name IMAGE.JPG
                                       char filename[10];
                                       strcpy(filename, "IMAGE.JPG");
                                    // Open the file for writing
                                       File imgFile = SD.open(filename, FILE_WRITE);

                                    // Get the size of the image (frame) taken  
                                       uint16_t jpglen = cam.frameLength();
                                       Serial.print("Storing ");
                                       Serial.print(jpglen, DEC);
                                       Serial.print(" byte image.");

                                       int32_t time = millis();
                                       pinMode(4, OUTPUT);
                                       // Read all the data up to # bytes!
                                       byte wCount = 0; // For counting # of writes
                                     while (jpglen > 0) {
                                       // read 32 bytes at a time;
                                       uint8_t *buffer;
                                       uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
                                       buffer = cam.readPicture(bytesToRead);
                                       imgFile.write(buffer, bytesToRead);
                                       jpglen -= bytesToRead;
                                      }
                                       imgFile.close();
                                       time = millis() - time;
                                       Serial.println("done!");
                                       Serial.print(time); Serial.println(" ms elapsed");
                        
                                      webFile = SD.open("index.htm");       // open web page file
  */                                    
                                   }
        
      
          
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                }
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}

/**********************StrClear *********************/

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

/**********************StrContains *********************/

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}




// *********************
int freeRam ()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
};




Hier der Serial Monitor (ich sehe von freeRam nichts):

server is at 192.168.178.45
Initializing SD card...
SUCCESS - SD card initialized.
SUCCESS - Found index.htm file.
GET / HTTP/1.1
Host: 4711engel.ddns.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:19
Beitrag #22
RE: Ethernet-WebServer: Button-Belegung
Ist es denn wirklich so schwer zu verstehen: Du sollst das Ergebnis von freeRam() über Serial ausgeben. Ich glaube, dass ich das jetzt schon mehrfach erwähnt hatte.

Falls ich mit einer Antwort helfen konnte, wuerde ich mich freuen, ein paar Fotos oder auch ein kleines Filmchen des zugehoerigen Projekts zu sehen.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:22
Beitrag #23
RE: Ethernet-WebServer: Button-Belegung
Hatte ich nicht erwähnt, dass ich ein Anfänger bin. dann bitte klare angaben die auch anfänger verstehen.

Also wie gebe ich das Ergebnis von freeRam auf Serial aus? Sorry
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
07.06.2015, 15:24
Beitrag #24
RE: Ethernet-WebServer: Button-Belegung
Wer hat Dir denn das restliche Coding geschrieben? Vielleicht könntest Du den fragen? Ich bin davon ausgegangen, dass so gewisse Grundlagen schon vorhanden sind.
Na egal:
Code:
Serial.println(freeRam());

Falls ich mit einer Antwort helfen konnte, wuerde ich mich freuen, ein paar Fotos oder auch ein kleines Filmchen des zugehoerigen Projekts zu sehen.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
  Arduino UNO und Ethernet Shield 2 POE und Fritzbox 3272 tr3 2 148 19.11.2016 10:46
Letzter Beitrag: tr3
  ESP8266 ESP12-E Webserver-Frage Claus_M 8 236 14.11.2016 22:02
Letzter Beitrag: Claus_M
  Webserver + Bild als Hintergrund ?! Marc2014 8 244 11.10.2016 21:39
Letzter Beitrag: Bitklopfer
  Ethernet Modul Enc28j60 Pin13 LED Schalten BennIY 16 491 27.09.2016 20:30
Letzter Beitrag: BennIY
  ESP8266 Webserver Programmieren HDT 11 752 23.08.2016 13:28
Letzter Beitrag: HDT
  Hilfe gesucht. Webserver Statsiche und Dynamische HTMl Seite b3ta 11 447 22.08.2016 08:07
Letzter Beitrag: b3ta
  ESP8266 Webserver Marc2014 0 345 30.07.2016 20:15
Letzter Beitrag: Marc2014
Question Webserver, Client, Loop Marc2014 6 362 29.07.2016 21:04
Letzter Beitrag: Marc2014
Sad Die Grafik Kontakt/Pin Belegung ATtiny 85 malsehen 3 258 15.07.2016 19:31
Letzter Beitrag: hotsystems
  Frage zu One Button in Kombination mit Fast LED Wolfgang_2801 3 237 26.06.2016 22:11
Letzter Beitrag: hotsystems

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste