📄 rs232.h
字号:
/*
* Copyright (c), Philips Semiconductors Gratkorn / Austria
*
* (C)PHILIPS Electronics N.V.2000
* All rights are reserved. Reproduction in whole or in part is
* prohibited without the written consent of the copyright owner.
* Philips reserves the right to make changes without notice at any time.
* Philips makes no warranty, expressed, implied or statutory, including but
* not limited to any implied warranty of merchantability or fitness for any
*particular purpose, or that the use will not infringe any third party patent,
* copyright or trademark. Philips must not be liable for any loss or damage
* arising from its use.
*/
/*! \file MfRc500.h
*
* Projekt: MF EV X00 Firmware
*
* $Workfile:: RS232.H $
* $Modtime:: 23.07.01 15:10 $
* $Author:: Hb $
* $Revision:: 16 $
*
*/
#ifndef RS232_H
#define RS232_H
#ifdef __cplusplus
extern "C" {
#endif
//----------------------------------------------------------------------------
// INCLUDES
//----------------------------------------------------------------------------
#include <ReaderInterface.h>
//----------------------------------------------------------------------------
// PROTOTYPE DECLARATIONS
//----------------------------------------------------------------------------
class ProtocolBase;
/// RS232 communication interface
/*!
* \ingroup hostrdcom
* Derived class from ReaderInterface.
* Controls properties of the RS232 interface
* (e.g. ComPort, BaudRate, ...)
*/
class DLLEXP_IMP RS232
: public ReaderInterface
{
//----------------------------------------------------------------------------
// Member Functions
//----------------------------------------------------------------------------
public:
//------------------------------------------------------------------------
// Construction, destruction
RS232();
virtual ~RS232();
//------------------------------------------------------------------------
// Overloaded member functions
// General member functions
virtual short OpenInterface();
virtual short CloseInterface();
// ResetInterface - closes the open interface and reopens it
virtual short ResetInterface();
// purge all remaining data and initialize internal structures
virtual short ClearInternalBuffers();
//------------------------------------------------------------------------
// Interface properties
// ComPort
short SetComPort(char ComPort);
short GetComPort() const;
// BaudRate
short SetDefaultBaudRate(long BaudDefaultRate);
long GetDefaultBaudRate() const;
// BaudRate
short SetBaudRate(long BaudRate);
long GetBaudRate() const;
// Send 1 byte to the reader, timeout after "Timeout" ms
short WriteBytesUnblocked(unsigned char* ch,
unsigned long datalen,
unsigned long &dwBytesWritten,
unsigned long Timeout);
// Receive 1 byte from the reader, timeout after "Timeout" ms
short ReadBytesUnblocked(unsigned char* ch,
unsigned long datalen,
unsigned long &dwBytesRead,
unsigned long Timeout);
//! BUG: Wrong Operator Delete Called for Exported Class
/*!
* \name BUG: Q122675
*
* When allocating and deleting an object of a class that is exported from a DLL,
* you may find that the new operator in the EXE is called to allocate the memory but
* the delete operator in the DLL is called to delete the memory. Therefore, there is
* a new/delete mismatching problem, which may cause run-time errors.
*/
//@{
void* operator new( size_t tSize );
void operator delete( void* p );
//@}
private:
// Copy constructor
RS232(const RS232& rs232) {};
// Assignment operator
RS232& operator= (const RS232& rs232){ return *this;};
//----------------------------------------------------------------------------
// Data Members
//----------------------------------------------------------------------------
public:
// Default values for RS232 properties after startup
enum RS232_DEFAULT_VALUES { COM_PORT = 1,
BAUD_RATE = 57600
};
private:
char m_cComPort;
long m_lBaudRate;
long m_lDefaultBaudRate;
HANDLE* m_hInterface;
};
#ifdef __cplusplus
}
#endif
#endif // RS232_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -