mirror of
https://gitea.tendokyu.moe/TeamTofuShop/taitools.git
synced 2026-09-22 22:28:06 +03:00
properly implement jvs reader to read blue nesica serials
This commit is contained in:
+80
-27
@@ -18,8 +18,12 @@
|
||||
|
||||
// JVS card reader, A/B/C vairants
|
||||
|
||||
static const uint8_t k92x0249_ident[] = "TAITO CORP.;RFID CTRL P.C.B.;Ver1.00;";
|
||||
static const uint8_t k92x0249_ident[] = "TAITO CORP.;RFID CTRL P.C.B.;Ver1.11;";
|
||||
static const uint8_t card_uid[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00 };
|
||||
static const uint8_t card_id[] = {
|
||||
0x01, 0x2E, 0x4C, 0xE4, 0x00, 0x01, 0x00, 0x01,
|
||||
0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static struct k92x0249_config cfg;
|
||||
|
||||
static uint8_t k92x0249_features[] = {
|
||||
@@ -61,6 +65,8 @@ static HRESULT k92x0249_cmd_get_comm_version(struct k92x0249 *k92x0249, struct c
|
||||
static HRESULT k92x0249_cmd_get_features(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_write_gpio1(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_taito_nesica_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_taito_aic_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
|
||||
void k92x0249_init(
|
||||
struct k92x0249 *k92x0249,
|
||||
@@ -146,11 +152,17 @@ static HRESULT k92x0249_cmd(
|
||||
case JVS_CMD_GET_FEATURES:
|
||||
return k92x0249_cmd_get_features(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_WRITE_GPIO1:
|
||||
case JVS_CMD_WRITE_GPIO1: // Set reader state
|
||||
return k92x0249_cmd_write_gpio1(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_READ_MISC_SWITCHES: // used to check reader state?
|
||||
case JVS_CMD_READ_MISC_SWITCHES: // Read for old (1.00/0.02) fw
|
||||
return k92x0249_cmd_read_misc_switches(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_TAITO_NESICA_READ: // Check reader state for new fw
|
||||
return k92x0249_cmd_taito_nesica_read(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_TAITO_AIC_READ: // Check reader state for new fw
|
||||
return k92x0249_cmd_taito_aic_read(k92x0249, req, resp);
|
||||
|
||||
default:
|
||||
dprintf("K92X0249: Node %02x: Unhandled command byte @ %02X %02x\n",
|
||||
@@ -344,30 +356,17 @@ static HRESULT k92x0249_cmd_write_gpio1(struct k92x0249 *k92x0249, struct const_
|
||||
}
|
||||
|
||||
if (k92x0249->state != io_state[0]) {
|
||||
dprintf("K92X0249: Update state %02X\n", io_state[0]);
|
||||
dprintf("K92X0249: Update state %02X\n", io_state[0], num_io);
|
||||
}
|
||||
|
||||
k92x0249->state = io_state[0];
|
||||
hr = iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write(resp_buf, card_uid, 8);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
return iobuf_write(resp_buf, cfg.serial, 16);
|
||||
return iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
}
|
||||
|
||||
static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf)
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t num_switches;
|
||||
uint8_t switches[255];
|
||||
uint8_t arg;
|
||||
HRESULT hr;
|
||||
|
||||
hr = iobuf_read_8(req_buf, &cmd);
|
||||
@@ -376,18 +375,12 @@ static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_read_8(req_buf, &num_switches);
|
||||
hr = iobuf_read_8(req_buf, &arg);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_read(req_buf, switches, num_switches);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
|
||||
if (FAILED(hr)) {
|
||||
@@ -396,8 +389,68 @@ static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct
|
||||
|
||||
if (k92x0249->state == POLL_AICC && (GetAsyncKeyState(cfg.read_button) & 0x8000)) {
|
||||
dprintf("K92X0249: Detect Card\n");
|
||||
return iobuf_write_8(resp_buf, BLUE_NESICA | CARD_TOUCHED | SUCCESS);
|
||||
return iobuf_write_8(resp_buf, CARD_READ_OK);
|
||||
}
|
||||
|
||||
return iobuf_write_8(resp_buf, NO_CARD); /* Write status byte */
|
||||
}
|
||||
|
||||
static HRESULT k92x0249_cmd_taito_nesica_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf)
|
||||
{
|
||||
uint8_t cmd;
|
||||
HRESULT hr = iobuf_read_8(req_buf, &cmd);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write(resp_buf, card_uid, 8); // AICC: Unused, should be IDm
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
return iobuf_write(resp_buf, cfg.serial, 16); // AICC: SPAD0
|
||||
}
|
||||
|
||||
static HRESULT k92x0249_cmd_taito_aic_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf)
|
||||
{
|
||||
uint8_t cmd;
|
||||
HRESULT hr = iobuf_read_8(req_buf, &cmd);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write(resp_buf, card_id, 16); // ID
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write(resp_buf, "\x00\x01", 2); // CKV
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = iobuf_write(resp_buf, "\x02\x00\x00", 3); // WCNT
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
return iobuf_write(resp_buf, "12345678", 8); // MAC_A?
|
||||
}
|
||||
|
||||
+8
-7
@@ -25,16 +25,17 @@ enum k92x0249_state {
|
||||
POLL_AICC = 0xC2, // any AmusementIC card
|
||||
};
|
||||
|
||||
//
|
||||
enum k92x0249_card_status {
|
||||
NO_CARD = 0x00,
|
||||
BLUE_NESICA = 0x01,
|
||||
UNK01 = 0x01, // trumps AICC
|
||||
AICC = 0x02,
|
||||
UNK04 = 0x04,
|
||||
CARD_TOUCHED = 0x08,
|
||||
SUCCESS = 0x10,
|
||||
ERR = 0x20,
|
||||
UNK40 = 0x40,
|
||||
UNK80 = 0x80,
|
||||
UNK04 = 0x04, // trumps AICC
|
||||
UNK08 = 0x08, // No effect?
|
||||
CARD_READ_OK = 0x10, // Always triggers blue nesica read except when AICC is set and UNK01 and UNK04 are not set
|
||||
CARD_READ_NG = 0x20, // If CARD_READ_OK is not set, triggers read error
|
||||
UNK40 = 0x40, // No effect?
|
||||
UNK80 = 0x80, // No effect?
|
||||
};
|
||||
|
||||
void k92x0249_init(
|
||||
|
||||
Reference in New Issue
Block a user