-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceIo.h
More file actions
81 lines (70 loc) · 2.09 KB
/
DeviceIo.h
File metadata and controls
81 lines (70 loc) · 2.09 KB
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
#ifndef __DEVICE_IO_CLASS__
#define __DEVICE_IO_CLASS__
#include "Queue.h"
class CDeviceIo
{
#define MAX_READ_BUFFER_SIZE 0x400
#define MAX_WRITE_BUFFER_SIZE 0x400
#define CODE_RECV_FROM_DEVICE 0x0000
#define CODE_RECV_FROM_NETWORK 0x0001
#define CODE_THREAD_EXIT 0x0002
#define THREAD_ID_SERIAL 0x0001
#define THREAD_ID_PIPE 0x0002
#define THREAD_ID_USBBULK 0x0003
#define THREAD_ID_TELNET 0x0004
#define THREAD_ID_SERVER 0x0005
#define THREAD_ID_LISTEN 0x0006
#define THREAD_ID_CONNECT 0x0007
#define CODE_CONNECT_FAIL 0x00FF
protected :
CWnd *m_pWnd;
CString m_csName;
HANDLE m_hDevice;
BOOL m_bWriteReady;
CQueue m_QueueRx;
CQueue m_QueueTx;
HANDLE m_hEventRead;
HANDLE m_hEventWrite;
HANDLE m_hEventExit;
CWinThread *m_pThead;
public :
typedef struct {
HWND hWnd;
HANDLE hDevice;
HANDLE hEventQuit;
HANDLE hEventWrite;
BOOL *pWriteReady;
CQueue *pQueueRx;
CQueue *pQueueTx;
VOID *pContext;
} THREAD_PARAM;
typedef enum {
EnumTypeSerialPort = 1,
EnumTypeNamedPipe,
EnumTypeUsbBulk,
EnumTypeTelnet,
} DEVTYPE;
DEVTYPE m_Type;
CDeviceIo ( void )
{
m_hDevice = INVALID_HANDLE_VALUE;
m_hEventRead = INVALID_HANDLE_VALUE;
m_hEventWrite = INVALID_HANDLE_VALUE;
m_hEventExit = INVALID_HANDLE_VALUE;
m_bWriteReady = TRUE;
m_pWnd = NULL;
m_pThead = NULL;
};
~CDeviceIo ( void )
{
};
// Public operations
virtual BOOL IoOpen ( CWnd *pWnd, TCHAR *pCfgStr) = 0;
virtual int IoWrite ( BYTE *Buffer , int nNumberOfBytesToWrite ) = 0;
virtual int IoRead ( BYTE *Buffer , int nNumberOfBytesToRead ) = 0;
virtual void IoClose ( void ) = 0;
virtual void IoReset ( void ) = 0;
virtual BOOL IoIsValid ( void ) = 0;
CString& IoGetName ( void ) {return m_csName;}
};
#endif