Serial communication issues

I'm trying to use an Arduino Uno as a translator between two devices: a pixhawk flight controller and a Sagetech MXS transponder. The Arduino requests data from the pixhawk (gps, transponder mode, etc), receives the data, and translates the data into the proprietary Sagetech format.
It would be going just fine, but I can't figure out how to use two SoftwareSerial ports (I'm using the hardware serial port for debugging). Here's the code I'm using:

#include <NeoSWSerial.h>
#include <mavlink.h> 

NeoSWSerial pixhawk_port(6, 7);
NeoSWSerial sagetech_port(2, 3);

void setup() {
  pixhawk_port.begin(38400);

  sagetech_port.begin(38400);

  Serial.begin(57600);
  while(!Serial){
    ;
  }
}
mavlink_message_t msg_ident;
uint8_t len;
uint8_t buf[MAVLINK_MAX_PACKET_LEN];
uint8_t flight_id[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6, 7};
uint8_t squawk[] = {1, 2};

void send_and_receive(NeoSWSerial& out_port, NeoSWSerial& in_port){
  mavlink_msg_sagetech_adsb_parameters_pack(0, 0, &msg_ident, 0xFF, flight_id, squawk, 0xF0);

  len = mavlink_msg_to_send_buffer(buf, &msg_ident);

  out_port.write(buf, len);

  in_port.listen();

  mavlink_message_t msg;

  mavlink_status_t status;

  while(in_port.available()) {

    uint8_t c = in_port.read();

    if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)){

      if(msg.msgid == MAVLINK_MSG_ID_SAGETECH_ADSB_PARAMETERS){

        Serial.println("ADSB msg");
      }
      if(msg.msgid == MAVLINK_MSG_ID_HEARTBEAT){
        Serial.println("HB msg");
      }
    }
    
  }
}


void listen(NeoSWSerial& port){
  mavlink_message_t msg;
 
 mavlink_status_t status;
  
  while(port.available()) {

    uint8_t c = port.read();

    if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)){

      if(msg.msgid == MAVLINK_MSG_ID_SAGETECH_ADSB_PARAMETERS){

        Serial.println("ADSB msg");
      }

      if(msg.msgid == MAVLINK_MSG_ID_HEARTBEAT){

        Serial.println("HB msg");
      }
    }

  }

}




void loop() {
  send_and_receive(pixhawk_port, sagetech_port);

}

When I run my listen(port) method, I see constant heartbeats printed out on the serial monitor on both ports, so I know the wiring is correct. However, when I run my send_and_receive method, nothing is printed on the serial monitor.

I was thinking a possible problem would be my placement of the port.listen() method in send_and_receive.

If anyone could help me resolve this problem, I'd be very grateful.

Search this forum. I've addressed this issue a dozen (or more) times, some quite recently, with solutions. SoftwareSerial is problematic with its use of pin change interrupts and needs to be re-worked to function collaboratively with other users of interrupts, or itself for that matter.

It would make a lot more sense to use a Mega which has 3 spare HardwareSerial ports.

...R

DKWatson:
Search this forum. I've addressed this issue a dozen (or more) times, some quite recently, with solutions. SoftwareSerial is problematic with its use of pin change interrupts and needs to be re-worked to function collaboratively with other users of interrupts, or itself for that matter.

May I suggest that you create a Thread that includes your code and explains, with examples, how to use it and then we can post a link to it whenever this question arises.

...R

DKWatson:
Search this forum. I've addressed this issue a dozen (or more) times, some quite recently, with solutions. SoftwareSerial is problematic with its use of pin change interrupts and needs to be re-worked to function collaboratively with other users of interrupts, or itself for that matter.

Please note that OP is using NeoSWSerial library.