Compare commits

...
Author SHA1 Message Date
Benjamin Berg 3a3d70f0bc egis_etu905: move commands into read-only memory
There is no need for them to be writable and with the previous commit
this change will also not result in any compiler warnings. Simply change
all of the static definitions to be static const.

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
2026-06-28 12:31:23 +02:00
Benjamin Berg 44704a9b1e egis_etu905: use const buffer for egis_etu905_exec_cmd command
The function only uses the passed command as a const buffer and makes a
copy immediately. As such, there is also no need for a destroy callback
as the caller can simply clean up afterwards.

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
2026-06-28 12:25:34 +02:00
Benjamin Berg 4ea0726f45 fixup! egis_etu905: support template update after identify/verify
Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
2026-06-28 12:25:28 +02:00
Jason HuangandBenjamin Berg d643231546 egis_etu905: support template update after identify/verify
Add IDENTIFY_SEND_CANCEL_RESULT state to send cancel command
after identify/verify completes, triggering firmware template update.
Implement cancel() callback for enroll and identify/verify cancellation.
Updated umockdev test data to cover the new flow.
2026-06-28 12:12:11 +02:00
5 changed files with 189 additions and 129 deletions
+48 -32
View File
@@ -331,9 +331,8 @@ egis_etu905_get_check_bytes (FpiByteReader *reader)
static void
egis_etu905_exec_cmd (FpDevice *device,
guchar *cmd,
const guchar *cmd,
const gsize cmd_length,
GDestroyNotify cmd_destroy,
SynCmdMsgCallback callback)
{
g_auto(FpiByteWriter) writer = {0};
@@ -378,10 +377,6 @@ egis_etu905_exec_cmd (FpDevice *device,
fpi_byte_writer_set_pos (&writer, egis_etu905_write_prefix_len);
written &= fpi_byte_writer_put_uint16_be (&writer, check_value);
/* destroy cmd if requested */
if (cmd_destroy)
g_clear_pointer (&cmd, cmd_destroy);
g_assert (self->cmd_ssm == NULL);
self->cmd_ssm = fpi_ssm_new (device,
egis_etu905_cmd_run_state,
@@ -523,7 +518,7 @@ egis_etu905_list_run_state (FpiSsm *ssm,
switch (fpi_ssm_get_cur_state (ssm))
{
case LIST_GET_ENROLLED_IDS:
egis_etu905_exec_cmd (device, cmd_list, cmd_list_len, NULL,
egis_etu905_exec_cmd (device, cmd_list, cmd_list_len,
egis_etu905_list_fill_enrolled_ids_cb);
break;
@@ -743,7 +738,7 @@ egis_etu905_delete_run_state (FpiSsm *ssm,
{
case DELETE_GET_ENROLLED_IDS:
/* get enrolled_ids from device for use building delete payload below */
egis_etu905_exec_cmd (device, cmd_list, cmd_list_len, NULL,
egis_etu905_exec_cmd (device, cmd_list, cmd_list_len,
egis_etu905_list_fill_enrolled_ids_cb);
break;
@@ -758,8 +753,8 @@ egis_etu905_delete_run_state (FpiSsm *ssm,
if (!payload)
return;
egis_etu905_exec_cmd (device, g_steal_pointer (&payload), payload_length,
g_free, egis_etu905_delete_cb);
egis_etu905_exec_cmd (device, payload, payload_length,
egis_etu905_delete_cb);
break;
}
}
@@ -1084,17 +1079,16 @@ egis_etu905_enroll_run_state (FpiSsm *ssm,
{
case ENROLL_START:
egis_etu905_exec_cmd (device, cmd_enroll_starting, cmd_enroll_starting_len,
NULL, egis_etu905_enroll_begin_cb);
egis_etu905_enroll_begin_cb);
break;
case ENROLL_CAPTURE_SENSOR_RESET:
egis_etu905_exec_cmd (device, cmd_sensor_reset, cmd_sensor_reset_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
case ENROLL_CAPTURE_SENSOR_START_CAPTURE:
egis_etu905_exec_cmd (device, cmd_sensor_start_capture, cmd_sensor_start_capture_len,
NULL,
egis_etu905_task_ssm_next_state_cb);
break;
@@ -1104,17 +1098,17 @@ egis_etu905_enroll_run_state (FpiSsm *ssm,
case ENROLL_CAPTURE_READ_RESPONSE:
egis_etu905_exec_cmd (device, cmd_read_capture, cmd_read_capture_len,
NULL, egis_etu905_read_capture_cb);
egis_etu905_read_capture_cb);
break;
case ENROLL_DUPLICATE_CHECK:
egis_etu905_exec_cmd (device, cmd_duplicate_check, cmd_duplicate_check_len,
NULL, egis_etu905_enroll_duplicate_check_cb);
egis_etu905_enroll_duplicate_check_cb);
break;
case ENROLL_COMMIT_START:
egis_etu905_exec_cmd (device, cmd_commit_starting, cmd_commit_starting_len,
NULL, egis_etu905_commit_start_cb);
egis_etu905_commit_start_cb);
break;
case ENROLL_COMMIT:
@@ -1141,19 +1135,27 @@ egis_etu905_enroll_run_state (FpiSsm *ssm,
}
payload_length = fpi_byte_writer_get_size (&writer);
egis_etu905_exec_cmd (device, fpi_byte_writer_reset_and_get_data (&writer),
payload_length,
g_free, egis_etu905_task_ssm_next_state_cb);
payload = fpi_byte_writer_reset_and_get_data (&writer);
egis_etu905_exec_cmd (device, payload, payload_length,
egis_etu905_task_ssm_next_state_cb);
break;
case ENROLL_COMMIT_SENSOR_RESET:
egis_etu905_exec_cmd (device, cmd_sensor_reset, cmd_sensor_reset_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
case ENROLL_COMPLETE:
egis_etu905_enroll_status_report (device, enroll_print, ENROLL_STATUS_COMPLETE, NULL);
fpi_ssm_next_state (ssm);
/* Success, do *not* send cancel command at this point */
fpi_ssm_jump_to_state (ssm, ENROLL_STATES);
break;
/* Cleanup states follow */
case ENROLL_CANCEL:
egis_etu905_exec_cmd (device, cmd_enroll_discard, cmd_enroll_discard_len,
egis_etu905_task_ssm_next_state_cb);
break;
}
}
@@ -1170,7 +1172,9 @@ egis_etu905_enroll (FpDevice *device)
enroll_print->stage = 0;
g_assert (self->task_ssm == NULL);
self->task_ssm = fpi_ssm_new (device, egis_etu905_enroll_run_state, ENROLL_STATES);
self->task_ssm = fpi_ssm_new_full (device, egis_etu905_enroll_run_state,
ENROLL_STATES, ENROLL_CANCEL,
"enroll");
fpi_ssm_set_data (self->task_ssm, g_steal_pointer (&enroll_print), g_free);
fpi_ssm_start (self->task_ssm, egis_etu905_task_ssm_done);
}
@@ -1321,7 +1325,7 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
case IDENTIFY_GET_ENROLLED_IDS:
/* get enrolled_ids from device for use in check stages below */
egis_etu905_exec_cmd (device, cmd_list, cmd_list_len,
NULL, egis_etu905_list_fill_enrolled_ids_cb);
egis_etu905_list_fill_enrolled_ids_cb);
break;
case IDENTIFY_CHECK_ENROLLED_NUM:
@@ -1336,12 +1340,12 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
case IDENTIFY_SENSOR_RESET:
egis_etu905_exec_cmd (device, cmd_sensor_reset, cmd_sensor_reset_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
case IDENTIFY_SENSOR_IDENTIFY:
egis_etu905_exec_cmd (device, cmd_sensor_identify, cmd_sensor_identify_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
case IDENTIFY_WAIT_FINGER:
@@ -1350,18 +1354,23 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
case IDENTIFY_SENSOR_CHECK:
egis_etu905_exec_cmd (device, cmd_sensor_check, cmd_sensor_check_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
case IDENTIFY_CHECK:
payload = egis_etu905_get_check_cmd (device, &payload_length);
egis_etu905_exec_cmd (device, g_steal_pointer (&payload), payload_length,
g_free, egis_etu905_identify_check_cb);
egis_etu905_exec_cmd (device, payload, payload_length,
egis_etu905_identify_check_cb);
break;
case IDENTIFY_SEND_CANCEL_RESULT:
egis_etu905_exec_cmd (device, cmd_identify_cancel_result, cmd_identify_cancel_result_len,
egis_etu905_task_ssm_next_state_cb);
break;
case IDENTIFY_COMPLETE_SENSOR_RESET:
egis_etu905_exec_cmd (device, cmd_sensor_reset, cmd_sensor_reset_len,
NULL, egis_etu905_task_ssm_next_state_cb);
egis_etu905_task_ssm_next_state_cb);
break;
/*
@@ -1379,7 +1388,14 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
else
fpi_device_verify_complete (device, NULL);
fpi_ssm_mark_completed (ssm);
/* Success, do *not* send cancel command at this point */
fpi_ssm_jump_to_state (ssm, IDENTIFY_STATES);
break;
/* Cleanup states follow */
case IDENTIFY_CANCEL:
egis_etu905_exec_cmd (device, cmd_identify_cancel, cmd_identify_cancel_len,
egis_etu905_task_ssm_next_state_cb);
break;
}
}
@@ -1519,12 +1535,12 @@ egis_etu905_dev_init_handler (FpiSsm *ssm,
{
case DEV_GET_FW_VERSION:
egis_etu905_exec_cmd (device, cmd_fw_version, cmd_fw_version_len,
NULL, egis_etu905_fw_version_cb);
egis_etu905_fw_version_cb);
return;
case DEV_INIT_CONTROL:
egis_etu905_exec_cmd (device, cmd_init, cmd_init_len,
NULL, egis_etu905_cmd_init_cb);
egis_etu905_cmd_init_cb);
return;
default:
+74 -58
View File
@@ -65,68 +65,77 @@ typedef struct
/* standard prefixes for all read/writes */
static guchar egis_etu905_write_prefix[] = {'E', 'G', 'I', 'S', 0x00, 0x00, 0x00, 0x01};
static gsize egis_etu905_write_prefix_len = sizeof (egis_etu905_write_prefix) / sizeof (egis_etu905_write_prefix[0]);
static const guchar egis_etu905_write_prefix[] = {'E', 'G', 'I', 'S', 0x00, 0x00, 0x00, 0x01};
static const gsize egis_etu905_write_prefix_len = sizeof (egis_etu905_write_prefix) / sizeof (egis_etu905_write_prefix[0]);
static guchar egis_etu905_read_prefix[] = {'S', 'I', 'G', 'E', 0x00, 0x00, 0x00, 0x01};
static gsize egis_etu905_read_prefix_len = sizeof (egis_etu905_read_prefix) / sizeof (egis_etu905_read_prefix[0]);
static const guchar egis_etu905_read_prefix[] = {'S', 'I', 'G', 'E', 0x00, 0x00, 0x00, 0x01};
static const gsize egis_etu905_read_prefix_len = sizeof (egis_etu905_read_prefix) / sizeof (egis_etu905_read_prefix[0]);
/* hard-coded command payloads */
static guchar cmd_fw_version[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x0c};
static gsize cmd_fw_version_len = sizeof (cmd_fw_version) / sizeof (cmd_fw_version[0]);
static guchar rsp_fw_version_suffix[] = {0x90, 0x00};
static gsize rsp_fw_version_suffix_len = sizeof (rsp_fw_version_suffix) / sizeof (rsp_fw_version_suffix[0]);
static const guchar cmd_fw_version[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x0c};
static const gsize cmd_fw_version_len = sizeof (cmd_fw_version) / sizeof (cmd_fw_version[0]);
static const guchar rsp_fw_version_suffix[] = {0x90, 0x00};
static const gsize rsp_fw_version_suffix_len = sizeof (rsp_fw_version_suffix) / sizeof (rsp_fw_version_suffix[0]);
static guchar cmd_init[] = {0x00, 0x00, 0x00, 0x29, 0x50, 0x81, 0x80, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x45, 0x67, 0x69, 0x73,
0x46, 0x50, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x51, 0xc6, 0xbd, 0x71};
static gsize cmd_init_len = sizeof (cmd_init) / sizeof (cmd_init[0]);
static const guchar cmd_init[] = {0x00, 0x00, 0x00, 0x29, 0x50, 0x81, 0x80, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x45, 0x67, 0x69, 0x73,
0x46, 0x50, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x51, 0xc6, 0xbd, 0x71};
static const gsize cmd_init_len = sizeof (cmd_init) / sizeof (cmd_init[0]);
static guchar cmd_list[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x19, 0x04, 0x00, 0x00, 0x01, 0x40};
static gsize cmd_list_len = sizeof (cmd_list) / sizeof (cmd_list[0]);
static const guchar cmd_list[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x19, 0x04, 0x00, 0x00, 0x01, 0x40};
static const gsize cmd_list_len = sizeof (cmd_list) / sizeof (cmd_list[0]);
static guchar cmd_sensor_reset[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x1a, 0x00, 0x00};
static gsize cmd_sensor_reset_len = sizeof (cmd_sensor_reset) / sizeof (cmd_sensor_reset[0]);
static const guchar cmd_sensor_reset[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x1a, 0x00, 0x00};
static const gsize cmd_sensor_reset_len = sizeof (cmd_sensor_reset) / sizeof (cmd_sensor_reset[0]);
static guchar cmd_sensor_check[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x17, 0x02, 0x00};
static gsize cmd_sensor_check_len = sizeof (cmd_sensor_check) / sizeof (cmd_sensor_check[0]);
static const guchar cmd_sensor_check[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x17, 0x02, 0x00};
static const gsize cmd_sensor_check_len = sizeof (cmd_sensor_check) / sizeof (cmd_sensor_check[0]);
static guchar cmd_sensor_identify[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x17, 0x01, 0x01};
static gsize cmd_sensor_identify_len = sizeof (cmd_sensor_identify) / sizeof (cmd_sensor_identify[0]);
static const guchar cmd_sensor_identify[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x17, 0x01, 0x01};
static const gsize cmd_sensor_identify_len = sizeof (cmd_sensor_identify) / sizeof (cmd_sensor_identify[0]);
static guchar rsp_identify_match_suffix[] = {0x90, 0x00};
static gsize rsp_identify_match_suffix_len = sizeof (rsp_identify_match_suffix) / sizeof (rsp_identify_match_suffix[0]);
static const guchar rsp_identify_match_suffix[] = {0x90, 0x00};
static const gsize rsp_identify_match_suffix_len = sizeof (rsp_identify_match_suffix) / sizeof (rsp_identify_match_suffix[0]);
static guchar rsp_identify_notmatch_suffix[] = {0x90, 0x04};
static gsize rsp_identify_notmatch_suffix_len = sizeof (rsp_identify_notmatch_suffix) / sizeof (rsp_identify_notmatch_suffix[0]);
static const guchar rsp_identify_notmatch_suffix[] = {0x90, 0x04};
static const gsize rsp_identify_notmatch_suffix_len = sizeof (rsp_identify_notmatch_suffix) / sizeof (rsp_identify_notmatch_suffix[0]);
static guchar cmd_enroll_starting[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x01, 0x00, 0x00, 0x00, 0x20};
static gsize cmd_enroll_starting_len = sizeof (cmd_enroll_starting) / sizeof (cmd_enroll_starting[0]);
static const guchar cmd_enroll_starting[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x01, 0x00, 0x00, 0x00, 0x20};
static const gsize cmd_enroll_starting_len = sizeof (cmd_enroll_starting) / sizeof (cmd_enroll_starting[0]);
static guchar cmd_sensor_start_capture[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x16, 0x02, 0x01};
static gsize cmd_sensor_start_capture_len = sizeof (cmd_sensor_start_capture) / sizeof (cmd_sensor_start_capture[0]);
static const guchar cmd_sensor_start_capture[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x16, 0x02, 0x01};
static const gsize cmd_sensor_start_capture_len = sizeof (cmd_sensor_start_capture) / sizeof (cmd_sensor_start_capture[0]);
static guchar cmd_read_capture[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x02, 0x02, 0x00, 0x00, 0x02};
static gsize cmd_read_capture_len = sizeof (cmd_read_capture) / sizeof (cmd_read_capture[0]);
static const guchar cmd_read_capture[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x02, 0x02, 0x00, 0x00, 0x02};
static const gsize cmd_read_capture_len = sizeof (cmd_read_capture) / sizeof (cmd_read_capture[0]);
static guchar cmd_duplicate_check[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x16, 0x05, 0x00};
static gsize cmd_duplicate_check_len = sizeof (cmd_duplicate_check) / sizeof (cmd_duplicate_check[0]);
static const guchar cmd_duplicate_check[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x16, 0x05, 0x00};
static const gsize cmd_duplicate_check_len = sizeof (cmd_duplicate_check) / sizeof (cmd_duplicate_check[0]);
static guchar rsp_read_success_prefix[] = {0x00, 0x00, 0x00, 0x04};
static gsize rsp_read_success_prefix_len = sizeof (rsp_read_success_prefix) / sizeof (rsp_read_success_prefix[0]);
static guchar rsp_read_success_suffix[] = {0x90, 0x00};
static gsize rsp_read_success_suffix_len = sizeof (rsp_read_success_suffix) / sizeof (rsp_read_success_suffix[0]);
static guchar rsp_read_offcenter_prefix[] = {0x00, 0x00, 0x00, 0x04};
static gsize rsp_read_offcenter_prefix_len = sizeof (rsp_read_offcenter_prefix) / sizeof (rsp_read_offcenter_prefix[0]);
static guchar rsp_read_offcenter_suffix[] = {0x64, 0x91};
static gsize rsp_read_offcenter_suffix_len = sizeof (rsp_read_offcenter_suffix) / sizeof (rsp_read_offcenter_suffix[0]);
static guchar rsp_read_dirty_prefix[] = {0x00, 0x00, 0x00, 0x02, 0x64};
static gsize rsp_read_dirty_prefix_len = sizeof (rsp_read_dirty_prefix) / sizeof (rsp_read_dirty_prefix[0]);
static const guchar rsp_read_success_prefix[] = {0x00, 0x00, 0x00, 0x04};
static const gsize rsp_read_success_prefix_len = sizeof (rsp_read_success_prefix) / sizeof (rsp_read_success_prefix[0]);
static const guchar rsp_read_success_suffix[] = {0x90, 0x00};
static const gsize rsp_read_success_suffix_len = sizeof (rsp_read_success_suffix) / sizeof (rsp_read_success_suffix[0]);
static const guchar rsp_read_offcenter_prefix[] = {0x00, 0x00, 0x00, 0x04};
static const gsize rsp_read_offcenter_prefix_len = sizeof (rsp_read_offcenter_prefix) / sizeof (rsp_read_offcenter_prefix[0]);
static const guchar rsp_read_offcenter_suffix[] = {0x64, 0x91};
static const gsize rsp_read_offcenter_suffix_len = sizeof (rsp_read_offcenter_suffix) / sizeof (rsp_read_offcenter_suffix[0]);
static const guchar rsp_read_dirty_prefix[] = {0x00, 0x00, 0x00, 0x02, 0x64};
static const gsize rsp_read_dirty_prefix_len = sizeof (rsp_read_dirty_prefix) / sizeof (rsp_read_dirty_prefix[0]);
static guchar cmd_commit_starting[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x05, 0x00, 0x00, 0x00, 0x20};
static gsize cmd_commit_starting_len = sizeof (cmd_commit_starting) / sizeof (cmd_commit_starting[0]);
static const guchar cmd_commit_starting[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x05, 0x00, 0x00, 0x00, 0x20};
static const gsize cmd_commit_starting_len = sizeof (cmd_commit_starting) / sizeof (cmd_commit_starting[0]);
static const guchar cmd_enroll_discard[] = {0x00, 0x00, 0x00, 0x07, 0x50, 0x16, 0x04, 0x00, 0x00, 0x00, 0x20};
static const gsize cmd_enroll_discard_len = sizeof (cmd_enroll_discard) / sizeof (cmd_enroll_discard[0]);
static const guchar cmd_identify_cancel[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x04, 0x01, 0x00};
static const gsize cmd_identify_cancel_len = sizeof (cmd_identify_cancel) / sizeof (cmd_identify_cancel[0]);
static const guchar cmd_identify_cancel_result[] = {0x00, 0x00, 0x00, 0x04, 0x50, 0x04, 0x02, 0x00};
static const gsize cmd_identify_cancel_result_len = sizeof (cmd_identify_cancel_result) / sizeof (cmd_identify_cancel_result[0]);
/* prefixes/suffixes and other things for dynamically created command payloads */
@@ -134,22 +143,22 @@ static gsize cmd_commit_starting_len = sizeof (cmd_commit_starting) / sizeof (cm
#define EGIS_ETU905_IDENTIFY_RESPONSE_PRINT_ID_OFFSET 46
#define EGIS_ETU905_CMD_CHECK_SEPARATOR_LENGTH 32
static guchar cmd_new_print_prefix_type2[] = {0x00, 0x00, 0x00, 0x50, 0x50, 0x16, 0x03, 0x00, 0x00, 0x00, 0x49};
static gsize cmd_new_print_prefix_type2_len = sizeof (cmd_new_print_prefix_type2) / sizeof (cmd_new_print_prefix_type2[0]);
static const guchar cmd_new_print_prefix_type2[] = {0x00, 0x00, 0x00, 0x50, 0x50, 0x16, 0x03, 0x00, 0x00, 0x00, 0x49};
static const gsize cmd_new_print_prefix_type2_len = sizeof (cmd_new_print_prefix_type2) / sizeof (cmd_new_print_prefix_type2[0]);
static guchar cmd_delete_prefix[] = {0x50, 0x18, 0x04, 0x00, 0x00};
static gsize cmd_delete_prefix_len = sizeof (cmd_delete_prefix) / sizeof (cmd_delete_prefix[0]);
static guchar rsp_delete_success_prefix[] = {0x00, 0x00, 0x00, 0x02, 0x90, 0x00};
static gsize rsp_delete_success_prefix_len = sizeof (rsp_delete_success_prefix) / sizeof (rsp_delete_success_prefix[0]);
static const guchar cmd_delete_prefix[] = {0x50, 0x18, 0x04, 0x00, 0x00};
static const gsize cmd_delete_prefix_len = sizeof (cmd_delete_prefix) / sizeof (cmd_delete_prefix[0]);
static const guchar rsp_delete_success_prefix[] = {0x00, 0x00, 0x00, 0x02, 0x90, 0x00};
static const gsize rsp_delete_success_prefix_len = sizeof (rsp_delete_success_prefix) / sizeof (rsp_delete_success_prefix[0]);
static guchar cmd_check_prefix_type1[] = {0x50, 0x17, 0x03, 0x00, 0x00};
static gsize cmd_check_prefix_type1_len = sizeof (cmd_check_prefix_type1) / sizeof (cmd_check_prefix_type1[0]);
static guchar cmd_check_prefix_type2[] = {0x50, 0x17, 0x03, 0x80, 0x00};
static gsize cmd_check_prefix_type2_len = sizeof (cmd_check_prefix_type2) / sizeof (cmd_check_prefix_type2[0]);
static guchar cmd_check_suffix[] = {0x00, 0x40};
static gsize cmd_check_suffix_len = sizeof (cmd_check_suffix) / sizeof (cmd_check_suffix[0]);
static guchar rsp_check_not_yet_enrolled_suffix[] = {0x90, 0x04};
static gsize rsp_check_not_yet_enrolled_suffix_len = sizeof (rsp_check_not_yet_enrolled_suffix) / sizeof (rsp_check_not_yet_enrolled_suffix[0]);
static const guchar cmd_check_prefix_type1[] = {0x50, 0x17, 0x03, 0x00, 0x00};
static const gsize cmd_check_prefix_type1_len = sizeof (cmd_check_prefix_type1) / sizeof (cmd_check_prefix_type1[0]);
static const guchar cmd_check_prefix_type2[] = {0x50, 0x17, 0x03, 0x80, 0x00};
static const gsize cmd_check_prefix_type2_len = sizeof (cmd_check_prefix_type2) / sizeof (cmd_check_prefix_type2[0]);
static const guchar cmd_check_suffix[] = {0x00, 0x40};
static const gsize cmd_check_suffix_len = sizeof (cmd_check_suffix) / sizeof (cmd_check_suffix[0]);
static const guchar rsp_check_not_yet_enrolled_suffix[] = {0x90, 0x04};
static const gsize rsp_check_not_yet_enrolled_suffix_len = sizeof (rsp_check_not_yet_enrolled_suffix) / sizeof (rsp_check_not_yet_enrolled_suffix[0]);
/* SSM task states and various status enums */
@@ -174,8 +183,12 @@ typedef enum {
IDENTIFY_WAIT_FINGER,
IDENTIFY_SENSOR_CHECK,
IDENTIFY_CHECK,
IDENTIFY_SEND_CANCEL_RESULT,
IDENTIFY_COMPLETE_SENSOR_RESET,
IDENTIFY_COMPLETE,
/* Cleanup states follow */
IDENTIFY_CANCEL,
IDENTIFY_STATES,
} IdentifyStates;
@@ -190,6 +203,9 @@ typedef enum {
ENROLL_COMMIT,
ENROLL_COMMIT_SENSOR_RESET,
ENROLL_COMPLETE,
/* Cleanup states follow */
ENROLL_CANCEL,
ENROLL_STATES,
} EnrollStates;
Binary file not shown.
+29 -1
View File
@@ -5,7 +5,7 @@ import sys
import gi
gi.require_version('FPrint', '2.0')
from gi.repository import FPrint, GLib
from gi.repository import FPrint, GLib, Gio
# Exit with error on any exception, included those happening in async callbacks
sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1))
@@ -64,6 +64,34 @@ prints2 = len(stored)
print(f"--- LIST DONE: Found {prints2} prints after enroll---")
assert (prints2 - prints1) == 1
# Cancel test - start async identify and cancel it
print("--- TESTING CANCELLATION ---")
deserialized_prints = []
for sp in stored:
deserialized_prints.append(FPrint.Print.deserialize(sp.serialize()))
cancellable = Gio.Cancellable()
identify_cancelled = False
cancel_result = None
def identify_cancelled_cb(dev, res):
global identify_cancelled, cancel_result
identify_cancelled = True
try:
result = dev.identify_finish(res)
cancel_result = result
except Exception as e:
cancel_result = e
print(f"Identify cancelled with error: {e}")
d.identify(deserialized_prints, cancellable=cancellable, callback=identify_cancelled_cb)
cancellable.cancel()
while not identify_cancelled:
ctx.iteration(True)
print(f"--- CANCELLATION TEST DONE, result: {cancel_result} ---")
del deserialized_prints
# Verify
print("--- VERIFYING ---")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
+38 -38
View File
@@ -1,8 +1,8 @@
P: /devices/pci0000:00/0000:00:08.1/0000:05:00.4/usb3/3-3
N: bus/usb/003/002=12010002FF0000407A1CAE0542530102030109022700010100A0320904000003FFFFFF00070581024000000705020240000007058303400001
N: bus/usb/003/005=12010002FF0000407A1CAE0545530102030109022700010100A0320904000003FFFFFF00070581024000000705020240000007058303400001
E: BUSNUM=003
E: DEVNAME=/dev/bus/usb/003/002
E: DEVNUM=002
E: DEVNAME=/dev/bus/usb/003/005
E: DEVNUM=005
E: DEVTYPE=usb_device
E: DRIVER=usb
E: ID_BUS=usb
@@ -12,14 +12,14 @@ E: ID_MODEL_ID=05ae
E: ID_PATH=pci-0000:05:00.4-usb-0:3
E: ID_PATH_TAG=pci-0000_05_00_4-usb-0_3
E: ID_PATH_WITH_USB_REVISION=pci-0000:05:00.4-usbv2-0:3
E: ID_REVISION=5342
E: ID_REVISION=5345
E: ID_SERIAL=EGIS_ETU905Axx-E_0A8606PNA357
E: ID_SERIAL_SHORT=0A8606PNA357
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_MODEL=ETU905Axx-E
E: ID_USB_MODEL_ENC=ETU905Axx-E
E: ID_USB_MODEL_ID=05ae
E: ID_USB_REVISION=5342
E: ID_USB_REVISION=5345
E: ID_USB_SERIAL=EGIS_ETU905Axx-E_0A8606PNA357
E: ID_USB_SERIAL_SHORT=0A8606PNA357
E: ID_USB_VENDOR=EGIS
@@ -30,8 +30,8 @@ E: ID_VENDOR_ENC=EGIS
E: ID_VENDOR_FROM_DATABASE=LighTuning Technology Inc.
E: ID_VENDOR_ID=1c7a
E: MAJOR=189
E: MINOR=257
E: PRODUCT=1c7a/5ae/5342
E: MINOR=260
E: PRODUCT=1c7a/5ae/5345
E: SUBSYSTEM=usb
E: TYPE=255/0/0
A: authorized=1\n
@@ -44,13 +44,13 @@ A: bMaxPacketSize0=64\n
A: bMaxPower=100mA\n
A: bNumConfigurations=1\n
A: bNumInterfaces= 1\n
A: bcdDevice=5342\n
A: bcdDevice=5345\n
A: bmAttributes=a0\n
A: busnum=3\n
A: configuration=
H: descriptors=12010002FF0000407A1CAE0542530102030109022700010100A0320904000003FFFFFF00070581024000000705020240000007058303400001
A: dev=189:257\n
A: devnum=2\n
H: descriptors=12010002FF0000407A1CAE0545530102030109022700010100A0320904000003FFFFFF00070581024000000705020240000007058303400001
A: dev=189:260\n
A: devnum=5\n
A: devpath=3\n
L: driver=../../../../../../bus/usb/drivers/usb
L: firmware_node=../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:0c/device:1b/device:1c/device:1f
@@ -65,16 +65,16 @@ A: physical_location/lid=no\n
A: physical_location/panel=top\n
A: physical_location/vertical_position=upper\n
L: port=../3-0:1.0/usb3-port3
A: power/active_duration=93136758\n
A: power/active_duration=3828402\n
A: power/async=enabled\n
A: power/autosuspend=2\n
A: power/autosuspend_delay_ms=2000\n
A: power/connected_duration=93139621\n
A: power/connected_duration=3828402\n
A: power/control=on\n
A: power/level=on\n
A: power/persist=1\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=93138826\n
A: power/runtime_active_time=3828158\n
A: power/runtime_enabled=forbidden\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n
@@ -95,11 +95,11 @@ A: rx_lanes=1\n
A: serial=0A8606PNA357\n
A: speed=12\n
A: tx_lanes=1\n
A: urbnum=5855\n
A: urbnum=1021\n
A: version= 2.00\n
P: /devices/pci0000:00/0000:00:08.1/0000:05:00.4/usb3
N: bus/usb/003/001=12010002090001406B1D020014060302010109021900010100E0000904000001090000000705810304000C
N: bus/usb/003/001=12010002090001406B1D020017060302010109021900010100E0000904000001090000000705810304000C
E: BUSNUM=003
E: CURRENT_TAGS=:seat:
E: DEVNAME=/dev/bus/usb/003/001
@@ -115,26 +115,26 @@ E: ID_MODEL_FROM_DATABASE=2.0 root hub
E: ID_MODEL_ID=0002
E: ID_PATH=pci-0000:05:00.4
E: ID_PATH_TAG=pci-0000_05_00_4
E: ID_REVISION=0614
E: ID_SERIAL=Linux_6.14.0-37-generic_xhci-hcd_xHCI_Host_Controller_0000:05:00.4
E: ID_REVISION=0617
E: ID_SERIAL=Linux_6.17.0-35-generic_xhci-hcd_xHCI_Host_Controller_0000:05:00.4
E: ID_SERIAL_SHORT=0000:05:00.4
E: ID_USB_INTERFACES=:090000:
E: ID_USB_MODEL=xHCI_Host_Controller
E: ID_USB_MODEL_ENC=xHCI\x20Host\x20Controller
E: ID_USB_MODEL_ID=0002
E: ID_USB_REVISION=0614
E: ID_USB_SERIAL=Linux_6.14.0-37-generic_xhci-hcd_xHCI_Host_Controller_0000:05:00.4
E: ID_USB_REVISION=0617
E: ID_USB_SERIAL=Linux_6.17.0-35-generic_xhci-hcd_xHCI_Host_Controller_0000:05:00.4
E: ID_USB_SERIAL_SHORT=0000:05:00.4
E: ID_USB_VENDOR=Linux_6.14.0-37-generic_xhci-hcd
E: ID_USB_VENDOR_ENC=Linux\x206.14.0-37-generic\x20xhci-hcd
E: ID_USB_VENDOR=Linux_6.17.0-35-generic_xhci-hcd
E: ID_USB_VENDOR_ENC=Linux\x206.17.0-35-generic\x20xhci-hcd
E: ID_USB_VENDOR_ID=1d6b
E: ID_VENDOR=Linux_6.14.0-37-generic_xhci-hcd
E: ID_VENDOR_ENC=Linux\x206.14.0-37-generic\x20xhci-hcd
E: ID_VENDOR=Linux_6.17.0-35-generic_xhci-hcd
E: ID_VENDOR_ENC=Linux\x206.17.0-35-generic\x20xhci-hcd
E: ID_VENDOR_FROM_DATABASE=Linux Foundation
E: ID_VENDOR_ID=1d6b
E: MAJOR=189
E: MINOR=256
E: PRODUCT=1d6b/2/614
E: PRODUCT=1d6b/2/617
E: SUBSYSTEM=usb
E: TAGS=:seat:
E: TYPE=9/0/1
@@ -149,11 +149,11 @@ A: bMaxPacketSize0=64\n
A: bMaxPower=0mA\n
A: bNumConfigurations=1\n
A: bNumInterfaces= 1\n
A: bcdDevice=0614\n
A: bcdDevice=0617\n
A: bmAttributes=e0\n
A: busnum=3\n
A: configuration=
H: descriptors=12010002090001406B1D020014060302010109021900010100E0000904000001090000000705810304000C
H: descriptors=12010002090001406B1D020017060302010109021900010100E0000904000001090000000705810304000C
A: dev=189:256\n
A: devnum=1\n
A: devpath=0\n
@@ -163,20 +163,20 @@ A: idProduct=0002\n
A: idVendor=1d6b\n
A: interface_authorized_default=1\n
A: ltm_capable=no\n
A: manufacturer=Linux 6.14.0-37-generic xhci-hcd\n
A: manufacturer=Linux 6.17.0-35-generic xhci-hcd\n
A: maxchild=4\n
A: power/active_duration=93137993\n
A: power/active_duration=40424267\n
A: power/async=enabled\n
A: power/autosuspend=0\n
A: power/autosuspend_delay_ms=0\n
A: power/connected_duration=93139758\n
A: power/connected_duration=40424455\n
A: power/control=auto\n
A: power/level=auto\n
A: power/runtime_active_kids=1\n
A: power/runtime_active_time=93139206\n
A: power/runtime_active_time=40424257\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n
A: power/runtime_suspended_time=50\n
A: power/runtime_usage=0\n
A: power/wakeup=disabled\n
A: power/wakeup_abort_count=\n
@@ -194,7 +194,7 @@ A: rx_lanes=1\n
A: serial=0000:05:00.4\n
A: speed=480\n
A: tx_lanes=1\n
A: urbnum=989\n
A: urbnum=421\n
A: version= 2.00\n
P: /devices/pci0000:00/0000:00:08.1/0000:05:00.4
@@ -233,7 +233,7 @@ A: driver_override=(null)\n
A: enable=1\n
L: firmware_node=../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:0c/device:1b
L: iommu=../../0000:00:00.2/iommu/ivhd0
L: iommu_group=../../../../kernel/iommu_groups/20
L: iommu_group=../../../../kernel/iommu_groups/19
A: irq=44\n
A: link/l0s_aspm=0\n
A: link/l1_aspm=0\n
@@ -252,11 +252,11 @@ A: msi_irqs/50=msix\n
A: msi_irqs/51=msix\n
A: msi_irqs/52=msix\n
A: numa_node=-1\n
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 4 5 2112 5\nxHCI ring segments 23 23 4096 23\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\n
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 256 port bw ctx arrays 0 0 256 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 4 5 2112 5\nxHCI ring segments 23 23 4096 23\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\n
A: power/async=enabled\n
A: power/control=on\n
A: power/runtime_active_kids=1\n
A: power/runtime_active_time=93139523\n
A: power/runtime_active_time=40424587\n
A: power/runtime_enabled=forbidden\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n
@@ -308,7 +308,7 @@ A: driver_override=(null)\n
A: enable=2\n
L: firmware_node=../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:0c
L: iommu=../0000:00:00.2/iommu/ivhd0
L: iommu_group=../../../kernel/iommu_groups/8
L: iommu_group=../../../kernel/iommu_groups/7
A: irq=33\n
A: local_cpulist=0-11\n
A: local_cpus=fff\n
@@ -322,7 +322,7 @@ A: power/async=enabled\n
A: power/autosuspend_delay_ms=100\n
A: power/control=auto\n
A: power/runtime_active_kids=5\n
A: power/runtime_active_time=93139537\n
A: power/runtime_active_time=40424606\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=0\n