WDTV Tools

June 5, 2009

wiidtv – Using the Wiimote With the WDTV

Filed under: osd, wiidtv — Tags: , , , , , , , — Elmar Weber @ 01:42

Just a quick hacked demo of the Wiimote controlling the Western Digital TV HD. The more the Wiimote is rolled the faster it scrolls. But it’s currently not really usable because of the rather poor performance of the WDTV GUI when the scrolling gets faster.

If you want to try this here is a quick howto (you should know how to handle yourself with telnet or SSH on the WDTV):

  1. You need
    • eiri application image
    • optware (opt.bin)
    • USB bluetooth adapter that is supported by Linux (if you have one it probably is)
  2. You need to install some packages on your WDTV for bluetooth support – and because some people reported problems with the busybox tar you should also install the GNU tar:

    # ipkg install bluez-utils tar
  3. Download the bluetooth kernel modules and install them (you need to be in a directory that is writeable, so when using WDLXTV you should a directory in /opt/):

    # wget http://wdtv.elmarweber.org/temp/bt.tar.gz
    # tar xvfz bt.tar.gz
    # sh insert.sh

    If everything works you should get no messages, if you get a notice that firmware_class is already loaded that’s OK, but no other message should appear.
  4. Next must setup your bluetooth adapter. If not already done, first connect it to the WDTV. Now you should see it with # hciconfig -a if no device called hci0 is listed there was a problem with the bluetooth adapter. Take a look at dmesg | tail do get possible error message.

    Next you can bring the bluetooth adapter into play with # hciconfig hci0 up. To check if everything works you can do a quick # hcitool scan to show any bluetooth devices in your vicinity. Even if you don’t have any active bluetooth devices you can assume that everything works when you don’t get any error messages.

  5. The last step before using the Wiimote with your WDTV you need the wiidtv application and install it.

    # wget http://wdtv.elmarweber.org/temp/wiidtv.tar.gz
    # tar xvfz wiidtv.tar.gz
  6. Now you can put it all together by starting the wiidtv application and connecting your Wiimote. Start wiidtv with

    # sh wiidtv.sh

    and then you must set your Wiimote into discovery mode by pressing the 1 and 2 buttons at the same time. The wiidtv program will connect with the first Wiimote it finds and use it. You have 10 seconds to do this, if there is no Wiimote found until then the program exits, so have your Wiimote ready and near your WDTV. In case your Wiimote was detected you’ll feel a short vibration from it, this is the signal that wiidtv is connected to it.

    Control is very limited, you can scroll up/down by tilting / rolling the device (simulates up down remote command, if you have thumbnails enabled you’ll be out of luck). With the B button you can enter a directory or play a file and with A you return to the previous view. Finally, you can disconnect the Wiimote by pressing the Power button for a few seconds.

I’ll release an application image ASAP. As usual the sources are in the SVN if anyone wants to give it a hack.

June 4, 2009

Preview Release of eiri: A Command Line and Network Interface to the Infrared Port

Filed under: eiri — Tags: , , , , , , — Elmar Weber @ 01:03

I had some time to finish the IR adapter I’ve been working on. A preview release of eiri (extended infrared interface) is available at http://sourceforge.net/project/downloading.php?group_id=261153&filename=eiri-r128-wdtv.zip.

eiri is an improved alternative to irset. It allows you to send IR commands to the WDTV GUI from the command line, thus enabling third party applications like web pages or SSH to control the WDTV GUI. Compared to irset it fixes some bugs, namely the 100% CPU utilization and it supported repeated keys (so you can hold down UP/DOWN and it is executed again without the need to press it again). Furthermore it adds a network mode that can be used to control the WDTV from a remote device over the network. The rest of this article first describes the command line interface and then the network mode.

The command line program is called irsend or eiric and can be used to send an arbitrary sequence of commands where a command can be one of POWER, HOME, UP, LEFT, ENTER, RIGHT, DOWN, BACK, STOP, OPTION, REWIND, PLAY, PAUSE, FORWARD, PREVIOUS, NEXT, SEARCH, EJECT or a number larger than 0 that is interpreted as a wait in milliseconds. For example

# irsend UP 1000 ENTER

will emulate an UP command from the remote, then wait 1000 milliseconds (1 second) and finally send the ENTER command. It is the same as when you press the UP and ENTER keys consecutive on the remote with a delay of one second. More complex combinations are possible but always remember to put a wait between two commands because the WDTV GUI won’t be able to process most commands if they are executed without delay.

A second feature of the preview release of eiri is the network mode. the eiri daemon (eirid) starts a TCP server on port 14247 that listens for connections from clients. When you connect your client two things happen and can be done

  1. You can send command sequences in the same way you can do with the irsend command line program. The communication is done in ascii mode (No UTF-8 or other encoding) and each line must be terminated with a n character or otherwise no commands are executed. So you would send the string “UP 1000 ENTERn” to achieve the same as the irsend call done above.
  2. You are notified about any commands received from the real remote. For each command a line is send to your program in the form of 4177951108:HOME:0 where the first parameter is the IR code, the second one the alias and the third parameter the repeat count. Repeat count comes into play when the user holds a key pressed. It is increased by one each time a pressed key is resend. If another key is pressed is it reset to zero. Even when you don’t use the notifications you should still read them and flush them into the digital nirvana because otherwise it can happen that some buffer runs full and your process cannot communicate any longer with eiri.

