Online embedded web-server demo

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
For anyone interested:

http://embeddedwebserver.net

Enjoy,
Wilfred

Re: Online embedded web-server demo

Hi Wilfred,
That's a very interesting approach. Are you actually embedding the C
compiler on the device, or it is all precompiled? What is the
footprint? What are the intended target platforms? Is this a new
company? Is this product for sale yet? How much?

Z-World also has a new scripting language for rapid web interface
development (for sale now for $149). It's called RabbitWeb. It runs on
Z-World/Rabbit Semiconductor platforms. It operates on program
variables and structures to eliminate complex CGI programming. Here's
the hangman program source code and HTML ported to RabbitWeb:


// <pre>
#define TCPCONFIG      1
#define USE_RABBITWEB  1

#use "dcrtcp.lib"
#use "http.lib"
#use "rand.lib"

#ximport "/hang.zhtml" index_html
#ximport "/hang0.gif"  hang0gif
#ximport "/hang1.gif"  hang1gif
#ximport "/hang2.gif"  hang2gif
#ximport "/hang3.gif"  hang3gif
#ximport "/hang4.gif"  hang4gif
#ximport "/hang5.gif"  hang5gif
#ximport "/hang6.gif"  hang6gif
#ximport "/hang.c"     csource

SSPEC_RESOURCETABLE_START
   SSPEC_RESOURCE_XMEMFILE("/", index_html),
   SSPEC_RESOURCE_XMEMFILE("/index.zhtml", index_html),
   SSPEC_RESOURCE_XMEMFILE("/hang.c", csource),
   SSPEC_RESOURCE_XMEMFILE("/hang0.gif", hang0gif),
   SSPEC_RESOURCE_XMEMFILE("/hang1.gif", hang1gif),
   SSPEC_RESOURCE_XMEMFILE("/hang2.gif", hang2gif),
   SSPEC_RESOURCE_XMEMFILE("/hang3.gif", hang3gif),
   SSPEC_RESOURCE_XMEMFILE("/hang4.gif", hang4gif),
   SSPEC_RESOURCE_XMEMFILE("/hang5.gif", hang5gif),
   SSPEC_RESOURCE_XMEMFILE("/hang6.gif", hang6gif)
SSPEC_RESOURCETABLE_END

SSPEC_MIMETABLE_START
   SSPEC_MIME_FUNC(".zhtml", "text/html", zhtml_handler),
   SSPEC_MIME(".html", "text/html"),
   SSPEC_MIME(".gif", "image/gif"),
   SSPEC_MIME(".c", "text")
SSPEC_MIMETABLE_END

struct Word
{
   char* clue;
   char* answer;
};

struct Word * wrd;
char guess[20], newGuess[40], prompt[80], hint[20];
int  noOfUsedGues, mode, currentgif, chr;

#web chr;
#web prompt
#web newGuess
#web noOfUsedGues
#web hint
#web currentgif
#web mode

