Home

Up: Smart Plug

Previous: W5500 Driver for Rust Embedded-HAL on AVR

Working UDP Listener in Rust (finally)

After much wailing and gnashing of teeth, I figured out what the problem with my program was. The W5500 driver's ability to edit registers is not broken, it was my own mistake. In my simple example set up to write/read to/from a register, I forgot to alter the configuration of the SPI instance to match what the W5500 chip expects. Fixing this instantly yielded results.

https://github.com/jonahbron/smart-plug/blob/0655b0671ad76788fccc0043198b9e15e715d753/src/main.rs

Hello from Arduino!
initialized
activated
IP: 192.168.86.30

This gave me new-found hope in the possibility of using the driver and not needing to implement my own. So I pushed forward to try receiving a UDP packet again. After messing around with the same compiler/linker errors I've been getting around the library, I found that passing in a buffer 16 bytes in length or less fixes the problem with receive.

https://github.com/jonahbron/smart-plug/blob/3bce81436a8eb3d8e97249d21715ebaef374a786/src/main.rs

And to my extreme excitement (and surprise), it worked! I was able to use netcat to send a packet to the board via the network, and see the serial output displaying the ASCII character codes.

The light is finally green. Next I will create the v2 prototype of the Smart Plug, while continuing my contributions to the AVR-HAL/w5500 projects in parallel.

Next: USB Serial Mod

Creative Commons License