Mac Serial Applications

I found a python serial modual which gives me all sorts of scripting capabilities that I didn't think of before, I'll report back if I have any success.

You can also easily do serial I/O from perl on the Mac. I have been logging some data from my Arduino with the code below. I based it heavily on a snippet I Googled...

#!/usr/bin/perl
use Device::SerialPort 0.12;

$LOGDIR    = "/Users/peterl/Projects";              # path to data file
$LOGFILE   = "plant.log";            # file name to output to
$PORT      = "/dev/tty.usbserial-A20e1evB";          # port to watch

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

# Send a string to the port
$pass=$ob->write("AT");
sleep 1;

# open the logfile, and Port

open(LOG,">>${LOGDIR}/${LOGFILE}")
    ||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n";

open(DEV, "<$PORT") 
    || die "Cannot open $PORT: $_";

select(LOG), $| = 1;      # set nonbufferd mode

# Loop forver, logging data to the log file
while($_ = <DEV>){        # print input device to file
      $theTime = `date`;
      chomp($theTime);
    print LOG $theTime . " - " . $_;
}

undef $ob;