support icon indicating copy to clipboard operation
support copied to clipboard

[Feature] Build HAT Pybricks Protocol support

Open dlech opened this issue 1 month ago • 0 comments

The Raspberry Pi Build HAT communicates to a connected Raspberry Pi computer via a serial port on the 40-pin header.

We will need to implement the Pybricks Protocol over this connection in order to be able to use this with coding tools like pybricksdev and Pybricks Code.

This comes with some challenges since we don't have any other hubs that use serial ports. The existing hubs are packet/message based, so we can get the size of a message from the transport. With UART, there is nothing to group bytes together into a message. So we will need to add a layer to the protocol to include the size of the message that follows in the data stream.

I would also like to have a background service running on the Raspberry Pi that handles the actual UART communication. For example, if we implement a low battery shutdown, this service would handle receiving the message from the Build HAT and telling the Raspberry Pi to shut down. This could be potentially extended in the future to allow adding missing Pybricks features like button, Bluetooth and/or USB support to the Build HAT by offloading these things to the Raspberry Pi.

This background service would also provide a network socket (websocket?) that acts as a bridge for the Pybricks protocol. This network socket is what Pybricks Code and pybricksdev would actually connect to. This would allow Pybricks Code/pybricksdev to run on the Raspberry Pi itself or remotely on another computer.

For now, we have a hack to just have stdio piped to the serial port so that we can progress with developing other features.

dlech avatar Dec 05 '25 03:12 dlech