AltSoftSerial - flushing and/or waiting for completion

Does anyone know of a reliable way to insure that AltSoftSerial has completed transmission? I am using altSoft.flush() but I suspect it's not working correctly. altSoft.flush() should wait to completion so I can reliably turn off the RS485 driver, but it doesn't seem to be happening.

Have you looked at the source code? If you want someone else to look at it for you, post a link.

altSoft.flush() should wait to completion so I can reliably turn off the RS485 driver, but it doesn’t seem to be happening.

If you’re using an IDE version greater equal 1.0 it does, otherwise it empties the input buffer.

Why do you think that it doesn’t happening?

See this topic:

http://forum.arduino.cc/index.php?topic=171542.0

It seems like I am missing the reply from the slave to the server. I don't really know what's going on, but something is not right in that code, in that the master never gets the response.

It's not hardware as I have successfully tested the hardware using one way connections. It's something in the timing of the query/response and turning around the half-duplex MAX485 chip.

From looking at the AltSofSerial library code, there is a flushOutput() which should wait until the tx is done, but it doesn't make any difference to my code. So....

I'm clutching at straws here.

Have you tried what I proposed in my post there? Just opening a new thread won't help you much.

You haven't described what's going wrong yet. Did you attach a scope to see what's happening?

Yup, I tried various delays, no joy.

The issue is definitely with AltSoftSerial. I just redid my breadboard to use the hardware serial port for communication between the arduinos and it works just fine, with my monitoring data coming from the softserial port.

The problem then becomes that I have to physically unplug the MAX485 before I can program the arduino, which just will not work in the field. I have to be able to program the board in the field with the MAX485 attached.

I don't have a reliable scope to test the signal, but it looks like with AltSoftSerial nothing comes back out of the second board, it's as if the buffer is not getting flushed to the port.

OK, never mind, the problem was between the keyboard and the chair… I had at some point in the past initialized pins 8 and 9 with:

pinMode(addressPin1, INPUT_PULLUP);

This apparently does not play well with AltSoftSerial, allowing it to receive but not send. GRRRR…