Демонстрирует поиск считывателей.
#include <iomanip>
#include <iostream>
#include "../ilr_cpp_helpers.h"
#define ILR_LOG_FILE
using namespace ilr;
#ifdef ILR_LOG
const char kLogLevelChars[] = {'-', 'E', 'W', 'I', 'D'};
const char kLogFileName[] = "ilreaders.log";
void LogCallback(
ilr_log_level level,
const char* pContext,
const char* pMessage,
void*) {
#ifdef ILR_LOG_FILE
std::ofstream file(kLogFileName, std::ios_base::out | std::ios_base::app);
auto& out = file;
#else
auto& out = std::cout;
#endif
auto t = std::time(nullptr);
auto tmb = std::localtime(&t);
out << std::put_time(tmb, "%d-%m-%Y %H:%M:%S") << " [" << kLogLevelChars[level] << ' '
<< pContext << "] " << pMessage << std::endl;
}
#endif
int main() {
std::cout << "Версия SDK: " << SdkVersionToStr(CILR::GetVersion()) << std::endl;
try {
#ifdef ILR_LOG
#ifdef ILR_LOG_FILE
std::ofstream file(kLogFileName, std::ios_base::out | std::ios_base::trunc);
file.close();
#endif
CILR::SetLogCallback(LogCallback);
#endif
CILR oILR;
CReaderSearch oSearch(oILR.GetSearch());
#if 0
oSearch.GetOptions(rOptions);
oSearch.SetOptions(rOptions);
const uint16_t aListenPorts[] = {25000};
oSearch.SetListenPorts(aListenPorts, std::size(aListenPorts));
#endif
std::cout << "Поиск считывателей..." << std::endl;
oSearch.Scan();
auto nCount = oSearch.GetReaderCount();
if (nCount != 0) {
std::cout << "Найдено " << nCount << ':' << std::endl;
for (size_t i = 0; i < nCount; i++) {
oSearch.GetReaderInfo(i, rInfo);
std::stringstream ss;
ss << kReaderModelNames[rInfo.
nModel];
ss <<
" с/н:" << rInfo.
nSn;
ss <<
" прошивка:" << ReaderVersionToStr(rInfo.
nFwVersion);
<< "]: " << ss.str() << std::endl;
}
}
else
std::cout << "Считыватели не найдены" << std::endl;
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
@ ILR_READER_SERVER
Definition: ilreaders.h:447
@ ILR_READER_CCID
Definition: ilreaders.h:454
@ ILR_READER_ILUSB
Definition: ilreaders.h:440
@ ILR_READER_CLIENT
Definition: ilreaders.h:449
Заголовочный файл API SDK Readers.
ilr_log_level
Уровень лога.
Definition: ilreaders.h:306
@ ILR_LOG_LEVEL_DEBUG
Отладочные сообщения.
Definition: ilreaders.h:336
@ ILR_READER_MODEL_UNKNOWN
Definition: ilreaders.h:200
Информация о считывателе.
Definition: ilreaders.h:282
ilr_reader_model nModel
Definition: ilreaders.h:291
uint32_t nFwVersion
Definition: ilreaders.h:297
const char * pszConnect
Definition: ilreaders.h:289
const char * pszPortName
Definition: ilreaders.h:286
int64_t nFwBuildDate
Definition: ilreaders.h:300
int nSn
Definition: ilreaders.h:293
Настройки поиска считывателей.
Definition: ilreaders.h:461
uint32_t nReaderTypes
Definition: ilreaders.h:466