Pictures from DWX’14 conference

July 23, 2014 on 8:33 am | In DotNet, Netduino, Software Engineering, Tinkerforge | No Comments

This year I was once again an invited speaker at the Developer Week conference in Nuremberg, Germany. I was speaking (in German of course) about the basics of hardware programming in .NET. Developer Week is biggest developer conference in Germany: 250 session, 150 speakers. It consists of .NET Developer Conference (DDC), Web Developer Conference (WDC) and Mobile Developer Conference (MDC). Here are some pictures from the conference.

Waiting for the first .NET wrist watch

May 9, 2014 on 2:26 pm | In Continuous Integration, DotNet, Netduino | No Comments

Almost a year ago there was a Kickstarter campaign to found a first .NET Micro Framework watch: Agent smartwatch. Nice thing about it is that you will be able to program it using C# and Visual Studio. While we are still waiting for the product there is a SDK with an emulator. It is from the same guys that gave us Netduino! I decided to check it out.

Think about it: you have a Continuous Integration server running your builds and you want to monitor it on the fly. Is there a better device to do it than a wrist watch? So I thought and decided to check it out.

Here is a quick project I’ve hacked to proof the concept. But before we begin let me show you the result:

image

Neat! Isn’t it?

I’m using Jenkins as my Continuous Integration server. It has a set of APIs for the developer to use. I decided to give Json API a try.

I typed:

http://jenkins_url/api/json?tree=jobs[name,lastBuild[building,result]]

What gave me nice Json result:

{

  • "jobs": [
    • {
      • "name": "Demo4Dev1",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      },

    • {
      • "name": "Demo4Dev2",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      },

    • {
      • "name": "DemoTest1",
      • "lastBuild": {
        • "building": false,
        • "result": "SUCCESS"

        }

      }

    ]

}

I went to the Agent website and got the SDK. I fired up Visual Studio and wen New Project –> Visual C# –> Micro Framework –> AGENT Watch Application

image

Which gave me a Hello World application.

I added System.Http and System.IO references and headed straight to get the HTTP response and read the response stream to the end. Like this:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(JenkinsApiUrl);
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string respStr = sr.ReadToEnd();

Now I needed something to parse the Json text. Luckily for me I wasn’t the only one. There is nice NuGet project with Json parser. To get it issue:

PM> Install-Package Json.NetMF

Having it I head straight to deserialization:

Hashtable deserializedObject = Json.NETMF.JsonSerializer.DeserializeString(respStr) as Hashtable;

Now I went to hack and slash over over the result to find out everything is all right.

// Assume success
bool generalFailure = false;

foreach (DictionaryEntry de in deserializedObject)
{
    foreach (Hashtable ht in de.Value as ArrayList)
    {
        foreach (DictionaryEntry job in ht)
        {
            if (!job.Key.ToString().Equals("name"))
            {

                Hashtable ht2 = job.Value as Hashtable;
                if (ht2 == null) continue;
                foreach (DictionaryEntry results in ht2)
                {
                    if (!results.Key.ToString().Equals("building"))
                    {
                        if (results.Value.ToString().Equals("FAILURE"))
                            generalFailure = true;
                    }

                }
            }
        }
    }

}

I have added two result images to the resources:

image

And headed to show the result:

// initialize display buffer
_display = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);

// Show result
_display.Clear();
Font fontNinaB = Resources.GetFont(Resources.FontResources.NinaB);

_display.DrawText("Jenkins", fontNinaB, Color.White, 35, 10);
if (generalFailure)
{
    _display.DrawText("FAIL!", fontNinaB, Color.White, 35, _display.Height - 20);
    Bitmap image =
        new Bitmap(Resources.GetBytes(Resources.BinaryResources.storm), Bitmap.BitmapImageType.Bmp);
    _display.DrawImage(_display.Width / 2 - image.Width / 2,
        _display.Height / 2 - image.Height / 2,
        image, 0, 0, image.Width, image.Height);

}
else
{
    _display.DrawText("SUCCESS!", fontNinaB, Color.White, 35, _display.Height - 20);
    Bitmap image =
        new Bitmap(Resources.GetBytes(Resources.BinaryResources.sun), Bitmap.BitmapImageType.Bmp);
    _display.DrawImage(_display.Width / 2 - image.Width / 2,
        _display.Height / 2 - image.Height / 2,
        image, 0, 0, image.Width, image.Height);
}
_display.Flush();
I packed everything in a never ending while loop with small delay:
while (true)
{
  // ... code ...
  Thread.Sleep(10000);
}

Done!

That’s the screen with the failure notice.

image

I can’t wait to get the Agent Watch to make the final app!

Hardware programming in .NET at DWX 2014

April 18, 2014 on 2:12 pm | In DotNet, Netduino, Tinkerforge | No Comments

Once again I was invited to give a talk at the DWX – Developer Week in Nuremberg, Germany.  Last year I was speaking about “Continuous Integration in .NET”. This year it is a time to give “Hardware programming in .NET” a try. I will show how to create software for Netduino, Tinkerforge and Raspberry Pi using .NET Micro Framework, .NET Framework and Mono. Oh, and I’m planning to build the circuits the talk! It should be a lot of fun. And here a small example of RGB LED attached to Raspberry Pi and programmed in Mono.

 

CODEFUSION’s Illuminated RaspberryPi

 

To get mono to your Raspberry Pi issue following commands:

sudo apt-get update

sudo apt-get isntall mono-runtime

sudo apt-get install mono-mcs

