HTPC birthday present that was not nice and easy

by Zach 22. September 2011 14:21

For my 30th birthday I received a bare bones Zotac ND22 system, a hard drive, some ram and an infra-red remote for it all.  Inspired by the ease presented by this Lifehacker article in regards to setting up your own Home Theatre PC, I had my heart set on setting up my own.  The idea was simple: I was tired of hauling my PC around and tired of using DLNA solutions for streaming my media to my TV.  DLNA is a semi-functional standard in my opinion, requiring a Java Application (in this case, Serviio) to remain continually running on my system.  Some times it wouldn’t show up as a media source to my TV (although, it was very cool when it did work), and other times it would get confused and report multiple sources.  My Samsung TV and my Xbox 360 both were able to receive the DLNA source and play media, however there were some files that would only play on the Samsung and others that would only play on the 360.  It soon became a chore to remember which type of media worked on which platform.  This was all when it worked, when it didn’t show up as a source, it meant either restarting the DLNA service or rebooting my machine.

And frankly, my box is too damn heavy to lug around and plug an HDMI cable in to the TV.

I’d been intrigued by this idea of a HTPC for a long time, but never really could justify the cost of one of the Windows based ones.  I also had already been maintaining my media, keeping it’s meta-data up to date, assigning covers, keeping an organized folder structure, etc.  It resolves my need to organize something once a day.  I know, it’s a problem.  I’d re-read the Lifehacker articles regarding setting up your own XBMC box several times.  When my wife had suggested what kind of things I could get for my birthday, this setup bubbled up to the list.

After multiple orders and a couple weeks, I had my little box in hand.  The machine came up without a hitch and as expected hardware was not an issue.  I ended up putting 4 GB of RAM and a 160GB hard drive in the machine, with the intent as using it for a backup source for important things like family photos.  You really can’t go wrong with adding more storage.  The real fun was to begin with the software setup.

Installation

The Lifehacker article started with the idea of burning the latest XBMC Live ISO and using it’s installer to install a version of itself on to a USB memory stick for another installation on the ND22.  The issue I found with that was when installed using the XBMC installer, it would not add an install option on the boot loader of the USB stick.  When I plugged the memory card in, it would simply load XBMC into memory, without giving me the option to install the program to the hard disk, as I wanted.  In the end, I ended up having to go with a program called UNetBootin after a few hours of reading on how to do this.  In short, this program makes your USB stick bootable with an ISO image or a Linux distribution straight from the Internet. 

Lo and behold, first time around, I have a USB stick that can install XBMC to my ND22.  It was an extremely painless procedure.  One item of note is that I had my Ethernet cable plugged in so the installer could identify and install networking from the start.  It was kind of a gut reaction to seeing the installer a few times.

The Remote

I had a shiny new XBMC installation on the TV, I could navigate it using the keyboard and mouse, and my IR Receiver had the little red light steadily shining showing it was ready to receive commands.  After playing around for a few minutes I pointed my remote and pushed a button.  Unlike the Lifehacker article, my remote was not plug and play.  In fact, it did nothing.  The light didn’t blink, the screen didn’t respond.  This was the only piece of hardware that I purchased equivalent to the article and it didn’t work!  Needless to say I was frustrated a bit, and went back to researching these kinds of problems.

It seems the only place to get decent information about troubleshooting this sort of thing is the XBMC forums and, if lucky, a personal blog by people in similar situations.  Identifying the problem was easy enough: The LIRC Driver (i.e. the software that listens to the IR receiver getting commands from the remote) that is used by XBMC may not be listening for the newer revisions of the remote I had purchased.  The only way to identify if this was true was to enter the command prompt of XBMC and start running some tests. 

It took a little skimming and searching, but eventually I found that from the XBMC screen you can enter the command prompt using the keyboard shortcut CTL-ALT-F1

