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

  • Ensure the port is opened beforehand via flange_serial_open.

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

Example: Send simple command to flange device

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

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

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

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

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.