And here is the source code for the blinking LED:

using RaspberryPiDotNet;

namespace HelloRaspberryPi
{
    class Program
    {
        static void Main(string[] args)
        {
            GPIOMem ledRed = new GPIOMem(GPIOPins.Pin_P1_22);
            GPIOMem ledGreen = new GPIOMem(GPIOPins.Pin_P1_18);
            GPIOMem ledBlue = new GPIOMem(GPIOPins.Pin_P1_16);

            while (true)
            {
                ledRed.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledRed.Write(false);
                ledGreen.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledGreen.Write(false);
                ledBlue.Write(true);
                System.Threading.Thread.Sleep(1500);
                ledBlue.Write(false);
            }
        }
    }
}

Prototype is showed showed on the following picture.

2014-04-17 17.01.59

The image below shows the used Raspberry Pi pins used. For Description and matching PIN names to numbers see here http://elinux.org/RPi_Low-level_peripherals. I have used the GPIOPins.Pin_P1_22 = GPIO25 for red, GPIOPins.Pin_P1_18 = GPIO24 for green and GPIOPins.Pin_P1_16 = GPIO23 for blue. Plus the P1-20 for the grounding. I was using 3 220 Ohm resistors connected the the colors (+).

image

To get it running you will have to reference and use the RaspberryPiDotNet.dll from https://github.com/cypherkey/RaspberryPi.Net/ and have the BCM2835 library compiled. You can get install it using following commands:

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.3.tar.gz

tar -zxvf bcm2835-1.3.tar.gz

cd bcm2835-1.3.tar.gz

./configure

make

sudo make install

cd src

cc -shared bcm2835.o -o libbcm2835.so

And compile your program using Mono.

sudo msc ./Program.cs –r: ./RaspberryPiDotNet.dll

and to run it

sudo mono ./Program.exe

Voila!

If you happen to attend the Developer Week / .NET Developer in conference between 14th and 17th July 2014 please drop by to see my talk!

PS. My mono is enclosed in a self printed case (using our 3D printer) with my company CODEFUSION logo.

.NET hardware programming basics

December 18, 2013 on 12:01 pm | In Article, DotNet, Netduino, Software Engineering, Tinkerforge | No Comments

I’m a “bits sculptor”! I work with bits to create beautiful software. I have done it myself for years and now I’m running a software development company to create “better software”. But I was always jealous of people creating more tangible items than software. Not that I ever thought about software as a lesser creation then physical objects. Oh, no! Creating good software takes the same amount of effort and talent as creating for example a good car. But still. But you cannot “touch” the software you are creating. So I decided to go a bit into hardware. And what is the better way for .NET software developer than to go programming .NET based electronics?!?! 

Yesterday I’ve added a talk about the basics of .NET hardware programming to my repertoire. It’s basically the material I’ve worked on while writing the two articles published by dotnetpro Magazin in Munich, Germany. The first one was about Netduino and it was published in 08/2012 issue and the second one was about Tinkerforge from the 12/2013 issue. I’ve added a bit information and a demo for Raspberry Pi and Mono. I gave a talk at the meeting of .NET Developers Group München (17.12.2013). It went quite well. Despite the technical versatility I had to manage (and believe me the table was crowded with electronics!).

And here are two photos from the talks I gave last week (11.12.2013) at the Opole University of Technology. The topic was: testing mobile software and I showed (among other things) our RoboTouch project.

wyklady_otwarte_2013-12-11-7702wyklady_otwarte_2013-12-11-7710

Hardware programmieren in .NET – Netduino, Tinkerforge, Raspberry Pi

September 24, 2013 on 10:16 am | In DotNet, Netduino | No Comments

image

On 17 December 2013 I will be speaking at .NET Developers Group München. Of course in Munich, Germany. And of course in German. The topic is hardware programming with .NET. I will take Netduino, Tinkerforge and Raspberry Pi some LEDs, resistors, RFID sensors and tags (or even more) and show on live examples how funny it is develop software for real things. Juggling atoms is as much fun as juggling bits. I know that!

I’m getting started with Netduino

February 25, 2012 on 2:51 pm | In DotNet, Netduino | No Comments

I’m recently extending my .NET toolbox with .NET Micro Framework skills. I got myself a Netduino board and I’m currently tinkering. Here is the my HELLO WORLD program:

 1: OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
 2: 
 3: while (true)
 4: {
 5:     foreach (char t in "HELLO WORLD")
 6:     {
 7:         for (int i =
 8:              ",ETIANMSURWDKGOHVF,L,PJBXCYZQ,,54
                 ,3,,,2,,,,,,,16,,,,,,,7,,,8,90".IndexOf(t);
 9:              i > 0; i /= 2)
 10:         {
 11:             led.Write(true);
 12:             if ("-."[i-- % 2] == '.')
 13:                 Thread.Sleep(100);
 14:             else
 15:                 Thread.Sleep(300);
 16:             led.Write(false);
 17:             Thread.Sleep(100);
 18:         }
 19:         Thread.Sleep(300);
 20:         if (t.Equals(' ')) Thread.Sleep(400);
 21:     }
 22: 
 23:     Thread.Sleep(1400);
 24: }

 

Yeap I’m blinking the hello to the world with the Netduino onboard LED and Morse code (thanks for the Morse code translator to the Code Golf community).

Here is the Netduino in action:

Powered by WordPress with Pool theme design by Borja Fernandez.
Text © Marcin Kawalerowicz. Hosting CODEFUSION.