Commit f0f0131f8c5d4118a4354e57ff3c696dd8be9d34
1 parent
0344002f
feat<etadeclient>:替换硬件接口
替换原有硬件接口,采用新接口,支持so库的版本。
Showing
5 changed files
with
104 additions
and
19 deletions
etrade_card_client/Config/application_config.json
etrade_card_client/ETradeClient.vcxproj
... | ... | @@ -45,6 +45,8 @@ |
45 | 45 | <PropertyGroup Label="UserMacros" /> |
46 | 46 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
47 | 47 | <LinkIncremental>true</LinkIncremental> |
48 | + <LibraryPath>$(ProjectDir)\ExLib\hardware\id_card_reader;$(ProjectDir)\ExLib\hardware\dili_card_device;D:\GitProject\etradeclient\etrade_card_client;$(LibraryPath)</LibraryPath> | |
49 | + <LibraryWPath>$(LibraryWPath)</LibraryWPath> | |
48 | 50 | </PropertyGroup> |
49 | 51 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
50 | 52 | <LinkIncremental>false</LinkIncremental> | ... | ... |
etrade_card_client/ETradeClient/hardware/DLCardManager.h
1 | +// 作者:刘野 | |
2 | +// 卡片硬件操作库导出接口。 | |
3 | +// 包含dll导出接口和so库导出接口 | |
4 | + | |
1 | 5 | #ifndef DL_CARD_MANAGER_H |
2 | 6 | #define DL_CARD_MANAGER_H |
3 | 7 | |
4 | 8 | #define DL_DLL_API extern "C" __declspec(dllexport) |
5 | 9 | |
6 | -DL_DLL_API int __stdcall ConnectDLDevice(); | |
7 | -DL_DLL_API int __stdcall FindDLCard(); | |
8 | -DL_DLL_API int __stdcall AuthenticationDLKey(unsigned char* pKey); | |
9 | -DL_DLL_API int __stdcall ReadDLCardData(unsigned char* pDirID, unsigned char cFileID, short u16Offset, int u32DateLen, unsigned char* pData, unsigned char* pKey = 0); | |
10 | -DL_DLL_API int __stdcall WriteDLCardData(unsigned char* pDirID, unsigned char cFileID, unsigned char cOffset, unsigned short cDateLen, unsigned char* pData, unsigned char* pKey); | |
11 | -DL_DLL_API int __stdcall InstallDLKey(unsigned char* pDirID, unsigned char cKeyID, unsigned char* pNewKey, int iKeyType, unsigned char* pMainKey); | |
12 | -DL_DLL_API int __stdcall DisconnectDLDevice(); | |
13 | 10 | |
14 | -#endif | |
15 | 11 | \ No newline at end of file |
12 | +/* 连接读卡器 */ | |
13 | +DL_DLL_API int __stdcall DLCConnectDevice(); | |
14 | + | |
15 | +/* 关闭读卡器 */ | |
16 | +DL_DLL_API int __stdcall DLCDisconnectDevice(); | |
17 | + | |
18 | +/* 寻卡 */ | |
19 | +DL_DLL_API int __stdcall DLCFindCard(); | |
20 | + | |
21 | +/* | |
22 | + * 验证秘钥 | |
23 | + * 输入16字节秘钥key_。 | |
24 | + * 返回值返回结果 | |
25 | + * */ | |
26 | +DL_DLL_API int __stdcall DLCAuthenticationKey(const unsigned char* dir, const unsigned char key_id, const unsigned char* key); | |
27 | + | |
28 | +/* | |
29 | + * 读取数据 | |
30 | + * 输入dir2字节目录标识、file_id1字节文件标识、read_offset2字节、 | |
31 | + * data_len2字节、read_key16字节读秘钥(没有置空)和read_data(长度依据读取长度而定)。 | |
32 | + * 输出结果填入read_data。 | |
33 | + * */ | |
34 | +DL_DLL_API int __stdcall DLCReadCardData(const unsigned char* dir, const unsigned char file_id, const unsigned int data_offset, const unsigned int data_len, const unsigned char* read_key, unsigned char* read_data); | |
35 | + | |
36 | +/* | |
37 | +* 写入数据 | |
38 | +* 输入dir2字节目录标识、file_id2字节文件标识、read_offset2字节、 | |
39 | +* data_len2字节、read_key16字节读秘钥(没有置空)和read_data(长度依据读取长度而定)。 | |
40 | +* 输出结果填入read_data。 | |
41 | +* */ | |
42 | +DL_DLL_API int __stdcall DLCWriteCardData(const unsigned char* dir, const unsigned char file_id, const unsigned int data_offset, const unsigned int data_len, const unsigned char* write_key, const unsigned char* write_data); | |
43 | + | |
44 | +/* | |
45 | + * 安装/更新秘钥 | |
46 | + * 输入dir2字节目录标识、key_id1字节文件标识、key_type32位秘钥类型、 | |
47 | + * main_key16字节主控秘钥(没有置空)、new_key16字节新秘钥。 | |
48 | + **/ | |
49 | +DL_DLL_API int __stdcall DLCInstallKey(const unsigned char* dir, const unsigned char key_id, const int key_type, const unsigned char* main_key, const unsigned char* new_key); | |
50 | + | |
51 | +/* | |
52 | + * 建立文件 | |
53 | + * 输入parent_dir2字节父目录、parent_key2字节父目录主控秘钥、file_name2字节文件标识、 | |
54 | + * file_size2字节文件大小、safe_type4字节安全类型和file_type4字节文件类型 | |
55 | + **/ | |
56 | +DL_DLL_API int __stdcall DLCCreateFile(const unsigned char* parent_dir, const unsigned char* parent_key, const unsigned char* file_name, const unsigned char* file_size, const int file_type); | |
57 | + | |
58 | + | |
59 | +DL_DLL_API int __stdcall DLCSelectFile(const unsigned char* dir); | |
60 | + | |
61 | +//SO库API | |
62 | +// | |
63 | +/* | |
64 | + * 该函数用以获取8字节随机数 | |
65 | + * 输入5字节的无符号字符型数组指针,函数将更改数组内容,输出5字节指令。 | |
66 | + * 返回值返回错误码。 | |
67 | + */ | |
68 | +int __stdcall DLCSOGetRandom(unsigned char* get_randam_cmd); | |
69 | + | |
70 | +/* | |
71 | + * 该函数用于验证秘钥。 | |
72 | + * 输入key_id1字节秘钥标识、key16字节16进制秘钥值和random8字节16进制随机数,返回cmd13字节16进制指令。 | |
73 | + * 返回值返回结果。 | |
74 | + */ | |
75 | +int __stdcall DLCSOAuthenticationKey(const unsigned char key_id, const unsigned char* key, const unsigned char* random, unsigned char* cmd); | |
76 | + | |
77 | +/* | |
78 | + * 该函数用于读取数据。 | |
79 | + * 输入data_offfset数据初始偏移,data_offfset最大为ffff,data_len数据长度,data_len最大为ff,返回16进制cmd指令,cmd数组长度 = data_len + 5。 | |
80 | + * 读出的数据将存在data_中。 | |
81 | + * 返回值返回错误码。 | |
82 | + */ | |
83 | +int __stdcall DLCSOReadData(const unsigned int data_offfset, const unsigned int data_len, unsigned char* cmd); | |
84 | + | |
85 | +/* | |
86 | +* 该函数用于写入数据。 | |
87 | +* 输入write_key字节16进制读秘钥(没有置空)、random8字节16进制随机数(没有置空)、data_offfset2字节数据初始偏移、data_len2字节数据长度和data16进制数据,cmd数组长度 = data_len + 9。 | |
88 | +* 返回值返回错误码。 | |
89 | +*/ | |
90 | +int __stdcall DLCSOWriteData(const unsigned char* write_key, const unsigned char* random, const unsigned int data_offfset, const unsigned int data_len, const unsigned char* data, unsigned char* cmd); | |
91 | + | |
92 | + | |
93 | +/*该函数用于选择目录 | |
94 | + *输入dir两字节16进制目录标识,返回cmd7字节16进制指令 | |
95 | + **/ | |
96 | +int __stdcall DLCSOSelectDir(const unsigned char* dir, unsigned char* cmd); | |
97 | + | |
98 | +#endif //end DL_CARD_MANAGER_H | |
16 | 99 | \ No newline at end of file | ... | ... |
etrade_card_client/ETradeClient/hardware/dili_card_device.cpp
... | ... | @@ -113,7 +113,7 @@ namespace DILICard |
113 | 113 | { |
114 | 114 | bool bResult = true; |
115 | 115 | |
116 | - int iResult = ConnectDLDevice(); | |
116 | + int iResult = DLCConnectDevice(); | |
117 | 117 | if (0 != iResult) |
118 | 118 | { |
119 | 119 | bResult = false; |
... | ... | @@ -124,7 +124,7 @@ namespace DILICard |
124 | 124 | } |
125 | 125 | void RWDevice::Disconnect() const |
126 | 126 | { |
127 | - DisconnectDLDevice(); | |
127 | + DLCDisconnectDevice(); | |
128 | 128 | } |
129 | 129 | void RWDevice::Beep(uint32_t time) const |
130 | 130 | { |
... | ... | @@ -134,7 +134,7 @@ namespace DILICard |
134 | 134 | { |
135 | 135 | bool bResult = true; |
136 | 136 | |
137 | - int iResult = FindDLCard(); | |
137 | + int iResult = DLCFindCard(); | |
138 | 138 | if (0 != iResult) |
139 | 139 | { |
140 | 140 | bResult = false; |
... | ... | @@ -457,11 +457,11 @@ namespace DILICard |
457 | 457 | if (NULL != key_id) |
458 | 458 | { |
459 | 459 | memcpy(aucKey, key.c_str(), 32); |
460 | - iResult = ReadDLCardData(aucDir, file_id, offset, length, aucData, aucKey); | |
460 | + iResult = DLCReadCardData(aucDir, file_id, offset, length, aucData, aucKey); | |
461 | 461 | } |
462 | 462 | else |
463 | 463 | { |
464 | - iResult = ReadDLCardData(aucDir, file_id, offset, length, aucData); | |
464 | + iResult = DLCReadCardData(aucDir, file_id, offset, length, NULL, aucData); | |
465 | 465 | } |
466 | 466 | |
467 | 467 | |
... | ... | @@ -499,7 +499,7 @@ namespace DILICard |
499 | 499 | { |
500 | 500 | unsigned char aucDataBlock[DATA_MAX_LEN] = { 0 }; |
501 | 501 | memcpy(aucDataBlock, data.substr(iStartIndex, DATA_MAX_LEN).c_str(), DATA_MAX_LEN); |
502 | - iResult = WriteDLCardData(aucDir, file_id, iOffset, DATA_MAX_LEN, aucDataBlock, aucKey); | |
502 | + iResult = DLCWriteCardData(aucDir, file_id, iOffset, DATA_MAX_LEN, aucKey, aucDataBlock); | |
503 | 503 | if (0 != iResult) |
504 | 504 | { |
505 | 505 | err_msg << "Write data to file failed, FILE: " << file_id << ", ErrorCode: " << iResult; |
... | ... | @@ -514,7 +514,7 @@ namespace DILICard |
514 | 514 | { |
515 | 515 | unsigned char aucData[DATA_MAX_LEN] = { 0 }; |
516 | 516 | memcpy(aucData, data.substr(iStartIndex, iDataLength).c_str(), iDataLength); |
517 | - iResult = WriteDLCardData(aucDir, file_id, iOffset, iDataLength, aucData, aucKey); | |
517 | + iResult = DLCWriteCardData(aucDir, file_id, iOffset, iDataLength, aucKey, aucData); | |
518 | 518 | if (0 != iResult) |
519 | 519 | { |
520 | 520 | err_msg << "Write data to file failed, FILE: " << file_id << ", ErrorCode: " << iResult; |
... | ... | @@ -536,7 +536,7 @@ namespace DILICard |
536 | 536 | memcpy(aucDir, dir.c_str(), 4); |
537 | 537 | memcpy(aucMainKey, main_key.c_str(), 32); |
538 | 538 | memcpy(aucNewKey, install_key.c_str(), 32); |
539 | - int iResult = InstallDLKey(aucDir, key_id, aucNewKey, emKeyType, aucMainKey); | |
539 | + int iResult = DLCInstallKey(aucDir, key_id, emKeyType, aucMainKey, aucNewKey); | |
540 | 540 | if (0 != iResult) |
541 | 541 | { |
542 | 542 | err_msg << "Update key failed, key to be updated: " << install_key << ", ErrorCode: " << iResult; |
... | ... | @@ -549,7 +549,7 @@ namespace DILICard |
549 | 549 | bool bResult = true; |
550 | 550 | unsigned char aucKey[32] = { 0 }; |
551 | 551 | memcpy(aucKey, sKey.c_str(), 32); |
552 | - int iResult = AuthenticationDLKey(aucKey); | |
552 | + int iResult = DLCAuthenticationKey((const unsigned char*)"3f00", 0, aucKey); | |
553 | 553 | if (iResult) |
554 | 554 | { |
555 | 555 | bResult = false; | ... | ... |
etrade_card_client/ETradeClient/mfc_ui/ConfigDialog.cpp
... | ... | @@ -53,7 +53,7 @@ void CConfigDialog::DoDataExchange(CDataExchange* pDX) |
53 | 53 | DDV_MinMaxInt(pDX, m_pin_pad_pwd_len, kMinPwdLen, kMaxPwdLen); |
54 | 54 | |
55 | 55 | DDX_Text(pDX, IDC_EDIT_PIN_PAD_TIMEOUT, m_pin_pad_timeout); |
56 | - DDV_MinMaxInt(pDX, m_pin_pad_timeout, kMinTimeoutSeconds, kMaxTimeoutSeconds); | |
56 | + //DDV_MinMaxInt(pDX, m_pin_pad_timeout, kMinTimeoutSeconds, kMaxTimeoutSeconds); | |
57 | 57 | |
58 | 58 | DDX_Radio(pDX, IDC_RADIO_HUASHIDIANZI, m_id_reader_type); |
59 | 59 | } | ... | ... |