Wednesday, January 30, 2008

Perl on HP-UX

Started playing around with HP-UX/parisc again...

bash-2.04# perl -v

This is perl, version 4.0

$RCSfile: perl.c,v $$Revision: $$Date: 1993/02/05 19:39:30 $
Patch level: 36

Copyright (c) 1989, 1990, 1991, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 4.0 source kit.


Monday, January 28, 2008

MacBook Air Parody

I'm not a huge fan of YouTube, but I did find the following parody for the MacBook Air to be pretty funny:

Satellite coming crashing to Earth!

CNN, the New York Times, and most of the major news outlets are giving front page coverage to the U.S. satellite that has failed and is coming down some time in the Spring:

Didn't any of them see the episode of the West Wing where Donna freaks out about the Chinese satellite that is crashing down to Earth?

Sunday, January 27, 2008

Fun with device drivers

Continued my work tonight on my HVR-950 digital support. Forgot how fun drivers can be when you don't have the design manuals for any of the chips...

Trying to figure out why the LGDT3303 wasn't responding to I2C commands on initialization. It looks like the reset pin is actually hard-wired to one of the GPIO pins of the em2880 bridge chip. This allows it to toggle which components are active based on whether it's doing digital reception or analog. This in itself isn't that uncommon (in fact, we did the same thing at 3Com when we designed the 56K version of the OCLM - the main CPU could reset the modem chipset by just pulling up a GPIO pin).

The funny thing is though that the resetting of the demodulator is done as a product of a callback in the tuner reset.

So here's how analog support works today:

  1. em28xx driver loads
  2. Bridge initializes
  3. Driver tells bridge to initialize tuner in analog node
  4. Tuner loads firmware and trips reset
  5. reset callback from tuner sets GPIO pins enabling tvp5150 video decoder

Now the fun part is when you want to be in digital mode. The way the DVB driver is layered as an extension to the analog driver, the workflow basically looks like this:

  1. em28xx driver loads
  2. Bridge initializes
  3. Driver tells bridge to initialize tuner in analog node
  4. Tuner initialize issues reset to the tuner
  5. reset callback from tuner sets GPIO pins enabling tvp5150 video decoder
  6. em28xx-dvb digital driver loads
  7. Digital driver tells bridge to initialize tuner in digital mode
  8. Tuner loads firmware and trips reset
  9. reset callback from tuner sets GPIO pins enabling lgdt3303 digital demodulator (and presumably disabling the tvp5150 as well)
  10. dvb_attach() is called against the lgdt3303 driver

Bearing in mind that the driver supports probably a dozen different combinations of tuner, digital demodulator, and video decoder chipsets, it's little wonder that it's is such a mess.

Unfortunately, without breaking out an oscilloscope and mapping out the GPIO pins, I'm afraid to just start twiddling them until it works. Driving a pin high that's designed to be an input will likely burn out whatever it's connected to. This was another valuable lesson which I learned at 3Com when I burned the tip of my finger discovering that I had wired up a UART chip backwards (the burn took two months to heal).

After showing my father the burn, he pointed out that when checking a chip for heat you're only supposed to barely touch it. I guess little gems of wisdom like that might have been what kept me out of hardware design.


Had a pleasant weekend. Vikki came to New York. Went to Candle 79 for a nice dinner last night. Supposedly it's one of the best Vegetarian restaurants in New York according to Zagat's, and it did not disappoint.

Worked on my HVR-950 ATSC port yesterday. Got the ported em28xx-dvb driver to compile, which is a start. I'm pretty excited about it, since the bulk of the changes I had to make so far were shallow enough that I could understand what would be required to make them work in the standard v4L2 framework.

Also picked up a 3.5" external hard drive enclosure from CompUSA at 20% off. Was thinking about maybe hooking up some of the old hard drives I have kicking around in a box to rip the data off of them.

Not sure what we're going to do today.

Tuesday, January 22, 2008

Video4Linux hacking

Left work early to pick up the print of Central Park that I had framed (Christmas present from Mom). Turned out really good. Planning on hanging it in the hallway next to the front door.

