基于zigduino 平台的contiki 学习笔记
2012年07月18日 10:54 发布者:xiaocai一碟
----------------------- Page 1-----------------------基于zigduino 平台的contiki 学习笔记
1 环境搭建
接下来的所有操作都是基于instant contiki 这个环境,首先在你的
windows 或者mac 上必须有一个虚拟机软件(VMware),接着再从网上下载instant
contiki 以及avr-zigduino 平台下的contiki 源码。instant contiki 的安装请
参考:http://contiki-os.blogspot.com/p/instant-contiki.html
1.1安装instant contiki 工具包
进入到instant contiki,打开终端运行如下命令来安装所需的工具包。
--------------------------------------------------------------
$ sed -i '/avr/d' /home/user/.profile
$ sudo aptitude update
$ sudo apt-get install avr-libc gcc-avr binutils-avr avrdude git
--------------------------------------------------------------
然后重启虚拟机。
1.2下载contiki
avr-zigduino 源码目前在github 上,打开终端,运行一下命令来下载源码:
--------------------------------------------------------------
$ cd ~
$ git clone git://github.com/maniacbug/contiki-avr-zigduino.git
-b avr-zigduino
$ cd contiki/platform/avr-zigduino
--------------------------------------------------------------
完成了以上的步骤,接下来就可以完成下面的实验了。
2 实验
2.1设置节点id
每一个节点都有一个唯一的mac 地址。avr-zigduino 平台将节点的id 作为
mac 地址的最后一个字节。
----------------------- Page 2-----------------------
通过运行一下命令来设置每个节点的节点id。
--------------------------------------------------------------
$ cd tools/set-eeprom
$ make NODE=3 AVRDUDE_PORT=/dev/ttyUSB0
-------------------------------------------------------------
2.2做一个简单的ping 实验
这个实验需要两个节点,按照上述的步骤将一个节点的nodeid 设为3,另
一个设为4。
我们在nodeid 为3 的节点中烧写hello-word 程序,在nodeid 为4 的节点
中烧写ping-ipv6 程序,步骤如下:
首先在nodeid 为3 的节点中烧写hello-world 程序,打开终端键入以下命
令:
--------------------------------------------------------------
$ cd tests/hello-world
$ make upload AVRDUDE_PORT=/dev/ttyUSB0
$ make login AVRDUDE_PORT=/dev/ttyUSB0
-------------------------------------------------------------
如果成功的话,终端将会显示:
--------------------------------------------------------------
connecting to /dev/ttyUSB0 (57600)
Power-on reset.
External reset!
*******Booting Contiki 2.5*******
MAC address 2:11:22:ff:fe:33:44:3
nullmac sicslowmac, channel 26
IP addresses
fdfd::3
fe80::11:22ff:fe33:4403
Hello, world
-------------------------------------------------------------
接下来在nodeid 为4 这个节点中烧入ping-ipv6,在终端里面键入以下命
----------------------- Page 3-----------------------
令,我们将要ping 正在运行hello-world 程序的NODE=3 节点:
--------------------------------------------------------------
$ cd tests/ping-ipv6
$ make upload AVRDUDE_PORT=/dev/ttyUSB1 NODE=3
$ make login AVRDUDE_PORT=/dev/ttyUSB1
-------------------------------------------------------------
如果运行无误,终端将会显示:
--------------------------------------------------------------
connecting to /dev/ttyUSB1 (57600)
Power-on reset.
External reset!
*******Booting Contiki 2.5*******
MAC address 2:11:22:ff:fe:33:44:1
nullmac sicslowmac, channel 26
In Process PING6
Wait for DAD
IP addresses
fdfd::1
fe80::11:22ff:fe33:4404
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003
from fdfd:0000:0000:0000:0000:0000:0000:0004
Echo reply received.
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003
from fdfd:0000:0000:0000:0000:0000:0000:0004
Echo reply received.
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003
from fdfd:0000:0000:0000:0000:0000:0000:0004
Echo reply received.
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003
from fdfd:0000:0000:0000:0000:0000:0000:0004
Echo reply received.
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003
from fdfd:0000:0000:0000:0000:0000:0000:0004
----------------------- Page 4-----------------------
Echo reply received.
END PING6
-------------------------------------------------------------
2.3一个UDP 通信实验
接下来我们来做一个两个节点间通过UDP 来进行运用层数据的传输。同样的,
我们需要两个节点,一个节点运行服务器程序,一个节点运行客户端程序。当我
们编译客户端程序时,我们需要指定NODE=the nodeid 来使客户端能找到服务器
的地址。
在终端运行如下的命令:
--------------------------------------------------------------
$ cd tests/udp-ipv6
$ make NODE=3 -j10
$ make udp-client.avr-zigduino.u AVRDUDE_PORT=/dev/ttyUSB1
NODE=3
$ make udp-server.avr-zigduino.u login AVRDUDE_PORT=/dev/ttyUSB0
-------------------------------------------------------------
如果运行成功,终端将会显示 (服务端节点的输出):
--------------------------------------------------------------
connecting to /dev/ttyUSB0 (57600)
Power-on reset.
External reset!
*******Booting Contiki 2.5*******
MAC address 2:11:22:ff:fe:33:44:3
nullmac sicslowmac, channel 26
IP addresses
fdfd::3
fe80::11:22ff:fe33:4403
UDP server started
Server IPv6 addresses: fdfd::3
fe80::11:22ff:fe33:4403
----------------------- Page 5-----------------------
+READY
Server received: 'Hello 2 from the client' from fdfd::4
Responding with message: Hello from the server! (1)
Server received: 'Hello 3 from the client' from fdfd::4
Responding with message: Hello from the server! (2)
Server received: 'Hello 4 from the client' from fdfd::4
Responding with message: Hello from the server! (3)
Server received: 'Hello 5 from the client' from fdfd::4
Responding with message: Hello from the server! (4)
Server received: 'Hello 6 from the client' from fdfd::4
Responding with message: Hello from the server! (5)
Server received: 'Hello 7 from the client' from fdfd::4
+OK PASS
-------------------------------------------------------------
2.4运行shell 程序
Shell 是contiki 操作系统里面的一个非常重要的特性。接下来我们在其中
一个节点上运行shell 程序。
在终端上键入以下命令:
--------------------------------------------------------------
$ cd tests/shell
$ make uploadAVRDUDE_PORT=/dev/ttyUSB0
$ make loginAVRDUDE_PORT=/dev/ttyUSB0
-------------------------------------------------------------
如果成功,终端上将会显示:
--------------------------------------------------------------
connecting to /dev/ttyUSB0 (57600)
Power-on reset.
External reset!
*******Booting Contiki 2.5*******
MAC address 2:11:22:ff:fe:33:44:3
----------------------- Page 6-----------------------
nullmac sicslowmac, channel 26
Contiki command shell
Type '?' and return for help
68.1: Contiki>
IP addresses
fdfd::1
fe80::11:22ff:fe33:4403
-------------------------------------------------------------
它可以使用一下命令:
-------------------------------------------------------------
binprint: print binary data in decimal format
blink : blink LEDs ( times)
echo
exit: exit shell
hd: print binary data in hexadecimal format
help: shows this help
kill
killall: stop all running commands
netstat: show UDP and TCP connections
null: discard input
ping
ps: list all running processes
quit: exit shell
randwait
a command
repeat
网友评论
luhuaneda 2012年07月22日
haox
haox
bbslhb 2015年06月25日
非常有技术含量的分享。多谢楼主。
非常有技术含量的分享。多谢楼主。
这是提问么?