Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By mikekgr
#70735
tele_player wrote:The modification for 7 bits is extremely simple, have you looked at SoftwareSerial.cpp?
Note: rxRead() might trick you, since it is written using 0x80 and right shift. I'd change it to 0x01 and left shift, so it can handle 7-bit correctly simply by changing the loop limit.

I'd mod software serial to have a method for setting a variable for bits., rather than constant 8.

These mods would take a minute to do. It might take a few minutes, or an hour, to figure out. Hint: there are two loops with 8 hard-coded, and one place where 0x80 is OR'ed into the received byte.


Dear tele_player,
thanks for your reply and the guiding. For my needs I will not use receiving data at all, so, in my case it is better to remove all rx parts in the software serial routine.
With the above in mind, can you modify the software serial ( .cpp & .h ) to meet my need?
I asking this because I am not sure that I can do it by myself even if it simple as you told.
In all cases thanks for your helping hand.
Best Regards,
Mike Kranidis
User avatar
By tele_player
#70755 I don't want to get into figuring out what version you have installed, and I don't know what may or may not have changed, but here's the relevant function grabbed from somewhere on Github.
I've added comments showing what I changed to transmit 7 bits, no start, no stop. My comments will start with ***

Caveat: I haven't compiled this, or tested it, and I have little confidence that this will be of any use to you.

Code: Select all
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, HIGH);
   unsigned long start = ESP.getCycleCount();
    // Start bit;
//   digitalWrite(m_txPin, LOW);   // *** disable START bit
//   WAIT;          // *** disable START bit
   for (int i = 0; i < 7; i++) {.  // *** Was 8
     digitalWrite(m_txPin, (b & 1) ? HIGH : LOW);
     WAIT;
     b >>= 1;
   }
   // Stop bit
//   digitalWrite(m_txPin, HIGH);  // *** disable STOP bit
//   WAIT;   // *** disable STOP bit
   if (m_txEnableValid) digitalWrite(m_txEnablePin, LOW);
   sei();
   return 1;
}