FLANGE_SERIAL_DATA

Serial communication information is defined using a union, composed of:

  • Serial communication setting information (_tConfig)

  • Serial communication data information (_tValue)

It is used with _iCommand to determine which field is valid:

  • 0 : Open

  • 1 : Close

  • 2 : Send

  • 3 : Receive

BYTE#

Field Name

Data Type

Value

Remarks

0

_iCommand

unsigned char

Serial communication command in the low 4 bits
(0: Open, 1: Close, 2: Send, 3: Recv)
The high 4 bits hold the port number (nPort * 16) on a rev2 flange, and for Recv on either flange (port 1 on a rev1 flange).

1

_tData

union

Contains either configuration info or data buffer.

_tConfig structure (Serial Configuration):
The union for serial communication information is defined as follows. On a rev1 flange, flange_serial_open fills these fields from its parameters; see flange_serial_open for the accepted values. On a rev2 flange, flange_serial_open sets only _iCommand (nPort * 16) and these fields stay zero.

BYTE#

Field Name

Data Type

Value

Remarks

0

_tConfig._szBaudrate

unsigned char[7]

ASCII

Baud rate as 7-byte text

7

_tConfig._szDataLength

unsigned char

byte size

8

_tConfig._szParity

unsigned char

Parity Check

9

_tConfig._szStopBit

unsigned char

1 or 2

Stop bits

_tValue structure (Serial Data Buffer):
Serial communication data information is defined as follows.

BYTE#

Field Name

Data Type

Value

Remarks

0

_tValue._iLength

unsigned short

RX/TX data length (bytes)

2

_tValue._szValue

unsigned char[MAX_SYMBOL_SIZE]

Data buffer (up to 32 bytes)

Total size: 35 bytes

Defined in: DRFS.h

typedef struct _FLANGE_SERIAL_DATA
{
    unsigned char _iCommand;   // 0: Open, 1: Close, 2: Send, 3: Recv
    union {
        struct {
            unsigned char _szBaudrate[7];  // "0115200"(ASCII)
            unsigned char _szDataLength;   // 0: 1bit, 7: 8bit
            unsigned char _szParity;       // 0x00: None, 0x01: Odd, 0x02: Even
            unsigned char _szStopBit;      // 0x01: 1 Stop bit, 0x02: 2 Stop bits
        } _tConfig;

        struct {
            unsigned short _iLength;             // RX Data Length
            unsigned char  _szValue[MAX_SYMBOL_SIZE]; // RX/TX Data (32 bytes)
        } _tValue;
    } _tData;
} FLANGE_SERIAL_DATA, *LPFLANGE_SERIAL_DATA;