Sunday, April 21, 2013

Dead End

It is springtime here at Mad Scientist Labs, though you would never know it.  Mother Nature has decided to totally screw us out of our spring.  Snow still covers most of our yard.  I took Buddy for a walk today wearing an old parka and nearly froze to death.

"That sucks", you must be thinking.  You would be thinking wrong.  The weather sucking outside lets me play around inside with little gadgets and gizmos.  The focus of my efforts the last couple of weeks has been trying to get my Stellaris LM4F120 (bought for the princely sum of $4.99 with free shipping) to play nicely with a little RF1100SE CC1101-based board I picked up at Deal Extreme.  The goal here, of course, is to pick up the signal from my Davis Weather Station's Outdoor Sensor Suite (ISS).  In other words, I want to get the Stellaris to tell me how cold it is outside without me having to walk the dog to find out.
Stellaris On Left, RF1100SE On Right, BMP085 Module Hanging In Mid-Air In Middle
"Should be a piece of cake", thought I.  Long ago, I had figured out the mysteries of the ISS wireless transmissions, going so far as to get my Pretty Pink Pager to work as a portable weather station.  Turns out it wasn't so simple.  It might not even be possible.

I've burned a couple of weeks on this trying to get it to work, and when it works, it barely works.  I was seeing all kinds of strange things, and I didn't know if it was my unfamiliarity with the Stellaris board or with the poorly documented RF1100SE CC1101-based module.  At times I would get a bunch of garbage.  At times I would get nothing at all.  But now I think I've come to a conclusion: if you are thinking of picking up one of these RF1100SE boards to work at anything other than 433 MHz, don't to it.  Simple as that.  And here's why.

This picture is taken from the CC1101 datasheet for using the module at 433 MHz.
Recommended CC1101 Schematic for 433 MHz Operation
And this picture is taken from the same datasheet for using the module at 915 MHz, the frequency the ISS operates at.
Recommended CC1101 Schematic for 915 MHz Operation
The two circuits are very different in the connection between the CC1101 and the antenna.  The 433 MHz recommended circuit has four inductors between the chip and the antenna, while the 915 MHz recommends either six or seven inductors between the chip and the antenna.

Now, here is a picture of my module taken from the DX website.
RF1100SE Module With Inductors Circled
Count the inductors circled in red and it becomes pretty obvious pretty fast that these RF1100SE modules are designed for 433 MHz operation.  I feared that this might be the case, and I hoped that getting a proper length antenna for 915 MHz operation might be enough.  It is not.

This is the output from my Stellaris board talking SPI to the RF1100SE with a 915 MHz antenna attached.
This Sucks
This is what I get after tweaking the register settings to within an inch of their life.  You can see all kinds of things here.
  • My frequency error (a two's complement value shown on the very right" is about as low as you can get, so I'm dialed right on the signal.
  • My RSSI value is terribly low: I'm barely seeing the signal above the background noise.
  • As tweaked up as I am, I'm still seeing a lot of bit errors.  Those packets starting with 68 and 78 are corrupted - all of the packets from this ISS should end with zero.
  • You can't see it here, but many times the radio misses the packet altogether.
In the process of banging my head against a wall, I went looking for other people using this RF1100SE module at 915 MHz and found none.  People have tried but I haven't come across anybody reporting success.  And this is why.  The CC1101 needs a very different circuit between the 433 and 868 / 915 MHz bands.  This board is designed for the one, and getting it to work at the other isn't going to happen if you expect any kind of performance out of it.

What to do, what to do?  Not quite sure yet.  Any kind of CC11xx module that doesn't already incorporate some kind of processor on it (8051, Atmega) and is cheap seems to be designed for 433 MHz.  What I'm looking for is just the RF chip itself that I can drive directly with the Stellaris board without having to fuss with two different toolchains, processors, etc.  I might have to consider a non-CC11xx type chip instead, like something HopeRF based (like this one, or maybe this new one out soon).

Anyway, this problem was just consuming me for a while.  It wasn't the "not working" part, it was the "why isn't it working" part.  I gave up several times trying to get this working, only to keep going back to it when I realized I couldn't stop thinking about the problem.  Now I know what's wrong.  I haven't been defeated.  I just realize that victory with this module doesn't look to be possible, and I'm OK with that.  You can't do what you can't do.

Mad Scientist Labs: wasting weekends so that you don't have to.

Saturday, April 6, 2013

Happy Birthday, Buddy Boy

Around April 1st, our dog Buddy turned a year old.  I say "around" because we're not exactly sure when his birthday is.  He is a rescue dog, and it turns out he is lucky to have gotten as far as he has.

I've blogged about the experience we had when we first came across the little guy.  He basically went right through somebody to come and greet us when we first visited the shelter.  "There was something about Buddy", we said back then.  One thing led to another, and we ended up bringing the little guy into our home last August.

After we got him home, we found him to be a little different than we expected.  I would say he was either On or Off.  When he was On, he was tearing around as you'd expect a puppy to tear around.  When he was Off,  he was powered down and very low energy.  We thought it was maybe because he hadn't had the best start in life.  Now that he was living with us, he was getting the food he needed to finally get growing, and all that growing would take a lot of energy.  We were wrong.

Buddy was battling bladder infections from the first weeks that we brought him home.  We were lucky to catch this and get him to the vet for treatment.  He would go onto antibiotics for a couple weeks and would seem to do OK while he was on them.  He still wasn't a dynamo, but he'd spend less time "Off" and a little more time "On".  Then the antibiotics would finish up and he'd be fine.  For a couple days.

Then he'd get sick again.  And then again.  The poor little guy went through five rounds of antibiotics for his bladder infection.  Different meds, different durations, and each time we thought that this time would do it.  He'd do OK while he was on the meds and for a couple days after they ran out, and then he'd get sick again.

His fifth round of meds wrapped up while I was off traveling on business and, as per usual, he seemed to be doing OK.  Then he got sick one night.  Really sick.  My Lovely Wife stayed up with him all night and rushed him into the vet the next day.  The news was not good.  Based on their initial look at him, they thought he might be in either liver failure or kidney failure.  My wife was girding herself for having to make a terribly difficult decision with me a few thousand miles away, and with the loss of our last dog Abby still weighing on her mind.

But we caught a break.  The blood tests came back and what they discovered was the infection in his bladder had moved on to his prostate.  They hadn't looked for this previously because prostate infections happen in six year old dogs, not six month old dogs.  Buddy was the youngest by far of any dog they had seen with this problem.  It was the astute observations of Buddy's behavior that my wife relayed on to the vet that caused them to look down this road.  The vet told her that Buddy wouldn't have made it if it were not for her.

Now prostate infections are nasty bastards.  The wall of the prostate is very thick, and it is difficult for the drugs to work their way in there.  The course of treatment the vet called up would be 12 weeks long, with medication given twice a day.  This treatment ended a month ago.  When it did, we held our breath and waited to see if the infection would come back.  My Lovely Wife watched him like a hawk.

Days passed.  Then weeks.  And now a month, with no sign of the infection reappearing.  Buddy is now "On" pretty much all the time.  He has tons of energy.  He is strong.  He tears through the house.  He runs everywhere, blasting through deep snow like a plow.
That Name Again is Mr. Plow
Buddy seems to be making up for lost time.  The infections and subsequent treatments had robbed him of his energy.  The vet was also afraid that his growth could be stunted.  But this pup is a fighter and will not be denied his youth.  He eats like ten dogs plus two and is putting on some solid size.  He now stands around 24" at the withers, and is pretty close in size to what Abby used to be.  I keep thinking he looks a lot smaller, but some pictures we have tell a different story.  Plus, big dogs tend to grow until they are 14 - 18 months, so he might have a few pounds yet to go.

An interesting side note in Buddy's time with us here was that, besides not knowing when his birthday was, we didn't know his breed either.  I mean, we had no clue as to what his breed was.  Many people saw German Shepard in him.  Some saw Rottweiler.  A few people guessed Alaskan Malmute.  I hate not knowing stuff, so we got all CSI-like and had his DNA analyzed by DNA My Dog.  For $50, you too can have a cheek swab from your dog analyzed.  What we got back was...

  • Level 2 Golden Retriever (?!?!?)
  • Level 3 Siberian Husky

Level 1 would indicated a purebred and we knew for sure he wasn't that.  The Siberian Husky made a lot of sense to me (his massive forelegs should have been a dead giveaway) but the Golden Retriever didn't seem to add up.  Then a few months went by and golden-colored bits of hair started to show up around his eyes, legs, and tail.  Looks like they were right on after all.
Not To Mention An Arse Almost As Hairy As Mine...
Buddy's lineage explains his love for the snow.  But another trait of Siberian Huskies is that they apparently like to bury things.  That explains stuff like this...
This Spells Doom For Our Garden This Year

But where we really seem to be lucking out is his temperament.  He seems to be quite a good natured little guy and will capture your heart if you give him half a chance.  He has also been incredibly well behaved as a puppy.  You hear horror stories from people with a new puppy that have their furniture torn apart.  The worst we've suffered is Buddy chewing a bit of a hole into the heel of a slipper.  He's had pretty much the run of the house whether we are home or not since he's been around eight months old, and has never made a mess in the house except when he was sick.  His crate sits downstairs unused and empty.

This is a story that certainly could have gone another way.  Could have but didn't.  We seem to have a healthy, happy, and well-behaved puppy on our hands.  That's what we had last time around with Abby too, and she turned out to be the best dog that we could have possibly hoped for.  Hopefully lightning strikes twice.

Saturday, January 5, 2013

2013: The Year That Will Be

In the novel Flowers For Algernon by Daniel Keyes, a man named Charlie Gordon with an IQ of 68 is selected to have an operation to increase his intelligence following a similar surgery on a laboratory mouse.  The surgery works but the results turn out to be only temporary.  The story is told through the diary that Charlie keeps as his intelligence shoots up, only to later fade away.

This was one of those books that I was assigned to read in grade school, and it is one of the few that really stuck with me.  It has played on my mind more and more in the last few years.  I am at the age where my mind and body are not quite where they used to be.  I have worn glasses since I was around 10 years old but recently had to go to progressive lenses.  I sometimes have trouble putting a sentence together because the words just don't come (oddly enough, this seems to be restricted to nouns: persons, places or things).  My memory is terrible.

I am stronger than I have ever been but I realize that that won't last forever.  At some point I will go from gaining strength, to maintaining it, and then to losing it.  Aches and pains now stick with me longer.  I think I might have a touch or arthritis in a joint or two.

What to do?  Well...
“The path I choose through the maze makes me what I am. I am not only a thing, but also a way of being--one of many ways--and knowing the paths I have followed and the ones left to take will help me understand what I am becoming.”
The key in the quote above is "The path I choose...".  Every morning when you wake up gives you the opportunity to make a new and better choice.  I think I let a few too many years just kind of slide by.  A friend of mine likes to say that "Youth is wasted on the young."  Indeed.  But no more.
"I'm like a man who's been half-asleep all his life, trying to find out what he was like before he woke up."
I now regularly challenge myself both physically and mentally.  I want to use my time to reach my goals and get things done.  I love the internet for letting me expand my horizons into areas I never knew existed or thought I'd be able to do.  For example, I was never much of a cook but thanks to Sous Vide and a little motivation, I can whip up a pork tenderloin or turkey breast that is better than any restaurant in town.  And with a few simple techniques, I can serve that with a slice of bread so good it would make you cry...
... Like This Blue Cheese & Toasted Sesame Seed Bread
Now more than ever, I feel at the top of my game.
“I'm living at a peak of clarity and beauty I never knew existed. Every part of me is attuned to the work. I soak it up into my pores during the day, and at night—in the moments before I pass off into sleep—ideas explode into my head like fireworks. There is no greater joy than the burst of solution to a problem. Incredible that anything could happen to take away this bubbling energy, the zest that fills everything I do. It's as if all the knowledge I've soaked in during the past months has coalesced and lifted me to a peak of light and understanding. This is beauty, love, and truth all rolled into one. This is joy.”
Accomplishment.  That is now where it is at for me.  I want to learn new things, make things work, and get things done.  My biggest problem now is finding the time for all of the things I want to do.  I have to force myself to focus instead of taking off on a dozen different tangents.  I realize that I'll never get good at anything new if I spread myself too thin.  I also have some upcoming obligations that will dig into that time even further.

In my last post, I reviewed the goals I set for myself in 2012.  I worked hard to try and hit those goals, and the ones I missed weren't for lack of effort.  The list itself was an excellent motivator.  Given that, it is time to set myself a new list for 2013.  Note first, however, that these are not resolutions along the lines of "I will quit smoking next week."  I wrote last year how resolutions of that type just show that you suck.  If there is something you want to do, and you can do it right now, then why aren't you doing it right now?

Working Out

I set a stronger squat as one of my goals for 2012 and this is a very worthwhile goal to carry into 2013.  It lags well behind my deadlift that I am quite happy with.  The squat is one of those standard strength markers that people measure themselves by.  Like I realized last time, I must continue to build up my bottom position strength to achieve some decent gains here.  I'll carry over the same goal that I set for myself last year, which was...

Goal #1: Squat 280lbs for a single rep below parallel.  285lbs - 290lbs would be even better.

I posted this video last year, and it is no less awesome this year.

 I get mistaken for Tom Platz all the time

I'm happy with my Military Press but I have a fairly crappy Bench Press.  I'll continue to work on the latter, but really it is the lift I care the least about.  It can also be pretty tough on my shoulders, so I'd rather maintain good shoulder health instead of trying to wring a few extra pounds out on this one.

Work

I mentioned last year that work isn't really something I talk about on this blog so I will continue not to do so for the most part.  However, it is worth mentioning that I am often called to put in substantial amounts of extra effort as required.  This leaves me with less time to play around with the stuff I talk about here.  Hopefully things won't be too crazy this year in that respect.

Hacking

One of the things I wanted to get done last year was some basic home monitoring set up.  If I head off for a weekend in the wintertime, it would be nice to know that my furnace is still running without having the neighbor to check in on it daily.  I have myself a couple of JeeNodes that I have been playing around with but I haven't had enough time to really dig into them and get them talking back to, say, my router which could then push the data out to someplace like Cosm (nee Pachube).  So this goal remains the same as I set it last year...

Goal #2: Get some basic home monitoring going by 2013.

For some time I have also been playing around with my Davis weather station.  I wrote a little while ago that Davis is actively working to close off this platform and prevent me from getting at my own data.  I wasn't very happy about this.  Their actions have made me even more determined to implement my own alternative receiver.  My current platform is a Pretty Pink Pager, and while the cool factor in this approach is off the charts, it isn't a solution that lends itself to widespread use by others.  I want to take an approach that is more accessible.

I'm mulling over a couple of different options for an alternative receiver.  Right now I'm liking PanStamps.  These are Arduinos with an on-board radio receiver chip compatible with that used in the Davis console.  They also seem to have a very nice low level library that would let me work with the radio chip at the level I need.  Another consideration is using a Ciseco Eve Alpha.  This has the benefit of being multi-radio capable but they aren't calling it "Alpha" for nothing.  Either way...

Goal #3: Reverse engineer the Davis frequency hopping algorithm and implement it on an independent platform.

and while I'm at it...

Goal #4: Get a skeleton driver for the Davis console into MESS.  This one won't make much sense unless you've read my earlier post on the subject.

I consider #4 to be like a KickStarter-like "stretch" goal.  It would be great to get this done, but it will take a lot of work to make it happen.  The AVR emulator in MESS right now will need some enhancements to work with the specific chip used in the console, and I'll have to implement a sufficient level of functionality within the emulation to make it worthwhile submitting.  However, doing so would enable a lot of other people to dig into the console and figure out what makes it tick.  It would also be fun to be part of the MESS project itself.

Wrapping Up

That should do it in terms of goals but I won't be restricting myself to just those.  There are still a lot of other things I want to get done this year, such as
  • I have a bunch more landscaping I want to get done around here.  There is an area around our walk-out deck that needs to get finished up that is going to take a ton of work.
  • I want to grow more of our own food out here.  We have a great garden that we get a lot of wonderful fresh vegetables from.  Last year we planted some grapes and kiwis and are looking forward to their fruit this year.  This year I'm thinking strawberries and more haskaps at a minimum.  Deer, rabbits, and other critters remain our nemesis.
  • I'd like to learn a little OpenGL and maybe play around with more emulation stuff.
These things lead me to the same goal I set myself last year.  I met this goal, but it is a goal that can never be considered complete.

Goal #5: Keep this blog going, share the adventure, and enjoy the ride.
“Strange about learning; the farther I go the more I see that I never knew even existed. A short while ago I foolishly thought I could learn everything - all the knowledge in the world. Now I hope only to be able to know of its existence, and to understand one grain of it. Is there time?”
And I also want to re-read this book.

Tuesday, January 1, 2013

2012: The Year That Was

Today is the first day of 2013.  I sit at my kitchen table in front of my laptop with a compile of MESS going in the background.  Like many people today, I sit here finding myself thinking back over the last 365 days.

Certainly, the biggest thing that stands out for me was the passing of our dear dog, Abby.  She was a constant and faithful companion for her eleven and a half years, and was a far better dog than we could have hoped for.  I think about her all the time.
Abby:  January 2001 - August 2012
We now have Buddy in our lives.  Buddy is quite a different dog than Abby was, and certainly a lot more will be written about him in the days and weeks ahead.  He has scared us with some health issues and he has entertained us with his puppy-dog antics.  I look at him each day and wonder what kind of dog he'll turn out to be.  The one thing we learned from Abby is that this is pretty much impossible to predict.
Impossible, Except To Say That He Is Going To Be Trouble
Anyhoo, I sat down and set some goals for myself in 2012 around this time last year.  This was actually a very useful thing to do.  I like to cross things off my TODO list, and I found that putting this list out there was a pretty strong motivator in getting me off my butt.  I need to mull this over a bit still, but I certainly want a new list going in to 2013.  In the meantime, why not take a look back while waiting for the compile to finish to see how I've done in 2012?

Working Out

Goal #1 Hit: "Deadlift 405lbs for a single rep. That's four wheels a side. This goal should be doable. I just have to do it."

It wasn't long after I wrote this that I wrote some more about how much it sucked to have written that in the first place.  In a nutshell, why was I talking about something I could do rather than just going and doing it?  So I went and did it, and made it with pounds to spare.  The year went by and my deadlift continued to improve, culminating with this bad boy.
435 lbs, Baby

Goal #2 Missed (barely): "Squat 280lbs for a single rep below parallel.  285lbs - 290lbs would be even better, as this would be 2x bodyweight."

This was a case of "close, but no cigar".  I hit a 275 lb squat in May, a weight that was indeed 2x my bodyweight at the time.  But 275 lbs is not 280 lbs, so I did not reach this goal.  It wasn't for lack of trying though.  I hit that 275 after several runs of Sheiko, an extremely high volume routine designed to bring your numbers up.

This is a worthy goal to keep shooting for.  Unfortunately, a long stint in Mexico has caused my strength to drop off sharply and my squat seems to have been hit the hardest.  It is coming up again since my return, but a second trip is on the horizon and back down I'll go.  Such is life.

Hacking

Goal #3 Missed: "Get some basic home monitoring going by Christmas 2012."

I put some considerable time into this one but didn't hit it either.  I ran into a couple of snags.  First was the aforementioned  long stint in Mexico.  Second was that my WRT-54G router decided to start acting flaky as I sat down to implement some of this stuff.  The idea was to hack the router so I could plug a Jeenode into it to act as a receiver to other remote Jeenodes around the house.  I added the serial port and SD card mods, but my attempts to get Optware installed on the thing were randomly failing and I couldn't figure out why.  I had suspected bugs in the custom firmware and kept trying various options to see if that would make the problem go away.  Then the router fell over altogether so I bought the mighty Asus RT-NT16 to replace it.  That router now runs Tomato by Shibby with Optware installed just fine.

Again, this is a worthy goal to keep pursuing in 2013.

Goal #4 - Hit: "Get a standalone receiver picking up the transmissions from a Davis outdoor sensor suite by the end of 2012."

I hit this baby back in April and was pretty psyched at having done so.  After that I had to spend a bunch of time figuring out what those transmissions actually carried.  First I sorted out rain and followed that up with outdoor humidity.  The deciphering of all the weather related parameters is now laid bare on github.
This Took Forever To Get Right
I want to keep plugging away at this stuff going into 2013.  I wrote last time about how Davis' recent antics were making me pretty grumpy.  It is my data, and I don't want people trying to take it away from me.

Goal #5 - Hit: "Keep this blog going, share the adventure, and enjoy the ride."

I put up 25 posts in the past year.  Not incredibly prolific, but far from abandoned.  I wrote some stuff that made people laugh, and I wrote some stuff that made people cry.  The goal of this blog was never just to put something out there.  If it wasn't going to be interesting or entertaining, it wouldn't be worth the effort.  Hope you think that it has been.

Have a good 2013 from all of us here at Mad Scientist Labs.  Enjoy the ride

Friday, December 28, 2012

Making A MESS

I loved video games growing up.  Pacman and Donkey Kong reigned supreme with the general populace, but for me it was Defender that grabbed me hardest and wouldn't let go.  I remember once having a single quarter burning a hole in my pocket.  I jumped on my 10-speed and biked the couple of miles to the nearest arcade where that classic Williams' game awaited me.  I dropped in my quarter and suddenly became the pilot of that ship.  With its frantic gameplay and excellent graphics, I could have played that game for hours.
My First Love
Unfortunately for me, the game was fiendishly difficult and all I had was one quarter and no skill.  It was only a matter of moments before my butt was back on my bike seat and I was headed home.  I got a lot of exercise that way, one quarter at a time.

Today our computers have processors easily 1000x more powerful than the Motorola 6809 running at 1 MHz at the heart of Defender.  All of that processing power has been put to work in projects like MAME (Multiple Arcade Machine Emulator) and MESS (Multi Emulator Super System) to deliver cycle-accurate emulations of the processors in these old arcade wonders.  These projects do more than just the emulation of the processors: many games have perfect sound and video emulations as well.  Dig up the original ROMs that were in these games, and you aren't playing just some reasonable facsimile of the game.  You are playing THE game.

There are many things I love about the MAME and MESS projects.
  • They are intended as a preservation project rather than an emulation project.  The emulation is an accurate representation of the hardware, sans a few things like emulating transistor level stuff like programmable logic chips and a couple other exceptions.
  • They are open source.  As a matter of fact, MAME and MESS joined forces a short while ago and now their code lives in a common repository.  Want to know how this stuff works?  Grab a copy, poke around, and try compiling it yourself.  It isn't hard.
  • One look at their SVN Repository shows the project is very active.  There are additions and fixes going in all the time.
  • The scope is enormous.  There are around one hundred processors and a similar number of sound chips emulated.  Thousands of games and old computer platforms are emulated.  Thousands.
Now let's change gears.  Something like three years ago, I bought myself a Davis weather station.  The undocumented expansion port at the back of the thing nagged at me.  With some knowledge of electronics and some helpful documentation from the manufacturer, I was first able to figure out how to interface to the weather station console with nothing more than a commonly available USB to LVTTL serial adapter.  A while later I sorted out how to build my own datalogger to store weather data for periods when the console wasn't connected to a computer.  These two projects were cheap and easy to put together.  They also faithfully duplicated the expensive equivalent sold by the manufacturer.

Other people then expanded on this work with projects of their own.  One person developed a way to connect the console directly to a WRT54G router and upload weather data without a computer in the middle.  Another developed a wireless interface with commonly available XBee modules.  One or two enterprising folk actually started selling low cost third-party designs to what could only have been a fairly limited audience of enthusiasts.  This gave the enthusiast crowd a low cost option for an interface to their console for their own data while the mainstream crowd could always buy a console interface off-the-shelf if they wanted one.  Everybody seemed happy.  Or so we thought.

Apparently, Davis is putting the hammer down.  There is a new version of the console firmware that prevents the DIY interfaces from working.  This is a pretty wrong-headed move if you think about this for a bit.  They are pissing off their biggest supporters by deliberately breaking something that would amount to a small fraction of their sales of these units.  These big supporters are the same people who recommend these systems to other people.  These supporters also buy a lot of Davis hardware in the first place.  So maybe, just maybe, Davis could lose money rather than make money by doing something like this.  Also consider that what Davis can do to differentiate their logger from a DIY version is very limited.  Efforts are already underway to see if the new logger can be reverse-engineered.  Given that the SPI interface between the logger and the console is easily sniffed, I don't expect this reverse engineering effort to take very long or be difficult to emulate.  Then we'll all be back to where we started, but with incompatible hardware versions floating around.  Brilliant.

This situation doesn't make me very happy.  Not happy at all.  In fact, it makes me kind of angry.  Angry enough to wonder if there isn't something I can do about it.

Maybe there is.  Followers of this blog will know that I've built my own receiver using a child's toy and can decode all of the weather related information transmitted from the ISS (Integrated Sensor Suite) outdoor unit.  There was still some work to do though: the ISS transmits a Frequency Hopped Spread Spectrum signal, and I was able to determine the hop sequence so I could write some code to follow its transmissions continually.  However, I only figured the hop sequence out for one of the eight possible transmitter IDs, and only for the version sold in North America.  Figuring out the hop sequence for the other IDs and the other regions would be a lot of work that I didn't feel like doing.

I then considered reverse engineering the firmware by disassembling it.  This is not a lot of laughs either.  The disassembler doesn't know code from data so you've got to tell it which is which, meaning that you need to figure that part out first.  Then you aren't able to actually run the code and get an understanding of how it works.

That made me think about emulation.  I had thought about writing my own CPU emulator for the Atmel ATMEGA128 processor running the console.  I had done this kind of thing before, actually.  I wrote an 8086 emulator in x86 assembly language for the old Retrocade arcade game emulator that brought Q-Bert to the party.  I learned a ton in doing so, but one of the biggest things I learned is that writing a CPU emulator is HARD.  Very hard.  The initial coding isn't so bad.  It is debugging it that is a killer.  A very simple error in the emulator can totally screw the emulation up, and often these errors are very difficult to find.

I didn't want to spend a ton of time writing my own emulator so I started poking around.  Atmel's own AVR Studio looked promising, but it was more suitable for code development than reverse engineering.  I also couldn't see how I'd be able to hook in functionality to the processor emulator for things like the console's keyboard.  Then it occurred to me that MAME/MESS might have a CPU emulator I could mess with.  And what do you know?  Looks like a lot of work has gone into an Atmel 8-bit CPU emulator that had potential for use in reverse engineering how the Davis code works.  I checked the SVN Repository which also showed that there were a bunch of recent fixes going into this emulator since the last official release.  And finally, I was impressed by the statement at the top of the code stating that this emulator could faithfully run code written for the "demo scene".  These demos (check it out) are written to push a platform to its absolute limits using every trick in the book.  The fact that demo code could work on this emulator spoke well of its accuracy.

Check it Out

Looking at the avr code showed me that the emulator itself ties in all kinds of MAME / MESS dependencies for loading firmware, enabling a debugger, etc.  I would have to work around all of that if I wanted to use this CPU emulator in a project of my own.  Then I realized that I was looking at things backwards.  Why consider this a project of my own?  Why not see if I could make this a part of MAME / MESS itself?  I had a week off between Christmas and New Year, so why not see how far I could get?
Click To Embiggen
What you are looking at is MESS running the actual Davis firmware in its debug mode.  The window in the upper left shows a disassembly of the code at the current program counter location as well as other good stuff like CPU register values.  The right side shows a view into the firmware, RAM, and EEPROM memory spaces.  I am now able to single step through the code and see exactly what it is doing.

Getting this far wasn't all smiles and sunshine.  MAME / MESS undergoes constant churn, so an accurate tutorial on how to add a new driver to the code base doesn't seem to exist.  And while the AVR emulator seems to be quite accurate, that doesn't necessarily mean it is complete.  Last night I had to code up the emulation of the ELPM (Extended Load Program) instruction.  That ended up being pretty straightforward based on the existing infrastructure, but it was just another hoop to jump through.  Never mind that there also seem to be some compiler bug triggered by MAME that had me doing nothing but segfault when I started out.

How far will I get with this?  We'll see.  It is certainly a powerful tool for deep-diving into the belly of the console to figure out how it works.  Working against me is that I have some stuff coming up that will severely limit how much time I can spend on this stuff.

What will I do with what I find out?  That is a topic for a future post assuming all goes well.  But it is cool.

Monday, November 19, 2012

Once Upon A Time In Mexico

Thanks to this gig I have called “work”, I am called upon from time to travel on the company nickel.  I am in the middle of one of these stints now.  Mexico City has been my home away from home for over three weeks now.  I have never been here before and did not know what to expect, besides what I had seen from watching “Once Upon A Time In Mexico”.   Don’t watch that movie before going to Mexico.
A Tender Love Story It Is Not
There are many things to like about this place.  One of my favorite things is food (I try to eat some of it everyday) and the food here has been great.  Food here is also inexpensive.  I’m reminded of a comment I heard when I was working in rural Italy regarding a local restaurant: “The food there is cheap, and it is good, so it must be the best”.  Indeed.

But the more time I’ve spent here, the more it has become apparent that something is going on , and it ain’t pretty.  I cannot fathom why the major news organizations have not taken this story and run with it, because it makes the fighting going on in Syria right now look like a Playboy Bunny pillow fight.  There is a war going on here.  A hidden war.  You might be thinking I’m talking of the war on drugs, and you’d be wrong.

The war I’m talking about is going on right under the noses of the citizen’s of this fair city.  Some seem to be oblivious to the battle, while others won’t talk about it because they know what is good for them.

The story is this: there exists a band of rebels known as the Mexican Anti-Sidewalk Coalition (MASC).  Their sworn goal is the destruction of every square inch of sidewalk in this town.  Sure.  Go ahead and laugh.  But I’ve got the pictures to prove it.  First, some background.

Driving in Mexico City is insanity incarnate.  It is a well known fact that many insurance companies won’t insure someone taking their vehicle in to parts of Mexico.  A taxi driver gave us shit the other day for opening the driver’s side door when getting out of the car because you can apparently get a ticket for doing so.  However, making a right turn from the leftmost lane and cutting off the other two lanes of traffic here is perfectly acceptable,.  Running solid red lights while barely slowing down won’t elicit a second glance from the local Policia.

For this reason we have drivers that take us to work and back.  These drivers take our lives into their hands twice a day, and do so with apparent reckless abandon.  One of these drivers (Mario, I’ll call him, for that is his name) would cross himself just as we’d start each journey.  At first this worried me that I thought he had to do that.  Now I’m thinking that I was glad that he was taking out that little bit of extra insurance.

The drive is a lengthy one, ranging from 40-95 minutes every day.  This gives us passengers plenty of time to stare out the window and watch the streets of Mexico City go by.  Sometimes we’d joke about that which was so different from where we were from.  Take this hole for example.
What's Wrong With This Picture?
Now there are numerous differences between this hole and a hole back home.  The first thing that jumps out at you is that this hole is not round.  Far from it, in fact (the root cause is likely the spent toilet paper tubes used as concrete forms during its construction).  Second, note that the grass around the hole is neither green nor flat, despite having been laid just a week ago.  Third, this hole is ten feet deep and left uncovered in a well traveled area that, to boot, is unlit at night.  Here they call this hole a hole.  Back home, we’d call this hole a lawsuit waiting to happen.  But I digress, and quite substantially.

It was from these idle observations on the twice daily drive that we put the pieces together and realized just what was going on here.  Proof for my claims?  I have plenty.

The battles between the Federales Sidewalko (the government’s Sidewalk Police) and the MASC are intense and in close quarters.  Here we see the Sidewalko constructing their latest generation super-sidewalk, known colloquially as the “double-wide”…
The Next Big Thing In Sidewalk Technology
… while on just the other side of the barrier we found this.
Complete Distruction
Incredibly, these last two pictures were taken from within this walled federal compound…
These Dudes Mean Business
… where elite government forces would be more than happy to bring their .50 calibre friends to the party for so much as chalking “Joanie Loves Chachi” on one of their concrete masterpieces.
Say "Hello" To My Little Friend
The MASC usually conduct their operations at night.  Only smashed pieces of rubble are left behind to litter the street, just as warriors of old would put the decapitated heads of their vanquished enemies on a pike as a warning to the others.
The MASC Were Here
However, seasoned veterans of the MASC show their bravado by conducting the most difficult of operations in broad daylight.  It takes a man made of naught but nails and grit to take on something this size with nothing but a sledgehammer.
This Guy Has 'Nads
It is thus beyond imagination that he did so completely shunning the opportunity to bring a readily accessible piece of heavy equipment to the party.  You want to talk about making a statement?
This Is A Statement
The Sidewalko have made various attempts to disrupt the activities of the MASC.  They have placed boobytraps throughout the city at sites where they believe the MASC will strike next.  However, these boobytraps are totally ineffective because of their crude construction.  They are easily identified by sections of sidewalk that rise up from surrounding sections for no reason whatsoever.  They do nothing but trip the unsuspecting pedestrian, as happened to this citizen just moments before this picture was taken.
Hello Obvious
The guerrilla warface tactics of the MASC make it unlike that the Federales Sidewalko will put an end to their activities anytime soon.  At the same time, the MASC do not yet have the numbers to accomplish their goal.  The result is, predictably, a stalemate.  Each side can claim their share of battles, but neither can win the war.  Me?  I wouldn't mind seeing a little more grass on the boulevards of this town.
My Intrepid Field Assistant Risked Everything For This Picture
More on this story as it develops.

Monday, October 8, 2012

The Graduate

It has been a little more than a month since we brought our new dog Buddy into our home.   And like anyone bringing a new puppy into their home, we've had quite a ride so far.

My favorite story about Buddy so far goes back to My Lovely Wife, who would always say to our first dog Abby: "Abby, where's your food?!?!".  Abby of course knew where her food was and would run to the small hall closet where it was kept.  There she would wait for My Lovely Wife to walk over to the closet and get her some food, or maybe even a treat.  Out of habit, My Lovely Wife asked Buddy: "Buddy, where's your food?!?!".  Buddy took one look at her and then ran to that small hall closet.  The door just happened to be ajar, so he pushed his nose in and opened it wide.  Then he grabbed the bag of food in his mouth and started dragging the bag along the floor to her.

My Lovely Wife watched this in utter amazement.  At this point we had had Buddy for only four days.  Four days at our place and he is retrieving bags of food.  We had made no attempt whatsoever to train him how to do this.  I was stunned when I heard the story, especially since he had been living chained up outside his whole life before coming to live with us.  It is a good thing that Buddy doesn't have opposable thumbs or I think we'd all be in serious trouble.
Speaking Of Trouble...
One thing about Buddy that we noticed right away was that he loves chasing after bugs.  Dragonflies are great.  Grasshoppers are awesome.  He'll be following along beside us and the next thing we know he is chasing down a bug and eating it up.  We both thought this was pretty entertaining for a couple of days.  That was until I realized that he probably ate bugs to survive at his previous home because he wasn't given enough food to eat.  "Don't worry, Buddy" I told him.  "There will always be lots of food here to eat."  But he still eats bugs anyway.

Speaking of eating, he does this.  A lot.  He is a growing pup, and he's got some lost time to make up for the insufficient amount of food he used to get.  Buddy is putting on over two pounds of solid weight a week.  It seems like every day he looks a little bigger.  Every day he takes up just a bit more space on the floor.  Every day, the old collar of Abby's that he wears seems to fit just a little bit tighter.  To quote the Simpsons - "A dog like that, you've got to feed every day."
World's Largest Paws
He is coming along in so many ways.  He used to have very little confidence: the slightest touch and he would drop to his back with his paws in the air.  Now he'd sit there, get petted, and soak up the adoration.  His training is coming along nicely as long as there aren't a lot of bugs around.  And he is no longer deathly afraid of brooms; one day just after we got him, My Lovely Wife went to sweep the floor and Buddy instantly cowered in the corner.  Obviously, he was taught early on that a broom can be used for more than just cleaning the floor.  I'd like to teach his previous owners the same thing one of these days.

Oh, and I almost forgot to mention that he was house-broken almost immediately and was sleeping next to our bed after only three weeks.  And that he had free run of most of the house pretty much right off the bat, yet has not chewed any furniture or done any other damage (not counting one unfortunate Ethernet cable).  This despite the fact that he seems to have razor blades for teeth.
Needs A New Seat Belt
About the only thing dragging the little man down has been a bladder infection.  Symptoms of this showed up just a couple days after we got him, and my guess is it was somehow a complication from when he was neutered.  His condition improved almost immediately after being put on antibiotics for a two week run.  Unfortunately, the infection reappeared just a day after the meds finished up, so he went back on a different prescription for a couple weeks.  Those ran out just this past Thursday, and the symptoms reappeared the very next day.  We kind of saw this coming, so we were fortunate that the vet gave us meds for another five days to tide us over the long weekend we are enjoying now.  But we'll need to get Buddy in another appointment first thing next week to to see what the heck is going on there.

I'll tell ya though.  When that plumbing is working right, that dog can take one mean pee.  With Abby, I would count steamboats: "One steamboat, two steamboats...".  Abby would sometimes get to six and rarely to nine.  Buddy knocked out a 20 steamboat pee yesterday.  If I had to take a 20 steamboat pee, well...

It is that camel-like ability that brings another of Buddy's oddities to light.  Every dog I've ever known LOVES to go outside.  Going outside IS THE BEST THING EVER.

Unless you are a dog named Buddy.  Buddy could usually give two shits as to whether he goes outside or not.  The other night we had to actually drag him and his sorry ass off his bed to get him outside to do his business.  And then when he got out there, he had a poo.  And then he had another.  I'll tell ya... if I had two poos in me, I'd be breaking down that damn door to get outside.

And every morning is the same thing.  My lovely wife gets up first and goes to the bathroom.  Then she heads for the door to take the dog out and I get up.  Buddy would much rather sit at the side of the bed and demand my attention while My Lovely Wife waits at the door for him to go outside.

One thing My Lovely Wife was really enjoying was Puppy Club ("The first rule of Puppy Club is that you don't talk about Puppy Club").  Puppy Club is put on by our vet every Thursday.  They give a little talk about some aspect of puppy rearing, and then the rest of the evening is a wild free-for-all where the puppies cut loose and spend the night smelling each other's assess.  What's not to like?

What's not to like is when you can't go anymore.  Last time My Lovely Wife was there, they pointed out that Buddy best-guessed birthday of April 1st makes him six months old now.  That means that Buddy is considered "graduated" from puppy club after only going three times.

This graduation is one of those little markers in the course of owning a dog.  One minute they are nothing but fur and energy, the next minute you are left wondering how so many wonderful years went by so quickly.  Matthew Inman (perhaps the greatest cartoonist of our time) put it this way in this snippet from his incredible comic about dogs.  Click that link - you have to read the whole thing.

Buddy isn't quite the dog we expected him to be, but I think he'll be the dog we need.