tell me HOW I could detect an edge on the RX pin (how would I wire it up) and how to attach an interrupt handler method.
Your solution checks if there is serial data. If not, it returns immediately. You have no idea how long the serial buffer has been empty. Maybe that's OK. Maybe not.If there is as-yet-unread serial data, it records how much, and waits the entire amount of time defined.
If any data arrives during that time, it again waits the entire amount of time before checking whether new data has arrived.Between when that function ends and the next function gets called, to actually send the data, more data could have arrived.
Nothing else can happen during those delays (and, yes I recognize that they are short).Mine, on the other hand, checks on every pass through loop, and records when there is a change in the amount of data.The delays only occur when there is data to send. My function waits only if there has been activity on the bus, and as soon as the bus has been idle long enough starts to send data.
You can wire one of the INT pins to RXD and use attachInterrupt().