Wer hat 5 min zeit mein server zu testen?

Gast #1183977
Lesenswert?

Hallo zusammen ich hab auf der Embedded World eine EVA Bord von RABBIT 
bekommen, und test diesen gerade....

Hab einen Webserver mal darauf geladen....

Hier die Adresse:

http://australia-puls.serveftp.net/

und Hier sind Bilder von dem ding ->

http://www.australia-puls.de/IMG_1722.jpg
http://www.australia-puls.de/IMG_1726.jpg
http://www.australia-puls.de/IMG_1730.jpg

Ist nur ein kleines Programm mit 4 Buttons und 4 LEDs... einfach Drücken 
und dann müßte auf meinem Schreibtisch die LEDs an gehen ....

Ich hoffe die LEDs fangen gleich an zu Blinken


MFG Daniel
Gast #1184294
Lesenswert?

Ist alles in C geschrieben ....
1
/**********************************************************
2
   browseled.c
3

4
   Digi International, Copyright (C) 2008.  All rights reserved.
5

6
  This program is used with RCM57xx series controllers
7
  with Digital I/O accessory boards.
8

9
  Description
10
  ===========
11
  This program demonstrates a basic controller running a
12
  Web page. Four "device LED's" are created with four
13
  buttons to toggle  them.  Users can browse to the device
14
  and change the  status of the lights. The LED's on the
15
  base board will match the ones on the web page.
16

17
   This program is adapted from \Samples\TCPIP\ssi.c.
18

19
   Jumper settings (Digital I/O board)
20
   -----------------------------------
21
   JP7   2-4, 3-5
22

23

24
      1 o   o 2
25
            |
26
      3 o   o 4
27
        |
28
      5 o   o 6
29

30
      7 o   o 8
31

32

33
   JP5   1-2, 3-4, 5-6, 7-8
34
   JP8   1-2, 3-4, 5-6, 7-8
35

36
         2    4    6   8
37
         o    o    o   o
38
         |    |    |   |
39
         o    o    o   o
40
         1    3    5   7
41

42
  Instructions
43
  ============
44
  1. Make changes below in the configuration section to
45
     match your application.
46
  2. Compile and run this program.
47
   3. With your Web browser access the Web page running on
48
     the controller.
49
   4. View LEDS on Web page and the base board, DS1-DS4,
50
      to see that  they match-up when changing them via the
51
      Web page control button.
52

53
**********************************************************/
54
#class auto
55

56
#define DS1 4
57
#define DS2 5
58
#define DS3 6
59
#define DS4 7
60

61
#define USERLED 0
62
#define ON  0
63
#define OFF 1
64

65
/***********************************
66
 * Configuration Section           *
67
 * ---------------------           *
68
 * All fields in this section must *
69
 * be altered to match your local  *
70
 * network settings.               *
71
 ***********************************/
72
/*
73
 * NETWORK CONFIGURATION
74
 * Please see the function help (Ctrl-H) on TCPCONFIG for instructions on
75
 * compile-time network configuration.
76
 */
77
#define TCPCONFIG 1
78

79
/*
80
 * TCP/IP modification - reduce TCP socket buffer
81
 * size, to allow more connections. This can be increased,
82
 * with increased performance, if the number of sockets
83
 * are reduced.  Note that this buffer size is split in
84
 * two for TCP sockets--1024 bytes for send and 1024 bytes
85
 * for receive.
86
 */
87
#define TCP_BUF_SIZE 2048
88

89
/*
90
 * Web server configuration
91
 */
92

93
/*
94
 * Define the number of HTTP servers and socket buffers.
95
 * With tcp_reserveport(), fewer HTTP servers are needed.
96
 */
97
#define HTTP_MAXSERVERS 2
98
#define MAX_TCP_SOCKET_BUFFERS 2
99

100
/*
101
 * Our web server as seen from the clients.
102
 * This should be the address that the clients (netscape/IE)
103
 * use to access your server. Usually, this is your IP address.
104
 * If you are behind a firewall, though, it might be a port on
105
 * the proxy, that will be forwarded to the Rabbit board. The
106
 * commented out line is an example of such a situation.
107
 */
108

109
/********************************
110
 * End of configuration section *
111
 ********************************/
112

