I decided to have a deeper look into Flexradio’s SDR Software PowerSDR. PowerSDR is published as open source under the GPL license and was written under Visual Studio 2003 against the old .NET 1.1 Framework. Unfortunately, the code was never migrated to a higher Version of Visual Studio. The last couple of days I had enough time to dive deep into the source code and finally make it compilable under Visual Studio 2008. In this post I’ll share the details with you.
[This article has been updated on 7/April/2010]
before you start, read this:
[Update 7. April 2010]
Attention! The information in this article has been superseeded. I was not aware that PowerSDR has already been migrated to Visual Studio 2008. Bob MyGwier, N4HY did a terrific job with the migration. However, the source code is currently not available for download on the Flex-Radio website. You have to download it directly from the SVN. This Version has the codename Pretty Betty and will be released in 2010 as PowerSDR 2.0. The Sourcode of Powersdr – Pretty Betty is located in this branch of the PowerSDR SVN:
Flex Radio provides on it’s webpage a Tortoise SVN Quick Start Guide.
Again – if you want to compile PowerSDR under Visual Studio 2008 I urge you to use the Pretty Betty source code. However I will leave the original post online for legacy reasons.
[/Update 7. April 2010]
The original article
PowerSDR can’t be compiled out of the box in Visual Studio 2008. One the first attempt you will receive a ton of errors. While I could fixed some of them properly, others, especially the cross-threading exceptions between User Interface Forms will need much more effort. I currently can’t approximate the effort, but it would take for sure several days. For the sake of my purpose it was sufficient to disabled the cross-threading exceptions. Please note that this does not solve the problem. Disabling the cross-threading exceptions causes instability of the software! If you do so, please be aware of it.
The way I’m going to describe worked so far on three different PCs using VS2008 under WindowsXP with full administrative privileges. Be adviced that PowerSDR uses libraries and drivers which work very close to the OS kernel. It might be possible, that your PC configuration (hardware or software) cause additional exceptions during the compilation of PowerSDRs sourcecode.
Before we can start with with compiling and debugging of the source code I would like to mention the prerequisites:
- Visual Studio 2008: PowerSDR can not be compiled under the free Visual Studio (2008) Express edition. But – you can download a fully functional 90 day trail of Visual Studio 2008 (Professional) from Microsoft. This version will work perfectly.
- DirectX Software Development Kit (SDK). You will need a copy of the DirectX SDK on your development PC. The SDK can be downloaded from Microsoft. The SDK Version of February 2010 works well.
- Microsoft Data Access Components (MDAC) 2.8. You need an installed copy of this library on your development PC. It can be downloaded here.
- PowerSDR Source code. I used version 1.6.3 (SVN 788). On the Flexradios download page it’s called 1.8.0. Honestly I don’t know why. This is the download link to the Flexradio website.
- Add DirectX include and lib folders into Visual Studio 2008. As a lazy alternative you can copy the files dsound.h and dsound.lib into the PowerSDR source folders Portaudio and pa_win_ds.
Step1: Conversion Wizard
Once you have unzipped the source code, open PowerSDR.sln in Visual Studio 2008. The conversion wizard will pop up and assist you in converting the project into VS2008. Accept and click through the steps.
Step2: Review References
Check the project References in the Solution Explorer. In my case I only had to delete and renew the adodb1 reference. However on one of my other development environments I also had to delete and renew the DirectX references.
I set these references:
- adodb1 version 7.0.3300.0
- Microsoft.DirectX version 1.0.2902.0
- Microsoft.DirectX.DirectInput version 1.0.2902.0
Step 3: Cross-Thread Problems
Now we are actually ready to start the compiler and have a look on the errors and warnings. At this point PowerSDR should start until the spash screen but terminating with this nasty exception pointing out problems with cross threading.
As mentioned earlier, a proper solution of this problem would cause a major rework of the whole source code. Instead we will bypass this problem by disabling all cross threading exceptions in the source code. Again – this will decrease stability of PowerSDR. Don’t use this bypass if you want to release / publish your own Version of PowerSDR.
Disable the Cross-Thread exception in the constructor of console class in console.cs:
Step 4: Serial Port problems
Now, the compiler throws an IOException as shown below:
I wasn’t really sure where this exception originated from so I started a step by step debugging and finally ended up in the method GetAvailCOMPorts() located in setup.cs. This is the method:
The purpose of this function is to identify the available serial ports of your PC. It’s a kind of trial and error way. The for loop tries to open all serial ports from COM1…COM23. On my development PC, two serial ports are registered – COM3 and COM11 (which is curiously labeled as COM11c).
The exception is called while executing sp.Close(). Somehow the internal handle gets “lost” in the .NET method Freehandle(), located in SerialStream.cs.
Instead of debugging this .NET method, I rewrote the GetAvailCOMPorts() method. There better and faster ways to retrieve the available serial ports on a system. This is how the replacement looks like:
Step 5: Parsing Problems
While on two out of three machines, I could compile the source code at this stage another exception was thrown at my main development machine.
After a quick debug session I identified the following three methods in setup.cs causing the exception
These routines had problems to parse and handle my standard serial over bluetooth link, interestingly numerated as COM11c.
As an example, here is the code of comboCATPort_SelectedIndexChanged():
This is the content of the objects while debugging:
The sub-string 11c can not be transformed into an int32. This causes the format exception. I substituted the code with a more robust version:
This code was applied to all of the mentioned three methods.
Step 6: here we go!
By now, all problems should be resolved and the PowerSDR console should appear!
Let’s hope that Flexradio will release soon the next big version of PowerSDR! As far as I heard, they also migrated already on Visual Studio 2005 / 2008.
Do like this article? Do you have anything to add? Then leave me a comment!