Friday, February 23, 2018

Windows IoT on Raspberry Pi

As time moves on so do my interests. 

The Raspberry Pi is a very popular platform, but Python isn't the right language for me. I write most of my personal projects in C#, for the productivity and debugging capabilities. The question is do the benefits of C# translate over to the Raspberry Pi?

To be clear the following experience is mostly with a Raspberry Pi 2, Visual Studio 2017, Target Version "Windows 10 Fall Creators Update (10.0; Build 16299"), wired network connection.

If this project works out I'll use the Raspberry Pi with Windows IoT as a robot controller. If it doesn't work out I'll probably use a different hardware platform to control the robot, since I don't want to write and "debug" that much Python code.

The best reference for me has been this Microsoft Windows IoT Raspberry Pi page.

 It seems there are lots of random "gotchas" most aren't bad, in fact I haven't found a "deal breaker" yet, the first ones I ran into:

  • - Windows IoT doesn't run on the Raspberry Pi Zero or Zero W
    • Zero is Arm6 and WinIoT is compiled for Arm7 and above
  • - Several GPIO are unavailable (0, 1, 14, 15)
    • 0, 1 are EEPROM Id pins and shouldn't really be "re-used".
    • 14,15 are a dedicated USART and can't be "re-used".
Good news is that the Raspberry Pi 2 (RPi2) works and Raspberry Pi 3 (RPi3) support seems good.
  • - To setup Wireless for the RPi3, requires running on a PC that is connected to that Wireless network, i.e. not a wired desktop. I haven't seen a manual configuration option.
C# Language and Debugging on Windows IoT / Rasperry Pi
C# programming has some differences, it's an embedded platform so there are new Namespaces to support new features. There are also new concepts like the IBackgroundTask that take some getting used too. I haven't found any missing features, in fact I found a use for a Tuple and it worked as expected, basically I used it as a "lazy class" I wanted to collect Pin Data in a structured way and didn't have to make a 3 property struct/class to store the data.

I'm very happy that even the Resharper Visual Studio Add-In is working great in these UWP projects.

Debugging has a little more of an up and down story. When it's good it's very good, when it's bad your reminded that the Raspberry Pi is the same size as a baseball and would be very satisfying to destroy.

The good part of the debug experience is the variable expansion, setting the next line to execute (forward or backward). I'm a little bummed that Edit and Continue doesn't work.

The bad part of the debug experience is the Raspberry Pi seems to go to sleep or fall of the network after some period of time. Once this happens it's trial and error to get the debugger connected again. I think I have some reliable steps but I'll test a few more times before publishing.

More to come!

No comments:

Post a Comment