Wiznet makers

Aimee0

Published January 02, 2024 ©

17 UCC

12 WCC

8 VAR

0 Contests

0 Followers

0 Following

Original Link

tinygo w5500 TCP echo server

This is an example of implementing a TCP echo server and a client using the W5500 driver written as TinyGo.

COMPONENTS
PROJECT DESCRIPTION

This is an example of implementing a TCP echo server and a client using the W5500 driver written as TinyGo.

What is TinyGo?

A lightweight version of the Go programming language, a project that provides compilers and runtime to enable Go code execution on small embedded systems and web assembly platforms.

  • Support embedded Systems and IoT
  • Garbage Collection
  • Web Assembly Script and WASM (Wasm) support
  • Standard Library Support

 

#main.go

func main() {

	machine.SPI0.Configure(machine.SPIConfig{})

	time.Sleep(3 * time.Second)

	d, err := w5500.NewW5500(machine.SPI0, machine.D3,
		wiznet.IP{192, 168, 50, 55}, wiznet.IP{255, 255, 255, 0}, wiznet.IP{192, 168, 50, 1},
		[]byte{1, 2, 3, 4, 5, 6})

	if err != nil {
		fmt.Println(err)
		time.Sleep(24 * 60 * 60 * time.Second)
		return
	}

	fmt.Println(d.ShowStatus()) // show like `FullDup 100Mbps LinkUp`

	go tcpEchoServer(d, 5555) // Run echo server on port 5555

	tcpTerminalClient(d, &wiznet.TCPAddr{IP: wiznet.IP{192, 168, 50, 3}, Port: 7}) // 7 is echo

	time.Sleep(24 * 60 * 60 * time.Second)
}

 

Documents
  • tinygo-w5500

Comments Write