My suspicion is available() cannot be called in the same loop as write() because available() counts as reading from the port. I know that you cannot read and write in the same loop.
But could it be that write() just clears the buffer?
serial data is transmitted and received over separate signal paths that don't interfere with one another an allow simultaneous (duplex) transmission. the serial interface on the Arduino processor has separate buffers for transmission and receiving. this is not true when using an RS485 transceiver external to the processor, for example
of course transmission and reception can be done within the same loop. there's not need to check before transmission, just do a .write() or .print(). of course reception should check if .available() to know if there is something to read.
software serial is intended to behave the same as the hardware serial interface
Not quite, software serial (possibly depending on which library you use) has the problem of not being able to do a loopback test, where you connect the transmits pin directly to the receive pin and attempt to receive what you are sending.
I’ve been working on this for a month now and haven’t found an example of read and write working simultaneously. If you have one, I’d love to see it.
What baud rate are you using? Generally stick to 9600 baud or lower with SoftwareSerial.
I've seen some discussion that SoftwareSerial is only usable as half-duplex, because of its reliance on interrupts and the amount of code that needs to be executed by the receive and transmit routines, there just isn't time to reliably do both simultaneously.
Would really help if you could post your code for BOTH arduinos, getting two boards to work together reliably is not the easiest task.
available() does tell you the number of characters available in the receive buffer, but does not affect the contents of the buffer.
write() should have no effect at all on the receive buffer, other than possibly causing an overflow in the receive buffer if you write so much that you exceed the size of the transmit buffer. At that point the write() function will not return until space becomes available in the transmit buffer, which can allow enough time to fill the receive buffer completely and start losing characters.
That code, running on both boards, is basically a loopback test - you are saturating the transmit so that it runs continuously, and you will not be able to receive simultaneously with SoftwareSerial.
Communications between two boards is generally one boards sends a complete message, second board processes the message and responds, first boards processes that message and responds, etc.