.. _flange_serial_close: flange_serial_close ------------------------------------------ This function closes the **flange serial transfer port** in the robot controller. **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp bool flange_serial_close(int nPort) { return _flange_serial_close(_rbtCtrl, nPort); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - nPort - int - - - **Serial port index** |br| 1: X1, 2: X2 (X2 only on M/H models) **Return** .. list-table:: :widths: 25 75 :header-rows: 1 * - **Value** - **Description** * - 0 - Error: failed to close serial port. * - 1 - Success: serial port successfully closed. .. note:: The flange board revision used by the flange serial and flange I/O functions is read at open_connection. **Example** .. code-block:: cpp char buf[] = "test123"; Drfl.flange_serial_open(1, 115200); Drfl.flange_serial_write(7, buf, 1); LPFLANGE_SER_RXD_INFO_EX temp = Drfl.flange_serial_read(4.5, 1); printf("Serial read : %.*s\n", temp->_iSize, (const char*)temp->_cRxd); printf("Serial cnt : %d\n", temp->_iSize); Drfl.flange_serial_close(1); This example first opens the flange serial port, sends test data, reads incoming data using `flange_serial_read()`, and finally closes the connection using `flange_serial_close()` to safely release the port resource.