This guys as implementing a protocol were two or more devices were transmitting at same time on RS485 and he end up developing a collision detection using a GPIO pin to detect the moment the TX started transmitting and compared the transmitted signal with the received signal:
https://forum.pjrc.com/index.php?threads/implementing-collision-detection-with-rs485.57591/