earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
2.03k stars 421 forks source link

SoftwareSerial does not work anymore in 4.0.1 #2419

Closed jaszczurtd closed 1 month ago

jaszczurtd commented 1 month ago

As mentioned in the description, my code works without any issues up to version 3.9.5. Platform: RP2040-Plus

I also tested whether adding "true" to the object constructor would make a difference, but unfortunately, it didn’t.

I noticed some upcoming changes related to RX/TX inversion (commit ID: 226a3188975b21d29d32fe4423a6c929766192a5). Perhaps you could take another look at the issue with this change in mind?

Please let me know if you need any further information.

[...]

#define SERIAL_RX_GPIO 22
#define SERIAL_TX_GPIO 21

static SoftwareSerial gpsSerial(SERIAL_RX_GPIO, SERIAL_TX_GPIO); <-- inserting "true" here does not change anything for 4.0.1
static TinyGPSPlus gps;

void serialTalks(void);

static bool isGPSInitialized = false;
void initGPS(void) {
  if(!isGPSInitialized) {
    attachInterrupt(SERIAL_RX_GPIO, serialTalks, FALLING);  
    gpsSerial.begin(9600, SERIAL_7N1);
    isGPSInitialized = true;
  }
}

void serialTalks(void) {
  if(gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
  }
}
earlephilhower commented 1 month ago

Looks like a typo. If you're using the git version, can you edit https://github.com/earlephilhower/arduino-pico/blob/226a3188975b21d29d32fe4423a6c929766192a5/cores/rp2040/SoftwareSerial.h#L40-L41 to the following and try (note the underscore in the name):

 setInvertTX(_invert); 
 setInvertRX(_invert); 

And make sure you have the invert flag set in the constructor, of course.

earlephilhower commented 1 month ago

Actually, it was a little more complicated. Please try #2423 and report back. The TX inversion got overwritten by the PIO TX setup before. I've verified normal and inverted on a logic analyzer just now with this new patch.