#if !defined(AFX_SCANNER_H__98052617_4EA4_11D7_A89C_005004C029CA__INCLUDED_) #define AFX_SCANNER_H__98052617_4EA4_11D7_A89C_005004C029CA__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include // If you will never build this for use in a DLL, you can comment out // this #if block. #ifdef BUILD_COMMDLL #define COMMDLL_DLLCLASS __declspec(dllexport) #else #define COMMDLL_DLLCLASS __declspec(dllimport) #endif #define MAX_COMM_PORT 16 #define MAX_PARITY 5 #define MAX_STOPBITS 3 const CString g_csCOMM[]= { "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10", "COM11", "COM12", "COM13", "COM14", "COM15", "COM16", }; const CString g_csPARITY[] = { "None", "Odd", "Even", "Mark", "Space", }; const double g_dSTOPBITS[]= { 1, 1.5, 2, }; #define COM1 1 #define COM2 2 #define COM3 3 #define COM4 4 #define COM5 5 #define COM6 6 #define COM7 7 #define COM8 8 /* Parity Codes */ #define NOPARITY 0 #define ODDPARITY 1 #define EVENPARITY 2 #define MARKPARITY 3 #define SPACEPARITY 4 /* Stop Bit Codes */ #define ONESTOPBIT 0 #define ONE5STOPBITS 1 #define TWOSTOPBITS 2 /* Word Length Codes */ #define WORDLENGTH7 7 #define WORDLENGTH8 8 class CSerialPort; class COMMDLL_DLLCLASS CScanner { public: CScanner(); virtual ~CScanner(); // Operations public: bool Send(CString csMsg); void ResetReceiveBuffer(); bool SetStopBits(int nStopBits=0); bool SetParity(int nParity=2); bool SetByteSize(int nByteSize=8); bool SetBaudRate(long lBaudRate=9600); CSerialPort * GetCommObject(void); BOOL ClearComm(void); virtual void ReceiveComm(const char *cpcBuffer, int nSize); bool Send(char *s); void Disconnect(); bool Connect(int nCommPort = COM1, long lBaudRate=9600, int nByteSize=8, int nStopBits = 0, int nParity = 2); bool Connect(CString csCommPort = "COM1", long lBaudRate=9600, int nByteSize=8, double dStopBits = 1.0, CString csParity = "None"); int GetCommPort() const { return m_nCommPort; } long GetBaudRate() /*const*/ { return m_lBaudRate; } int GetByteSize() const { return m_nByteSize; } int GetParity() const { return m_nParity; } int GetStopBits() const { return m_nStopBits; } bool IsConnected() const { return m_bConnected;} bool m_bTraceData; protected: CString GetReceiveData(); //char m_cData[4096]; char m_cReceiveData[4096]; char m_cMaintReceiveData[4096]; //static BOOL m_bDataComplete; //static int m_nBufferPtr; BOOL m_bDataComplete; int m_nBufferPtr; // Attributes private: CSerialPort *m_pComm; int m_nCommPort; long m_lBaudRate; int m_nByteSize; int m_nParity; int m_nStopBits; bool m_bConnected; static DWORD WINAPI CommThread(void *pvData); }; #endif // !defined(AFX_SCANNER_H__98052617_4EA4_11D7_A89C_005004C029CA__INCLUDED_)