As with all preview releases the target audience are advanced end users and developers that want to test things. The goal is to test if the application works on a broader base of devices. The application image does nothing permanently to your WDTV, so if you experience any problems simply delete the application from your USB stick.

May 14, 2009

Preview Release Shoutcast / Internet Radio Application

Filed under: shoutcast — Tags: , , — Elmar Weber @ 21:51

As kind of a byproduct I have been working on while getting the WDTV Tools project started is a proof-of-concept implementation of a Shoutcast / Internet Radio application that delivers you the Shoutcast Radio Stations to the WDTV.

This is a preview release for a shoutcast filesystem for the WDTV. It just contains an unsorted, unchecked, un-everything browse by genre function that for the most part works.

This release is targeted at people who know know their WDTV box and Linux because there is a rather high probability that it will not work directly on your box, so you have to mount it from the command line to find the error.

Tested with ext-boot-0.9.2.

You can get the image at http://sourceforge.net/project/showfiles.php?group_id=261153&package_id=322629&release_id=682670.

Known issues:

  • sometimes the downloaded list of stations / genres has an error (you’ll see an empty folder), in this case just use another genre. If this happens at the “Browse by Genre” directory you have to reboot your device (or remount the application) and try again.
  • if you see everything but no stations plays try installing streamripper in optware, I’m not sure I have included all dependencies
  • there will sometimes be left over stream caches at your boot usb stick
  • will not work if /boot is not your USB stick, this is no problem on ext3-boot, but I don’t know about WDLXTV
  • if you play a low bandwidth stream (e.g. 64k) the first few seconds will have breaks in them because the WDTV can’t handle a half full cache, I did not observe this problem with 128k and larger streams
Screenshot of browsing a genre.

Screenshot of browsing a genre.

May 13, 2009

Finding The Path – Or Finding Out Where The Heck You Are

Filed under: osd — Tags: , , , , — Elmar Weber @ 03:18

One of the most interesting and most discussed features for the WDTV HD are GUI / OSD modifications. There are already a lot of modifications out there, several icon sets (WDTVForum Thread) and some themes (e.g. from reaverxai or here ) which give the WDTV GUI a complete new feeling. But current available mods only focus on static content, e.g. do not display context sensitive information for the current Folder / Movie.

In order to produce great GUI features like the ones from MovieJukebox we need an event mechanism that allows you to generate the GUI description (XML + images) on the fly for the current directory.

As it turns out its not that easy. Our first idea was to modify the OSD XML files the moment the dmaosd process (GUI program for the WDTV) access the directory. With a custom filesystem where you control everything this is no problem as you get notified when someone accesses your directory. Unluckily the dmaosd process first reads the OSD XML files and after that access the directory. So you always end up one directory short when you want to modify the files on the fly.

The next tries were all going in the direction to monitor what the dmaosd process does. There are several access points for this: The dmaosd process outputs lots of information to the console, including sometimes the access directory. But this output comes too late, i.e. also after the XML files are loaded. So no luck there.

AirSeb over at the WDTV Forum tried the same things and also hacked a clever solution that works and uses several elements. He monitors the dmaosd output to get the current directory, then, to get the selected directory, he monitors the infrared commands. So basically he counts the ups and downs and page up / downs and then calculates the next directory when the user hits “Enter” on the remote. He also has this working to create a cool GUI, see the first post in the thread.

However, the IR hack IMHO poses some problems when deployed to a wider user base:

  • when the theme changes the number of displayed items may change, so page up/down can be interpreted wrongly
  • the OSD skips when you hold the up/down key pressed some pages, i.e. scrolls faster, maybe hard to track this
  • when the directory content changes during the navigations, the results may be inaccurate (e.g. in a torrent incoming folder)

So, I got hacking on a solution and what follows are the adventures through the depths of the dmaosd process’ memory. The first part was to access the memory at the correct point in time, so just before the dmaosd process loads the XML files. To get this information I wrote a simple FUSE overlay based on fusexmp that intercepts all file system level calls to the /osd directory. So on the file open call for the basic_browse.xml I performend an analysis on the dmaosd process’ heap and stack memory. There were several occurrences of the current directory in the heap without any pattern or information if they were still used or just freed memory. So, I added the stack memory to the analysis and did a reverse lookup for all addresses of all strings I found in the memory, tracking back and searching for pointers to the strings. After an analysis of different memory images for different folders I found the common base address that was always the same. With this information it was easy to write a program that accesses the specific memory address and follows the pointer to the directory string.
The analysis itself is not very fast and takes several seconds (because the memory is searched dozens of times to find all pointer references), but since the pointer location in the stack memory is fixed the pure lookup is not noticeable.

Anyone who wants to take a closer look at the memory analysis tools because he wants to see if there is other information in the memory that may be useful can find the source code in the Subversion.

The next step is to combine the tool that performs the lookup (get_path.c) with an OSD overlay that executes a script every time a directory is reloaded. This way its easy for other’s to use this mechanism to produce context / directory sensitive GUI. Stay tuned.

May 10, 2009

Welcome to the WDTV Tools Blog

Filed under: wdtv — Tags: , , — Elmar Weber @ 01:42

The WDTV Tools project aims to be the central place for development for every kind of tool and application for the Western Digital TV HD. This will mainly include common utilities where other can build upon, e.g. IR modifications, OSD extensions and other stuff. Development information and tutorials will also be a part of this, these information will be in the Trac. General information regarding WDTV development will be posted here too.

« Newer Posts

Powered by WordPress