Created
July 25, 2013 10:38
-
-
Save jsleeio/6078594 to your computer and use it in GitHub Desktop.
Requires Device::SerialPort module from CPAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
use Device::SerialPort; | |
my $file = "/dev/tty.usbserial-A700fbpg"; | |
my $ob = Device::SerialPort->new ($file) || die "Can't open $file: $!"; | |
$ob->baudrate(9600) || die "fail setting baudrate"; | |
$ob->parity("none") || die "fail setting parity"; | |
$ob->databits(8) || die "fail setting databits"; | |
$ob->stopbits(1) || die "fail setting stopbits"; | |
$ob->handshake("none") || die "fail setting handshake"; | |
$ob->write_settings || die "no settings"; | |
$ob->error_msg(1); # use built-in error messages | |
$ob->user_msg(1); | |
while(1) { | |
$ob->write("p"); | |
print $ob->input; | |
sleep 5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment