November 26, 2009


A while back I discovered and wrote about the BSLA.
It's a great tool: it's low-cost with easy-to-use software.
I'm using the BSLA with my own devices, so I made a simple adapter:

(More details on the parallel port adapter here)

So I had the hardware, but in short order I found that I was having a REALLY hard time remembering which of the BSLA's pins were connected to my hardware, especially because I control many different devices with my I/O interface. The BSLA's UI displays the pin names for the Parallax Basic Stamp 2 (BS2):

What I really needed was to be able to display customizable, device-specific graphics in the BSLA's UI.
I contacted the Parallax folks (who sell the BSLA) and the USBee folks (who make the BSLA s/w), but neither were the least bit helpful. So I decided to do what any self-respecting Windows developer would do: hack their app!

My idea for hacking the BSLA s/w was to hijack that portion of their UI that shows the picture of the BS2. I wanted to be able to show any image of my choosing along with my own customized pin names. I knew that hacking into an existing application could be done, but I had never attempted it. My first attempt was to inject my custom dll into the BSLA process, but this had some issues that were beyond the scope of this project. So I experimented a bit and discovered (remembered, really) that the Win32 API CreateWindowEx() allows you to create a window that's parented to a window in any process, not just your own process. This turned out to be the cleanest, simplest way to do it.

My solution: BSLAHack

I wrote a small application, BSLAHack.exe, that runs in the background, showing only an icon in the tray:

(I stole the BSLA's icon :)

Hovering over the icon shows a status tooltip:

Right-clicking on the icon provides a menu of BSLAHack options:

(More on the tray menu below)

When the BSLA app is running, BSLAHack.exe finds it, injects BSLAHack.dll into it, and just like that you have custom UI of your own choosing:
Thisbecomes this
It's important to note that I didn't alter BSLA.exe in any way; I'm just hijacking a portion of its UI when it's running.

When the BSLA is hacked, BSLAHack shows a different icon:

(That's the BSLA icon overwritten with "HACK" in red)

Another useful feature is the display of user-defined pin names.
This is a HUGE help because you no longer need to remember which BSLA pin is actually connected to your circuit's pin:

Each pin's text, text color, and background are customizable on a per-pin basis. I've found it's useful to group pin functions by color, for example making all your SPI pins have a blue background while some other pins have, say, a green background and still others have a red background. Each pin's color and text are independantly configurable.

Also, hovering over any pin causes it to show the stock BSLA pin name:

This is very helpful when you can't remember which of the BLSA's pins is connected to which of your custom pins!

You can use BSLAHack too!

Click here to download a ZIP of the BSLAHack program (the ZIP contains just one file, BSLAHack.exe).
Unzip the EXE into any directory (doesn't need to be in the BSLA program dir, and in fact I'd suggest using a unique dir so as to not confuse things).
After unzipping, you can launch BSLAHack immediately by doubleclicking BSLAHack.exe. This will display the Config UI (more on that below).
Additionally, I'd suggest adding a Start Menu shortcut to BSLAHack.exe alongside the shortcut to BSLA in (Start > Programs > Parallax Inc > Basic Stamp Logic Analyzer).

Configuring BSLAHack

BSLAHack.exe creates & maintains it's own config file. When you start BSLAHack for the 1st time, the config file doesn't exist, so you'll see this message:

Clicking OK will open BSLAHack's "Edit Projects" UI and prompt you to enter the name of your 1st project:

Enter something relevant to the H/W you're monitoring, e.g. "USB Project", then click Save.

You can now enter your custom names for each pin.
Click a pin button (P0 is selected by default), type something in the edit box, and it appears in the preview:

By default, new text is black on a red background, but that's easily changed. Click on the "Txt Color" button:

To change the pin's text color (I selected white):

and click the "Bg Color" button to change the pin's background color (I chose blue):

You can select a custom image for the background by clicking the "Import Image" button:

(Note that BSLAHack will only import Windows .BMP files)
Ideally the BMP you import will be exactly 183 pixels wide by 323 pixels tall, but BSLAHack will accept any size image (it will be cropped to fit). This odd size reflects the UI real estate available to us in the BSLA window.

You can also create your own image by clicking the "Create Image" button:

This will show you a message:

Click OK. If you already have one or more copies of Paint open, you'll be prompted to close them before proceeding:

Close all copies of Paint then click "Retry"
(If you don't have Paint open you won't see this message)
BSLAHack will launch Paint with a blank image that you can edit and save:

You can change anything in this image to suit your needs, but note that the ares indicated by the yellow rectangles will be covered by the pin info, so anything you draw there will be invisible when displayed in the BSLA.
(Caveat: The "Create" feature is only tested on WinXP; it may not work on other OS'es)
After saving your image, use BSLAHack's "Import Image" button to load it into your Project.

Now that you've configured your pins and background image, click "OK to save your new project.
You'll get a message:

Even though you have a project (which you just created), BSLAHack doesn't know what to display.
Click OK and you'll get the "Edit Projects" UI again.

From the Projects list, click the project you created:

Then click the "Set 'USB Project' as the Current Project" button:

You could have clicked "Set ... as the Current Project" when you first saw the "Edit Projects" UI, but I wanted to demoonstrate the use of this button.

Tray menu

As mentioned above, BSLAHack's primary UI is a tray icon. Right-clicking the tray icon provides access to BSLAHack's user options:
You can close BSLAHack by choosing Exit:

You can open the "Edit Projects" UI:

And you can change the displayed project on the fly via the "Select Project" submenu:

Project Source Code

Because stuff like this is best when shared I'm putting BSLAHack into the public domain.
If you really want to know how it works, or want to customize it, or do anything at all with it, click here to download a ZIP of the BSLAHack source. It's a C++/MFC app written with Visual Studio 2008.

I hope you find BSLAHack useful - it's been incredibly useful to me.
If you have any suggestions, problems, etc, please email me at the address below.

Dave Chambers
Elkins, NH