     uint32_t invertMask = 0;
     if(pinSupport[pinCTS])
     {
-      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, pinCTS, /*cts_io_num*/UART_PIN_NO_CHANGE);
+      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, /*cts_io_num*/pinCTS);
       // cts is input to me, output to true RS232
       if(ctsActive == 0)
-        invertMask = invertMask | UART_INVERSE_RTS;
+        invertMask = invertMask | UART_INVERSE_CTS;
     }
     if(pinSupport[pinRTS])
     {
-      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, /*rts_io_num*/UART_PIN_NO_CHANGE, pinRTS);
+      uart_set_pin(UART_NUM_2, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, /*rts_io_num*/ pinRTS, UART_PIN_NO_CHANGE);
       s_pinWrite(pinRTS, rtsActive);
       // rts is output to me, input to true RS232
       if(rtsActive == 0)
-        invertMask = invertMask | UART_INVERSE_CTS;
-    }
-    uart_set_line_inverse(UART_NUM_2, invertMask);     
-    //uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_DISABLE,0);
+        invertMask = invertMask | UART_INVERSE_RTS;
+    }
+    //uart_set_line_inverse(UART_NUM_2, invertMask);     
     if(pinSupport[pinRTS])
     {
       if(pinSupport[pinCTS])


bool ZSerial::isSerialCancelled()
{
  if(flowControlType == FCT_RTSCTS)
  {
    if(pinSupport[pinCTS])
      return (digitalRead(pinCTS) == ctsInactive);
  }
  return false;
}


    }
    else
    if(pinSupport[pinCTS])
      uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_CTS,SER_BUFSIZE);
  }
  else
    uart_set_hw_flow_ctrl(UART_NUM_2,UART_HW_FLOWCTRL_DISABLE,0);
