3 s26_comgetrxcount(), 4 s26_comgettxcount() – Sensoray 2600 User Manual

Page 74

Advertising
background image

Sensoray 2600 Programming Guide

70

Comport Transaction Functions

RcvBuf[BufLen] = 0;

// Append null to end of string.

printf( "%s\n", RcvBuf );

// Display the string.

}

8.3.3 S26_ComGetRxCount()

Function:

Returns a comport’s receive buffer character count.

Prototype:

u32 S26_ComGetRxCount( u32 hbd, u8 LogDev, u16 *CharCount, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

S26_ComGetRxCount()

returns the number of pending received characters (i.e., receive characters that have not

yet been retrieved by an Ethernet client) remaining in a comport’s receive ring buffer.

Example:

// Determine the number of characters pending in MM number 0, COM1 receive buffer.

u16 RxCount;

u32 errstat = S26_ComGetRxCount( 0, 1, &RxCount, 1000, 1 );

if ( errstat & GWERRMASK )

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

else if ( errstat & COM_REJECTED )

printf( "COM1 is not open.\n" );

else

printf( "There are %d characters in the Rx buffer.\n", RxCount );

8.3.4 S26_ComGetTxCount()

Function:

Returns a comport’s transmit buffer character count.

Prototype:

u32 S26_ComGetTxCount( u32 hbd, u8 LogDev, u16 *CharCount, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

S26_ComGetTxCount()

returns the number of characters remaining in a comport’s transmit ring buffer that have

not yet been transmitted onto the serial interface. This can be useful if you must determine whether all characters
have been sent to a remote serial device, or if you need to find out if there is enough space in the transmit buffer for
new characters.

Example:

// Determine the number of characters remaining in MM number 0, COM1 transmit buffer.

u16 TxCount;

u32 errstat = S26_ComGetTxCount( 0, 1, &TxCount, 1000, 1 );

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.

CharCount

u16

Address of a 16-bit application buffer that will receive the character count.

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.

CharCount

u16

Address of a 16-bit application buffer that will receive the character count.

msec

u32

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

retries

u32

Maximum number of transaction retry attempts.

Advertising