Compiling PowerSDR with Visual Studio 2008
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:
svn://64.245.179.219/svn/repos_sdr_windows/PowerSDR/branches/ke5dto/pb-pal
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.
Prerequisites
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
- comboCATPort_SelectedIndexChanged
- comboCATPTTPort_SelectedIndexChanged
- initCATandPTTprops()
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!
private ArrayList GetAvailCOMPorts()
{
ArrayList a = new ArrayList();
for (int i = 1; i < 24; i++)
{
SerialPorts.SerialPort sp = new SerialPorts.SerialPort();
sp.PortName = “COM” + i.ToString();
try
{
sp.Open();
if (sp.IsOpen)
{
a.Add(sp.PortName);
sp.Close();
}
}
catch (Exception) { };
}
return a;
}
Related Posts
Please rate this article!
no login necessary; it's anonymous!
.


By Bob McGwier, March 21, 2010 @ 4:43 pm
Contrary to your article, well over a year ago, I ported PowerSDR to Visual Studio 2008. The team at Flex took this and ran with it. You have been able to download functional versions of this with skinning, etc. and is known as Pretty Betty from an svn branch for a year. It will soon be released as the official version.
Bob McGwier
N4HY
By Avinash, March 30, 2010 @ 8:05 pm
Can i use the same with MS Visual Studio 2005 Professional Edition???
By Tobias, March 30, 2010 @ 9:06 pm
Hey Avinash, I personally haven’t compiled PowerSDR in VS2005. But I recommend to use the Pretty Betty branch of PowerSDR. This is the Source code which will be published soon as PowerSDR 2.0. Bob, N4HY has ported the PowerSDR from VS2003 to VS2008. The Pretty Betty code compiles here without a single problem.
Just give it a try in VS2005. Using the Pretty Betty code is better than using the VS2003 (.NET 1.1) Version of PowerSDR.
You have to download the Pretty Betty Source code from the SVN repository. This Flex-Radio Knowledge-Base article describes how to setup SVN: http://bit.ly/8YDX6v
The Pretty Betty Source code is located in:
svn://64.245.179.219/svn/repos_sdr_windows/PowerSDR/branches/ke5dto/pb-pal
Good luck!
By BobG, December 18, 2011 @ 7:35 pm
Seems to have disappeared. . .
Checkout from svn://64.245.179.219/svn/repos_sdr_windows/PowerSDR/branches/ke5dto/pb-pal, revision HEAD, Fully recursive, Externals included
Can’t connect to host ’64.245.179.219′: A connection attempt failed because the
connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond.
By Tobias, December 23, 2011 @ 6:52 pm
Hi Bob,
FlexRadio Systems doesn’t grant access anymore to the SVN due to a change in their development philosophy. However you can request a copy of the latest source code from gpl@flex-radio.com. The sourcecode package comes with an instruction how to compile PSDR.
73 & happy programming!
Tobias