Advertisement
Guest User

Untitled

a guest
Nov 19th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use Device::SerialPort;
  4. use Sys::Syslog;
  5.  
  6. $interval = 180;
  7.  
  8. if (lc(@ARGV[0]) eq "test")
  9. {
  10. $test = true;
  11. if ($#ARGV == 1) {$interval = @ARGV[1];}
  12. }
  13.  
  14. $output = `/usr/bin/perl /usr/local/bin/svdrpsend NEXT rel`;
  15. if ($output =~ m/250\s(\d+)\s(-*\d+)/g)
  16. {
  17. $wakeuptime = $2;
  18. }
  19.  
  20. if ($test && defined $wakeuptime && $wakeuptime <= $interval)
  21. {
  22. $output = `/usr/bin/perl /usr/local/bin/svdrpsend LSTT $1`;
  23. if ($output =~ m/250\s\d+\s\d:\d+:[^:]+:(\d+):(\d+)/g)
  24. {
  25. $rec = ($2-$1)*60+$wakeuptime;
  26. print "recording:$rec\n";
  27. exit 1;
  28. }
  29. exit -1;
  30. }
  31. elsif ($test)
  32. {
  33. exit 0;
  34. }
  35.  
  36. if (defined $wakeuptime && $wakeuptime > 180)
  37. {
  38. $secs = $wakeuptime - 180;
  39. syslog('notice', "HTPC-Timer: $secs");
  40.  
  41. $out = pack("WL", ord('t'), $secs);
  42.  
  43. my $port = Device::SerialPort->new("/dev/ttyHTPC");
  44. $port->write($out);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement