Since my H2D2 project has quite a lot of code in it now, I've been using .Net interop as a quick way to write some unit tests for the H2D2 programming language.
I have written a C# unit test project in Visual Studio which tests much of the existing H2D2 language syntax. This means that I can add new features and quickly check that I've not broken any of the existing code. So I can very easily make sure that programs which used to run continue to work as expected.
Recently, I've been making H2D2 support function calls, and so it's been handy to write tests for various different types of function call (passing parameters, reading return values, allowing functions that don't return a value, etc). The unit tests have made it much easier to ensure that everything works after I've made changes.
Since I've written more unit tests in C# than anything else, I thought it would be the quickest way to get my tests up and running. And because I had already compiled H2D2 into a windows dll (the unmanaged kind), it is not very hard to run H2D2 programs from .Net - even easier because I had already written some basic wrapper code for all the interop stuff. It's not much harder than putting some H2D2 source code into a string and calling a Run() method. Obviously all this has been done 'just for fun', since it's only one of my hobbyist projects anyway.
But when I mentioned to one of my colleagues that I had spent some of my free time writing unit tests for fun he said that I was clearly stark raving mad. There's a possibility he's correct.
However, when I think of how I'd feel if I broke some of my existing H2D2 code and had to go back and unpick where I went wrong, I reckon that these unit tests are really less about having fun and more about preventing a severe loss of fun if I ended up scratching my head and trying to figure out what I'd done to make something break.
So I hope that's a suitable explanation for why I've been writing unit tests in my free time. It's the best excuse I've got.
Although ultimately, I may end up looking for a unit testing framework for C so that I only need one IDE loaded to run my tests... The .Net interop solution may just be a stepping stone.
I've just discovered Topshelf for creating Windows Services in .Net. It makes building Windows Services a breeze, and you can also run them in the Visual Studio debugger easily too. Just look at the simple code example here ... and you only need to create a console app to make this example work.
Adding Topshelf to your project is easy thanks to NuGet. Your service code just needs to be a plain object and doesn't need to inherit from any special base class. It makes the whole thing extremely simple.
When you've compiled your console app, you can run it in the debugger to check it, and when you want to install it as a proper service, you just pass "install" as a command line argument when you run the exe. To remove the service you re-run the console app and pass "uninstall" on the command line.
Back in the summer, on a Saturday in Cambridge I saw this busker playing guitar and singing whilst *inside* a litter bin. It was very entertaining, it really made me laugh:
... it was made better somehow because he was playing songs from Jungle Book.
In the last couple of weeks, a few people have said that my libpigpio GPIO shared library for the Raspberry Pi only works if
they recompile it from source, like here for example.
(although a chap called Brendan mentioned it first, thanks Brendan).
So I thought that it was worth making people aware of that. Since I compiled the library on the initial Debian Squeeze
release, there’s probably some difference with other Debian distributions that have come out since.
However, compiling the library from source on your own Raspberry Pi seems to work, so at some point I’ll update the zip file
without the .so file, so that people can just compile their own version. In the meantime, the instructions are as follows:
- Download the zip file from here.
- Copy the zip file to the Raspberry Pi and extract the files to a folder
- Open a terminal window and use the 'cd' command to change directory to where you extracted the files
- Now type these commands (press enter after each line):
gcc -c -fpic libpigpio.c
gcc -shared -o libpigpio.so libpigpio.o
sudo cp libpigpio.so /lib
- That will have compiled and installed the library into /lib
- I have also included a test program which you could try, like this...
- In the same terminal window enter these commands
(note the spelling of -lpigpio is important):
gcc -Wall -o test main.c -lpigpio
- Now the GPIO pins 7 to 11 should be turning on an off
(use CTRL+C when you’re fed up)
I hope that helps...
On my recent holiday to Fuerteventura, I decided that I should take the opportunity to understand more
about Quantum Mechanics, as you do, so I took the book
In Search Of Schrodinger's Cat with me. I really enjoyed it, I can recommend it if you need a bit
more wierdness in your life.
I suppose that I'm bound to try and think about it in terms of computing; but I couldn't help feeling that
since it seems impossible to measure certain pairs of properties simultaneously, it's like the universe has
built in security protocols which only allow us to go so far. For example, it's not possible to measure both
the position and momentum of a particle like an electron simultaneously, if you're certain about one of
those properties, the other becomes more uncertain.
So, to me, the whole of Quantum Mechanics seems to be about Hacking the Universe. Nice.