Skip to content

SoftwareSerial::Write() does not use inverse logic #2831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
titos-carrasco opened this issue Jan 5, 2017 · 4 comments
Closed

SoftwareSerial::Write() does not use inverse logic #2831

titos-carrasco opened this issue Jan 5, 2017 · 4 comments
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.

Comments

@titos-carrasco
Copy link

Basic Infos

Hardware

Hardware: NodeMcu

Description

In file SoftwareSerial.cpp, SoftwareSerial::write(uint8_t b) does not use "inverse logic".

I changed some lines...

Sketch

size_t SoftwareSerial::write(uint8_t b) {
   if (!m_txValid) return 0;

   if (m_invert) b = ~b;
   // Disable interrupts in order to get a clean transmit
   cli();
   if (m_txEnableValid) digitalWrite(m_txEnablePin, HIGH);
   unsigned long wait = m_bitTime;
   digitalWrite(m_txPin,!m_invert ? HIGH : LOW);
   unsigned long start = ESP.getCycleCount();
    // Start bit;
   digitalWrite(m_txPin, !m_invert ? LOW : HIGH );
   WAIT;
   for (int i = 0; i < 8; i++) {
     digitalWrite(m_txPin, (b & 1) ? HIGH : LOW);
     WAIT;
     b >>= 1;
   }
   // Stop bit
   digitalWrite(m_txPin, !m_invert ? HIGH : LOW);
   WAIT;
   if (m_txEnableValid) digitalWrite(m_txEnablePin, LOW);
   sei();
   return 1;
}
@devyte
Copy link
Collaborator

devyte commented Oct 4, 2017

@titos-carrasco per the lib properties, the repo for the ESP's SoftwareSerial is https://github.com/plerup/espsoftwareserial
You may want to open an issue/PR over there, then we can update the lib here.

@igrr I am using latest git, and the SoftwareSerial lib is not in the directory structure. However, it is present under the 2.3.0 release directory structure. I assume that means that it gets packaged in the release process. Exactly how is it pulled in, and which version is used?

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 4, 2017
@devyte
Copy link
Collaborator

devyte commented Jul 13, 2018

This issue is for SoftwareSerial. Similar issue for hw serial: #4896 .

@devyte
Copy link
Collaborator

devyte commented Oct 17, 2019

cc @dok-net

@devyte
Copy link
Collaborator

devyte commented Nov 10, 2019

No feedback in a long time.
I don't know if relevant, but I see an inverse flag available in the begin() signature.
Closing.

@devyte devyte closed this as completed Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

No branches or pull requests

2 participants