基于区块链的毕业设计ether-swtch – 乙醚开关

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计ether-swtch – 乙醚开关 是一篇很好的国外资料

ether-swtch

Low level Ethernet/IP/TCP/HTTP stack marshaller/unmarshaller for use in tiny places.

This is a work in progress. The API is subject to change.

Below is an example of an HTTP server for the ENC28J60 integrated circuit using TinyGo. Works on the Arduino Mega 2560. Use build tag -tags=noheap to reduce heap allocations.

package main  import (     "net"      swtch "github.com/soypat/ether-swtch"     "github.com/soypat/ether-swtch/hex" )  func main() { 	var ( 		// SPI Chip select pin. Can be any Digital pin. 		spiCS = machine.D53 		MAC   = net.HardwareAddr{0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFF} 		MyIP  = net.IP{192, 168, 1, 5} //static setup is the only one available 	)  	// Configure writer/reader integrated circuit. 	dev := enc28j60.New(spiCS, machine.SPI0)  	err := dev.Init(MAC) 	if err != nil { 		println(err.Error()) 	} 	const okHeader = "HTTP/1.0 200 OKrnContent-Type: text/htmlrnPragma: no-cachernrn" 	timeout := time.Second * 1 	// Spin up HTTP server which responds with "Hello world!" 	swtch.HTTPListenAndServe(dev, MAC, MyIP, timeout, func(URL []byte) (response []byte) { 		return []byte(okHeader + "Hello world!") 	}, printNonNilErr) }  func printNonNilErr(err error) { 	if err != nil { 		println(err.Error()) 	} }

With noheap build tag enabled the above program consumes the following memory

   code    data     bss |   flash     ram   22278     765     856 |   23043    1621 

The program should be small enough to run on the Arduino UNO as well (2k sram, 32k flash).


ether-swtch

用于小型场所的低级以太网/IP/TCP/HTTP堆栈封送器/解封器

这是一项正在进行的工作。API可能会发生变化

下面是使用TinyGo的ENC28J60集成电路的HTTP服务器示例。在Arduino Mega 2560上工作。使用build tag-tags=noheap减少堆分配

package main  import (     "net"      swtch "github.com/soypat/ether-swtch"     "github.com/soypat/ether-swtch/hex" )  func main() { 	var ( 		// SPI Chip select pin. Can be any Digital pin. 		spiCS = machine.D53 		MAC   = net.HardwareAddr{0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFF} 		MyIP  = net.IP{192, 168, 1, 5} //static setup is the only one available 	)  	// Configure writer/reader integrated circuit. 	dev := enc28j60.New(spiCS, machine.SPI0)  	err := dev.Init(MAC) 	if err != nil { 		println(err.Error()) 	} 	const okHeader = "HTTP/1.0 200 OKrnContent-Type: text/htmlrnPragma: no-cachernrn" 	timeout := time.Second * 1 	// Spin up HTTP server which responds with "Hello world!" 	swtch.HTTPListenAndServe(dev, MAC, MyIP, timeout, func(URL []byte) (response []byte) { 		return []byte(okHeader + "Hello world!") 	}, printNonNilErr) }  func printNonNilErr(err error) { 	if err != nil { 		println(err.Error()) 	} }

启用noheap build tag后,上述程序将消耗以下内存

   code    data     bss |   flash     ram   22278     765     856 |   23043    1621 

该程序应足够小,可以在Arduino UNO上运行(2k sram,32k闪存)

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/23746.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计ether-swtch – 乙醚开关

提供最优质的资源集合

立即查看 了解详情