Code Sample 2: Dynamic Instantiation Of One Of Two Driver Objects On The Heap - Honeywell UMC800 Reference Manual

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

Advertisement

PC Communication Driver
Code sample 1: instantiation of a driver object on the stack, continued
{
// Error handling goes here.
}
lRet = CommDriver.ClosePort();
if(lRet)
{
// Error handling goes here.
}
}
3.2.3

Code sample 2: dynamic instantiation of one of two driver objects on the heap

#include "Commbase.h"
#include "Elnapi.h"
void SomeClass::SomeFunction()
{
unsigned char pbyTxMsg[64];
unsigned char pbyRxMsg[64];
int nTxLength;
int nRxLength;
long lRet;
CCommBase* pDriver;
// Dynamically instantiate an EL+N driver object.
pDriver = new CElnApi(
if(!pDriver)
{
// Error handling goes here.
}
/*
From this point on we don't care what kind of driver it is because
all driver objects that are derived from the CCommBase base class
have the same public API functions.
*/
lRet = pDriver->SetUpPort(
if(lRet)
18
"COM2", // Connect driver to com2.
5000,
// 5 sec. timeout.
5,
// 5 retries.
9600,
// 9600 baud.
FALSE,
// No parity.
8,
// 8 data bits.
1);
// 1 stop bit.
RS232 Communications Reference Manual
continued next page
8/99

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rs232

Table of Contents