Code Sample 1: Instantiation Of A Driver Object On The Stack - Honeywell UMC800 Reference Manual

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

Advertisement

3.2.2 Code sample 1: instantiation of a driver object on the stack

#include "Commbase.h"
#include "Elnapi.h"
void SomeClass::SomeFunction()
{
unsigned char pbyTxMsg[64];
unsigned char pbyRxMsg[64];
int nTxLength;
int nRxLength;
long lRet;
CElnApi CommDriver(
lRet = CommDriver.SetUpPort(
if(lRet)
{
// Error handling goes here.
}
sprintf(pbyTxMsg, "My dog has fleas.")
lRet = CommDriver.OpenPort();
if(lRet)
{
/*
Error handling goes here.
out access to the port.
*/
}
lRet = CommDriver.TransCeive(
if(lRet)
8/99
"COM2",
// Connect driver to com2.
5000,
// 5 sec. timeout.
5,
// 5 retries.
2000);
// 2 sec. delay between retries.
9600,
// 9600 baud.
FALSE, // No parity.
8,
// 8 data bits.
1);
// 1 stop bit.
Chances are another application has locked
pbyTxMsg,
// Outgoing message ptr.
pbyRxMsg,
// Rx buffer.
17,
// Outgoing msg length.
64,
// Rx buffer size.
&nRxLength, // Actual length of Rx.
1);
// Unit addr. 1.
RS232 Communications Reference Manual
PC Communication Driver
continued next page
17

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rs232

Table of Contents