Shop OBEX P1 Docs P2 Docs Learn Events
Red-i Web Server info — Parallax Forums

Red-i Web Server info

Jeff B.Jeff B. Posts: 8
edited 2005-10-17 01:57 in BASIC Stamp
I found there was very little info on the Red-i Web Server on this forum. But for a while, this was the premier Ethernet solution from Parallax and several customers may have purchased this product. So, I've spent a few days hacking away at this Web Server. If anyone wants to control this product programatically from a PC or Linux box, this script may help you.

Regards, Jeff



#!/usr/bin/perl -w
#
# This code sends text to one of the common memory variables on the Red-i Web Server using
# Perl. All that is required is the basic IO::Socket module, which most installations include
# This allows one to mechanize interaction with the Red-i via a PC, Mac or Linux box.
# The code is written to use varaible Ri_var1X where X is the first argument and the data to
# put into the variable is the second argument. Thus, this would work for Ri_var10 through Ri_var19.
#
# Even though the Red-i has been discontinued because RedPoint controls is no longer in business,
# this code will help anyone out there who needs to programatically interact with an existing
# Red-i. Unfortunately, there was very little documentation on the Red-i, so I reverese engineered
# the transaction between the Red-i and a typical browser. The Red-i does not issue standard response
# headers that most web servers do, therefore Perl modules like WWW::Mechanize and LWP::UserAgent do
# not work because they can't see the form returned by the Red-i. Thus, this program goes to the Socket
# level and simply feeds the Red-i what it wants. It would be interesting to interact with the
# Red-i UDP interface as well, but again there was very little documentation, so I did not spend
# the time to do this. I hope this helps save someone the time that I had to spend on this.
# Regards,
#
# Jeff Boly, 10/16/2005, jboly .AT. teammojo.org

# declare Perl module needed for TCP/IP Socket interaction
use IO::Socket::INET;

# set host, use IP so no DNS lookup required. Port 80 for http
my $remote_host = '192.168.1.20';
my $remote_port = '80';

# open socket, use TCP and STREAM
$socket = IO::Socket::INET->new(PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM)
or die "Couldn't connect to $remote_host:$remote_port : $!\n";

# setup new line behavior so we can use $CR, $LF, $CRLF instead of \n and \r
use Socket qw([noparse]:D[/noparse]EFAULT :crlf);

# send variable and value to Red-i webserver over the socket,
# note that all the Red-i needs to see is the POST, Content-Length, a blank line and then the value
print $socket "POST /index.htm HTTP/1.1$CRLF";
print $socket "Content-Length: 1$CRLF";
print $socket "$CRLF";
print $socket "Ri_var1$ARGV[noparse][[/noparse]0]=$ARGV";

# read the remote answer, until the whole page comes back.
while ( <$socket>)
{print};

# and terminate the connection when we're done.
close($socket);

# Could add parsing below to do something with the results, etc.

Post Edited (Jeff B.) : 10/16/2005 10:30:14 PM GMT

Comments

  • Ken GraceyKen Gracey Posts: 7,387
    edited 2005-10-17 01:57
    Jeff,

    We've got a superior product almost ready for release: Parallax Internet Development Kit. Sorry the Red-I supply fell apart on us - it was a pain for many customers when our supplier stopped making these units.

    More to follow, within ten days or so.

    Ken Gracey
    Parallax, Inc.
Sign In or Register to comment.