Freitag, 26. Dezember 2014

Raspberry PI + lirc + arch linux

Hello again!
This time I will tell you how to get lirc running with an arch linux running on my Raspberry PI!

First, get lirc and lirc-utils:

pacman -S lirc lirc-utils

Next, load the module:

modprobe lirc_rpi

Check if the modules are loaded:

lsmod | grep lirc
lirc_rpi                7346  0
lirc_dev               10291  1 lirc_rpi
rc_core                17437  1 lirc_dev

Looks good! By default lirc_rpi uses GPIO 17 as output and GPIO 18 as input. We can check this doing the following:

cat /sys/kernel/debug/gpio
GPIOs 0-53, bcm2708_gpio:
 gpio-16  (led0                ) out hi
 gpio-17  (lirc_rpi ir/out     ) in  lo
 gpio-18  (lirc_rpi ir/in      ) in  lo

If you have wired up everything, you can check if your receiver works properly:

mode2 -d /dev/lirc0

Now you should press some buttons on your remote and should see some output like this:

space 16300
pulse 95
space 28794
pulse 80
space 19395
pulse 83
space 402351
pulse 135
space 7085
pulse 85
space 2903

Great, the receiver works. 

If you want to record your remote codes, you need to know the available keys lircd knows, therefore run 

irrecord --list-namespace  

reading from /dev/lirc0, writing to ~/lircd.conf, hit:

irrecord -d /dev/lirc0 ~/lircd.conf

The file now goes to /etc/lirc/lircd.conf and maybe you have to change the name variable  to REMOTE_NAME inside the config file, but I think this is more or less self-explanatory.

Now to test the blaster, fire up the lirc daemon:

systemctl start lircd

And finally blast some codes...

irsend SEND_ONCE REMOTE_NAME KEY_POWER

or whatever key you recorded.

If you like to start this automatically on boot, do this:

systemctl enable lircd

Additionally, the kernel modules need to be loaded, too. This is achieved by doing the following:

rm -f /etc/modules-load.d/lirc_dev.conf
echo "lirc_rpi" > /etc/modules-load.d/lirc_rpi.conf

I removed the lirc_dev.conf since lirc_rpi depends on lirc_dev and automatically loads lirc_dev. Now if you would like to employ different GPIO pins, you need to put the options for the kernel module into a different file.

echo "options lirc_rpi gpio_in_pin=23 gpio_out_pin=22" > /etc/modprobe.d/lirc_rpi.conf

This should do the trick.

Mittwoch, 30. Januar 2013

inetd superserver client ip retrieval

If you have ever used the internet superserver inetd and connected it to a bash script and wondered how to retrieve the ip and port of the client, here is the solution:

/etc/inetd.conf
666 stream tcp nowait root /opt/client_ip.sh

/opt/client_ip.sh
#!/bin/bash
read ip port <<< `getpeername`
# $ip now contains the ip
# $port now contains the port


Maybe you need to apt-get install tcputils to install getpeername.

Sonntag, 27. Januar 2013

Horde spitting out 404 on task creation

As I recently setup a server with Debian Squeeze and some groupware stuff, there was but one little problem, creating a new task in horde lead to a solid 404 on "horde/nag/t/save". Abusing Google in order to find a solution often lead to people suggesting one should enable mod_rewrite, but it was already enabled.
Another approach was changing AllowOverride directive on the vhost from none to all. But guess what, that was also correct.
So I had to investigate a little bit myself and found out that the
/usr/share/horde/.htaccess
file was missing a RewriteBase.

So in a nutshell, make sure /usr/share/horde/.htaccess looks somewhat like this:

# IMPORTANT: DO NOT EDIT THIS FILE!
# It will be overwritten with any future upgrade.

allow from all

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /horde
   RewriteCond   %{REQUEST_FILENAME}  !-d
   RewriteCond   %{REQUEST_FILENAME}  !-f
   RewriteRule ^(.*)$ rampage.php [QSA,L]
</IfModule>

Why this thing?

Because I often stumble across blogs containing solutions for my admin related problems and thus I thought, well maybe I'll give something back, so here it is.