Managing Multiple Threads; Taxonomy Of Classes; Api Functions Common To All Drivers - Honeywell UMC800 Reference Manual

Rs232 communications
Hide thumbs Also See for UMC800:
Table of Contents

Advertisement

3.2.7 Managing Multiple Threads

Do not pass a pointer to the same CElnApi object to two concurrently running threads. This will
defeat the system's port lockout capability and may cause fatal errors.
If you want to do an upload or download as a background routine, spawn a thread, then allow the thread to
instantiate a CElnApi object that is attached to the same port as the app's CElnApi object. The two objects
will coexist harmoniously despite being attached to the same port. However, TheApp.CElnApi.OpenPort()
will fail as long as the thread has access. Note also that if the app doesn't close the port before spawning the
thread, the thread will not be able to open the port.

3.3 Taxonomy of Classes

CCommBase is the base class from which all driver classes (CXxxApi) are derived. CCommBase contains
virtual implementations of all of the API functions that are common to all drivers. CCommBase only exists
so that a CCommBase pointer can be cast as a CElnApi pointer, a CLnApi pointer, a CModbusApi pointer,
etc. The implementations of the API functions in CCommBase don't do anything, though, so don't
instantiate a CCommBase object. It won't be useful for anything.

3.4 API Functions Common To All Drivers

CElnApi:: CElnApi(char* pszCommPort, int nTimeOut, int nRetry, int nRetryDelay);
pszCommPort:The name of the communication port you wish to attach the driver to (e.g. "COM1",
"COM2", etc.).
nTimeOut:
Length of time (in mS) driver will wait for an instrument to reply.
nRetry:
Number of repeats in the event of a communication failure.
nRetryDelay: Length of time (in mS) to wait between retries.
long CElnApi::SetUpPort(int baud, BOOL parity, int data, int stop);
baud: Baud rate.
parity: TRUE for parity, FALSE for no parity.
data: Number of data bits.
stop: Number of stop bits.
You cannot call this function while the port is open.
long CElnApi::OpenPort();
Call this function to get access to the port. If an error is returned, another app has probably locked out the port.
long CElnApi::ClosePort();
Call this function when you are done communicating to relinquish ownership of the port.
8/99
RS232 Communications Reference Manual
PC Communication Driver
continued next page
21

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rs232

Table of Contents