113
/*
114
 *  REDIRECTTO is used by each ledxtoggle cgi's to tell the
115
 *  browser which page to hit next.  The default REDIRECTTO
116
 *  assumes that you are serving a page that does not have
117
 *  any address translation applied to it.
118
 *
119
 */
120

121
#define REDIRECTTO     myurl()
122

123
#memmap xmem
124
#use "dcrtcp.lib"
125
#use "http.lib"
126

127
/*
128
 *  Notice that we have ximported in the source code for
129
 *  this program.  This allows us to <!--#include file="ssi.c"-->
130
 *  in the pages/showsrc.shtml.
131
 *
132
 */
133

134
#ximport "pages/browseled.shtml" index_html
135
#ximport "pages/rabbit1.gif"      rabbit1_gif
136
#ximport "pages/ledon.gif"        ledon_gif
137
#ximport "pages/ledoff.gif"       ledoff_gif
138
#ximport "pages/button.gif"       button_gif
139
#ximport "pages/showsrc.shtml"    showsrc_shtml
140
#ximport "browseled.c"            browseled_c
141

142

143
/*
144
 *  In this case the .html is not the first type in the
145
 *  type table.  This causes the default (no extension)
146
 *  to assume the shtml_handler.
147
 *
148
 */
149

150
/* the default for / must be first */
151
SSPEC_MIMETABLE_START
152
   SSPEC_MIME_FUNC( ".shtml", "text/html", shtml_handler), // ssi
153
   SSPEC_MIME( ".html", "text/html"),           // html
154
   SSPEC_MIME( ".cgi", ""),                     // cgi
155
   SSPEC_MIME( ".gif", "image/gif")
156
SSPEC_MIMETABLE_END
157

158
/*
159
 *  Each ledx contains a text string that is either
160
 *  "ledon.gif" or "ledoff.gif"  This string is toggled
161
 *  each time the ledxtoggle.cgi is requested from the
162
 *  browser.
163
 *
164
 */
165
char led1[15];
166
char led2[15];
167
char led3[15];
168
char led4[15];
169

170
/*
171
 *  Instead of sending other text back from the cgi's
172
 *  we have decided to redirect them to the original page.
173
 *  the cgi_redirectto forms a header which will redirect
174
 *  the browser back to the main page.
175
 *
176
 */
177
char *myurl() {
178
  static char URL[64];
179
   char tmpstr[32];
180
   long ipval;
181

182
   ifconfig(IF_DEFAULT, IFG_IPADDR, &ipval, IFS_END);
183
   sprintf(URL, "http://%s/index.shtml", inet_ntoa(tmpstr, ipval));
184
   return URL;
185
}
186

187
/*
188
 *  These ledXtoggle functions are called when buttons images
189
 *  in on the SHTML page are clicked. They toggle the LED images
190
 *  between lit LED and unlit LED images.
191
 *
192
 */
193
int led1toggle(HttpState* state)
194
{
195
   if (strcmp(led1,"ledon.gif")==0) {
196
      strcpy(led1,"ledoff.gif");
197
   }
198
   else {
199
      strcpy(led1,"ledon.gif");
200
   }
201
   cgi_redirectto(state,REDIRECTTO);
202
   return 0;
203
}
204

205
int led2toggle(HttpState* state)
206
{
207
   if (strcmp(led2,"ledon.gif")==0) {
208
      strcpy(led2,"ledoff.gif");
209
   }
210
   else  {
211
      strcpy(led2,"ledon.gif");
212
   }
213
   cgi_redirectto(state,REDIRECTTO);
214
   return 0;
215
}
216

217
int led3toggle(HttpState* state)
218
{
219
   if (strcmp(led3,"ledon.gif")==0) {
220
      strcpy(led3,"ledoff.gif");
221
   }
222
   else {
223
      strcpy(led3,"ledon.gif");
224
   }
225
   cgi_redirectto(state,REDIRECTTO);
226
   return 0;
227
}
228

229
int led4toggle(HttpState* state)
230
{
231
   if (strcmp(led4,"ledon.gif")==0) {
232
      strcpy(led4,"ledoff.gif");
233
   }
234
   else {
235
      strcpy(led4,"ledon.gif");
236
   }
237
   cgi_redirectto(state,REDIRECTTO);
238
   return 0;
239
}
240

241
SSPEC_RESOURCETABLE_START
242
   SSPEC_RESOURCE_XMEMFILE("/", index_html),
