rfxcom linux/perl
Posted: Sun May 13, 2007 10:59 pm
After some digging i found a piece of code that should work with the rfxcom and perl. However i have not tested this yet.
For the usb to work you need (to be safe) 2.6.9 or higher. It should be normally included in the kernel.
Anyone with some code under linux that works with the rfxcom, please share so we can have a bigger userbase/idea's.
Here is the piece of code:
#! /usr/bin/perl -w
use strict;
use Fcntl;
my $port = $ARGV[0];
print "Port: $port\n";
system("stty 4800 < $port");
system("stty -a < $port");
sysopen(RFXCOM, $ARGV[0], Fcntl::O_RDWR(), 0666) || die "ERROR: can not open $ARGV[0]\n";
my $timeout = 90;
my $inbuff = "";
my $char;
my $rin = "";
my $rout;
vec($rin, fileno(RFXCOM), 1) = 1;
while ((select($rout=$rin, undef, undef, $timeout)) && (!($inbuff =~ m/.+\n/))) {
sysread RFXCOM, $char, 1;
print "--$char--";
$inbuff .= $char;
}
if ($inbuff eq "") {
print "Error! Timed out waiting for input.\n";
}
else {
print "Got line:" . $inbuff . "";
}
For the usb to work you need (to be safe) 2.6.9 or higher. It should be normally included in the kernel.
Anyone with some code under linux that works with the rfxcom, please share so we can have a bigger userbase/idea's.
Here is the piece of code:
#! /usr/bin/perl -w
use strict;
use Fcntl;
my $port = $ARGV[0];
print "Port: $port\n";
system("stty 4800 < $port");
system("stty -a < $port");
sysopen(RFXCOM, $ARGV[0], Fcntl::O_RDWR(), 0666) || die "ERROR: can not open $ARGV[0]\n";
my $timeout = 90;
my $inbuff = "";
my $char;
my $rin = "";
my $rout;
vec($rin, fileno(RFXCOM), 1) = 1;
while ((select($rout=$rin, undef, undef, $timeout)) && (!($inbuff =~ m/.+\n/))) {
sysread RFXCOM, $char, 1;
print "--$char--";
$inbuff .= $char;
}
if ($inbuff eq "") {
print "Error! Timed out waiting for input.\n";
}
else {
print "Got line:" . $inbuff . "";
}