-
Notifications
You must be signed in to change notification settings - Fork 78
ZephyrSocket
Paul Sokolovsky edited this page May 24, 2017
·
8 revisions
Currently, building MicroPython Zephyr port with network sockets support requires special branches both for Zephyr and for MicroPython:
-
git clone https://github.com/pfalcon/zephyr; git checkout master-micropython
. Usegit pull --rebase
to update (branch rebased). -
git clone https://github.com/pfalcon/micropython; git checkout zephyr-socket2
. Usegit pull --rebase
to update (branch rebased). - Follow https://www.zephyrproject.org/doc/subsystems/networking/qemu_setup.html to bring up QEMU TAP/SLIP based local networking. To access Internet, you will need to setup NAT rules as described there too.
- Setup Zephyr environment for
master-micropython
per its docs. cd micropython/zephyr; make
-
make run
. If it doesn't start up, check your step 3. - From another terminal,
ping 192.0.2.1
. If pings don't come thru, check your step 3. - Switch back to QEMU terminal from step 6, and start playing!
Sample code, connecting to HTTP server on your local machine (Apache runs by default on many Linux machines, if not, install it):
import socket
s = socket.socket()
s.connect(("192.0.2.2", 80))
s.send(b"GET /foo HTTP/1.0\r\n\r\n")
s.recv(1000)
For further testing, DNS server/proxy running on the host (192.0.2.2) is required. A typical Ubuntu system runs dnsmasq
proxy, but it doesn't pick up newly created network interfaces, so you need to restart it explicitly:
service dnsmasq restart