3 s26_comclearflags(), 4 s26_comflush() – Sensoray 2600 User Manual

Page 76

Advertising
background image

Sensoray 2600 Programming Guide

72

Comport Transaction Functions

8.4.3 S26_ComClearFlags()

Function:

Resets all error flags belonging to a comport.

Prototype:

u32 S26_ComClearFlags( u32 hbd, u8 LogDev, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

If this function executes successfully, the

COM_FRAMINGERROR

,

COM_PARITYERROR and

COM_OVERFLOWERROR

flags will be reset to zero on the target comport. This will be reflected in the returned status byte as well.

Example:

// Reset all COM1 error flags on MM number 0.

// For clarity, error detection is not shown here.

S26_ComClearFlags( 0, 1, 1000, 1 );

8.4.4 S26_ComFlush()

Function:

Flushes a comport’s receiver buffer and resets its error flags.

Prototype:

u32 S26_ComFlush( u32 hbd, u8 LogDev, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

S26_ComFlush()

may be used to “reset” the receiver buffer to compensate for a detected error on a received

character from the remote serial device; this has the effect of resynchronizing the Ethernet client to the remote
serial device.

This function should be called, for example, if a parity, framing or overrun error is detected on a received character.
When a receive error occurs, the entire contents of the receiver buffer must be considered corrupt and the receiver
buffer should accordingly be dumped in preparation for a communication retry to the remote serial device.

The target comport must be open when this function is called. If the comport is already closed when this command
is issued, the command will be rejected and the status byte’s

COM_REJECTED

flag will be set.

Example:

// Fetch and display an ASCII string from COM1 on MM number 0.

char RcvBuf[256];

// Buffer that will receive the string.

u16 BufLen = sizeof(RcvBuf);

// Max number of characters to receive.

u32 errstat = S26_ComReceive( 0, 1, RcvBuf, &BufLen, 1000, 1 );

if ( errstat & GWERRMASK )

printf( "COM1 error detected.\n" );

else if ( errstat & ( COM_PARITYERROR | COM_OVERFLOWERROR | COM_FRAMINGERROR ) )

{

Parameter

Type

Description

hbd

u32

MM handle.

LogDev

u8

Logical device identifier for the target comport. Specify a value from 1 to 4 to
address comport 1 to 4, respectively.

msec

u32

Maximum time, in milliseconds, to wait for the MM to respond.

retries

u32

Maximum number of transaction retry attempts.

Parameter

Type

Description

hbd

u32

MM handle.

LogDev

u8

Logical device identifier for the target comport. Specify a value from 1 to 4 to
address comport 1 to 4, respectively.

msec

u32

Maximum time, in milliseconds, to wait for the MM to respond.

retries

u32

Maximum number of transaction retry attempts.

Advertising