I wrote common functions in order to manage serial ports, based on the following structure: I am calling these functions (see below) in another file in order to test an RS232 serial port. The flow control needs to be enabled. In order to validate the implementation, the pinouts Tx and Rx have been connected together, idem for CTS and RTS.