flange_serial_read (Manual Mode)

This section explains how to use flange_serial_read during Manual (Teach) operations to receive data from an external serial device connected to the robot’s flange port.

Typical usage

  • Read response messages from a gripper, sensor, or other serial tool.

  • Verify communication timing and response content after sending commands.

  • Perform real-time monitoring of tool feedback during manual diagnostics.

Note

  • Must be used after successfully opening the port with flange_serial_open.

  • The flange board revision used by the flange serial and flange I/O functions is read at open_connection.

Example: Read response after sending command

// Preconditions:
// - Connection established (open_connection)
// - Manual (Teach) mode active
// - Device connected and port open
drfl.flange_serial_open(1, 115200);

// 1) Send request command
const char cmd[] = "STATUS?\r\n";
drfl.flange_serial_write((int)strlen(cmd), (char*)cmd, 1);

// 2) Read response with timeout (3 sec)
LPFLANGE_SER_RXD_INFO_EX rx_info = drfl.flange_serial_read(3.0, 1);
if (rx_info && rx_info->_iSize > 0) {
    printf("[Flange] Received (%d bytes): %.*s\n",
                rx_info->_iSize, rx_info->_iSize, (const char*)rx_info->_cRxd);
} else {
    printf("[Flange] No response or timeout.\n");
}

// 3) Close port
drfl.flange_serial_close(1);

Tips

  • Adjust timeout depending on device response time.

  • Always check _iSize before accessing the received data.

  • If _iSize is 0, verify baud rate, parity, and wiring.

  • Combine with flange_serial_write for full request–response testing.