243
   SSPEC_RESOURCE_XMEMFILE("/index.shtml", index_html),
244
   SSPEC_RESOURCE_XMEMFILE("/showsrc.shtml", showsrc_shtml),
245
   SSPEC_RESOURCE_XMEMFILE("/rabbit1.gif", rabbit1_gif),
246
   SSPEC_RESOURCE_XMEMFILE("/ledon.gif", ledon_gif),
247
   SSPEC_RESOURCE_XMEMFILE("/ledoff.gif", ledoff_gif),
248
   SSPEC_RESOURCE_XMEMFILE("/button.gif", button_gif),
249

250
   SSPEC_RESOURCE_XMEMFILE("browseled.c", browseled_c),
251

252
   SSPEC_RESOURCE_ROOTVAR("led1", led1, PTR16, "%s"),
253
   SSPEC_RESOURCE_ROOTVAR("led2", led2, PTR16, "%s"),
254
   SSPEC_RESOURCE_ROOTVAR("led3", led3, PTR16, "%s"),
255
   SSPEC_RESOURCE_ROOTVAR("led4", led4, PTR16, "%s"),
256

257
   SSPEC_RESOURCE_FUNCTION("/led1tog.cgi", led1toggle),
258
   SSPEC_RESOURCE_FUNCTION("/led2tog.cgi", led2toggle),
259
   SSPEC_RESOURCE_FUNCTION("/led3tog.cgi", led3toggle),
260
   SSPEC_RESOURCE_FUNCTION("/led4tog.cgi", led4toggle)
261
SSPEC_RESOURCETABLE_END
262

263
/*
264
 *  Update the LEDs on the Digital I/O board to match
265
 *  the images chosen in the browser.
266
 *
267
 */
268
void update_outputs()
269
{
270
  if (strcmp(led1,"ledon.gif")) {
271
    BitWrPortI(PADR, &PADRShadow, OFF, DS1);
272
   }
273
   else {
274
    BitWrPortI(PADR, &PADRShadow, ON, DS1);
275
   }
276
  if (strcmp(led2,"ledon.gif")) {
277
    BitWrPortI(PADR, &PADRShadow, OFF, DS2);
278
   }
279
   else {
280
    BitWrPortI(PADR, &PADRShadow, ON, DS2);
281
   }
282
  if (strcmp(led3,"ledon.gif")) {
283
    BitWrPortI(PADR, &PADRShadow, OFF, DS3);
284
   }
285
   else {
286
    BitWrPortI(PADR, &PADRShadow, ON, DS3);
287
   }
288
  if (strcmp(led4,"ledon.gif")) {
289
    BitWrPortI(PADR, &PADRShadow, OFF, DS4);
290
   }
291
   else {
292
    BitWrPortI(PADR, &PADRShadow, ON, DS4);
293
   }
294
}
295

296
main()
297
{
298
   // Set Port A pins for LEDs low
299
   BitWrPortI(PADR, &PADRShadow, 1, DS1);
300
   BitWrPortI(PADR, &PADRShadow, 1, DS2);
301
   BitWrPortI(PADR, &PADRShadow, 1, DS3);
302
   BitWrPortI(PADR, &PADRShadow, 1, DS4);
303

304
   // Make Port A bit-wide output
305
   BitWrPortI(SPCR, &SPCRShadow, 1, 2);
306
   BitWrPortI(SPCR, &SPCRShadow, 0, 3);
307

308
   strcpy(led1,"ledon.gif");
309
   strcpy(led2,"ledoff.gif");
310
   strcpy(led3,"ledon.gif");
311
   strcpy(led4,"ledoff.gif");
312

313
   sock_init();
314
   http_init();
315
   tcp_reserveport(80);
316

317
   while (1)
318
   {
319
     update_outputs();
320
      http_handler();
321

322
  }
323
}
#1185140
Lesenswert?

Der Redirect nach nem Drücken einer Taste haut nid hin ... das scheint 
wohl bei dir ne lokale Netzwerkadresse zu sein, die nach außen hin nicht 
aufgelöst wird.

die IP deines Servers: 91.21.125.254
redirect auf: 192.168.2.36

Vllt. auch nen clientseitiges Cachen erzwingen, der scheint nämlich alle 
Bilder neu zu laden.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren