.. _flange_serial_read: flange_serial_read ------------------------------------------ This function receives serial data from the **flange serial port** in the robot controller. |br| The port parameter is **only available in the new flange version (v2).** **Definition** |br| ``DRFLEx.h`` within class `CDRFLEx`, public section .. code-block:: cpp LPFLANGE_SER_RXD_INFO_EX flange_serial_read(float fTimeout = -1, int nPort = 1) { return _flange_serial_read(_rbtCtrl, fTimeout, nPort); }; **Parameter** .. list-table:: :widths: 20 20 20 40 :header-rows: 1 * - **Parameter Name** - **Data Type** - **Default Value** - **Description** * - fTimeout - float - -1 - Timeout value in seconds. |br| A value of **-1** means the function will **wait indefinitely** for incoming data. |br| The call returns when data arrives or when fTimeout elapses. * - nPort - int - 1 - **Port number for flange serial interface** |br| 1: X1, 2: X2 (X2 only on M/H models) **Return** .. list-table:: :widths: 25 75 :header-rows: 1 * - **Value** - **Description** * - :ref:`FLANGE_SER_RXD_INFO_EX ` - Refer to the Definition of Structure .. note:: The returned pointer refers to storage in the CDRFLEx object that other DRFL calls and every reconnect reuse; copy the structure before making another DRFL call. The 3-argument ``ikin`` returns its result in storage shared by all CDRFLEx objects in the process instead; see :ref:`ikin `. Except for ``get_user_home``, the pointer is never NULL; do not use a NULL check to detect failure. 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 opens the flange serial port, sends the string `"test123"`, waits up to **4.5 seconds** for a response, and prints the received data and byte count using the returned structure.