Knowledge Base Nr: 00126 sr3964lib.cpp - http://www.swe-kaiser.de
Downloads:
Linux: R3964 Protokoll unter Linux und Oracle Forms verwenden.
das kleine programm pollt die schnittstelle. es wird eine lib und ein exe gebaut.
//////////////////c-interface/////////////////////////////////////////
extern "C"
{
int R3964_open(const char* szDevice, int nBaudrate, char cParity, int nBits, int nStopbits, int nUseBCC);
int R3964_close();
const char* R3964_send(const char* szRequest, int bWaitAndGetAnswer);
const char* R3964_checkRequest();
const char* R3964_lasterror();
const char* R3964_lastsyserror();
}
//////////////////c++-interface/////////////////////////////////////////
class CR3964
{
public:
CR3964();
~CR3964();
int openCom(const char* lpszPort, int nBaudrate, char cParity, int nBits, int nStopbits, int nUseBCC);
int closeCom();
const char* getLastError() { return m_szLastError; }
const char* getLastSysError() { return m_szLastSysError; }
int sendTelegram(char *cDataRecv, int* pnLenDataRecv, char *cDataSend, int nLenDataSend, bool bWaitAndGetAnswer, int nTimeout);
int checkRequestFromR3964(char *cDataRecv, int* pnLenDataRecv);
protected:
void resetError(const char* lpszHint, ...);
void setError(const char* lpszHint, ...);
bool checkForSysErrors(const char* lpszHint, ...);
int getTickCount();
private:
int m_hndPort;
struct termios m_termio;
char m_szLastError[MAXERRBUFFER];
char m_szLastSysError[MAXERRBUFFER];
};
//////////////////pld-interface/////////////////////////////////////////
/*--------------------------------------------------------------*\
* FUNCTION R3964_open:
\*--------------------------------------------------------------*/
FUNCTION R3964_open(
szDevice IN OUT VARCHAR2,
nBaudrate IN OUT PLS_INTEGER,
cParity IN OUT VARCHAR2,
nBits IN OUT PLS_INTEGER,
nStopbits IN OUT PLS_INTEGER,
nUseBCC IN OUT PLS_INTEGER
) RETURN PLS_INTEGER;
/*--------------------------------------------------------------*\
* FUNCTION R3964_close:
\*--------------------------------------------------------------*/
FUNCTION R3964_close RETURN PLS_INTEGER;
/*--------------------------------------------------------------*\
* FUNCTION R3964_send:
\*--------------------------------------------------------------*/
FUNCTION R3964_send(
szRequest IN OUT VARCHAR2,
bWaitAndGetAnswer IN OUT PLS_INTEGER
) RETURN VARCHAR2;
/*--------------------------------------------------------------*\
* FUNCTION R3964_checkRequest:
\*--------------------------------------------------------------*/
FUNCTION R3964_checkRequest RETURN VARCHAR2;
/*--------------------------------------------------------------*\
* FUNCTION R3964_lasterror:
\*--------------------------------------------------------------*/
FUNCTION R3964_lasterror RETURN VARCHAR2;
/*--------------------------------------------------------------*\
* FUNCTION R3964_lastsyserror:
\*--------------------------------------------------------------*/
FUNCTION R3964_lastsyserror RETURN VARCHAR2;