Yeraze's Domain 3.0

Supercomputers, Programming, and Life in Mississippi

Entries for June, 2007

Airlink AWLL3026 802.11g Adapter

My dad was kind enough to give me a $10 Airlink AWLL3026 802.11g USB WiFi Adapter.  I had been looking for one for a while to replace the long Cat5 Ethernet cable strung around the house, but I had no experience dealing with Linux’s WiFi support.  It was a bit of work, but I did finally get it working.

At first when I inserted the device, my System Logs showed that it was recognized, by the zd1211rw module.  Unfortunately, the module failed to load with a Firmware error.  After downloading the new firmware from sourceforge, and following their instructions got the module loading properly when I reinserted the device.  However, when I reinserted the device I noticed that it was loaded as "eth0", which is incorrect.  Running the "iwconfig" tool showed it on eth3, but all attempts to actually bring up that device resulting in error messages.

Around this time, I found a forum post indicating that the zd1211 driver has a bug that only allows it to load successfully the first time.  So when I removed the device & re-inserted it, the driver got confused and, hence the eth0.  A reboot later, I saw the device up and running and set out to configure linux’s WiFi support for my access point.  This is where things got tricky.  I edited the /etc/network/interfaces file, and added the following:

# /etc/network/interfaces — configuration file for ifup(8), ifdown(8)

# The loopback interface
# automatically added when upgrading
auto lo eth3
iface lo inet loopback

iface eth3 inet dynamic
        wireless-key <my security key >
        wireless-ap <my AP’s address>
        wireless-essid Gauntlet
        wireless-mode managed
        wireless-channel

I tried to bring the interface up, and no matter how long I waited or how many times I tried, it would never successfully get a DHCP address.  I tried several combinations, before stumbling upon one oddity:  If I ran a "iwlist scan" (Which scans for Access Points), then it could retrieve a DHCP lease.  It was an odd behavior that I could never fully understand.  I ran test after test after test, before I finally accepted the unusual truth:  The USB WiFi dongle simply can’t get a DHCP lease without performing a scan first. 

With that knowledge in mind, I finally built my /etc/network/interfaces file like the following:

# /etc/network/interfaces — configuration file for ifup(8), ifdown(8)

# The loopback interface
# automatically added when upgrading
auto lo eth3
iface lo inet loopback

iface eth3 inet static
        address 192.168.1.1
        netmask 255.255.255.0
        wireless-key <my security key>
        wireless-ap <my AP’s address>
        wireless-essid Gauntlet
        wireless-mode managed
        wireless-channel 6
        post-up iwlist scan
        post-up dhclient eth

This file loads the interface as a Static IP of 192.168.1.1 .  Then, once the interface it up, it performs a "iwlist scan", then starts up dhclient to get an IP address.  It’s a bit cumbersome, but it works.  Hopefully this will help someone else get their Airlink key up and running.
[tag:linux][tag:wifi][tag:airlink]

Microsoft’s MCE Remote

For my MythTV, I have a Microsoft MCE Remote to control it.  It’s supported under linux via the mceusb module.  As much as I typically hate anything Microsoft, it’s a surprisingly good remote and works very well.  I reprogrammed the "TV" button to operate the Power control for my TV, and made some fairly extensive customizations to the lircrc file to configure the extra buttons to work better.  The biggest change was moving the "Menu" controls from the "OK" button to the central Windows button.

But over the last few weeks, the remote has started randomly "shutting down" for no apparent reason.  I’ve heard of this before, and most people claim to simply replace the remote (It’s only $35 afterall) and everything’s better.  Most folks simply chalk it up to a fragile design, but it seemed pretty odd to me.  Of course, the first thing I checked was the batteries.  My multimeter showed them at nearly full charge and they worked just fine in other remotes.  I did some more research, and couldn’t find anything to fix it.  It seemed the only solution was to simply remove the batteries, wait about 10 minutes, and then reinsert the batteries.  That fixed it every time, but it’s an annoying thing to have to do when you’re navigating the list of recorded programs.  A 10 minute "please wait" is really not very WAF-friendly.

Today, however, I replaced the existing Energizer AA’s with my NiMH Rechargable AA’s (I love these things).  To my surprise, the entire remote seems to be "cured".  The previous batteries still test just fine, but there seems to be some kind of sustained voltage drain problem.  The remote would only shut down after I hit many buttons in long sequences (Navigating long menus or long lists), and I guess there was just a slight fluctuation that would cause the remote to "lock up".  Anyway, it’s fixed now and if anyone else comes to this page with similar problems: Just try switching the batteries.
[tag:mythtv][tag:mce][tag:remote]

Whirlwind of a Week

Last week at UGC just flew by.  While the flight there was a nightmare (Weather over Houston made us 5 hours late getting out of jackson), the flight back was uneventful.  I have, however, now completely read the entire Harry Potty series (Just finished the Half Blood Prince yesterday) and I’m really looking forward to next month’s movie.

So here’s a few quickie links I’ve come across this week:

  • The KeyPort – a key fob similar to the kind that ship with newer cars, except it hold 6 keys.. The FAQ says it should sell for under $50.  It would be great to drop all my carkeys, housekeys, and workkeys into 1 fob that doesn’t jangle and clang in my pocket, or scratch up my cellphone.
  • New Bad Behavior plugin for Geeklog – Just installed it.. Worked perfectly, and hopefully it’ll fix the recent problems I’ve had with spammers & garbage registrations.
  • A MSNBC Reporter refuses to talk about Paris Hilton – bout time someone finally did…
  • Bloxorz – an addictive little flash puzzle game
  • A great pair of Firefox Plugins:
    • Find Toolbar Tweaks – With this you can replace the "Quick Find" bar with the full Find Bar, and make the "Highlight All" option permanently on.
    • Search Marker – Extends the Highlight All functionality to put notches along the scrollbar where matches are.  Great for long documents.

I’ve been writing a file-reader for VTK this week, something similar to the vtkImageImport but mine supports striding, multiple datatypes, and GZ or BZ compressed files.  I’m proud of it, and it’s working great so far.  The zlib and bzip2 libraries are alot easier to work with than I expected.

The MythTV has been working great as well.  It finally lapped on the Voyager recordings, so it’s stopped recording episodes unless they’re ones i didn’t get to watch the first time. Same thing with Enterprise.  I did add a WiFi USB Internet adapter to the box a few weeks ago, and that proved to be a bit of a challenge.  It was an cheap $10 unit that my dad picked up using a Zydas 1211 chipset.  I’ll post more on that in a bit, hopefully what I discovered will be of use to someone.
[tag:keyport][tag:news][tag:firefox]

Pittsburgh, Pennsylvania & FlexCar

So, I’m up in Pittsburgh, Pennsylvania for the UGC2007 Conference.  It’s pretty sunny and fairly warm, you can break a sweat by beating outside for just a few minutes.  Lots of construction too, new buildings, bridges, and renovations goin all around.  The construction kinda makes the place a mess and difficult to navigate around, but we’re doin ok.

One interesting thing I saw today was a "FlexCar".  At first I thought it meant Flex-Fuel, but after a bit of research I found it’s actually a community rental-car program. Once you register, you can reserve & borrow a car for the low rate of $8 an hour, or $36 a day.  The cars seem to be in pretty good supply, and for a city with the population of a major metropolis, it’s probably a pretty significant cost-savings over making a car-payment and parking fees for it.  Shame there’s not something like it in Vicksburg. 
[tag:pittsburgh][tag:conference][tag:travel]

Huge Mallocs & 64-bit Wonkiness

A few months ago I wrote a piece of code capable of reading large "RAW" files on disk into VTK ImageData structures.  It works pretty well, and I’ve seen some simply amazing results from it in ezViz. (One researcher Volume Renders his 1080×540x1080 dataset in 38 seconds load-to-PNG with it!) It does some fancy stuff like support various data types (char, integer, float, signed, unsigned, etc) and support byte-swapping.  It wasn’t all that hard to write, although it does require that the entire file fit in memory in 1 chunk.

Well, a few weeks ago a researcher sent me an email saying that he was getting an error "Unable to allocate memory", quickly followed by a segmentation fault.  I recognized the error as a sanity check I added near the malloc in that code.  I figured he simply didn’t have enough memory on that machine, and suggested he try it on Amethyst (with it’s 128G of memory).  Yesterday he finally got a chance to try it, and still got the same error.  We talked for a bit, and he gave me access to his data & scripts and I tried it.