Once there it seemed relatively similar to a DOS command prompt.  I still feel comfortable with DOS so it seemed to me it wouldn’t be too much of a stretch to accomplish what I needed to do in a Linux command prompt, especially with instructions in front of me.  Needless to say, nothing is as easy as you want it to be.  Using the command irwin, I should have been able to see the infrared commands coming from my remote had it been working.  It appeared not to as nothing appeared on the screen.  I needed to then use the command lsusb to determine if my receiver was being picked up as a USB device by the operating system.  Luckily, it was.  That told me that it was there, just wasn’t being used.  This is apparently standard troubleshooting for any USB device in a Linux environment.  I was instructed to record the line I believed was the IR receiver.  After unplugging the receiver, running the command and seeing what was missing, I was able to identify the unused hardware.

For future reference it was: ID 1784:0011 TopSeed Technology Corp.

Breaking down this line it gives us the information used  by the driver to isolated what device it’s talking to.

The manufacturer code is 1784
The device code is 0011
The friendly name is TopSeed Technology Corp.

That is not a typo, it really is “TopSeed”, not “TopSpeed”.  The codes eventually were understood to be Hex values that are used in the code.

For those who remember using the command prompt, the first thing to keep in mind is there are multiple ways to get a job done.  This reasoning was only compounded in my research to find out how to add instructions to the LIRC driver to read the signals coming from my remote.  It was what needed to be done: getting the source code for the LIRC driver I was using, open up the file for media center remotes and add code to it.  Luckily, this ground had been tread before, in general.  There are multiple ways for a person to download the source code, I would assume for anything, and alter it to your liking.  I can see the allure to this, however as people get older they want things to “just work”.  Happily, I’m not that old, yet.

Using the command [Command] I was able to download the source code for the 0.8.6 version of LIRC.  This is apparently the version that is bundled with the version of XBMC Live I was using.  While researching I found there is a 0.9.0 version in existence, but I never figured out how to upgrade the driver.  This version of the driver I was using was using a consolidated driver for media center remotes using the file name lirc_mceusb.c.  Based on the .c extension, I believe it is written in the C language.  Having worked with the C# language for nearly 5 years now, it was easy to see what was going on.  I’m still amazed now how clean the code is for “a device driver".  I’d always imagined them as deep, dark, murky bits of code that one would have to comb through for ages.  As explained by multiple web pages, my device manufacturer and device id code did not exist in this driver. 

My first attempt was to add the necessary lines to the existing code.  I had to use a command line text editor to make the changes.  There are various programs that exist in the Linux universe using random names such as “Joe”.  I ended up liking the “Nano” text editor as I found it the most intuitive.  Looking through the file, it looked very well maintained.  I saw the list of supported manufacturers at the top and noticed what I had written down was not in the list at all.  The most confounding part about it was that at the beginning of the process the manufacturer name was “TOPSPEED”.   Looking in the list, there was an entry for “TOPSEED” with the same manufacturer code.  Assuming it wasn’t a coincidence, I used that same manufacturer entry (it appeared to work like an enumeration) and added a entry for my remote in the devices list.  I hit my first snag when I tried to recompile my driver and install my changes.

For future reference, look for static struct usb_device_id transmitter_mask_list[]
The line that needed to exist is: { USB_DEVICE(VENDOR_TOPSEED, 0x0011) }

After three hours of uninstalling, recompiling, verifying my change was in the code and repeating that over again, I managed to get the IR receiver to blink!  But, that was all, there were no responses from the irwin command, and eventually I had tinkered to the point that I couldn’t uninstall the LIRC driver again because it was in use.  I couldn’t stop it because it kept telling me it was in use, and I couldn’t successfully install a newly compiled driver.  Basically, it was all jacked up.  So with nothing left to lose, I reinstalled XBMC and followed some instructions that were a simple list of Linux commands.  Credit belongs to this post.  Know that when you put “sudo” in front of a Linux command, that basically means “Run as Administrator”.  After following those instructions, my remote worked! Smile

sudo dkms remove -m lirc -v 0.8.6 --all 
sudo dkms add -m lirc -v 0.8.6 
sudo dkms -m lirc -v 0.8.6 build 
sudo dkms -m lirc -v 0.8.6 install 
sudo rmmod lirc_mceusb 
sudo rmmod lirc_dev 
sudo modprobe lirc_mceusb 
sudo modprobe lirc_dev 
sudo /etc/init.d/lirc restart

 

The next day, I was able to start using my HTPC!  Here’s to more posts regarding!

Tags: , , ,

Movies