VectorLinux
April 17, 2014, 04:36:45 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: [SOLVED] LIRC (linux remote control) isn't setting up /dev properly,udev problem  (Read 3903 times)
rhauff
Vectorite
***
Posts: 105


« on: November 14, 2007, 02:59:14 pm »

I've been tearing my hair out for days, and Googled for hours on this one!  Apparently that's par for the course with LIRC.
(This is very long and the LIRC stuff probably of no interest/comprehension unless you have used it.)  My MAIN question here is about the udev part, which I've never touched before, and why the /dev files aren't getting created.

Anyway, I just got an ATI Remote Wonder RF/USB remote.  I plugged it in, and right off it's detected as:
input: ATI/X10 RF USB Remote Control(0bc7,0004) as /class/input/input4

and the module "ati_remote" is automatically loaded.  It works as a mouse replacement (up to 60' away!) immediately, no configuration required whatsoever, and the a-c letters and 0-9 characters type in a terminal!

My goal however, is to run XMMS from another room.  I've read I can use xmodmap and map some of the keys to run xmms, but the way I understand it, I would have to make sure that xmms was the selected window before I left the computer for this to work, and I don't want to worry about that.  What I'm trying now is to setup LIRC and the lirc-xmms plugin.  I've compiled them both from source, lirc-0.8.2 and lirc-xmms-plugin-1.4.  Next I
1.  Installed a proper /etc/lircd.conf for my ATI remote (part#5000015900A)
2.  Copied
### lirc dev entries
KERNEL=="lirc[0-9]*", NAME="lirc/%n", MODE="0666", SYMLINK+="%k"
to the end of /etc/udev/rules.d/udev.rules
3.  Edited an /etc/rc.d/rc.lircd file which starts the daemon lircd:
#!/bin/sh
#  Start/stop/restart the LIRC daemon:

#
#  To use this daemon, you need to create a file called /etc/lircd.conf
#  which shows the mapping of IR signals to buttons on your remote. Many
#  remote controls have already been mapped and can be found in
#  /usr/share/lirc/remotes. Just copy the file for your remote to
#  /etc/lircd.conf.  Install the lirc-remotes packages to get config files
#  for remotes not covered by the base lirc package.  If your remote isn't
#  in lirc-remotes, you can create a new config using the 'irrecord' tool.
#  See the man page for more info.
#
#  You will also need a file mapping IR signals from your remote control to
#  applications.  This file can be located at /etc/lircrc or $HOME/.lircrc.
#  A simple one has been included at /etc/lircrc for xine and xmms to get
#  you started.  You'll need a xine package that's been compiled with the
#  --enable-lirc option (not the default Slackware package) and for xmms
#  you'll need the lirc-xmms-plugin which works with the default Slackware
#  xmms.
#
#  I've only worked with xmms and xine on a laptop IrDA port, so there
#  are probably many areas for improvement in this package.  I had
#  problems compiling under 2.4 so this package is 2.6 only (from /extra).
#  If you have suggestions for improving this package, send me a note,
#  thanks!
#
#  cjm <cj@meidlinger.org>   28 Nov 2006   initial version

#

make_devices ()
{
        if [ ! -e /dev/lirc ]; then
                mknod /dev/lirc c 61 0
                chown root.root /dev/lirc
                chmod 660 /dev/lirc
   fi
   if [ ! -e /dev/lirc0 ]; then
                mknod /dev/lirc0 c 61 0
                chown root.root /dev/lirc0
                chmod 660 /dev/lirc0
        fi
   if [ ! -e /dev/lirc/0 ]; then
                mknod /dev/lirc/0 c 61 0
                chown root.root /dev/lirc/0
                chmod 660 /dev/lirc/0
        fi
        if [ ! -e /dev/lircd ]; then
                mknod /dev/lircd p
                chown root.root /dev/lircd
                chmod 666 /dev/lircd
        fi
        if [ ! -e /dev/lircm ]; then
                mknod /dev/lircm p
                chown root.root /dev/lircm
                chmod 666 /dev/lircm
        fi
}

lircd_start() {
   # clear serial port if necessary
   #
   # COM1
   # setserial /dev/ttyS0 uart none
   #
   # COM2
   # setserial /dev/ttyS1 uart none

   # since this service conflicts with IrDA services, we'll load and
   # unload modules here in the rc script.  If you have a dedicated IR
   # receiver, you can load modules in /etc/rc.d/rc.modules and not
   # worry about loading/unloading here.
   
   # standard laptop IrDA port
   #
   # COM1
   # /sbin/modprobe lirc_sir io=0x03f8 irq=4
   #
   # COM2
   # /sbin/modprobe lirc_sir io=0x02f8 irq=3

   # homebrew serial port receiver
   # /sbin/modprobe lirc_serial

   # check for loaded modules before starting the daemon
   lircmod=`lsmod | grep lirc_dev`
   if [ -z "$lircmod" ] ; then
      echo " "
      echo "You need to load lirc modules before starting this"
      echo "daemon.  Please edit either"
      echo "     /etc/rc.d/rc.lircd"
      echo "          or"
      echo "     /etc/rc.d/rc.modules"
      echo " "
   else
      /usr/sbin/lircd --device=/dev/lirc/0
   fi
}

lircd_stop() {
   killall lircd
   rm /dev/lircd

   #  remove modules if needed for IrDA operations
   #
   #  laptop IrDA port
   #  /sbin/rmmod lirc_sir lirc_dev
   #
   #  homebrew serial port
   #  /sbin/rmmod lirc_serial lirc_dev
}

lircd_restart() {
   lircd_stop
   sleep 2
   lircd_start
}

lircd_nodaemon() {
lircmod=`lsmod | grep lirc_dev`
   if [ -z "$lircmod" ] ; then
      echo " "
      echo "You need to load lirc modules before starting this"
      echo "daemon.  Please edit either"
      echo "     /etc/rc.d/rc.lircd"
      echo "          or"
      echo "     /etc/rc.d/rc.modules"
      echo " "
   else
      /usr/local/sbin/lircd --nodaemon --device=/dev/lirc/0
   fi
}

case "$1" in
'start')
  lircd_start
  ;;
'stop')
  lircd_stop
  ;;
'restart')
  lircd_restart
  ;;
'nodaemon')
  lircd_nodaemon
  ;;
*)
  echo "usage $0 start|stop|restart|nodaemon"
esac

End of rc.lircd

End of configuration & setup.

Now I tried both
# /etc/rc.d/rc.udev restart
and rebooting.  I am starting lircd with # /etc/rc.d/rc.lircd nodaemon (I guess it should start on it's own during bootup if the remote is plugged in).  I get the message:

lircd: lircd(atiusb) ready

However, the device files /dev/lirc0 and /dev/lirc/0 aren't getting made.  So, when I start irw, a test app. which calls lircd, I get the following message from lircd, which then dies:

lircd: accepted new client on /dev/lircd
lircd: could not get file information for /dev/lirc/0
lircd: default_init(): Not a directory
lircd: caught signal
/etc/rc.d/rc.lircd: line 120:  4386 Terminated              /usr/local/sbin/lircd --nodaemon --device=/dev/lirc/0

If I start mode2, another test app. mode2 gives me this message before dieing:

mode2: error opening /dev/lirc/0
mode2: Not a directory

Sooooo, after all that, any ideas why /dev/lirc/0 doesn't get created?HuhHuh??  Thanks!
« Last Edit: November 16, 2007, 01:23:13 pm by rhauff » Logged
uelsk8s
Administrator
Vectorian
*****
Posts: 2503



« Reply #1 on: November 14, 2007, 05:25:53 pm »

I dont know enough about udev to help you figure that part of this out now, but if you want to get it working I would suggest calling the lines in the rc.lircd file that make the device nodes.

try adding make_devices  right after lircd_nodaemon() {

so it lookes like this

lircd_nodaemon() {
make_devices
lircmod=`lsmod | grep lirc_dev`
   if [ -z "$lircmod" ] ; then
      echo " "
      echo "You need to load lirc modules before starting this"
      echo "daemon.  Please edit either"
      echo "     /etc/rc.d/rc.lircd"
      echo "          or"
      echo "     /etc/rc.d/rc.modules"
      echo " "
   else
      /usr/local/sbin/lircd --nodaemon --device=/dev/lirc/0
   fi
}

and then start it the way you have been

HTH,
Uelsk8s
Logged
rhauff
Vectorite
***
Posts: 105


« Reply #2 on: November 14, 2007, 07:00:59 pm »

That sure sounded like a good tip!  However, this is the result:

# /etc/rc.d/rc.lircd nodaemon
mknod: `/dev/lirc/0': Not a directory
chown: cannot access `/dev/lirc/0': Not a directory
chmod: cannot access `/dev/lirc/0': Not a directory
lircd: lircd(atiusb) ready

I guess that's what I get for hacking pieces from different rc.lircd's together.  That whole make_devices section I had found somewhere else & hoped it would help.  I also didn't quite understand the syntax, as I thought it was running that code already in my posted version!
Logged
uelsk8s
Administrator
Vectorian
*****
Posts: 2503



« Reply #3 on: November 14, 2007, 07:15:21 pm »

here is the problem
the code makes /dev/lirc into a node, and then it tries to add a node inside of it /dev/lirc/0 like it was a dir.

since all you need is /dev/lirc/0
try removing the rest of the make_devices function.

so it ends up just being this
make_devices ()
{
     if [ ! -e /dev/lirc ]; then
                mkdir /dev/lirc
   fi
   if [ ! -e /dev/lirc/0 ]; then
                mknod /dev/lirc/0 c 61 0
                chown root.root /dev/lirc/0
                chmod 660 /dev/lirc/0
        fi   
}
Logged
rhauff
Vectorite
***
Posts: 105


« Reply #4 on: November 14, 2007, 08:39:10 pm »

That gives Exactly the same results!  One thing I should mention, the original rc.lircd (I got it from a Slackware 11 package on LinuxPackages.net) did not have the make_devices section at all.

I just looked in that package's udev rules and it has:
KERNEL="lirc[0-9]*", NAME="lirc%n"
KERNEL="lirc0", SYMLINK="lirc"

I did not have the second line.  I put that in my udev.rules and restarted udev.  Now a /dev/lirc0 gets created!
OK, I checked the rc.lircd from that package, and it points lircd to open with:

/usr/sbin/lircd --device=/dev/lirc0

I adjusted my rc.lircd back to this as well (and removed the make_devices section).  Tested, and......Success!!!!!

It looks like the Slackware package probably would have worked, that's what I tried before compiling from source.  It had the correct udev rules, but the documentation is so poor I didn't know I needed to restart udev to make it work!!!

Thanks much for your help.
Logged
uelsk8s
Administrator
Vectorian
*****
Posts: 2503



« Reply #5 on: November 14, 2007, 08:44:15 pm »

glad you got it fixed.

I think you may still have the dev/lirc node, and thats why it didnt work the second time.
udev is the better way it will keep your device nodes dynamic.
Logged
rhauff
Vectorite
***
Posts: 105


« Reply #6 on: November 15, 2007, 06:33:30 pm »

glad you got it fixed.

It WAS fixed and working blissfully great..... for all of 10 minutes!  Then I decided I wanted more than 30' range so I unplugged the USB receiver to solder on a longer antenna.  I plugged it back in, and nothing I can do will make it work again!  I've tried restarting udev, rebooted, plugged in the receiver before & after rebootI continually get the following results when I try to access lircd:

# /etc/rc.d/rc.lircd nodaemon
lircd: lircd(atiusb) ready
lircd: accepted new client on /dev/lircd
lircd: could not get file information for /dev/lirc0
lircd: default_init(): No such file or directory
lircd: caught signal
/etc/rc.d/rc.lircd: line 124:  3638 Terminated              /usr/local/sbin/lircd --nodaemon --device=/dev/lirc0

The node /dev/lircd (socket) is getting created, but the nodes /dev/lirc and /dev/lirc0 are not.  I tried putting the make_dev section back in the /etc/rc.d/rd.lircd, and now the nodes DO indeed get created, but I still get the above error.
I'll post a question when I can figure out what to ask even!



Logged
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #7 on: November 15, 2007, 06:38:58 pm »

Doh! Think you might of smoked it?
Logged
rhauff
Vectorite
***
Posts: 105


« Reply #8 on: November 15, 2007, 08:38:31 pm »

No, I just added a few more inches to it's external tail.  I plugged it in and dmesg shows it is still detected properly and the kernel modules lirc_dev and lirc_atiusb still load and give the same messages.  I think it's still something with udev.
Logged
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #9 on: November 16, 2007, 08:41:48 am »

Phewww!  I had visions of you messing with the internals, possibly soldering directly to a PCB only visible under a electron microscope.  Cheesy

Sorry about your trouble though.  I'd offer to  help, but your problem is one that I'd be asking for help on as well.
Logged
rhauff
Vectorite
***
Posts: 105


« Reply #10 on: November 16, 2007, 01:22:08 pm »

Well, your visions are not unfounded!  I did pop it open first, and if the original wire had not been hot-melted for strain relief, I would have soldered right to the board.

But more importantly, WOOOOT!  It's working again!  Even better, I think I know why!  After more googling, I found the kernel module which automatically loads and makes it work right off the bat as a remote mouse & keypad needs to be removed as it interferes with lirc's lirc_dev and lirc_atiusb.  I have since plugged & unplugged it several times and it's still working great.  I plan to do a nicer writeup and maybe put it in Vector's howto, but definitely LIRC's.

Thanks for the help here, and Yes, the range is better w/ a longer antenna (not by much though).
Logged
nightflier
Administrator
Vectorian
*****
Posts: 3939



« Reply #11 on: November 16, 2007, 01:59:40 pm »

Good to hear it works. I have one of those and may use it for an HTPC. Would appreciate an outline of the steps you took.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!