Perl serial terminal scripts

We have a few commands which we can send to our onboard xbee controller.  We can ping the balloon, repeat a message, request information, and set settings.  These commands are typed in a normal serial terminal (like putty), and this keeps everything simple.  We don’t NEED special ground software.  But I started thinking, it would be nice be able to write command macros.  For example, say we are searching for the balloon.  What would be great is a script that sends the ping command every second until it gets a response (until he balloon is in range).   For this Matt Krass suggested Perl, and for once I agreed with him.  It will give us the ability to write short little scripts to automate certain commands to the balloon.  So far I put together a script for range testing which repeats the ping command to give us a constant stream of RSSI reports.  The only issue I have been having is it seems to be a little finicky about connecting to the serial port – it seems to be very very sensitive to the usb connection.  I will have to investigate.

I am using the Win32::SerialPort module.  Here is a simple example for windows (COM instead of tty):

use Win32::SerialPort;
my $port = Win32::SerialPort->new("COM5");
$port->baudrate(9600);
$port->databits(8);
$port->parity("none");
$port->stopbits(1);

while (1)
{
  my $c = $port->lookfor();
if($c)
 print $c . "\n";
}
Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent News
News Archives