forked from eltima-software/RS232-Data-Logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedirectPort.h
81 lines (65 loc) · 1.58 KB
/
RedirectPort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "commport.h"
//jaca start
#include <iostream>
#include <stdlib.h>
#include <string>
#include "atlbase.h"
#include "atlstr.h"
#include "comutil.h"
using namespace std;
//jaca end
#define WM_USER_UPDATE_WND WM_USER + 5587
#define WM_USER_CHANGE_STATUS WM_USER + 5588
const TCHAR PREFERENCES_KEY[] = _T("Software\\Eltima\\Port2File");
// status codes
enum
{
SC_NO_ERROR = 0,
SC_OPEN_SUCCESS = 1,
SC_OPEN_FILE_ERROR = 2,
SC_OPEN_PORT_ERROR = 3,
SC_FILE_EXCEPTION = 10
};
class CRedirectPort :
public CCommPort
{
private:
CWnd* m_pParentWnd;
CFile m_File;
CFile m_File2;
void OnRxChar( DWORD dwCount );
size_t m_stBytesInFile;
size_t m_stBytesInFile2;
size_t m_stBytesWritten;
CString m_sPortName;
int m_nIndex;
BYTE strTel[4096];
public:
bool m_bIsActive;
BOOL m_bLogStarted;
BOOL m_bAppend;
CString m_sLogFile;
CString m_sLogFileBase;
CString m_sLogFile2;
CString m_sStatusMessage;
DWORD m_dwBaudRate;
int m_iIndexDataBits;
int m_iIndexParity;
int m_iIndexStopBits;
int m_iIndexFlowCtrl;
int m_iStatus;
private:
public:
BOOL Open();
BOOL Open ( DWORD dwBaudrate, BYTE bDataBits, BYTE bParity, BYTE bStopBits, BYTE bFC );
void Close();
BOOL InitModem();
size_t GetFileTotalBytes() const { return m_stBytesInFile; }
size_t GetFileTotal2Bytes() const { return m_stBytesInFile2; }
size_t GetFileWrittenBytes() const { return m_stBytesWritten; }
BOOL SaveSettings ();
BOOL LoadSettings ();
CRedirectPort(const CString& sPortName, bool IsActive, CWnd* pWnd, int nIndex );
virtual ~CRedirectPort(void);
};