Clearing serial buffer solved

Random data which made its way through 8N1 encoding when your RX receiver was listening to data on a bus intended for another receiver.

If you are throwing out the whole buffer, how do you know where the random data ends and the good data starts? I'll say it again, throwing away data without knowing what it is that you are throwing away is foolish. I'm sure you'll find some corner case where it makes sense to you, but it is still foolish from a design perspective.

If your receiver is picking up random garbage from some other bus that it wasn't supposed to be listening to then you have a design issue, not a need to throw away data.