ComAcquire

This routine attempts to acquire exclusive or non-exclusive access to the communication port. ComAcquire allows the port to be seized, even if another process has the port opened exclusively, effectively overriding that process' exclusive open.

This function must be called whenever an application wishes to use a communication port it had previously opened, but may have lost ownership of. Ownership may be lost whenever an application is "switched out," if it receives and honors any System Manager deactivating event.

Making this call with "normal" seizure specified does not guarantee that port ownership will pass to the caller. An error may be returned indicating that the port is exclusively owned by another application. If the calling application receives this error, it can prompt the user as to whether port ownership should be seized from the owning application. If so, the ComAcquire call may be made again, specifying unconditional port seizure.

Since this function call does not nest, thirty consecutive calls to this function are equivalent (except possibly for side effects, see below) to a single call, and do not require thirty calls to the ComRelease function. Port acquisition may also be ended by a ComClose call.

This function has two important side effects. The first side effect is fairly transparent; whenever port ownership changes, UART parameters are changed to match those in effect when the new owner did a ComSet or ComSetParameters call.

The second side effect occurs when port ownership is changed as the result of this call. ComAcquire resets any "XON/XOFF" flow control currently in effect. If the local transmitter had been flow-controlled off by a remote (i.e., the remote device sent an XOFF), the flow control is considered expired and data transmission resumes. Similarly, if the local receiver has flow-controlled the remote transmitter, this flow controlling is considered expired and the local receiver sends an XON to the remote. Note that this expiration of flow control only occurs for the "transient" character-based flow control, the XON/XOFF variety, and not for "persistent" hardware-based flow control.