RS-485 Tx Enable

Hi
I am new to Beaglebone. I am supporting several UART interfaces on a custom designed Cape with RS-485 drivers and I want to know the best way to support driving TX-Enable on my RS-485 driver.

My preference would be for the O/S to look after Tx-Enable without me having to do this manually. Is this possible and if so, can you provide documentation on how to enable and achieve this? My app is in CPP.

Other options include:

Assigning UART RTS pins on P8 and P9 to UART and driving them manually eg

int rts = TIOCM_RTS;
if (ioctl(port, TIOCMBIC, &rts) < 0) {
throw std::runtime_error(“Failed to clear RTS”);
}

int rts = TIOCM_RTS;
if (ioctl(port, TIOCMBIS, &rts) < 0) {
throw std::runtime_error(“Failed to set RTS”);
}

Or assigning pins as GPIO and manually setting them high or low

Please advise the best approach.

When driving Tx-Enable manually, I have found permanently enabling the receiver on the RS-485 driver so I receive an echo back of what I transmit, enables me to detect the end of my transmitted data and disable RS-485 reasonably efficiently. But I would still prefer it if there was a way for the O/S to look after this.