The last two weeks were pretty busy on my side. Just before leaving for IDF 2014 in San-Francisco, I received the notification from Microsoft that I could finally access to their Windows for the Galileo gen1 board. I do love UNIX, do appreciate Linux, but I am a Windows developer and user at the core. I started event-driven and UI programming using the Petzold for Windows 2.0 (I say “Petzold” for Windows programming as I could say “Ritchie & Kernighan” for the C language).
Back from IDF, I gave a try to run Windows on my Galileo board. Overall, the installation is pretty straight forward, and as soon as you have access to a Galileo Gen1, you should be up and running the blinking LED sample in less than one hour. My main issues were to find a micro-SD card that could hold the OS image and to detect the IP address of the board (had the same issues with Linux). At this stage – I just had the time to try the new OS in Arduino mode –, I cannot say anything yet about building a stand-alone Win32 app. What I really loved, is the tight integration with Visual Studio, and the debug capability. This is really cool and a big step ahead for me.
what sense, ms windows on that device?
My first answer would be having the choice. By simply swapping out a micro-SD card, I can have the Windows or Linux environment. Also, keep in mind that this Windows version doesn’t have any UI. My second answer is that I can re-use my Windows tools, knowledge, etc. Now I still need to understand how much of the Windows system APIs I can use from within my Windows app. The broader the access, the higher the value for me.
OK, so I quickly put together a small program that creates a thread and blinks the LED at a higher rate. All works fine! I will post more on this later as my experiments will progress. For now, I am just adding below the code of the sample (an addition to the default template):
#include “stdafx.h”
#include “arduino.h”
#include “process.h”
#include “windows.h”
int led = 13; // This is the pin the LED is attached to.
HANDLE h_event_thread = NULL;
DWORD event_thread_id = 0;
unsigned int __stdcall event_thread(void *);
int _tmain(int argc, _TCHAR* argv[]) {
return RunArduinoSketch();
}
void setup() {
pinMode(led, OUTPUT);
h_event_thread = (HANDLE)_beginthreadex(
NULL,
0,
event_thread,
(void *)NULL,
0,
(unsigned int *)&event_thread_id
);
if (h_event_thread == NULL) {
; // ERROR
}
}
void loop() {
Sleep(1000);
}
unsigned int __stdcall event_thread(void *px) {
for (;;) {
digitalWrite(led, LOW);
delay(100);
digitalWrite(led, HIGH);
delay(100);
}
return(0);
}