forked from DragonMinded/ACIOLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACIO.h
105 lines (93 loc) · 2.23 KB
/
ACIO.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#pragma once
#include <tchar.h>
#include <windows.h>
/* Length of the card ID in bytes */
#define CARD_LENGTH 8
typedef enum
{
STATE_FRONT_SENSOR,
STATE_INSERTED,
STATE_READ,
STATE_REMOVED,
STATE_UNKNOWN,
} card_state_t;
typedef enum
{
STATE_NOT_READY,
STATE_GET_READY,
STATE_READY,
STATE_EJECT,
} reader_state_t;
typedef enum
{
KEY_NONE,
KEY_1,
KEY_2,
KEY_3,
KEY_4,
KEY_5,
KEY_6,
KEY_7,
KEY_8,
KEY_9,
KEY_0,
KEY_00,
KEY_BLANK,
} reader_keypress_t;
typedef enum
{
TYPE_UNKNOWN,
TYPE_READER,
TYPE_DISPENSER,
TYPE_LEDBOARD,
TYPE_IOBOARD,
} reader_type_t;
typedef struct
{
void *acio;
const _TCHAR *port;
} thread_context_t;
class ACIO
{
public:
ACIO(void);
~ACIO(void);
unsigned int getCount() { return readerCount; }
reader_keypress_t getPressedKey(int reader);
void requestCardInsert(int reader);
void requestCardEject(int reader);
bool getCardInserted(int reader);
void getCardID(int reader, unsigned char *cardId);
private:
unsigned int readerCount;
HANDLE serial;
unsigned int *old_keypresses;
unsigned char cardId[CARD_LENGTH];
card_state_t state;
HANDLE openSerial( const _TCHAR *arg, int baud );
const unsigned char * const getPacketData(
unsigned int *readerId,
unsigned int *command,
unsigned int *len,
unsigned int *checksum,
const unsigned char * const packet,
unsigned int length
);
unsigned char calcPacketChecksum( const unsigned char * const data );
int probeReader( HANDLE serial );
unsigned int getReaderCount( HANDLE serial );
void initReader( HANDLE serial, unsigned int id, int whichInit );
const char * const getReaderVersion( HANDLE serial, unsigned int id );
reader_type_t getReaderType( HANDLE serial, unsigned int id );
void getReaderState( HANDLE serial, unsigned int id, card_state_t *state, unsigned int *keypresses, unsigned char *cardId );
void setReaderState( HANDLE serial, unsigned int id, reader_state_t state );
void requestCardId( HANDLE serial, unsigned int id );
void InitReaders();
void InitReader(const _TCHAR *comport);
static DWORD initThread(LPVOID* param)
{
thread_context_t *tc = (thread_context_t *)param;
((ACIO *)tc->acio)->InitReader(tc->port);
return 0;
};
};