Bemanitools v5.26 release
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
exes += aciotest
|
||||
|
||||
libs_aciotest := \
|
||||
aciodrv \
|
||||
util \
|
||||
|
||||
src_aciotest := \
|
||||
icca.c \
|
||||
main.c \
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef ACIOTEST_HANDLER_H
|
||||
#define ACIOTEST_HANDLER_H
|
||||
|
||||
static const uint8_t aciotest_handler_max = 16;
|
||||
|
||||
/**
|
||||
* Handler interface for an ACIO device.
|
||||
*/
|
||||
struct aciotest_handler_node_handler
|
||||
{
|
||||
void* ctx;
|
||||
bool (*init)(uint8_t node_id, void** ctx);
|
||||
bool (*update)(uint8_t node_id, void* ctx);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "aciotest/icca.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "aciodrv/icca.h"
|
||||
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void** ctx)
|
||||
{
|
||||
*ctx = malloc(sizeof(uint32_t));
|
||||
*((uint32_t*) *ctx) = 0;
|
||||
|
||||
return aciodrv_icca_init(node_id);
|
||||
}
|
||||
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void* ctx)
|
||||
{
|
||||
if (*((uint32_t*) ctx) == 0) {
|
||||
*((uint32_t*) ctx) = 1;
|
||||
|
||||
/* eject cards that were left in the reader */
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct ac_io_icca_state state;
|
||||
|
||||
if (!aciodrv_icca_get_state(node_id, &state)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
printf(">>> ICCA %d:\n"
|
||||
"status_code: %d\n"
|
||||
"sensor_state: %d\n"
|
||||
"keypad_started: %d\n"
|
||||
"card_type: %d\n"
|
||||
"UUID: %02X%02X%02X%02X%02X%02X%02X%02X\n"
|
||||
"key_state: %04X\n"
|
||||
"key_events[0]: %02X\n"
|
||||
"key_events[1]: %02X\n",
|
||||
node_id, state.status_code, state.sensor_state, state.keypad_started,
|
||||
state.card_type,
|
||||
state.uid[0], state.uid[1], state.uid[2], state.uid[3],
|
||||
state.uid[4], state.uid[5], state.uid[6], state.uid[7],
|
||||
state.key_state, state.key_events[0], state.key_events[1]);
|
||||
|
||||
/* eject card with "empty" key */
|
||||
if (state.key_state & AC_IO_ICCA_KEYPAD_MASK_EMPTY) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_EJECT, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* allow new card to be inserted when slot is clear */
|
||||
if ( !(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
!(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_OPEN, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* lock the card when fully inserted */
|
||||
if ( (state.sensor_state & AC_IO_ICCA_SENSOR_MASK_BACK_ON) &&
|
||||
(state.sensor_state & AC_IO_ICCA_SENSOR_MASK_FRONT_ON)) {
|
||||
|
||||
if (!aciodrv_icca_set_state(node_id, AC_IO_ICCA_SLOT_STATE_CLOSE, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aciodrv_icca_read_card(node_id, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef ACIOTEST_ICCA_H
|
||||
#define ACIOTEST_ICCA_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool aciotest_icca_handler_init(uint8_t node_id, void** ctx);
|
||||
bool aciotest_icca_handler_update(uint8_t node_id, void* ctx);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "aciodrv/device.h"
|
||||
|
||||
#include "aciotest/handler.h"
|
||||
#include "aciotest/icca.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
static uint8_t aciotest_cnt = 0;
|
||||
|
||||
/**
|
||||
* Enumerate supported ACIO nodes based on their product id.
|
||||
*/
|
||||
static bool aciotest_assign_handler(char product[4],
|
||||
struct aciotest_handler_node_handler* handler)
|
||||
{
|
||||
if (!memcmp(product, "ICCA", 4)
|
||||
|| !memcmp(product, "ICCB", 4)
|
||||
|| !memcmp(product, "ICCC", 4)
|
||||
){
|
||||
handler->init = aciotest_icca_handler_init;
|
||||
handler->update = aciotest_icca_handler_update;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool to test real ACIO hardware.
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
printf(
|
||||
"aciotest, build "__DATE__ " " __TIME__ "\n"
|
||||
"Usage: %s <com port str> <baud rate>\n"
|
||||
"Example for two slotted readers: %s COM1 57600\n",
|
||||
argv[0], argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_to_writer(log_writer_stdout, NULL);
|
||||
|
||||
if (!aciodrv_device_open(argv[1], atoi(argv[2]))) {
|
||||
printf("Opening acio device failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Opening acio device successful\n");
|
||||
|
||||
uint8_t node_count = aciodrv_device_get_node_count();
|
||||
printf("Enumerated %d nodes\n", node_count);
|
||||
|
||||
struct aciotest_handler_node_handler handler[aciotest_handler_max];
|
||||
memset(&handler, 0,
|
||||
sizeof(struct aciotest_handler_node_handler) * aciotest_handler_max);
|
||||
|
||||
for (uint8_t i = 0; i < node_count; i++) {
|
||||
char product[4];
|
||||
aciodrv_device_get_node_product_ident(i, product);
|
||||
printf("> %d: %c%c%c%c\n", i + 1,
|
||||
product[0], product[1], product[2], product[3]);
|
||||
|
||||
if (!aciotest_assign_handler(product, &handler[i])) {
|
||||
printf("ERROR: Unsupported acio node product %c%c%c%c on node %d\n",
|
||||
product[0], product[1], product[2], product[3], i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||
|
||||
if (handler[i].init != NULL) {
|
||||
|
||||
if (!handler[i].init(i, &handler[i].ctx)) {
|
||||
printf("ERROR: Initializing node %d failed\n", i);
|
||||
handler[i].update = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf(">>> Initializing done, press enter to start update loop <<<\n");
|
||||
|
||||
if (getchar() != '\n') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
system("cls");
|
||||
printf("%d\n", aciotest_cnt++);
|
||||
|
||||
for (uint8_t i = 0; i < aciotest_handler_max; i++) {
|
||||
|
||||
if (handler[i].update != NULL) {
|
||||
|
||||
if (!handler[i].update(i, handler[i].ctx)) {
|
||||
printf("ERROR: Updating node %d, removed from loop\n", i);
|
||||
handler[i].update = NULL;
|
||||
Sleep(5000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* avoid cpu banging */
|
||||
Sleep(20);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user