flange_serial_write
This function sends serial data through the flange serial port in the robot controller.
The port parameter is only available in the new flange version (v2).
Definition
DRFLEx.h within class CDRFLEx, public section
bool flange_serial_write(int nSize, char* pSendData, int nPort = 1)
{
return _flange_serial_write(_rbtCtrl, nSize, pSendData, nPort);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
nSize |
int |
Number of bytes of |
|
pSendData |
char* |
Pointer to the data buffer to be sent. Maximum supported size: 256 bytes. |
|
nPort |
int |
1 |
Port number for flange serial interface |
Return
Value |
Description |
|---|---|
0 |
Error — failed to transmit data. |
1 |
Success — data successfully transmitted. |
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 the flange serial port, sends a 7-byte test message, reads back received data using flange_serial_read(), and finally closes the port. It demonstrates basic send/receive flow for flange serial communication.