Started looking at what would be required to get the HVR-950 ATSC support working under Linux. Started porting the em28xx-dvb.c from mrec's repository to the mainline (it's GPL), which is proving to be a considerable challenge for the following reasons:

  • He has a totally different implementation of the xc3028 tuner driver
  • He added all sorts of hooks to the core V4L DVB API which were never accepted in the mainline (or the community decided to implement the same functionality in a different way)
  • I don't have any real experience with the DVB API in general
  • I am spoiled by my monitor at work that is big enough to let me see fifty lines from four or five files at the same time (I have a 17" at home which makes this impractical).

The upside is that from the cx88-dvb driver, I can pretty much do a side-by-side comparison of the structure and port em28xx-dvb.c accordingly. I just have to study the cx88 driver a bit more before I try to jump in again. Perhaps doing a diagram of the structure of the driver will help me understand the flow better....

Drinking some sleepytime tea now. May read some more of Xenocide and try to get to bed at a reasonable hour.

Monday, January 21, 2008


Dan lit a fire under me to get to the bottom of some race conditions that had been stacking up in my bug queue for the last few weeks. Took a few hours of my undivided attention but I think I isolated and fixed all of them. I just hadn't had a chance to focus on anything else since I've been working to get feature complete. Still, it felt a little overwhelming this afternoon until I stepped out of the office and got some coffee.

So I've been giving Yahoo! Mail $25 per year since 2002 in exchange for 25 MB of mail storage. Since I've been using GMail for the last couple of years, the only reason I've kept paying Yahoo is because I had not moved the mail over (and I had been using it since 1998).

Finally got around to setting up GMail to rip the email over so I can drop back down to the free Yahoo Mail service (which I only keep because my website is hosted on Geocities).

Spent a good portion of the evening reading through email from the late nineties. Stumbled across this E-card from my father:

Date: Thu, 20 Apr 2000 12:29:35 PDT
To: devin_heitmueller@<redacted>
Subject: This Easter, Son, I Wish You a World of Happiness - from Bert

You have just received an animated greeting card from Bert
You'll see the personal greeting by using the following Web location.

(Your greeting card will be available for the next 90 days)
There is no charge for this service! :) HAVE a good day and have fun!

He sent it two days before his heart attack.

Friday, January 18, 2008

SQL Server puzzle

Here's a good issue Packy ran across last night. What's wrong with the following SQL?


He was showing me two SQL Server 2005 instances, side by side on his screen, and it worked on one but not the other. My initial thought was since the DBO namespace was from SQL Server 2000 and deprecated in SQL Server 2005 and he was running it against a 2005 instance, that perhaps the instance was in the wrong compatibility mode.

After playing with the SQL a bit more, we found the following worked against both instances perfectly:

select * from master.dbo.sysdatabases

Answer: the SQL collation for the instance it was failing on was set to LATVIAN_CP1257_CS_AS. Because the collation selected was case sensitive (as indicated by the "_CS"), the case sensitivity handling applies not just to field contents (such as WHERE and LIKE clauses), but also to table names, including the names of the system tables.

Something to think about if you're writing some SQL for that might be run somewhere other than in the United States...

Copyrights and licensing

I got into a conversation with some people yesterday about how copyright works. As a software developer (and therefore someone who creates copyrighted content), I take intellectual property very seriously. It's my livelihood after all, and so I'm a bit sensitive as to what others can do with my work (and how I use the work of others).

It's amazing some of the level of misconception I encountered.

For example, someone said that if you change an image slightly then the copyright no longer applies and you can freely redistribute it. Like changing a few pixels, or the colors, or giving it rounded corners...


It's called a derivative work. This is one of the most common misconceptions, and it's thoroughly documented on the Internet (here's just a small sampling):
Myth 13 -
Bullet point 6 -

Bear in mind that none of the examples above mention computer software. While they certainly apply to source code, most of the examples in the articles above refer to things like art and literature.

For those of you fellow software developers, I would encourage you to read about copyright and learn about how licensing works. Not just so you know what others can do with your work, but so you can make intelligent decisions about under what terms you can use the work of others. Especially with the proliferation of open source and the varying licenses, you will likely be prompted with questions like, "This library is under a modified BSD license - can we use it in our product? What implications/consequences would it have?"

[disclaimer - I realize that in fact I am not the copyright holder for the vast majority of the software I write, as it's almost all legally considered "work for hire"]

Tuesday, January 15, 2008

Apparently I reported a vulnerability in BugTraq

Well it's 4am, and I'm not sleeping. Not good. Friggen insomnia.

So with nothing better to do, I ran my name through Google for the first time in over a year. It turns up I got credited in BugTraq for reporting a vulnerability in the Citrix ICA protocol:

Kind of funny, since I remember the thread of discussion, but did not know that somebody had taken the result of that and registered the vulnerability in the database.

There's also a bit of irony because when I contributed to the discussion at the time I was in the process of writing an Ethereal dissector for the ICA protocol. The vulnerability published in Bugtraq is pretty superficial. However, I kept blue-screening the ICA server when I was doing my ICA dissector work, and I never bothered to publish any of those very real security bugs.

Quick and dirty stack dumps

So I had a situation where I didn't have root access but needed to get a stack trace of all the running threads in a daemon.

So I whipped up this little script, which I could just tell the sysadmin to run:


if [ "$1" == "" -o "$2" == "" ]; then
echo "usage: <program> <pid>"
exit 1

if [ ! -e $1 ]; then
echo "<program> specified not found"
exit 1


# Temporary files

/bin/echo "set height 1000000" > $CMDFILE
/bin/echo "thread apply all bt" >> $CMDFILE
/bin/echo "quit" >> $CMDFILE

# Cleanup
/bin/rm $CMDFILE
/bin/rm $STACKDUMP

It's not foolproof, but it is good enough for most situations and saves having to manually walk the user through a GDB session.

Monday, January 14, 2008

New Year's resolutions

So since the 1st, I've been reflecting a bit on things I want to change this year. Thought people might be interested in some of my New Year's resolutions. This is a mix of personal and work goals, in no particular order:

  • Figure out how to see my family more (in particular my nephew).
  • Don't be such a realist^H^H^H^H^H^H^H pessimist.
  • Be nicer to my coworkers (except Dan).
  • Find **one** open source project and stick with it. I have a tendency to get distracted easily, and the result of this is that I look at alot of code, but don't spend enough time on any one given project to make any significant contribution. In the last year, I've worked on Perl 5 core, Parrot, Video4Linux, MythTV, KnoppMyth, Komodo, and I haven't gotten far enough to really make a difference on any of them.
  • Reach out some people I haven't spoken to in a long time but should have.
  • Better organize my RSS feeds, so I can keep track of what is going on in the world around me.
  • Pay my taxes. Victoria says that's important.
  • Take better care of myself so I don't have a heart attack and die.


Had a relatively quiet weekend. Victoria came to New York City. Had Carter over Saturday night for dinner and the three of us played some Scrabble. Watched Shawshank Redemption since Vikki had never seen it before. Moved all of Vikki's files from her old laptop to her new one.

My street was shut down on Saturday because a film crew was shooting some new movie called The International. I do find some humor to a movie showing up in IMDB months while it's still being made.

Not much going happening on the tech front. Finally broke down and picked up an 802.11g router since the three year old 802.11b router I had been using just kept losing signal and requiring me to restart it (almost daily). Decided to go with a Belkin, since I had been 'borrowing' from one of my neighbors with a SSID of "belkin 54g", and I figured if I'm getting a stronger signal from my neighbor than I am from the router in my own apartment, it can't be such a bad choice.

Work is plugging along. Last Friday I found out the hard way that the Perl XML::Xerces module has an initialization routine that isn't threadsafe (causing some really nasty and hard to reproduce crashes on Win32). Committed a fix locally and will look at pushing something upstream later in the week. It's kind of surprising that a module that has been in use for years would have such a serious design flaw. I suppose not alot of people use it in a multithreaded environment.

Race conditions are my favorite type of bug...

Would like to get back to some of my Video4Linux stuff. Having some trouble getting enough critical mass to do anything productive. Kind of annoying. The last thing I worked on I spent an entire day on only to wake up the next morning and find that somebody had just made a fix for the same issue.

Thursday, January 10, 2008

Fun with the Visual Studio 2003 Debugger

Debugging a crash in Perl, and discovered a nice little nuance in the Visual Studio 2003 Debugger.

Take a look at this screenshot:

Notice how the second frame in the stack doesn't have a line number? I thought perhaps the DLL had not been compiled with debug symbols for some reason (or that the symbols had not been loaded). Neither problem was the case.

The problem didn't reveal itself until I went back and looked at the compile log file (which fortunately I had immediately at my disposal since I just rebuilt our Perl yesterday):

cl -c -I. -IHandler -Ic:\include -D_REENTRANT -DWIN32 -DHAS_BOOL -TP -GX -MD -Zi -DNDEBUG -O1 -DVERSION=\"2.7.0-0\" -DXS_VERSION=\"2.7.0-0\" "-IC:\perl\lib\CORE" Xerces.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

Xerces.cpp(65537) : warning C4049: compiler limit : terminating line number emission
Compiler limit for line number is 65535

It turns out that Visual Studio 2003 doesn't support line numbers greater than 65535. Fortunately, it looks like they increased the limit to 16,777,215 in Visual Studio 2005.

Normally, you might ask, "why on Earth would he have a single source file with more than 65535 lines?". Well, the module in question is XML::Xerces, and the C/C++ source code more the module is autogenerated by SWIG (a framework for wrapping native code so it can be called by high level languages like Perl or PHP).

Add one more reason to my list of why I want to upgrade to Visual Studio 2005.

Wednesday, January 9, 2008

Today's Perl cat test

Here is what a candidate today provided when asked to implement /bin/cat in Perl:

my $file = <ARGV>;
print $file;

Tuesday, January 8, 2008

How not to check the argument count passed to a Perl script

Pulled this little gem from a piece of sample code a job candidate sent today:


my $numArg = scalar (@ARGV);
&usage() unless ($numArg =~ /^[1,2]$/);

Thought my fellow Perl programmers might appreciate this...

Sunday, January 6, 2008

HVR-950 audio now working under V4L

Looks like, as a result of Mauro's 6952 commit, audio on the HVR-950 appears to be working (assuming I run the following command while running tvtime):

sox -r 48000 -w -c 2 -t ossdsp /dev/dsp1 -t ossdsp /dev/dsp

It might be worth noting for anybody running Ubuntu 7.10 with the latest kernel updates that the em28xx-alsa driver does not load properly showing errors in dmesg output such as:

em28xx_audio: disagrees about version of symbol snd_pcm_new
em28xx_audio: Unknown symbol snd_pcm_new
em28xx_audio: disagrees about version of symbol snd_pcm_lib_ioctl
em28xx_audio: Unknown symbol snd_pcm_lib_ioctl
em28xx_audio: disagrees about version of symbol snd_pcm_set_ops
em28xx_audio: Unknown symbol snd_pcm_set_ops

This appears to be a problem with the way Ubuntu built the snd-pcm.ko in the latest linux-backports-modules-2.6.22-14.10 update. If you remove that package (which causes the kernel to use the snd-pcm.ko that ships with the 2.6.22 kernel instead of the one in /lib/modules/2.6.22-14-generic/updates, then the em28xx-alsa module will successfully load.

Making America safe from.... shoulder fired missiles?

They're going to starting testing an anti-missile system on U.S. passenger jets:

Aviation Week says it's going to cost about $11,000,000,000 to protect all US aircraft (yes, that's 11 billion but it's more obvious how staggering an amount of money that is when you type out the zeros). The cost would go to 40 billion over the next 20 years.

Because, you know, there are so many U.S. domestic passenger planes being shot down by shoulder fired missiles.

47,000,000 Americans without health insurance in 2006.

10 Reasons To Hate Cellphone Carriers

Wired Magazine had a pretty good article summarizing why cellphone carriers suck.

No real surprises here, but it's nice to see it all in one concise list.

Saturday, January 5, 2008

Can You Count On These Machines?

At Friday lunch, we were talking about the issues with electronic voting. As it turns out, the New York Times just published an article (to appear in tomorrow's Times Magazine) that discusses the problems pretty well:

It gives a pretty good overview of the problems, for those of you not in computers who may not be familiar with how screwed up the situation is.

Friday, January 4, 2008

Plugging along...

Finished Speaker for the Dead at about 2am this morning. Will probably starting reading Xenocide on the bus to Philly tonight.

Going to Philly for the weekend. Not much of a plan beyond that yet.

Finally getting around to some long-needed cleanup of some code at work that I've wanted to do for a while. Go refactoring!

Hoping to take a look at the open source lib_x264 this weekend, to see how extensible it is to hook into the Quicktime API for the encoding phase (to leverage the Turbo.264's hardware acceleration).

Tuesday, January 1, 2008

New Years Day

Had a quiet evening at home last night with Vikki to celebrate New Years. Went to Josie's for a nice dinner. Played some scrabble. Watched the Simpsons movie on DVD.

I finally broke down and bought an iPod Nano. I spent all day playing with HandBrake and toying with various H.264 encodings. I had wanted to play with the video features for a while, and see how I might be able to better integrate it with MythTV. All I can say is that transcoding is REALLY slow. I takes about 50% realtime to transcode DVD quality 720x480 video down to 320x240 H.264. In other words, it takes about an hour to copy a 2 hour movie from a DVD to my iPod.

May take a closer look at the Elgato Turbo.264, which is a USB device with an ASIC specifically designed to accelerate the encoding process. Looks pretty neat, but has no hooks into HandBrake or any other open source library I could find.

Learned about some of the deficiencies of the DAAP protocol. I would really like to have a central repository for all my iTunes content. Looks like DAAP is a read-only protocol though and you can't sync the shared content to your iPod using iTunes (or manage playlists, or add new content, or any other "write" operation). Kind of annoying. I guess I can use nfs/rsync, but I was hoping for a cleaner solution...