00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SERIALC_H
00027 #define SERIALC_H
00028
00029 #ifdef _WIN32
00030 #ifdef _AFXDLL
00031 #include <afx.h>
00032 #else
00033 #include <windows.h>
00034 #endif
00035 #endif
00036
00037 #define COM1 1
00038 #define COM2 2
00039
00040 #include "../oawconfig.h"
00041
00042 OAW_BEGIN_NAMESPACE
00043
00044 class SerialC;
00045
00046 class OAW_DLLMAPPING ComStateC{
00047 friend class SerialC;
00048 public:
00049 ComStateC();
00050 public:
00051 DWORD m_baudRate;
00052 BYTE m_byteSize;
00053 BYTE m_parity;
00054 BYTE m_stopBits;
00055 };
00056
00057
00058 class OAW_DLLMAPPING SerialC{
00059 public:
00060 SerialC(short com = COM2);
00061 virtual ~SerialC();
00062 long Read(char*, long);
00063 long Write(const char*, long);
00064 void Get(char*);
00065 void Put(char);
00066 short SetState(ComStateC);
00067 short SetPort(short);
00068 short Open();
00069 short Close();
00070 protected:
00071
00072 char m_com[10];
00073
00074 HANDLE m_fd;
00075
00076 ComStateC m_comState;
00077 DCB m_dcb;
00078 DCB m_oldDcb;
00079 COMMTIMEOUTS m_timeout;
00080 COMMTIMEOUTS m_oldTimeout;
00081 short m_isOpen;
00082 };
00083
00084 OAW_END_NAMESPACE
00085
00086 #endif
00087
00088
00089
00090
00091