const struct Word wordDB[] = {
   {"action", "drool"}, {"action", "forecast"}, {"action", "forget"},
   {"action", "jump"}, {"action", "panic"}, {"action", "quash"},
   {"action", "snore"}, {"action", "talk"}, {"action", "walk"},
   {"activity", "boating"}, {"activity", "repair"}, {"activity",
"ruffle"},
   {"activity", "sleep"},{"activity", "surfing"},
   {"animal", "aardvark"}, {"animal", "adder"}, {"animal", "beaver"},
   {"animal", "bison"}, {"animal", "cardinal"}, {"animal", "cariboo"},
   {"animal", "cat"}, {"animal", "donkey"}, {"animal", "elephant"},
   {"animal", "koala"}, {"animal", "otter"}, {"animal", "rabbit"},
   {"animal", "raccoon"}, {"animal", "rodent"}, {"animal", "shark"},
   {"animal", "sheep"}, {"animal", "squirrel"}, {"animal", "tiger"},
   {"antique", "china"},
   {"band", "nirvana"}, {"band", "rush"}, {"band", "ventures"},
   {"creature", "elf"},  {"creature", "hobbit"},  {"creature",
"mummy"},
   {"creature", "troll"},  {"creature", "unicorn"},  {"creature",
"vampire"},
   {"creature", "warewolf"}, {"drink", "cola"},
   {"drink", "juice"},
   {"event", "drama"}, {"event", "mirage"}, {"event", "siesta"},
   {"event", "stampede"},
   {"food", "apple"}, {"food", "butter"}, {"food", "caesar salad"},
   {"food", "cashew"}, {"food", "celery"},
   {"food", "cheese"}, {"food", "chestnut"},
   {"food", "cream"},  {"food", "donut"},
   {"food", "grape"}, {"food", "honey"},
   {"food", "icecream"}, {"food", "limburger"},
   {"food", "milk"}, {"food", "noodle"}, {"food", "orange"},
   {"food", "pasta"}, {"food", "pizza"}, {"food", "potato"},
   {"food", "spice"}, {"food", "sugar"}, {"food", "tomatoes"},
   {"food", "turnip"},
   {"game", "cards"}, {"game", "golf"}, {"game", "pacman"},
   {"icon", "barbie"}, {"icon", "frosty"}, {"icon", "grinch"},
   {"icon", "gumby"},  {"icon", "lucy"},  {"icon", "popeye"},
   {"icon", "snoopy"}, {"icon", "waldo"},
   {"invention", "velcro"},
   {"person", "enemy"}, {"person", "giant"}, {"person", "hero"},
   {"person", "husband"}, {"person", "kennedy"}, {"person", "nixon"},
   {"person", "youngster"},
   {"place", "amsterdam"}, {"place", "athens"},  {"place", "beach"},
   {"place", "bob"}, {"place", "buffalo"}, {"place", "calgary"},
   {"place", "canada"}, {"place", "detroit"}, {"place", "downtown"},
   {"place", "england"}, {"place", "gorge"}, {"place", "graceland"},
   {"place", "hotel"}, {"place", "hotel"}, {"place", "india"},
   {"place", "japan"}, {"place", "land"},  {"place", "library"},
   {"place", "london"}, {"place", "norway"}, {"place", "oslo"},
   {"place", "ottawa"}, {"place", "quadrant"},  {"place",
"restaurant"},
   {"place", "rink"}, {"place", "toronto"}, {"place", "victoria"},
   {"place", "village"}, {"place", "zoo"}, {"plant", "daffodil"},
   {"plant", "eggplant"}, {"plant", "ivy"}, {"plant", "spinach"},
   {"plant", "tulip"},
   , {"profession", "bard"},{"profession",
"hermit"},
   {"profession", "lawyer"}, {"profession", "sorcerer"},
   {"state", "alaska"},
   {"subject", "geography"},
   , {"taste", "salty"},
,,
   {"tool", "anvil"}, {"tool", "buffer"}, {"tool", "hook"}, {"tool",
"knife"},
   {"tool", "lasso"}, {"tool", "pickaxe"}, {"tool", "pliers"},
{"tool", "plow"},
   {"tool", "screwdriver"}, {"tool", "wrench"},
   {"toy", "kite"},{"toy", "slinky"},
   {"trouble", "tribble"}
};


main(){
   int chCorrect, i;

   mode = -1;
   sock_init();
   http_init();
   http_set_path("/", "index.zhtml");
   tcp_reserveport(80);

   while(1){
     if(mode== -1){
         InitGame();
         mode = 0;
     }

     http_handler();

     if(noOfUsedGues == 6){
         mode = 1;
         noOfUsedGues = 0;
         strcpy(hint,wrd->answer);
     }

     if(chr)  {
        chCorrect = 0;
        for(i = 0 ; i < strlen(wrd->answer) ; i++)  {
          if(wrd->answer[i] == (char)chr) {
             guess[i] = newGuess[2*i] = (char)chr;
             chCorrect = 1;
          }
        }
        if( !strcmpi(guess, wrd->answer) )
          noOfUsedGues = 7; /* 7 signals "You Won!!!" */
        else if(chCorrect == 0) {
          noOfUsedGues++;
          currentgif++;
        }
        sprintf(prompt,"You have %d guesses left!", 6-noOfUsedGues);
        chr = 0;
     }
  }
}

InitGame(){
    int wordDbIndex, i;

    rand16_init(MS_TIMER);
    wordDbIndex = rand16() % (sizeof(wordDB) / sizeof(wordDB[0]));
    wrd = &wordDB[wordDbIndex];
    for(i=0; i<strlen(wrd->answer); i++){
        newGuess[2*i] = '_';
        newGuess[2*i+1] = ' ';
    }
    newGuess[2*i] = 0;
    guess[strlen(wrd->answer)] = 0;
    strcpy(hint,wrd->clue);
    currentgif = 0;
    chr = 0;
    noOfUsedGues = 0;
    strcpy(prompt,"Guess your first letter of the above unknown
word.");
}
// </pre>


************************************
********* HTML SOURCE ************
***********************************

<html>
  <head><title> hangman </title></head>
  <body bgcolor="white" text="#000010" link="blue" vlink="#ff00ff"
link="#ffff00">

    <div align=center>
      <font color="#ff3333" size=+5>H</font>
      <font color="#cc6633" size=+5>a</font>
      <font color="#999900" size=+5>n</font>
      <font color="#33cc33" size=+5>g</font>
      <font color="#339999" size=+5>m</font>
      <font color="#3366cc" size=+5>a</font>
      <font color="#0033ff" size=+5>n</font>
    </div>

 <?z if($mode <= 0) { ?>
    <div align=center>
      <font size=+3 color="#336699">
      <?z if($mode == 0) { ?>
            <?z  echo($newGuess)) ?>
      <?z } ?>
      <?z if($noOfUsedGues == 7) { ?>
          <p>Game Over - You Win!</p>
      <?z } ?>
      </font>
    </div>
    <br/>
    <div align=center>
      <img src="./hang<?z echo($currentgif) ?>.gif" height="150"
width="150">
      
            <p><?z echo($prompt) ?></p>
        
          <font color="#0033ff">hint : <B><?z echo($hint)
?></b></font>
      <TABLE>
       <TR>
          <?z for($A97%; $A<123; $A++) { ?>
           <TD>
            <form action="./index.zhtml" method="post" >
            <input type="hidden" NAME="chr" VALUE="<?z echo($A) ?>">
            <input type="submit" value="<?z printf("%c",$A) ?>">
               </form>
        </TD>
        <?z } ?>
      </TR>
    </TABLE>
<?z } ?>

<?z if($mode==1) { ?>
    <div align=center>
      <font size=+3 color="#336699">
      <p><?z echo($newGuess) ?></p>
      </font>
    </div>
    <br/>
    <div align=center>
      <img src='./hang6.gif' height15%0 width15%0>
      
          <p>
            <font size=+3 color="#ff3333">
              Game over.
            </font>
          </p>
          <p>
            <font size=+2 color="#3333cc">
              The correct answer is <B><?z echo($hint) ?></B>.
            </font>
          </p>
<?z } ?>

      <form action="./index.zhtml" method="post" >
           <input type="hidden" NAME="mode" VALUE="-1">
            <input type="submit" value="Start New Game">
     </form>

      <p>
        <a href = "./hang.c" target="_blank">view C source code</a>
      </p>
      <p>
        <a href =
"http://www.rabbitsemiconductor.com/documentation/docs/modules/RabbitWeb/RabbitWeb.pdf "
Quoted text here. Click to load it
      </p>
    </div>
  </body>
</html>


www.rabbitsemiconductor.com
www.zworld.com
www.imaginetools.com

Re: Online embedded web-server demo
Quoted text here. Click to load it

The CSP and the C code generated by the CSP compiler is precompiled and
embedded into the executable. Read the white papers.

The link http://embeddedwebserver.net is to a Motorola Coldfire 5272
board, which is powered by MQX from ARC.

More info:
http://www.smxinfo.com/rtos/tcpip/barracuda/index.html
http://www.realtimelogic.com/products/barracuda/EmbeddedWebServer.html

Re: Online embedded web-server demo
Quoted text here. Click to load it

Cool stuff (except for the $10,000 price tag - ouch!). I'd have to
limit the RabbitWeb version to one player at a time because users
change program variables. Does a single Coldfire board handle mutliple
instances of the game for your demo or is there a bank of them?.

Re: Online embedded web-server demo

Quoted text here. Click to load it

Well, yes, that should be obvious.
How do you manage to mix up multiple instances of the game and the
hardware? Maybe you need to read up on web-development. You can start of
by reading this: http://www.embeddedwebserver.net/WP/CSP/index.html

The Old Saying Goes, RTFM


Re: Online embedded web-server demo
or:

http://stacktools.com:100


Quoted text here. Click to load it

Wilfred, enjoy!



Site Timeline