Bug in SoftwareSerial and inverse logic

When using the SoftwareSerial and inverse logic, there is a bug in the setTX method, the method does not take into account the inverse logic flag when setting default output on the tx pin.

The second line in setTX should be

digitalWrite(tx, _inverse_logic ? LOW : HIGH);

Do you have a test case / a device that uses inverted logic?

Yes, I have two of these http://seetron.com/glo416.html, they use inverse logic.

When using one of them I had no trouble, but when using two of them together, I started getting weird data on the second screen I was using. So after a time of debugging and testing I found out that if the time from the instantiation of the SoftwareSerial and the first write was to long, the data was wrong on the display. The error was that the setTX is actually starting a start bit when using inverse logic, but not the rest of the trasmission.

When using two, both of them was instantiated at the same place, but before the first write to the second screen was done, the first screen was set up, and that took a little time.

So by doing the change i suggested, the setTX does not start a start bit when the SoftwareSerial is initilized.

Excellent. You have identified a bug, you have a good test case, and you have a simple fix.

The next step is to open an issue. Please go here... Sign in to GitHub · GitHub ...and create a new issue report for this bug. I suggest keeping the report brief and provide a reference to this thread.

Reported bug as Bug in SoftwareSerial when using inverse logic · Issue #1361 · arduino/Arduino · GitHub

Thank you.

By creating a "pull request" you greatly increase the chances of your bug fix getting into the official release. Are you interested in doing that?

I think I managed to do it...

Certainly looks like it to me. Thank you.