Linux LIRC with an Arduino
#1
Question 
I set up my IR receiver on my Arduino (Sparkfun Pro Micro) and have it sucessfully sending back the IR commands (when the serial port is open). This works great when viewing the commands through a serial console. It presents itself as /dev/ttyACM0. However, I'm having trouble setting it up with LIRC. I think that I may need to emulate another type of device the Pro Micro, but if so, then what? I got a little input once using the usbx driver (and irrecord), but now it doesn't do anything.

setserial output:
Code:
/dev/ttyACM0, UART: unknown, Port: 0x0000, IRQ: 0, Flags: low_latency

I haven't ever used LIRC before, but I'm tired of using the control apps. I plan to use the key commands from an old DVD player remote and then program that into my Logitech Harmony remote.

I'll have to go forum-hopping if I don't get the solution here, so any help is appreciated.

OpenSUSE 13.2 i586
Kernel 3.16.7-21-desktop
Intel Dual Core T2300 @ 1.66GHz
Dell Laititude D620 in dock (Pro Micro attached via USB to dock)
Sparkfun Pro Micro at 115200 baud
Kodi 15.0 (that doesn't matter yet though)
XBMC Kodi is awesome!
Image
Reply
#2
So I had more luck with usbx this time, but now I have another problem. I successfully used irrecord to create a config file, which I moved to /etc/lirc/lircd.conf, but when I either start lirc from the command line (as root) or with the service, I get no output from irw.

/etc/lircd.conf:
Code:
# Please make this file available to others
# by sending it to <[email protected]>
#
# this config file was automatically generated
# using lirc-0.9.0(usbx) on Wed Aug  5 14:44:14 2015
#
# contributed by
#
# brand:                       lircd.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  lircd.conf
  bits           48
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  gap          215959
  toggle_bit_mask 0x0

      begin codes
          KEY_0                    0x666536383936 0x000066666666
          KEY_1                    0x666535306166 0x000066666666
          KEY_2                    0x666539303666 0x000066666666
          KEY_3                    0x666531306566 0x000066666666
          KEY_4                    0x666537303866 0x000066666666
          KEY_5                    0x666562303466 0x000066666666
          KEY_6                    0x666533306366 0x000066666666
          KEY_7                    0x666534386236 0x000066666666
          KEY_8                    0x666538383736 0x000066666666
          KEY_9                    0x666530386636 0x000066666666
          KEY_BACKSPACE            0x666538303766 0x000066666666
          KEY_ENTER                0x666538323764 0x000066666666
          KEY_UP                   0x666562383436 0x000066666666
          KEY_DOWN                 0x666537613834 0x000066666666
          KEY_LEFT                 0x666537383836 0x000066666666
          KEY_RIGHT                0x666533386336 0x000066666666
          KEY_OK                   0x666535616134 0x000066666666
          KEY_STOP                 0x666565303166 0x000066666666
          KEY_BACK                 0x666531616534 0x000066666666
          KEY_PREVIOUS             0x666533326364 0x000066666666
          KEY_NEXT                 0x666562323464 0x000066666666
          KEY_PLAY                 0x666561323564 0x000066666666
          KEY_RECORD               0x666532306466 0x000066666666
          KEY_REWIND               0x666531326564 0x000066666666
          KEY_FORWARD              0x666539323664 0x000066666666
          KEY_PAUSE                0x666532326464 0x000066666666
          KEY_MENU                 0x666534326264 0x000066666666
          KEY_MODE                 0x666539613634 0x000066666666
          KEY_EXIT                 0x666539613634 0x000066666666
          KEY_POWER                0x666534306266 0x000066666666
          KEY_EJECT                0x666530306666 0x000066666666
          KEY_BLUE                 0x666563303366 0x000066666666
          KEY_INFO                 0x666531386536 0x000066666666
          KEY_SUBTITLE             0x666536303966 0x000066666666
          KEY_GREEN                0x666561303566 0x000066666666
          KEY_RED                  0x666532386436 0x000066666666
          KEY_YELLOW               0x666535386136 0x000066666666
          KEY_ESC                  0x666539383636 0x000066666666
          KEY_NUMERIC_STAR         0x666561383536 0x000066666666
          KEY_PAGEUP               0x666564303266 0x000066666666
          KEY_PAGEDOWN             0x666566303066 0x000066666666
          KEY_CHANNELUP            0x666530326664 0x000066666666
          KEY_CHANNELDOWN          0x666561613534 0x000066666666
      end codes

end remote
No, my old and now useless DVD player remote doesn't technically have all of these buttons (they're under different names), but LIRC and later my Harmony Remote don't need to know that. I would use the Microsoft remote codes, but I have another device (I'm sure that you can guess) that responds to all remote commands (not only power) even when it's off.

/etc/sysconfig/lirc:
Code:
## Path:           Hardware/Lirc
## Description:    lirc (infrared remote control) configuration
## Type:           string
## Default:        "660"
## ServiceRestart: lirc
#
# permissions for /dev/lircd
#
LIRCD_DEV_PERMISSIONS="660"

## Type:        string
## Default:     "root:video"
#
# owner and group for /dev/lircd
#
LIRCD_DEV_OWNER="root:video"

## Type:        string
## Default:     ""
#
# use given driver
#
LIRCD_DRIVER="usbx"

## Type:        string
## Default:     ""
#
# read from given device
#
LIRCD_DEVICE="/dev/ttyACM0"

## Type:        string(lirc_bt829,lirc_gpio,lirc_i2c,lirc_it87,lirc_parallel,lirc_sir,ir-kbd-i2c,ir-kbd-gpio)
## Default:     ""
#
# load given lirc driver module
#
LIRC_MODULE=

