Forum: Mikrocontroller und Digitale Elektronik LWIP: SSI Handler funktioniert nicht


von Entwickler (Gast)


Lesenswert?

Hi,

auf einem STM32 Mikrocontroller läuft der Lwip Stack mit einer Http 
Webserver Applikation. Der CGI Handler funktioniert. Es scheitert noch 
am SSI Handler.

Webseite Datei: index.html
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html>
3
  <meta http-equiv="refresh" content="1">
4
  
5
  <head>
6
    <title>Webserver</title>
7
  </head>
8
  
9
  <body>
10
    <h1>Webserver</h1>
11
  </body>
12
  
13
  <td><!--#t--> <small><span style="font-family: Verdana;">Value</span></small> </td>
14
15
  
16
</html>

STM32 Quellcode von der Datei: httpd_cgi_ssi.c
1
#include "httpd.h"
2
#include "../lwip_v1.3.2/src/include/lwip/tcp.h"
3
#include "fs.h"
4
5
#include <string.h>
6
#include <stdlib.h>
7
8
tSSIHandler ADC_Page_SSI_Handler;
9
10
/* we will use character "t" as tag for CGI */
11
char const* TAGCHAR="t";
12
char const** TAGS=&TAGCHAR;
13
14
/* CGI handler for LED control */
15
const char * LEDS_CGI_Handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[]);
16
17
/* Html request for "/Leds.cgi" will start LEDS_CGI_Handler */
18
const tCGI LEDS_CGI={"/Leds.cgi", LEDS_CGI_Handler};
19
20
/* Cgi call table, only one CGI used */
21
tCGI CGI_TAB[1];
22
23
char led=0;
24
25
/**
26
  * @brief  Send_Value_Handler : SSI handler for Send value page
27
  */
28
u16_t ADC_Handler(int iIndex, char *pcInsert, int iInsertLen)
29
{
30
  /* We have only one SSI handler iIndex = 0 */
31
  if (iIndex ==0)
32
  {
33
   char Digit1=0, Digit2=0, Digit3=0, Digit4=0;
34
   unsigned long ADCVal = 0x1234; // Beispielwert - ADC wurde hier deaktiviert bzw. nicht verwendet
35
36
   /* convert to Voltage,  step = 0.8 mV */
37
   ADCVal = (unsigned long)(ADCVal * 0.8);
38
39
   /* get digits to display */
40
41
   Digit1= ADCVal/1000;
42
   Digit2= (ADCVal-(Digit1*1000))/100 ;
43
   Digit3= (ADCVal-((Digit1*1000)+(Digit2*100)))/10;
44
   Digit4= ADCVal -((Digit1*1000)+(Digit2*100)+ (Digit3*10));
45
46
   /* prepare data to be inserted in html */
47
   *pcInsert       = (char)(Digit1+0x30);
48
   *(pcInsert + 1) = (char)(Digit2+0x30);
49
   *(pcInsert + 2) = (char)(Digit3+0x30);
50
   *(pcInsert + 3) = (char)(Digit4+0x30);
51
52
     /* 4 characters need to be inserted in html*/
53
     return 4;
54
  }
55
  return 0;
56
}
57
58
/**
59
  * @brief  CGI handler for LEDs control
60
  */
61
const char * LEDS_CGI_Handler(int iIndex, int iNumParams, char *pcParam[], char *pcValue[])
62
{
63
  unsigned long i=0;
64
65
  /* We have only one SSI handler iIndex = 0 */
66
  if (iIndex==0)
67
  {
68
    /* Check cgi parameter : example GET /leds.cgi?led=2&led=4 */
69
    for (i=0; i<iNumParams; i++)
70
    {
71
      /* check parameter "led" */
72
      if (strcmp(pcParam[i] , "led")==0)
73
      {
74
        /* switch led1 ON if 1 */
75
        if(strcmp(pcValue[i], "1") ==0)
76
          led = 1;
77
78
        /* switch led2 ON if 2 */
79
        else if(strcmp(pcValue[i], "2") ==0)
80
          led = 2;
81
82
        /* switch led3 ON if 3 */
83
        else if(strcmp(pcValue[i], "3") ==0)
84
          led = 3;
85
      }
86
    }
87
  }
88
  /* uri to send after cgi call*/
89
  return "/index.html";
90
}
91
92
/**
93
 * Initialize SSI handlers
94
 */
95
void httpd_ssi_init(void)
96
{
97
    /* configure SSI handlers (Send value page SSI) */
98
    http_set_ssi_handler(ADC_Handler, (char const **)TAGS, 1);
99
}
100
101
/**
102
 * Initialize CGI handlers
103
 */
104
void httpd_cgi_init(void)
105
{
106
  /* configure CGI handlers (LEDs control CGI) */
107
  CGI_TAB[0] = LEDS_CGI;
108
  http_set_cgi_handlers(CGI_TAB, 1);
109
}

Eigentlich müsste stndig der ADC_Handler ausgeführt werden. Bei mir wird 
der ADC_Handler nicht ausgeführt. WOran könnte dies liegen ?

von Entwickler (Gast)


Lesenswert?

Hab das Problem nun gefunden. Die HTML Skriptdatei muss die Endung 
.shtml haben.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.