Guest User

Irw

a guest
Jul 28th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package tk.adamj57.RPiCenter;
  2.  
  3.  
  4.  
  5. import org.lirc.*;
  6.  
  7. /** Listens for IR signals and prints them to System.out.
  8.     Similar in function to the <code>irw</code> program
  9.     in the LIRC package.
  10.  
  11.     @version $Revision: 1.3 $
  12.     @author Bjorn Bringert ([email protected])
  13. */
  14. public class Irw {
  15.  
  16.     /** Prints a few lines of info. */
  17.     public static void printInstructions() {
  18.         System.out.println("The program will listen for IR signals on the lircd socket and print them.");
  19.         System.out.println("The lircd daemon must be running for the program to work.");
  20.     }
  21.  
  22.     /** Runs Irw, use <code>-ins</code> to display a few lines of
  23.         info when starting the program.
  24.     */
  25.     public static void main(String[] args) {
  26.         // check for -ins option
  27.         if (args.length > 0 && args[0].indexOf("ins") > -1) {
  28.             printInstructions();
  29.         }
  30.  
  31.         try {
  32.             Receiver rec = ReceiverFactory.createReceiver();
  33.             try {
  34.                 while (true) {
  35.                     System.out.println(rec.readCode());
  36.                 }
  37.             } finally {
  38.                 rec.close();
  39.             }
  40.         } catch (LIRCException ex) {
  41.             System.err.println(ex.toString());
  42.             System.exit(1);
  43.         }
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment