Author Topic: Remotely controlled car  (Read 1988 times)

0 Members and 1 Guest are viewing this topic.

Offline dan87Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Remotely controlled car
« on: January 03, 2011, 06:07:13 PM »
Hello Guys,

I am building a remotely controlled car using the rabbit microcontroller RCM 3710. Basically I want to communicate with the rabbit through a router.

Now I configured the rabbit as an http server to listen for http traffic from a web browser "client" through a socket. I want to know how this can be done.

I think that i should connect the rabbit using ethernet to the router and to communicate using (through wifi) http but I don't know how to program this what I did is the following:

Code: [Select]
#class auto

#define _PRIMARY_STATIC_IP  "10.10.6.100"
#define _PRIMARY_NETMASK "255.255.255.0"

#define TCPCONFIG 1                // Default configuration of tcpip
#define SWFPORT 3333
#define SOCK_BUF_SIZE 16384
#define MAX_SOCKETS 8
#define TIMEZONE +3

#use "dcrtcp.lib"                  // bring in tcp/ip libraries
#use "http.lib"     // Bring http library
#use "hobbyist.lib" // Check!!

#ximport "Other TCP_IP Samples/pages/static.html"  index_html
#ximport "Other TCP_IP Samples/pages/rabbit1.gif" rabbit1_gif

SSPEC_MIMETABLE_START
   SSPEC_MIME(".html", "text/html"),
   SSPEC_MIME(".gif", "image/gif")
SSPEC_MIMETABLE_END

SSPEC_RESOURCETABLE_START
   SSPEC_RESOURCE_XMEMFILE("/index.html", index_html),
   SSPEC_RESOURCE_XMEMFILE("/rabbit1.gif", rabbit1_gif)
SSPEC_RESOURCETABLE_END

#define SW_ON 0
#define SW_OFF 1

void main()
{
   int i;
   float spd;
   int dir1, dir2, MotorUpdate;

   HBmotorInit(); //move it

   spd = 0.0;
   dir1 = dir2 = 1;
   MotorUpdate = 1;

   sock_init();                    // initialize the stack
   http_init();

   tcp_reserveport(3333);

   for (;;)                        // create an endless loop while(1)
   {
      http_handler();
   }
}

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Remotely controlled car
« Reply #1 on: January 04, 2011, 05:14:39 AM »
If your rabbit is configured as an http server you should not need to program anything provided you have working network connection, wired or wireless, between the rabbit and client. You just start the browser on the client computer and enter http://10.10.6.100:3333/ in the address bar (where 10.10.6.100 is the IP of your rabbit and 3333 is the port it listens on - values taken from your code below).

The problem is likely to be getting a working network connection. The easiest way for an initial test would be to use a crossover cable to connect your client computer directly to the rabbit. If you are connecting via a router you will probably need to have the the router set the rabbit's IP address by DHCP (if the rabbit supports this) or manually configure your router to assign the rabbit a fixed IP, then change the rabbit's IP to match.

Offline dan87Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: Remotely controlled car
« Reply #2 on: January 06, 2011, 04:16:27 PM »
But I need to program the rabbit as an http server first...

ok here it's in simple words. I need to publish data sent from an http client to the http server "The rabbit" to a webpage using the http post method continuously

So as soon as the server gets a new data it should be posted to the webpage

hope it's clear now 

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Remotely controlled car
« Reply #3 on: January 06, 2011, 05:33:08 PM »
Apologies - With the code you posted and the way the question was worded it looked like you already have webserver code and were looking for help with the connection side... simple words are more my level :)

A quick google led me to RabbitWeb, which would appear to do everything you need with sample code available etc. This .PDF contains examples for dynamic web pages and you should be able to make tweaks to do what you want.

HTH 

Offline dan87Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: Remotely controlled car
« Reply #4 on: January 06, 2011, 07:32:32 PM »
So after reading this....

it will be done in the following way:

1. tcp/ip stack will be initialized
2. RabbitWeb will be initialized "HTTP Server"
3. http.lib will be called
4. the Rabbit Web will listen using tcp socket for incoming data
5. data is parsed and saved in a buffer

then

6. zhtml page will be written with scripts to check for the buffer
7. buffer will be posted to the page

is this correct???

one last thing how could I read the data posted on the webpage to be logged to a mysql database.

thanks guys,,,

Offline dan87Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: Remotely controlled car
« Reply #5 on: January 07, 2011, 11:15:54 AM »
Any help guys will be appreciated  :'(

 


Get Your Ad Here

data_list