.. _manual_flange_serial_open: flange_serial_open (Manual Mode) ------------------------------------------ This section explains how to use :ref:`flange_serial_open ` during **Manual (Teach)** operations to **establish serial communication** between the robot’s flange port and an external device such as a **gripper, sensor, or tool controller**. **Typical usage** - Manually send/receive data to verify tool communication during setup. - Check device response and signal integrity before automatic program execution. .. Note:: - After opening, you can use :ref:`flange_serial_write ` and :ref:`flange_serial_read ` for data exchange. - The flange board revision used by the flange serial and flange I/O functions is read at open_connection. **Example: Open flange serial port and verify communication** .. code-block:: cpp // Preconditions: // - Connection established (open_connection) // - Manual (Teach) mode active // - External serial device connected to flange X1 // 1) Open the flange serial port bool opened = drfl.flange_serial_open( 1, // Port number 115200, // Baud rate BYTE_SIZE_EIGHTBITS, // Data bits PARITY_CHECK_NONE, // Parity STOPBITS_ONE // Stop bits ); if (!opened) { printf("[Flange] Failed to open X1.\n"); return -1; } printf("[Flange] X1 opened successfully.\n"); // 2) (Optional) Write / read test data // char cmd[] = "STATUS?"; // drfl.flange_serial_write((int)strlen(cmd), cmd, 1); // LPFLANGE_SER_RXD_INFO_EX rx = drfl.flange_serial_read(3.0f, 1); // printf("Response: %.*s\n", rx->_iSize, (const char*)rx->_cRxd); // 3) Close after test drfl.flange_serial_close(1); printf("[Flange] X1 closed.\n"); **Tips** - Match **baudrate, parity, and stop bits** exactly with the device’s serial configuration. - Use short test messages (e.g., 8–32 bytes) to confirm stable communication. - If open fails, check cable wiring (TX/RX swap) or ensure the port is not already active. - Always close the port using :ref:`flange_serial_close ` before reopening or switching devices.