RS485 on a BeagleBoneGreen + Waveshare Cape

I want to build a Modbus TCP to Modbus RTU gateway using a BeagleBoneGreen and a WaveShare RS485 CAN CAPE. Unfortunately the documentation on the Waveshare Cape is really bad, so I will try to document here what steps were necessary to get the...