查看“Microduino W5500 Network (6)”的源代码
←
Microduino W5500 Network (6)
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Purpose== This course will show you how to sue UDP (User Datagram Protocol) to communicate with Microduino-W5500. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-USBTTL]]''' *'''[[Microduino-W5500]]''' *'''[[Microduino-RJ45]]''' *Other hardware equipment **USB cable One ==UDP== UDP is short for User Datagram Protocol—a connectionless transmission level protocol in OSI reference model, providing transaction oriented simple unreliable message delivery service. It is formally defined in IETF RFC 768. ==Schematic== *Microduino-ENC28J60 *Microduino-RJ45 *Microduino-Core *Microduino-USBTTL Stack them and plug in the cable. As follows: [[File:MicroduinoW5500Show.png|600px|center|thumb]] ==Program== [[https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Advanced_Tutorial/W5500Code/MicroduinoW5500Six MicroduinoW5500Six]] ==Debugging== Step 1: First, make sure you have _02_Microduino_Ethernet_WIZ library in your IDE and put it into libraries folder of your IDE. Step 2: If there still exists the previous Ethernet library in your libraries folder, it needs to be deleted since the previous Ethernet is compiled according to W5100. Then, you need to change _02_Microduino_Ethernet_WIZ file so that the library function could be corresponding with Microduino-W5500: First find w5100.h of utility in _02_Microduino_Ethernet_WIZ library. Change #define wiz_cs_pin 8 //CS_PIN of the code to #define wiz_cs_pin 10 //CS_PIN. Step 3: Interpret the code: // if there's data available, read a packet int packetSize = Udp.parsePacket(); if(packetSize) { Serial.print("Received packet of size "); Serial.println(packetSize); Serial.print("From "); IPAddress remote = Udp.remoteIP(); for (int i =0; i < 4; i++) { Serial.print(remote[i], DEC); if (i < 3) { Serial.print("."); } } Serial.print(", port "); Serial.println(Udp.remotePort()); //Judge if there is any data from code above. If there is, IP address and port number of the client will be output through the serial port. // read the packet into packetBufffer Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE); Serial.println("Contents:"); Serial.println(packetBuffer); // send a reply, to the IP address and port that sent us the packet we received Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); Udp.write(ReplyBuffer); Udp.endPacket(); } delay(10); //Message read and transmitted from the code above is input through the serial port and responds “acknowledged” to the client. Step 4: Download the code and compile. Step 5: Test: SocketTool sends UDP packet. Open SocketTool, select UDP client and click to create. [[File:MicroduinoW5500SocketTool1.png|600px|center|thumb]] Input IP and port of the opposite side in the pop-up dialog box. [[File:MicroduinoW5500SocketTool2.png|600px|center|thumb]] Input messages in data sending box and send. [[File:MicroduinoW5500SocketTool3.png|600px|center|thumb]] The receiving box will show “acknowledged”. [[File:MicroduinoW5500SocketTool4.png|600px|center|thumb]] ==Result== Here we got a UDP receiver by Microduino-W5500, capable of receiving message and replying. ==Video== |}
返回至
Microduino W5500 Network (6)
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息