beautypg.com

3 s26_comopen(), 4 s26_comclose() – Sensoray 2600 User Manual

Page 71

background image

Sensoray 2600 Programming Guide

67

Comport Transaction Functions

condition is detected on the comport’s receive line. The break character may be set to a “printable” character, such
as a carriage return character, to provide a “visual” indication that a break was detected.

Break conditions are sometimes employed as message delimiters. For example, a hand-held barcode scanner may
assert a break when its trigger is squeezed, and again when the trigger is released. The resulting break characters
will then serve as delimiters for the barcode data.

The target comport may be either open or closed when this function is called.

Example:

// Configure COM1 on MM number 0 to use a carriage return as its break character.

u32 errstat = S26_ComSetBreakChar( 0, LOGDEV_COM1, 13, 1000, 1 );

if ( errstat & GWERRMASK )

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

else

printf( "Successfully set COM1 break char.\n" );

8.2.3 S26_ComOpen()

Function:

Enable transmit and receive operations on a comport.

Prototype:

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

Returns:

Error/status value, as described in section 8.1.1.

Notes:

By default, all comports are closed after a MM reset.

S26_ComOpen()

must be called to enable each comport that

will be used. A comport must be enabled before attempting to send data to or receive data from the its remote serial
device. Before calling

S26_ComOpen()

, the application should call

S26_ComSetMode()

to configure the comport.

The target comport must be closed when this function is called. If the comport is already open 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 asserted in the returned status byte if this function executes successfully.

Example:

// Open COM1 on MM number 0.

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

if ( errstat & GWERRMASK )

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

else if ( errstat & COM_REJECTED )

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

else

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

8.2.4 S26_ComClose()

Function:

Disable transmit and receive operations on a comport.

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.