## Type:        string
## Default:     ""
#
# listen for network connections on specified port.
# WARNING: don't use this on a machine with an internet
# connection as lircd is running as root!
#
LIRCD_LISTENPORT=

## Type:        string
## Default:     ""
#
# connect lircd to specified host
#
LIRCD_CONNECT=

In case you're not acustomed to the OpenSUSE version of LIRC, here is /etc/init.d/lirc:
Code:
#! /bin/sh
# Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Kurt Garloff <[email protected]>
# Author: Ludwig Nussel <[email protected]>
#
# /etc/init.d/lirc
#   and its symbolic link
# /usr/sbin/rclirc
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
#
### BEGIN INIT INFO
# Provides:          lirc
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: lirc daemon
# Description:       The  main  task  of lircd is to decode the infrared
#       signals and provide an uniform interface for client applications
### END INIT INFO

# Check for missing binaries (stale symlinks should not happen)
lircd_BIN=/usr/sbin/lircd
test -x $lircd_BIN || exit 5

# Check for existence of needed config file and read it
lircd_CONFIG=/etc/sysconfig/lirc
test -r $lircd_CONFIG || exit 6
. $lircd_CONFIG

lircd_CONF=/etc/lirc/lircd.conf
lircd_PID=/var/run/lirc/lircd.pid

. /etc/rc.status

rc_reset

setdefaults()
{
    # set LIRCD_DEVICE default if unset
    for retries in 1 2; do
        if test "$LIRCD_DEVICE" != ""; then
            break;
        fi
        if test -L "/dev/input/ir"; then
            # have input driver
            LIRCD_DEVICE="/dev/input/ir"
        elif grep -q BaseRemoteCtl /proc/devices && [ -e /dev/lirc0 -o -e /dev/lirc ]; then
            # have lirc driver
            if [ -e /dev/lirc0 ]; then
                LIRCD_DEVICE="/dev/lirc0"
            else
                LIRCD_DEVICE="/dev/lirc"
            fi
        else
            # wait for udev and try again
            udevadm settle
        fi
    done

    # set LIRCD_DRIVER default if unset
    if test "$LIRCD_DRIVER" = "" -a "$LIRCD_DEVICE" = "/dev/input/ir"; then
        LIRCD_DRIVER="dev/input"
    fi
}

case "$1" in
    start)
        echo -n "Starting lircd "
        modinfo evdev > /dev/null 2>&1 && modprobe evdev || :
        if test "$LIRC_MODULE" != ""; then
                modprobe "$LIRC_MODULE"
        fi
        setdefaults
        if [ -z "$LIRCD_DRIVER" -a -z "$LIRCD_DEVICE" -a ! -e /dev/lirc ]; then
                echo -n "Error: no device found"
                rc_failed 6
                rc_status -v
                rc_exit
        fi
        if [ ! -e "$lircd_CONF" ]; then
                DEVINPUTCONF='/usr/share/lirc/remotes/devinput/lircd.conf.devinput'
                if [ "$LIRCD_DEVICE" = "/dev/input/ir" -a -e "$LIRCD_DEVICE" -a -e "$DEVINPUTCONF" ]; then
                        install -m 644 "$DEVINPUTCONF" "$lircd_CONF"
                else
                        echo -n "Error: please create "$lircd_CONF""
                        rc_failed 6
                        rc_status -v
                        rc_exit
                fi
        fi
        [ -n "$LIRCD_DEVICE" ] && echo -n "($LIRCD_DEVICE)"
        install -d -m 755 /var/run/lirc
        install -m "$LIRCD_DEV_PERMISSIONS" /dev/null /var/run/lirc/lircd
        chown "$LIRCD_DEV_OWNER" /var/run/lirc/lircd
        if [ ! -L /dev/lircd ]; then
                rm -f /dev/lircd
                ln -s /var/run/lirc/lircd /dev/lircd
        fi

        lircd_ARGS=()
        [ -n "$LIRCD_DRIVER" ]     && lircd_ARGS+=(-H "$LIRCD_DRIVER")
        [ -n "$LIRCD_DEVICE" ]     && lircd_ARGS+=(-d "$LIRCD_DEVICE")
        [ -n "$LIRCD_LISTENPORT" ] && lircd_ARGS+=(--listen="$LIRCD_LISTENPORT")
        [ -n "$LIRCD_CONNECT" ]    && lircd_ARGS+=(-c "$LIRCD_CONNECT")

        start_daemon -p $lircd_PID $lircd_BIN "${lircd_ARGS[@]}"
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down lircd "
        killproc -TERM -p $lircd_PID $lircd_BIN
        rc_status -v
        ;;
    try-restart)
        $0 status >/dev/null &&  $0 restart
        rc_status
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    force-reload|reload)
        echo -n "Reload service lircd "
        killproc -HUP $lircd_BIN
        touch "$lircd_PID"
        rc_status -v
        ;;
    status)
        echo -n "Checking for service lircd "
        checkproc -p $lircd_PID $lircd_BIN
        rc_status -v
        ;;
    probe)
        if test "$lircd_CONFIG" -nt "$lircd_PID"; then
                 echo reload
        elif test "$lircd_CONF" -nt "$lircd_PID"; then
                 echo reload
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
        exit 1
        ;;
esac
rc_exit
XBMC Kodi is awesome!
Image
Reply
#3
Well, I got irman working with this, but I still can't get irw to work. Does anyone have experience with debugging lirc? It's creating /var/run/lirc/lircd when lirc starts and shows that irw connects, but nothing it written to the console. It puzzles me that irrecord works, but lirc doesn't.
XBMC Kodi is awesome!
Image
Reply

Logout Mark Read Team Forum Stats Members Help
LIRC with an Arduino0