예제 #1
0
int32_t cardreader_do_checkhealth(struct s_reader * reader)
{
	struct s_client *cl = reader->client;
	if (reader_card_inserted(reader)) {
		if (reader->card_status == NO_CARD || reader->card_status == UNKNOWN) {
			rdr_log(reader, "card detected");
			led_status_card_detected();
			reader->card_status = CARD_NEED_INIT;
			add_job(cl, ACTION_READER_RESET, NULL, 0);
		}
	} else {
		rdr_debug_mask(reader, D_READER, "%s: !reader_card_inserted", __func__);
		if (reader->card_status == CARD_INSERTED || reader->card_status == CARD_NEED_INIT) {
			rdr_log(reader, "card ejected");
			reader_nullcard(reader);
			NULLFREE(reader->csystem_data);
			if (cl) {
				cl->lastemm = 0;
				cl->lastecm = 0;
			}
			led_status_card_ejected();
		}
		reader->card_status = NO_CARD;
	}
	rdr_debug_mask(reader, D_READER, "%s: reader->card_status = %d, ret = %d", __func__,
		reader->card_status, reader->card_status == CARD_INSERTED);
	return reader->card_status == CARD_INSERTED;
}
예제 #2
0
int32_t reader_checkhealth(struct s_reader * reader)
{
	struct s_client *cl = reader->client;
	if (reader_card_inserted(reader)) {
		if (reader->card_status == NO_CARD || reader->card_status == UNKNOWN) {
			rdr_log(reader, "card detected");
			led_status_card_detected();
			reader->card_status = CARD_NEED_INIT;
			//reader_reset(reader);
			add_job(cl, ACTION_READER_RESET, NULL, 0);
		}
	} else {
		if (reader->card_status == CARD_INSERTED || reader->card_status == CARD_NEED_INIT) {
			rdr_log(reader, "card ejected");
			reader_nullcard(reader);
			if (cl) {
				cl->lastemm = 0;
				cl->lastecm = 0;
			}
			led_status_card_ejected();
		}
		reader->card_status = NO_CARD;
	}
	return reader->card_status == CARD_INSERTED;
}