#!/usr/bin/perl
#
#
# Author: Bruce S. Garlock
# Date:   2002-09-11
# Requirements: Device::SerialPort 0.12 (from cpan)
#
# Version: 0.1
#
#
# Description:  This perl script is for logging of data from a serial
# port, to a specified logfile.  The logfile can then be parsed with
# other programs for reporting purposes.
# 
# This program was written for specifically logging Multitech's
# MTASR2-203 T1 Router.  The router outputs text to the command
# port with 57.6k, 8-1-N, and No flow control.
#
#

use Device::SerialPort 0.12;

$LOGDIR    = "/home/frida";              # path to data file
$LOGFILE   = "arduino.log";            # file name to output to
$PORT      = "/dev/usb/tts/1";          # port to watch

#
#
# Serial Settings
#
#

$ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!";
$ob->baudrate(4800)   || die "failed setting baudrate";
$ob->parity("none")    || die "failed setting parity";
$ob->databits(8)       || die "failed setting databits";
$ob->stopbits(1)       || die "failed setting stopbits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings    || die "no settings";

# read command line

$numArgs = $#ARGV + 1;

#print "$numArgs args given\n";
#foreach $argnum (0 .. $#ARGV) {
#  print "$argnum: $ARGV[$argnum]\n";
#}


#
# Send a string to the port
#
#

$pass=$ob->write("w $ARGV[0] $ARGV[1]\n");

undef $ob;
