You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
973 B

#!/usr/bin/perl -w
# getArduino.pl
#
# Based on Original Perl code by Paul Mutton.
# See http://www.jibble.org/currentcost/
# which was then Updated for CC128 by Mark E Taylor. April 2009.
# http://metphoto.homeunix.net/met_current/
# http://metphoto.net
#Adapted to read the USB serial port on an Arduino Nano clone
# by Tardus, November 2013, http://tardus.net
# this straightup doesn't do anything. - steak
use strict;
use Device::SerialPort qw( :PARAM :STAT 0.07 );
# port now passed via argument to this script, typically ttyUSB0 or ttyUSB1
print "$ARGV[0]\n";
#my $PORT = "/dev/ttyUSB0";
my $PORT = "$ARGV[0]";
my $ob = Device::SerialPort->new($PORT);
$ob->baudrate(9600); # default speed for Arduino serial over USB
#$ob->databits(8);
#$ob->parity("none");
#$ob->stopbits(1);
$ob->write_settings;
open(SERIAL, "+>$PORT");
while (my $line = <SERIAL>) {
open (DATFILE, '>>./arduino.dat');
print DATFILE "$line" ;
close (DATFILE);
}