The file he was loading was a 1080×540x1080 grid of Floating points.. Do the math and you get 1080×540x1080*4(bytes per float) = 2,519,424,000 bytes, or roughly 2.5G of memory.  That should have fit easily into the 128G of ram on the machine, so what was going wrong?  I initially thought I had hit a 2GB memory barrier, so began looking for a 64-bit version of malloc.  From what I could find, 64-bit linux automatically uses 64-bit compatible malloc, so that wasn’t the problem. 

After a bit of searching, I finally found the problem.  The code looked like this:

    if ((data = (unsigned char*)malloc(iSize * jSize * kSize *
                                       NumComponents * NumberSize))
             == NULL) {
        perror("Unable to allocate memory!nt");
        return NULL;
    }

Seems simple enough right?  So what was going wrong?  After some diagnostics, I realized that the large multiplications (i*j*k*components*size) was all being done with Integers, which overflowed at 2^31 (2,147,483,648 ), so it was returning a big negative number.  Since you can’t allocate negative memory, it returned an error.

The solution was simple enough: Typecast everything as long:

    if ((data = (unsigned char*)malloc((unsigned long)iSize *
                                       (unsigned long)
jSize *
                                      
(unsigned long)kSize *
                                       (unsigned long)
NumComponents *
                                       (unsigned long)
NumberSize))
             == NULL) {
        perror("Unable to allocate memory!nt");
        return NULL;
    }

That fixed it.. Works like a charm now.  Type conversion in C is one of the trickier problems to find and figure out, and one again I got burned by it.
[tag:c][tag:memory][tag:malloc][tag:64bit]

A Bit too much excitement

Updated 6/14, with the Police Report
True story, from 1 hour ago.  So I’m at home today, all by myself, just chilling with lunch in front of the TV.  Everything good, right?  Right as I start to enjoy Dirty Jobs, I hear a helicopter outside.  No biggie, I hear them alot.  The local news channels run helicopters alot, and we’re fairly close to the airport.  No biggie.

About 30-45 minutes later, I notice I’m still hearing that helicopter.  It seems to be making laps around the house. I poke my head out the back door and notice this balding white guy crouched behind the fence between myself and my neighbors.  He pops his head up, and pulls himself up onto the fence.  He stops for a few minutes, trying to figure out what to do.  By this point, Daisy is going nuts barking and growling from the safe distance of the porch.  I don’t recognize the guy, the family next door is black so he doesn’t really belong.  I walk out the back door (like an idiot) and start to walk over to him.  He quickly jumps the fence into the neighbors yard, and walks around to the other side, and I don’t see him any more.

So, I go back inside and go through the garage out to the front door.  Sure enough, the helicopter is still circling, getting lower and close to the house with every pass.  I look down the road and see the neighbor’s minivan parked in their driveway, with someone in the driver’s seat on their cell phone.  I look a little further down and see everyone standing in their driveways, on cell phones.  What the hell is going on?

Finally, it hits me.  I grab my phone and call the local police department.
   
    Operator: Clinton police department, how can I help you?
    Me: There’s a helicopter that’s been circling over my house for the last hour or so and I was ..
    Operator: (concerned) Sir, where do you live?
    Me: (give her the street name)
    Operator: Sir, get inside your house and lock the doors.. We have the situation under control.
    Me: uhhhhh… Would you be looking for a balding white guy with a blue t-shirt & blue pants with a yellow stripe?
    Operator: Yes sir, we already have units dispatched to your area.. Remain inside your house.
    *click*

Sure enough, soon as I hang up the phone I see 3 squad cars screaming down the street to lock up the tires at the dead end.  They all file out and pour into the woods.  I go back inside, lock up, and wait.  Sure enough, about 20 minutes later the cops come back out of the woods and drive away.  I call the police dept back, and they’ve caught the guy.

A few minutes later I see the neighbors come back outside to enjoy an afternoon in the pool.  I walk over..

    Me: You guys ok?
    Neighbors: Yeah.. How ya doin?
    Me:  Did they catch the guy?
    Neighbors: Yeah, my husband says they did.. Is that why the cops were here?
    Me: Yeah, you didn’t see him in your backyard?
    Neighbors: (dumb stare)  What?
    Me: He jumped the fence and ran into your backyard..
    Neighbors:  What?

They had no idea he was that close.  Apparently the wife/mother was inside the house, asleep during all this.  One of her friends was the driver of the minivan in the driveway, sitting there trying to reach her inside while this was going on.. Neither of them knowing the guy was less than 20 feet away, in their backyard.  They were visibly upset about the whole situation, and I had to give them all the details.  Including the fact that he took something from their backyard and/or threw something into their pool  (I don’t know what, just saw him kneel down to get it).

So, the situation is over now, but I’m still pretty shaken up.  If I hadn’t been home, would he have come into our backyard?  Would he have come into our house?  Daisy seemed to slow him down a bit, but he didn’t actually go away until I stuck my head out.  I’ve got alot to think about now… Home Defense, Alarms, etc… This week just keeps getting weirder and weirder.

Update: 6/14/2007
The weekly Clinton newspaper finally ran, and in the police reports I found this:

A Trout, La., man has been charged with eluding police after leading Clinton police on a foot chase.

Hinds County sheriff deputies and the Metro One helicopter helped Clinton officers spot John Paul Bell, 38, in the early hours June 10 after he allegedly pointed a weapon at Clinton police officer Darin Lofton.

Police received a call that a man was jumping in front of I-20 traffic about 11:30 p.m. June 9. When Lofton responded, Bell began running, turned and pointed some type of weapon at Lofton and then ran off again, according to reports

Three hours later, Bell was captured near the Abby Oak area of Trailwood subdivision. He allegedly had a pellet gun in his possession.

He has been charged with eluding police, resisting arrest and simple assault by physical menace. Bond was set at $2,000. As of Monday morning, Bell was hospitalized at the University of Mississippi Medical Center for psychiatric treatment, according to police reports.

That’s an exact cut-n-paste of the article, although I think they got some of their dates/times mixed up.  i think he started jumping in front of traffic atound 11:30 AM, and I have no idea what they mean about June 10th.  Nonetheless, it sounds like it was just a random crazy guy in the area.

[tag:home][tag:criminal][tag:police]

Practical MythTV

In my line of work, I read alot of technical books.  Technical books tend to wind up as either incredibly useful reference manuals, or a memorial for the rain forest.  Companies like O’Reilly typically hold the "gold standard" for good manuals, and I own quite a few.  But earlier this week a got a copy of "Practical MythTV: Building a PVR & Media Center PC" from APress, and I have to admit I’m impressed.  Granted, my MythTV box is pretty much finished and working just fine, but it’s helpful to have these kind of books around just for reference and ideas, and it seems the more that my friends hear me rant about the power of a MythTV, the more they want to have one too.

The book starts with an introduction of PVR’s, covering Windows Media Center, SageTV, and even  the Tivo.  After that is a great discussion of typical PVR Hardware, with discussions on Hard-Drives, Video cards, and Video Capture cards.  They discuss linux kernel compatibilities, hardware acceleration, and cross-compatibility problems you’ll want to avoid.  After that, they jump right into the Linux Install.  While, personally, I would have recommended KnoppMyth or MythDora, they instead choose Ubuntu.  Initially this seemed annoying, but with further thought I think they really took the right track.  Projects like KnoppMyth and MythDora, while mentioned briefly in the book, change too quickly to really be properly covered in any book (By the time it reached print, another version is out).  Building their entire MythTV rig on a standard distribution allows them to cover installation of Linux with some detail, and then installation and configuration of MythTV and all the associated modules (PVR drivers, plugins, system services, remote drivers, etc) in such a way that it will be useful for several versions to come.

From there the book quickly dives into the nuts and bolts.  They spend a large portion of the book discussing how to setup recording schedules with the program guide, search functions, and even the "Advanced Scheduler" (This part I found particularly interesting as I haven’t figured out to make this work on my system yet).  Resolving conflicts, setting up intelligent schedules, lots of great information in here, enough to fill up 80 pages of this 345 page book.  Then they move into using themes, creating your own themes, all the major MythTV Plugins (downloaded from source and then compiled), how to setup multiple front-ends (This topic is at the heart of many, many mythtv discussions), and working with DVD’s.  It’s a great resource, and one I plan to use frequently as my MythTV experiments grow in complexity.  One chapter of particular interest is on "Expanding MythTV", which discusses concerns and tests you can run for adding new hard drives, adding new tuners, and setting up multiple backends.

If you’re interested in setting up a PVR, then this is definately a book to check out.  APress sells the paper version for $30, and offers an eBook for $15.  Amazon offers it for $19.79, but I doubt that price will last long.  I definitely give this book a 5 out of 5, and plan to keep it right next to my MythTV.  [tag:mythtv][tag:book][tag:reference]