You're reading the documentation for an older, but still supported version (1.33.4).
For information on the latest version, please have a look at 1.33.5.

flange_serial_open

This function opens the flange serial transfer port in the robot controller.

Definition
DRFLEx.h within class CDRFLEx, public section

bool flange_serial_open(
    int nPort,
    int baudrate = 115200,
    BYTE_SIZE eByteSize = BYTE_SIZE_EIGHTBITS,
    PARITY_CHECK eParity = PARITY_CHECK_NONE,
    STOP_BITS eStopBits = STOPBITS_ONE)
{
    return _flange_serial_open(_rbtCtrl, nPort, baudrate, eByteSize, eParity, eStopBits);
};

Parameter

Parameter Name

Data Type

Default Value

Description

nPort

int

Serial port index
1: X1, 2: X2 (X2 only on M/H models)

baudrate

int

115200

Baudrate setting for serial communication.
Supported values: 2400, 4800, 9600, 19200, 38400, 57600, 115200, etc.

eByteSize

BYTE_SIZE

BYTE_SIZE_EIGHTBITS

Data bit length

eParity

PARITY_CHECK

PARITY_CHECK_NONE

Parity configuration

eStopBits

STOP_BITS

STOPBITS_ONE

Stop bit configuration

Note

On a rev2 flange, only nPort is used; baudrate, eByteSize, eParity and eStopBits are ignored. On a rev1 flange, nPort is ignored.

Return

Value

Description

0

Error: failed to open serial port.

1

Success: serial port successfully opened.

Note

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

Example

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 flange serial port 1 (X1) at 115200 baud, sends a 7-byte test string, reads back the response, and closes the serial connection.