Wintel物联网平台-Windows IoT新手入门指南

1. 引言

近期,微软跟进物联网的速度也在不断加速,除了微软手环,。NET MicroFramework,还有一个叫做Windows IoT的项目。该项目早在今年4月份的Build大会上就提出来了,7月份收集初期的开发者和用户。目前虽然还是处于Developer Program的状态,但是已经在软件和硬件上拿得出手了。关于Windows IoT的资源,主要可以参考下面几个链接:

1. Windows Developer Program for IoT 主页:http://dev.windows.com/en-us/featured/Windows-Developer-Program-for-IoT

2. GitHub主页:http://ms-iot.github.io/content/WhatsNew.htm

3. Building Apps for Windows主页:http://blogs.windows.com/buildingapps/

目前,Windows IoT运行在英特尔Galileo 平台上。该平台已经发布了第一代和第二代开发板。第二代开发主板是基于英特尔Quark SoC X1000 应用处理器的微控制器板,它也是一个 32 位英特尔奔腾品牌的片上系统 (SoC)。它是第一款基于英特尔架构且设计为与用于 Arduino Uno R3的防护实现硬件和软件引脚兼容的板。此平台支持 Microsoft Windows、Mac OS 和 Linux 主机操作系统,因此让英特尔架构开发简单易行。它还简化了 Arduino 集成开发环境 (IDE) 软件。

关于Galileo平台,可以参考一下资源:

1. Galileo 第二代开发板主页:

http://www.intel.cn/content/www/cn/zh/embedded/products/galileo/galileo-overview.html?_ga=1.201686033.105208985.1416798644

2. Galileo开发板主页:http://www.intel.cn/content/www/cn/zh/education/higher-education/galileo-development-board.html

 

2. 开发环境搭建

2.1 设置PC环境(参考链接为Link

2.1.1

使用LiveID登陆Windows Developer Program for IoT,链接地址为Microsoft Connect.

2.1.2

然后下载Visual Studio插件:WindowsDeveloperProgramforIOT.msi,该插件位于Microsoft Connect上,必须登陆以后才能下载。然后安装。

安装结束以后,增加了一个Galileo Watcher软件,如下图:

image

2.1.3

启用Telnet客户端:具体位于控制面板->程序->启用或关闭Windows功能,选中Telnet客户端,如下图。

image

  然后重启PC。

2.2 设置Intel Galileo

2.2.1 创建一个包含Windows IoT系统的MicroSD卡

硬件上,需要一个容量为16G或者更大的MicroSD卡,同时需要有USB接口的读卡器,方便和PC连接。

在Connect上下载apply-BootMedia.cmd文件,以及对应Galileo板子对应的系统镜像,要注意的是,一代伽利略和二代伽利略的镜像是不一样的,按需下载:

然后就是把操作系统镜像写入SD了。首先,把microSD卡格式化为FAT32格式,使用管理管方式打开命令行,

image

在命令行中进入apply-BootMedia.cmd文件所在的路径,然后输入命令:

cd /d %USERPROFILE%\Downloads apply-bootmedia.cmd -destination {YourSDCardDrive} -image {.wimFile downloaded above} -hostname mygalileo -password admin

以我的为例,具体命令如下:

F:\Software\Develop\WindowsIoT>apply-bootmedia.cmd -destination I: -image 9600.16384.x86fre.winblue_rtm_iotbuild.140925-1000_galileo_v2.wim -hostname mygalileo-password admin

如果是在Windows 7下操作,还需要做如下链接的操作:Link

然后就开始写操作系统镜像,整个过程大约需要15分钟左右,需要耐心等待。命令行截屏信息如下:

image

 

 

 

 

注意,一定要等到“正在应用映像”结束以后才算是成功。

2.2.2 启动Galileo的Windows

首先,将SD卡插入到板子上,然后,给板子上电,同时,将PC的网口和板子的网口通过网线连接。如下图所示。

image

上电以后,板子的电源指示灯亮起。SD卡对应的LED灯闪烁。启动系统大概需要2分钟的时间。启动完毕以后,SD卡对应的LED灯就熄灭了。

然后,可以看到Galileo Watcher软件上出现板子的信息:

image

2.2.3 与Galileo进行TelNet通信

我们需要使用Telnet客户端与Galileo进行通信,从而判断其连接是否正常,同时,需要通过Telnet客户端来关闭Galileo。

在“运行”中,输入“telnet mygalileo”,如下图所示。

image

在弹出的验证窗口中输入如下用户名和密码信息:

Username: Administrator

Password: admin

image

 

 

 

当出现如上所示的信息以后,才表示PC与Galileo正确连接,下面就可以使用Visual Studio进行调试了,如果没有做这一步,那么是无法进行Visual Studio调试的。

2.2.4 关闭Galileo

在上述的telnet mygalileo命令行中,输入以下指令:shutdown /s /t 0

当Galileo关闭以后,其microSD卡的指示灯会停止闪烁。注意,每次关闭电源之前最好使用指令关闭Galileo。因为不然的话,下一次启动时间会比较长,需要经过Check Disk的过程,和PC上一样。

 

3. Hello Blinky工程

打开Visual Studio,新建项目,选择File -> New Project and Select Templates -> Visual C++ -> Windows for IoT -> Galileo Wiring app。如下图所示。

image

其Main.cpp文件代码如下:

// Main.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include "arduino.h"

int _tmain(int argc, _TCHAR* argv[])

{

    return RunArduinoSketch();

}

int led = 13; // This is the pin the LED is attached to.

void setup()

{

    // TODO: Add your code here

    pinMode(led, OUTPUT); // Configure the pin for OUTPUT so you can turn on the LED.

}

// the loop routine runs over and over again forever:

void loop()

{

    // TODO: Add your code here

    digitalWrite(led, LOW); // turn the LED off by making the voltage LOW

    Log(L"LED OFF\n");

    delay(1000); // wait for a second

    digitalWrite(led, HIGH); // turn the LED on by making the voltage HIGH

    Log(L"LED ON\n");

    delay(1000); // wait for a second

}

其代码结构如下:

image

4. 测试硬件准备

需要一个面包板,一个电阻,一个LED灯,两根导线,连接方式如下图所示:

 

image

 

5. 调试结果

编译以后,点击部署,在弹出的对话框中,输入

Username: mygalileo\Administrator

Password: admin

如下图所示:

image

部署成功以后,可以看到LED灯闪烁。如下图所示。

image

 

参考链接:

1. Windows Developer Program for IoT 主页:http://dev.windows.com/en-us/featured/Windows-Developer-Program-for-IoT

2. GitHub主页:http://ms-iot.github.io/content/WhatsNew.htm

3. Building Apps for Windows主页:http://blogs.windows.com/buildingapps/

4. Galileo 第二代开发板主页:

http://www.intel.cn/content/www/cn/zh/embedded/products/galileo/galileo-overview.html?_ga=1.201686033.105208985.1416798644

5. Galileo开发板主页:http://www.intel.cn/content/www/cn/zh/education/higher-education/galileo-development-board.html

posted on 2014-12-01 16:59  施炯  阅读(20229)  评论(6编辑  收藏  举报