3 communication, 1 s26_comsend() – Sensoray 2600 User Manual

Page 72

Advertising
background image

Sensoray 2600 Programming Guide

68

Comport Transaction Functions

Prototype:

u32 S26_ComClose( HMM hbd, u8 LogDev, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

This function flushes the target comport’s serial transmitter and receiver queues. Any character transmission that is
in progress is completed.

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

COM_REJECTED

flag will be set.

The

COM_ISOPEN

flag will be negated in the returned status byte if this function executes successfully.

Example:

// Close COM1 on MM number 0 and flush all transmit and receive buffers.

u32 errstat = S26_ComClose( 0, 1, 1000, 1 );

if ( errstat & ( GWERRMASK | COM_REJECTED ) )

printf( "COM1 communication problem detected.\n" );

else if ( errstat & COM_REJECTED )

printf( "COM1 already closed.\n" );

else

printf( "COM1 is %s.\n", ( status & COM_ISOPEN ) ? "open" : "closed" );

8.3 Communication

8.3.1 S26_ComSend()

Function:

Sends data bytes to a comport.

Prototype:

u32 S26_ComSend( u32 hbd, u8 LogDev, char *MsgBuf, u16 MsgLen, u32 msec, u32 retries );

Returns:

Error/status value, as described in section 8.1.1.

Notes:

This function transfers data bytes to the target comport’s transmitter queue. The comport transmitter queue is a
FIFO queue, so any bytes that are already pending in the queue will be transmitted before the new bytes are
transmitted.

If the transmitter queue would overflow as a result of adding the new data bytes to it, all of the data bytes in the
comport command packet will be discarded and the status byte’s

COM_REJECTED

flag will be set.

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

COM_REJECTED

flag will be set.

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.

MsgBuf

char*

Address of a buffer that contains the data bytes to be sent to the target comport.

MsgLen

u16

Number of bytes in MsgBuf[] that are to be sent to the target comport.

msec

u32

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

retries

u32

Maximum number of transaction retry attempts.

Advertising