flange_serial_write (Manual Mode)

This section explains how to use flange_serial_write during Manual (Teach) operations to transmit data from the robot’s flange serial port to an external device (e.g., gripper, force sensor, or tool controller).

Typical usage

  • Send control commands or queries to a connected serial device.

  • Test manual command transmission before automatic DRL integration.

  • Verify that the connected device correctly receives and responds to data.

Note

Example: Send simple command to flange device

// Preconditions:
// - Connection established (open_connection)
// - Manual (Teach) mode active
// - Device connected to flange COM1

// 1) Open port
if (!drfl.flange_serial_open(FLANGE_COM1, 115200))
    return -1;

// 2) Prepare and send message
const char cmd[] = "STATUS?\r\n";
bool sent = drfl.flange_serial_write(strlen(cmd), (char*)cmd, FLANGE_COM1);
if (sent)
    printf("[Flange] Sent: %s\n", cmd);
else
    printf("[Flange] Transmission failed.\n");

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

Tips

  • Append termination characters (e.g., \r or \n) if the device expects ASCII-based commands.

  • Avoid sending large data blocks continuously in manual mode.

  • Use flange_serial_read afterward to confirm the device’s response.