Perhaps that solution will be less useful that you hope.
It relies on the "idle detection" feature. The RX idle condition occurs after one character time of silence (aka "idle character") and this timeout is not configurable.
But the Modbus protocol requires gap between messages to be at least 3.5 characters.
For this the UART has the Receive timeout feature (RTO). The HAL library seems to support it, but using it is more complicated that it should be. Look for more specific Modbus examples.