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

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