Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # get_gsm_signal.pl
- # jp - 01082013
- # Connects to wavecom gsm modem on /dev/ttyS0.
- # Issues AT+CSQ command to get RSSI and BER
- # Outputs ready for collection by cacti.
- use Device::Modem;
- my $modem = new Device::Modem( port => '/dev/ttyS0' );
- if( $modem->connect( baudrate => 9600 ) ) {
- } else {
- print "sorry, no connection with serial port!\n";
- }
- # Reset the modem, then send in the AT commands.
- # Use the builtin carriage return function - or have a bad time.
- $modem->atsend( 'AT+CSQ' . Device::Modem::CR );
- $csq = $modem->answer();
- # Some wrangling - its content over style I'm afraid
- $csq =~ s/OK//g;
- # Remove all newline chars to get sensible output.
- $csq =~ s/\r\n//g;
- $csq =~ s/^\+CSQ\:\ //;
- my($sig, $ber) = split(/,/, $csq, 2);
- # Finally output in a format that cacti expects
- print "SIG:$sig BER:$ber\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement