Skip to content
ndphuPublic
forked from chbmuc/lirc

About

lirc.go - a library to send and receive via lircd

Resources

Stars

0 stars

Watchers

1 watching

Forks

 
 

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

LIRC

Go client for Linux Infrared Remote Control (LIRC) package

Usage

package main

import (
  "github.com/chbmuc/lirc"
  "log"
  "time"
)

func keyPower(event lirc.Event) {
  log.Println("Power Key Pressed")
}

func keyTV(event lirc.Event) {
  log.Println("TV Key Pressed")
}

func keyAll(event lirc.Event) {
  log.Println(event)
}

func main() {
  // Initialize with path to lirc socket
  ir, err := lirc.Init("/var/run/lirc/lircd")
  if err != nil {
    panic(err)
  }

  // Receive Commands

  // attach key press handlers
  ir.Handle("", "KEY_POWER", keyPower)
  ir.Handle("", "KEY_TV", keyTV)
  ir.Handle("", "", keyAll)

  // run the receive service
  go ir.Run()

  // Send Commands
  reply := ir.Command(`LIST DenonTuner ""`)
  log.Println(reply.DataLength, reply.Data)

  err = ir.Send("DenonTuner PROG-SCAN")
  if err != nil {
    log.Println(err)
  }
  err = ir.SendLong("DenonTuner VOL-DOWN", time.Duration(time.Second * 3))
  if err != nil {
    log.Println(err)
  }
}

About

lirc.go - a library to send and receive via lircd

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages