OpenWrt Forum Archive

Topic: (Ab)using WRT54G as remote control (lirc?)

The content of this topic has been archived on 27 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
could this be implemented by replacing one of the LEDs by an IR LED and lirc? http://www.lirc.org
Greetings,
Frieder

My guess would be that those leds can be controlled with 2 values.. on and off big_smile

But someone else with better info could continue from here..

I would think it would be easier to add a serial port and then put the transmitter on that.

However I think remote controlls only need on and off so maybe the status led would do the trick, but it would be more coding since lirc wouldnt support it obviously.

The only led on a WRT54G that's directly controlable via software (revision > v1.0) is the DMZ led -- tied directly to a GPIO line.

Hi,
the driver serial_lirc.c unfortunately uses the handshake lines to switch the infrared LED on/off (or to detect incoming pulses).

As only RXD or TXD are present on the internal connector this would probably require some external CPU which would switch on/off a 38kHz carrier.

Or can the UART be switched into a baudrate of approximately 380 kBaud? (350..550kBaud?) In this case "carrier on" could be implemented by continuously outputting characters 0x0f to the serial port.

Otherwise the CPU would have to toggle the DMZ Led (thanks mbm) at about 76kHz (probably with interrupt disabled...)

Just to mention it:
OpenWRT runs well on the Asus WL500G which has a USB Port. Attach a USB<->RS232 converter and you get a serial device which behaves like a physical standard serial line capable of running lirc (not tested yet)

What is the DB-25 connector on the back of the Asus unit?  I think I read that they call it a "printer port" but that might mean serial or it might mean parallel.

I'm assuming parallel because of the form factor, but I don't have my units in yet to know for sure. . .

The Asus WL500G has one USB 1.1 Interface and one parallel printer port. But again, you can attach also USB<->LPT Adapters.

AFAIK Asus does not release the source of the printer port module (splink_parport.o), but you can use their binary module without modifications.
It's also possible to write a own small module which just writes to the base adress of the printer port (it's not PC-like 0x378...) to put data onto the port pins.
I helped a friend to write such a module and it works well to switch low current LEDs attached to the parport.

If you wait a few more weeks you may buy the Asus WL500GX which has USB 2.0.

Hello,

Yesterday evening I tweaked/changed/messed up lirc_serial.c to use the WRT54GS v4 DMZ LED GPIO line to send IR signals.  I just now replaced the DMZ led by an IR led and it is working just as it should :-).  I haven't done detailed measurements to check if the generated signals are 100% correct, but it seems to work.  The receiving part is completely disabled since I didn't really need it.  Perhaps it is possible to use the button behind the cisco logo as input for this, but I didn't check it at all.

I've packeged the needed stuff at http://users.pandora.be/esteevens/Links … mipsel.ipk

To use lirc, you need a configuration file that matches the remote control of the device you wish to control.  In my case I've recorded a config file for my remote using a linux live CD with LIRC (stux-linux-0.8.1).  Once you have this config file, you need to store it on your WRT54GS as /etc/lircd.conf.

To start using it load the 2 required kernel modules and start the LIRC daemon:

insmod lirc_dev.o
insmod lirc_serial.o
lircd --device=/dev/lirc/0

To send e.g. the power on command to your device, use:

irsend SEND_ONCE JVC_CA_E33 power

JVC_CA_E33 is the name of my remote control, so you should replace it by the name of your remote control (or use irsend LIST "" "" to see the name you should use).

Have fun
Eddy

P.S. I'm still using whiterussion RC3

(Last edited by esteevens on 13 Jun 2006, 22:26)

Got any source code? smile

Ofcourse.  Is there a 'prescribed' way of packaging the 'source' (patches, Makefile, ...)?  For RPM it is possible to build an SRPM which contains everything you need to rebuild the RPM.  Is there a similar thing for IPKG?

Just make a tarball of the package directory... You used the OpenWrt build system, right?

OK,

I've uploaded a tarbal of my package dir (http://users.pandora.be/esteevens/Links … ackage.tgz).

There are a few things I do not like about it right now:

1. The modification to lirc_serial.c is rather crude and just throws out all I didn't need by means of a #define LIRC_SERIAL_WRT54GS.  This should be made much cleaner.  Perhaps creating a lirc_wrtgpio driver would be a nicer solution.  I haven't dug into the original LIRC stuff to see how it could be fit in.

2. To include the files with the gpio stuff in lirc_serial.c, I've used hardcoded paths.  Again I need to dig into the makefiles to figure out where a cleaner solution should be fitted in.

3. In the package/lirc/Makefile, I have hardcoded the destination path for the kernel drivers as being /lib/modules/2.4.30.  Isn't there a less version dependant solution?

4. In the package/lirc/Makefile, I have also hardcoded the kernel source path --with-kerneldir="/home/es/OpenWrt-Buildroot/openwrt/build_mipsel/linux-2.4-brcm/linux-2.4.30".  The SDK doesn't really know where the Buildroot is so I didn't know what else todo... roll

Eddy

P.S. Don't hit me too hard, it's my first port/patch... cool

(Last edited by esteevens on 21 Feb 2006, 10:36)

I've created a new package out of the above.  It implements a new driver: lirc_openwrt.  It transmits and receives.  The module takes a few insmod paramaters as follows.

gpio_out=      default is gpio_out=32.     the gpio bit to use for transmit
gpio_in=        default is gpio_in=16.       the gpio bit to use for receive
gpio_ind=      default is gpio_ind=128    the gpio bit to use for indicating reception 0 for none
irq=               default is 3                       the interrupt line to use
share_irq=     default is 1                      share the interrupt or not
sense=          default is -1                     receive is active 0=high,1=low,-1=autodetect
txsense=       default is 0                       transmit is active 0=high,1=low
softcarrier=   default is 1                       use a software carier or not
debug=          default is 0                      enable debugging messages

This is working on a wrtsl54gs.  I removed the white ses led which is gpio 5 to transmit with.  I attached the input to the ses switch which is gpio 4.  I'm using the orange ses led to indicate reception.  I'm using the transiever that I found at the following url for 2.00 each!

http://www.allelectronics.com/cgi-bin/i … VICE_.html

I got 5v from a surface mount part close to the ses button to power it.  be carefull using the reset button for reception since during power up  gpio bits driving led's are hi which causes the xmit led's to light up and feed back into the receiver which is acitve low which causes fail safe mode!

Unfortunately, I have no way of posting this package.  If someone has somewhare I can stick it I'll be happy to do so.

My thanks to eestevens for his original package which I hacked.  Also many thanks to mbm and xj600 for their information on gpio interrupts.

allmost forgot:
for building the package I made one assumption and that is that the OpenWrt-SDK-Linux-i686-1 and whiterussian directories reside in the same directory for include purposes.

d3arnold

Hey I can probably host the stuff if you need someone to and I would be interested in your package for my own project if your willing to pass it on.

Thanks

Naz

That's fantastic!  I've been wanting to do something like that, but I am completely hopeless at kernel space stuff....

Could you by any chance document how the GPIO works?  I need to adapt it to different hardware.

Also, you may find the lirc folks are pretty good about merging patches like that.  There's lots of use for a generic GPIO driver in LIRC.

--Yan

Also if someone wants ipk for the driver posted by d3arnold, I've tested this on a wrtsl54gs and it works fine.

http://silverninja.net/~naz/lirc_0.8.0-1_mipsel.ipk

Also not mentioned in the previous posts is the fact that this driver won't work with a ir reciever that has a pull up resistor on the DCD line.

Naz

Has anyone got lirc_openwrt working on a wrt54gl?
I am trying to set up a transmit only lirc box. Everything seens to load, but nothing happens when a command is sent.

insmod lirc_dev.o
insmod lirc_openwrt.o gpio_out=128 txsense=1 debug=1
lircd --device=/dev/lirc/0

irsend send_once dish info

Hi!

I have just came across this threat, and it's got my immediate attention as I am trying to implement LIRC Infrared Receiver with my good old WGT634U which is currently running Kamikaze 7.09.

- Has anyone tried to port lirc_openwrt kernel module to 2.6.x for use with Kamikaze 7.09 (or Kamikaze 8.09 / trunk) before? Got the source code?
- Is anyone interested in this topic and is anybody out there who might be able to help with coding or testing if I try to do it?  big_smile

Thanks,
Stan

Hi all

Existing a possibility that lirc works on my wrt54gl with brcm47xx ?

Now i have tried your lirc_0.8.0-1_mipsel.ipk on my Router and i get the follow error:

lircd: can't resolve symbol '__uClibc_start_main'

I search day and night for a solution :-(

I also wrote this question:
http://forum.openwrt.org/viewtopic.php?id=19719

Many greetings

Dusty

hi
i'm working on a port of lirc_openwrt for kamikaze 8.09 and it may work in near future..
But i have a little problem:
lirc_openwrt needs some header files (sbutils.h, sbconfig.h usw) which the buildroot can not find.
I've searched manually and found the files in build_dir/b43/broadcom.../include
but i don't know how i tell lirc_openwrt where to find them.

yes  i can hardcode the path but thats awful

does anybody know a pretty solution for this??

Hi,

This is the Makefile which I have modified in order get lirc working. It's been a while so I don't remember exact details.

HTH

#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 5624 2007-09-04 00:29:07Z Dottout $

include $(TOPDIR)/rules.mk
# we use the $LINUX_DIR and $TARGET_MODULES_DIR variables, 
# which are defined in kernel.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=lirc
PKG_VERSION:=0.8.3
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@SF/${PKG_NAME}
PKG_MD5SUM:=8e78eeded7b31e5ad02e328970437c0f

include $(INCLUDE_DIR)/package.mk

define Package/lirc/Default
    SECTION:=utils
    CATEGORY:=Utilities
    URL:=http://lirc.org/
endef

define Package/lirc
    $(call Package/lirc/Default)
    TITLE:=LIRC - Linux Infrared Remote Control
    DEPENDS:=@!LINUX_2_4
    MENU:=1
endef

define Package/lirc/description
  LIRC is a package that allows you to decode and send 
  infra-red signals of many (but not all) commonly used 
  remote controls.
  This package contains only lircd and lircd.conf
  Make sure you select then correct driver!
endef

define Package/lirc/config
    config LIRC_DRIVER
        string
        prompt "Driver to be complined with LIRC Daemon" if PACKAGE_lirc
        default none
endef

define Package/lirctools
    $(call Package/lirc/Default)
    DEPENDS:=lirc
    TITLE:=LIRC tools
endef

define Package/lirctools/description
  This package contains the rest of LIRC daemons and tools:
   -irrecord
   -lircmd
   -ircat:   prints config strings to standard output, can be used to provide remote control input to scripts
   -irexec:  execute programs according to the pressed remote control buttons
   -irpty:   pseudo tty driver. Connects to lircd via socket to receive infra-red codes and converts them to key strokes
   -irsend:  application for sending IR-codes via lirc
   -irw:     watch the codes as lircd recognize them
   -lircrcd: daemon that manages current mode for all applications
   -mode2:   shows the pulse/space length of a remote button
endef

CONFIGURE_ARGS += \
    --disable-nls \
    --disable-static \
    --enable-shared \
    --with-kerneldir="$(LINUX_DIR)" \
    --with-driver=$(CONFIG_LIRC_DRIVER) \
    --with-moduledir=$(TARGET_MODULES_DIR) \
    --without-x \
    --with-pic \
    --with-gnu-ld \
    --enable-sandboxed \

define Package/lirc/conffiles
/etc/lircd.conf
endef

MAKE_FLAGS += \
    DESTDIR="$(PKG_INSTALL_DIR)" \
    ARCH="$(LINUX_KARCH)" \
    all install

define  Package/lirc/install
     $(INSTALL_DIR) $(1)/etc/
    @if [ -f "$(PKG_INSTALL_DIR)/etc/lircd.conf" ]; then \
        $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/lircd.conf $(1)/etc; \
    else \
        $(INSTALL_CONF) $(PKG_BUILD_DIR)/contrib/lircd.conf $(1)/etc; \
    fi
    @if [ -d "$(PKG_INSTALL_DIR)/lib" ]; then \
         $(CP) -r $(PKG_INSTALL_DIR)/lib $(1)/; \
    fi
    $(INSTALL_DIR) $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/lircd $(1)/usr/sbin/
endef

define  Package/lirctools/install
    $(INSTALL_DIR) $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/lircmd $(1)/usr/sbin/
    $(INSTALL_DIR) $(1)/usr/bin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mode2 $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ircat $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/irexec $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/irpty $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/irrecord $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/irsend $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/irw $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lircrcd $(1)/usr/sbin/
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mode2 $(1)/usr/sbin/
    $(INSTALL_DIR) $(1)/usr/lib/
    $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblirc_client.so* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,lirc))
$(eval $(call BuildPackage,lirctools))

(Last edited by baracudaz on 10 Jun 2009, 20:39)

How can I get this working in Backfire?

I had a working white-russian with a 433MHz transmitter connected to the dmz-led of my wrt54G (v2.0). After upgrading to backfire I can not get this to work. I need a driver that does not say:
   irsend: hardware does not support sending

How do I do that? Where is  the lirc_dev or gpio transmission device?

The discussion might have continued from here.