Audio::Radio::XM::PCR - Perl extension for the XM PCR Radio
use Audio::Radio::XM::PCR; my $radio = new Audio::Radio::XM::PCR; $radio->open; # Basic $radio->tune(8); # Listen For a while sleep(900); # Advanced $radio->set_trigger('artist_title_changed', \&print_info); # Run for an hour my $time = time; my $end_time = $time + 3600; while (1) { my $now = time; if ($now > $end_time) { last; } $radio->monitor; } $radio->close; sub print_info { my $channel = $radio->{'current_channel'}; my $artist = $radio->{'channels'}->{$channel}->{'artist'}; my $title = $radio->{'channels'}->{$channel}->{'title'}; my $length = $radio->{'channels'}->{$channel}->{'remaining'}; my $minutes = int $length/60; my $seconds = $length % 60; print "$channel $artist - $title - $minutes:$seconds"; }
The XM PCR Radio is a USB serial device.
We use the following modules: Device::SerialPort - Unix/Linux Win32::SerialPort - Windows
Peter Bowen, <peter-radio@bowenfamily.org>
Special thanks to others who figured out the protocol. I'm definately standing on the shoulders of giants.
Copyright (C) 2004 by Peter Bowen
XM, XM Direct, and PCR are trademarks of XM Sattelite Radio. Windows is a trademark of Microsoft Corp.
Use of this library may be limited by the XM Service and Subscription Terms availalble at http://www.xmradio.com/get_xm/customer_service.html.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
To install Audio::Radio::XM::PCR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Audio::Radio::XM::PCR
CPAN shell
perl -MCPAN -e shell install Audio::Radio::XM::PCR
For more information on module installation, please visit the detailed CPAN module installation guide.