Underwater Software!

Here is a nice video by the underwater videographer Tony Exall that demonstrates underwater photography using Cathx Ocean solid-state lights. The embedded software that runs on these lights was developed in ANSI C using the GNU Tool Chain (gcc et al.).

 

http://www.youtube.com/watch?v=YUWDj3AqiSg

 

Visual Studio 2010 Test – ‘The agent process was stopped while the test was running.’ wrecked my day!

Lots of software development time wasted yesterday due to a rubbish error and associated error message produced by the Visual Studio Unit test framework!

 

The agent process was stopped while the test was running.

 

No resolution as of yet – but I think it is due to a worker thread in a library that outlives the test’s existence… The problem doesn’t happen if I run the unit test as debug via the ‘Test / Debug / Run Tests in Current Context’ menu. Apparently, from my research it seems that this problem will also not happen in Visual Studio 2012, cold comfort indeed….

 

If I get it fixed Ill let you know…

 

Raspberry Pi – Install boost 1.50 C++ Libraries on Wheezy

If you are doing modern C++ development these days you will be using the boost libraries. I have started using the Raspberry Pi as a stand-in ARM platform for some smart-cam development while I wait for the actual hardware to become available and as such need to install boost. To this end, the boost 1.50 libs can be installed on wheezy as follows:
[crayon lang=”Shell”]
sudo apt-get install libboost1.50-all
[/crayon]
Now for a little example of using and building with the libs, consider this little test program that uses the boost regex library:

[crayon lang=”cpp”]

#include
#include
#include

int main() {

std::string text(“a fat cat sat on the mat”);
boost::regex re(“\\w+”);

boost::sregex_token_iterator i(text.begin(), text.end(), re, 0);
boost::sregex_token_iterator end;

for( ; i != end ; ++i ) {
std::cout << *i << ' '; } std::cout << std::endl; return 0; } [/crayon] If we stick this code into a file called it.cpp then we can build it using C++0x (C++11 ish), the standard c++ lib and the boost regex lib like this:

 

[crayon lang=”Shell”]
g++ -std=c++0x -lstdc++ -lboost_regex it.cpp
[/crayon]
This will output to a.out, which can then be executed like this:

./a.out
 

Visual Studio 2010 – DLL Reference path won’t change when remove and re-add reference

On the whole Visual Studio is a great software development tool with a relatively low number of annoying bugs. However, there is one annoying bug that Microsoft doesn’t seem to be bothered enough to fix…

 

The problem happens if you remove and re-add a file reference to a DLL. When you re-add the reference (same file name in a different folder) by browsing to a different file location, Visual Studio will for some reason insist on using the previous file path to the DLL and not the new one!!!

 

You can find some more information about the problem here.

 

We were trying to change a reference’s path by removing and re-add it but it just didn’t work due to this bug!

 

So how can we get around this problem? Well one way is to change the reference path directly by editing the project file.

 

To do this, right click on the project in the solution explorer and choose ‘Unload Project.’ Once the project is unloaded, right-click on it again and then choose ‘Edit’, the project’s XML will be displayed in the editor.

 

Now search for references to the incorrect reference path and change it to your new path. To do this, look near the following elements:
[code lang=”xml”] and [/code]
and:
[code lang=”xml”] and [/code]

 

Finally, right-click on the project again and choose ‘Reload Project’ – check that the references are correct….

 

I hope this helps someone, it was the only way we could figure out how to get around the problem…

 

.NET – How to tell if a DLL is 32bit or 64bit

So in the world of MS Windows software development, the bitness of DLLs (64bit vs 32bit) is the new DLL Hell!! It is slightly annoying that Microsoft eventually dug itself out of decades of DLL hell just to create a new hellish DLL vista – anyway there’s nothing to be done.

 

API vendors will often have 2 versions of their API, a 32bit one and a 64bit one, sometimes if you are really unlucky they will name their assemblies and DLLs using the same names for both platforms so there will be no way to easily tell if a DLL is 32bit or 64bit just by looking at the file name.

 

So how do you figure out the bitness of a DLL when you are trying to debug and fix .NET ‘Incorrect Format’ errors?

 

Annoyingly it turns out that there is no easy way to do this through windows. There is, however, a nice little tool by Silurian Software that integrates into windows explorer’s file properties pages called InspectEye, it gives you loads of info about an EXE or DLL including whether it’s 32 or 64 bit! It worked nicely for us anyway although I haven’t looked at the rest of the software’s features yet…

 

The tool can be downloaded from here:

 

http://www.silurian.com/win32/inspect.htm

 

Games For the Raspberry Pi

When setting up the Raspberry Pi for the kids I initially found it quite difficult to find any good games to install, the python games are great for learning to program etc, but as video games they are a bit dull.

 

Then I came across this list of games that was put together by the The MagPi, they have tested them on the Pi – this saves you the hassle of having to weed out the bad or half-working games yourself. The list can be found here:

 

http://www.raspians.com/Knowledgebase/1-debian-wheezy-games-repository-sudo-apt-get-install/

 

If you are wondering which games to try for young kids (3->5 years) you might try supertux, it is great fun with good graphics and sound. To get the most out of these games you will need to have audio working, depending on your set-up this can prove tricky but it is worth it!

 

.NET WPF – Provide value on ‘System.Windows. Baml2006.TypeConverter MarkupExtension’ threw an exception.

Here’s a strange WPF error we encountered at a client’s site today:

 

[code]Provide value on ‘System.Windows.Baml2006.TypeConverterMarkupExtension’ threw an exception.[/code]

 

If you get this error, then chances are your running your WPF app on Windows XP, and your app will probably work fine on Windows 7. Here is a good post about the problem:

 

http://blog.themagicsoftware.com/2011/07/provide-value-on-system-windows-baml2006-typeconvertermarkupextension-threw-an-exception.html

 

In our case we just had to remove an unneeded Icon attribute from our .xaml Window element and the error went away… I am not quite sure why the error occurred but now it’s gone anyway!

 

Raspberry Pi – Neewer HDMI To VGA Adapter Setup

The Neewer HDMI Input To VGA Adapter allows you to hook your Pi up a venerable VGA display via the HDMI port, this is handy if you have an old VGA only screen hanging around doing nothing.

 

It is very neat adaptor and I found that it works well with good video quality, but it requires a little bit of set-up to get it working with audio being output via the headphone jack.

 

It took me quite a while to figure out the settings to change in /boot/config.txt to get it to work (it was a a fairly random process… ;-) ), but in the end it was simple enough – here’s what worked for me:

 

In /boot/config.txt, set the value of hdmi_drive to 2, like this:
[code]
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
hdmi_drive=2
[/code]
But how do you make these changes to config.txt if the screen isn’t working? well you have two options here:

 

1.) SSH into your pi (if it’s connected to your network), or

 

2.) Power it down and pop out the SD card, place the SD card into your laptop or whatever and edit the file there, put the SD card back into your Pi to test.

 

This should be enough to get the display working, now to get the sound to come out of the headphone socket I had to run the following commands from terminal:
[code]
sudo amixer cset numid=1 — 90%
sudo amixer cset numid=3 1
[/code]
The first sets the volume to 90% (it was at 0?). The second sets the headphone jack as the output port for sound, I test if the audio setting are working by running:
[code]
sudo aplay /usr/share/sounds/alsa/Front_Center.wav
[/code]
When you run this you should hear somebody muttering about something to do with front and centres!

 

I think that there are versions of these HDMI to VGA adaptors with sound built in, so if audio is important to you this adaptor may be a better buy than this one…

 

Web2py – You don’t have permission to access /admin on this server.

If you try to access the web2py admin pages and get an error like the following:
[code]
You don’t have permission to access /admin on this server.
[/code]
Then don’t panic immediately, by default the admin stuff is only available on HTTPS, so make sure that your URL starts with https: and try again, if this doesn’t work than feel free to panic… I keep forgetting this and it wrecks my head, software development can be trying!

 

Setting up EdiMax WiFi on Raspberry Pi (EdiMax EW-781Un)

Here is a good article about how to setup a wifi dongle on your Raspberry Pi.

 

http://dembtech.blogspot.ie/2012/09/how-to-install-wifi-on-raspberry-pi.html

 

I used the terminal version of wicd – wicd-curses over SSH to set-up my EdiMax EW-781Un as I don’t have a screen connected to my smart-cam simulator. You don’t have to install any other software as a driver for this hardware is bundled in the Rpi build.

 

The wicd-curses UI is a little confusing so be careful what you press on in there as you can easily disconnect your existing wired network and leave yourself with no network connection (as I did!), if this happens you may have to power cycle your pi to get a network connection back.

 

In the UI you should see a list of the available WiFi networks, use the up/down arrows to highlight the one that you want to connect to and then press the right arrow key (donated as -> in wicd-curses) to get to the configuration screen where you can set-up the WiFi key etc.

 

Once you have configured the connection you can connect by pressing C in the main screen, when you connect to WiFi you will be probably dumped off the wired network connection so you will have to SSH in again on the new IP address that was assigned to the WiFi adaptor.