/*
 * This file is auto-generated, do not modify!
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib.h>

#include "fu-focal-touch-struct.h"
#include "fu-byte-array.h"
#include "fu-bytes.h"
#include "fu-mem-private.h"
#include "fu-string.h"

#ifdef G_LOG_DOMAIN
  #undef G_LOG_DOMAIN
#endif
#define G_LOG_DOMAIN "FuStruct"


/**
 * fu_focal_touch_cmd_to_string:
 * @val: value, e.g. %FU_FOCAL_TOUCH_CMD_CHECK_CURRENT_STATE
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_focal_touch_cmd_to_string(FuFocalTouchCmd val)
{
    if (val == FU_FOCAL_TOUCH_CMD_ENTER_UPGRADE_MODE)
        return "enter-upgrade-mode";
    if (val == FU_FOCAL_TOUCH_CMD_CHECK_CURRENT_STATE)
        return "check-current-state";
    if (val == FU_FOCAL_TOUCH_CMD_READY_FOR_UPGRADE)
        return "ready-for-upgrade";
    if (val == FU_FOCAL_TOUCH_CMD_SEND_DATA)
        return "send-data";
    if (val == FU_FOCAL_TOUCH_CMD_UPGRADE_CHECKSUM)
        return "upgrade-checksum";
    if (val == FU_FOCAL_TOUCH_CMD_EXIT_UPGRADE_MODE)
        return "exit-upgrade-mode";
    if (val == FU_FOCAL_TOUCH_CMD_USB_READ_UPGRADE_ID)
        return "usb-read-upgrade-id";
    if (val == FU_FOCAL_TOUCH_CMD_USB_ERASE_FLASH)
        return "usb-erase-flash";
    if (val == FU_FOCAL_TOUCH_CMD_USB_BOOT_READ)
        return "usb-boot-read";
    if (val == FU_FOCAL_TOUCH_CMD_USB_BOOT_BOOTLOADERVERSION)
        return "usb-boot-bootloaderversion";
    if (val == FU_FOCAL_TOUCH_CMD_READ_REGISTER)
        return "read-register";
    if (val == FU_FOCAL_TOUCH_CMD_WRITE_REGISTER)
        return "write-register";
    if (val == FU_FOCAL_TOUCH_CMD_BIN_LENGTH)
        return "bin-length";
    if (val == FU_FOCAL_TOUCH_CMD_ACK)
        return "ack";
    if (val == FU_FOCAL_TOUCH_CMD_NACK)
        return "nack";
    return NULL;
}

/**
 * fu_focal_touch_uc_mode_to_string:
 * @val: value, e.g. %FU_FOCAL_TOUCH_UC_MODE_RUNTIME
 *
 * Converts an enumerated value to a string.
 *
 * Returns: identifier string
 **/
static const gchar *
fu_focal_touch_uc_mode_to_string(FuFocalTouchUcMode val)
{
    if (val == FU_FOCAL_TOUCH_UC_MODE_UPGRADE)
        return "upgrade";
    if (val == FU_FOCAL_TOUCH_UC_MODE_RUNTIME)
        return "runtime";
    return NULL;
}

/**
 * fu_struct_focal_touch_read_register_req_ref: (skip):
 **/
FuStructFocalTouchReadRegisterReq *
fu_struct_focal_touch_read_register_req_ref(FuStructFocalTouchReadRegisterReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_read_register_req_unref: (skip):
 **/
void
fu_struct_focal_touch_read_register_req_unref(FuStructFocalTouchReadRegisterReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchReadRegisterReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_read_register_req_new_internal: (skip):
 **/
static FuStructFocalTouchReadRegisterReq *
fu_struct_focal_touch_read_register_req_new_internal(void)
{
    FuStructFocalTouchReadRegisterReq *st = g_new0(FuStructFocalTouchReadRegisterReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_read_register_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_read_register_req_set_report_id(FuStructFocalTouchReadRegisterReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_read_register_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_read_register_req_set_len(FuStructFocalTouchReadRegisterReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_read_register_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_read_register_req_set_cmd(FuStructFocalTouchReadRegisterReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_read_register_req_set_address: (skip):
 **/
void
fu_struct_focal_touch_read_register_req_set_address(FuStructFocalTouchReadRegisterReq *st, FuFocalTouchRegister value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_focal_touch_read_register_req_new: (skip):
 **/
FuStructFocalTouchReadRegisterReq *
fu_struct_focal_touch_read_register_req_new(void)
{
    FuStructFocalTouchReadRegisterReq *st = fu_struct_focal_touch_read_register_req_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_focal_touch_read_register_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_read_register_req_set_len(st, 6);
    fu_struct_focal_touch_read_register_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_READ_REGISTER);
    return st;
}
/**
 * fu_struct_focal_touch_read_register_res_ref: (skip):
 **/
FuStructFocalTouchReadRegisterRes *
fu_struct_focal_touch_read_register_res_ref(FuStructFocalTouchReadRegisterRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_read_register_res_unref: (skip):
 **/
void
fu_struct_focal_touch_read_register_res_unref(FuStructFocalTouchReadRegisterRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchReadRegisterRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_read_register_res_new_internal: (skip):
 **/
static FuStructFocalTouchReadRegisterRes *
fu_struct_focal_touch_read_register_res_new_internal(void)
{
    FuStructFocalTouchReadRegisterRes *st = g_new0(FuStructFocalTouchReadRegisterRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_read_register_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_read_register_res_get_report_id(const FuStructFocalTouchReadRegisterRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_read_register_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_read_register_res_get_len(const FuStructFocalTouchReadRegisterRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_read_register_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_read_register_res_get_cmd(const FuStructFocalTouchReadRegisterRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_read_register_res_get_value: (skip):
 **/
guint8
fu_struct_focal_touch_read_register_res_get_value(const FuStructFocalTouchReadRegisterRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[6];
}

/* setters */
/**
 * fu_struct_focal_touch_read_register_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_read_register_res_to_string(const FuStructFocalTouchReadRegisterRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchReadRegisterRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_read_register_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_read_register_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_read_register_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_read_register_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_read_register_res_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  value: 0x%x\n",
                           (guint) fu_struct_focal_touch_read_register_res_get_value(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_read_register_res_validate_internal(FuStructFocalTouchReadRegisterRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_read_register_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchReadRegisterRes.report_id was not valid");
        return FALSE;
    }
    if (memcmp(st->buf->data + 1, "\xFF\xFF", 2) != 0) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchReadRegisterRes._pad was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_read_register_res_get_len(st) != 7) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchReadRegisterRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_read_register_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_READ_REGISTER) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchReadRegisterRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_READ_REGISTER' and got 0x%x '%s'",
                    fu_struct_focal_touch_read_register_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_read_register_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_read_register_res_parse_internal(FuStructFocalTouchReadRegisterRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_read_register_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_read_register_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_read_register_res_parse: (skip):
 **/
FuStructFocalTouchReadRegisterRes *
fu_struct_focal_touch_read_register_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchReadRegisterRes) st = fu_struct_focal_touch_read_register_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 7, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchReadRegisterRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 7);
    if (!fu_struct_focal_touch_read_register_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_send_data_req_ref: (skip):
 **/
FuStructFocalTouchSendDataReq *
fu_struct_focal_touch_send_data_req_ref(FuStructFocalTouchSendDataReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_send_data_req_unref: (skip):
 **/
void
fu_struct_focal_touch_send_data_req_unref(FuStructFocalTouchSendDataReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchSendDataReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_send_data_req_new_internal: (skip):
 **/
static FuStructFocalTouchSendDataReq *
fu_struct_focal_touch_send_data_req_new_internal(void)
{
    FuStructFocalTouchSendDataReq *st = g_new0(FuStructFocalTouchSendDataReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_send_data_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_send_data_req_set_report_id(FuStructFocalTouchSendDataReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_send_data_req_set_len: (skip):
 **/
void
fu_struct_focal_touch_send_data_req_set_len(FuStructFocalTouchSendDataReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_send_data_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_send_data_req_set_cmd(FuStructFocalTouchSendDataReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_send_data_req_set_packet_type: (skip):
 **/
void
fu_struct_focal_touch_send_data_req_set_packet_type(FuStructFocalTouchSendDataReq *st, FuFocalTouchPacketType value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_focal_touch_send_data_req_new: (skip):
 **/
FuStructFocalTouchSendDataReq *
fu_struct_focal_touch_send_data_req_new(void)
{
    FuStructFocalTouchSendDataReq *st = fu_struct_focal_touch_send_data_req_new_internal();
    st->buf = g_byte_array_sized_new(6);
    fu_byte_array_set_size(st->buf, 6, 0x0);
    fu_struct_focal_touch_send_data_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_send_data_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_SEND_DATA);
    return st;
}
/**
 * fu_struct_focal_touch_bin_length_res_ref: (skip):
 **/
FuStructFocalTouchBinLengthRes *
fu_struct_focal_touch_bin_length_res_ref(FuStructFocalTouchBinLengthRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_bin_length_res_unref: (skip):
 **/
void
fu_struct_focal_touch_bin_length_res_unref(FuStructFocalTouchBinLengthRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchBinLengthRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_bin_length_res_new_internal: (skip):
 **/
static FuStructFocalTouchBinLengthRes *
fu_struct_focal_touch_bin_length_res_new_internal(void)
{
    FuStructFocalTouchBinLengthRes *st = g_new0(FuStructFocalTouchBinLengthRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_bin_length_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_bin_length_res_get_report_id(const FuStructFocalTouchBinLengthRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_bin_length_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_bin_length_res_get_len(const FuStructFocalTouchBinLengthRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_bin_length_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_bin_length_res_get_cmd(const FuStructFocalTouchBinLengthRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_bin_length_res_get_reg: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_bin_length_res_get_reg(const FuStructFocalTouchBinLengthRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_focal_touch_bin_length_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_bin_length_res_to_string(const FuStructFocalTouchBinLengthRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchBinLengthRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_bin_length_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_bin_length_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_bin_length_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_bin_length_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_bin_length_res_get_cmd(st));
        }
    }
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_bin_length_res_get_reg(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  reg: 0x%x [%s]\n", (guint) fu_struct_focal_touch_bin_length_res_get_reg(st), tmp);
        } else {
            g_string_append_printf(str, "  reg: 0x%x\n", (guint) fu_struct_focal_touch_bin_length_res_get_reg(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_bin_length_res_validate_internal(FuStructFocalTouchBinLengthRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_bin_length_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchBinLengthRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_bin_length_res_get_len(st) != 6) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchBinLengthRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_bin_length_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_WRITE_REGISTER) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchBinLengthRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_WRITE_REGISTER' and got 0x%x '%s'",
                    fu_struct_focal_touch_bin_length_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_bin_length_res_get_cmd(st)));
        return FALSE;
    }
    if (fu_struct_focal_touch_bin_length_res_get_reg(st) != FU_FOCAL_TOUCH_CMD_BIN_LENGTH) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchBinLengthRes.reg was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_BIN_LENGTH' and got 0x%x '%s'",
                    fu_struct_focal_touch_bin_length_res_get_reg(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_bin_length_res_get_reg(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_bin_length_res_parse_internal(FuStructFocalTouchBinLengthRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_bin_length_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_bin_length_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_bin_length_res_parse: (skip):
 **/
FuStructFocalTouchBinLengthRes *
fu_struct_focal_touch_bin_length_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchBinLengthRes) st = fu_struct_focal_touch_bin_length_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchBinLengthRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_focal_touch_bin_length_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_bin_length_req_ref: (skip):
 **/
FuStructFocalTouchBinLengthReq *
fu_struct_focal_touch_bin_length_req_ref(FuStructFocalTouchBinLengthReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_bin_length_req_unref: (skip):
 **/
void
fu_struct_focal_touch_bin_length_req_unref(FuStructFocalTouchBinLengthReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchBinLengthReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_bin_length_req_new_internal: (skip):
 **/
static FuStructFocalTouchBinLengthReq *
fu_struct_focal_touch_bin_length_req_new_internal(void)
{
    FuStructFocalTouchBinLengthReq *st = g_new0(FuStructFocalTouchBinLengthReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_bin_length_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_bin_length_req_set_report_id(FuStructFocalTouchBinLengthReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_bin_length_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_bin_length_req_set_len(FuStructFocalTouchBinLengthReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_bin_length_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_bin_length_req_set_cmd(FuStructFocalTouchBinLengthReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_bin_length_req_set_reg: (skip):
 **/
static void
fu_struct_focal_touch_bin_length_req_set_reg(FuStructFocalTouchBinLengthReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[5] = value;
}
/**
 * fu_struct_focal_touch_bin_length_req_set_size: (skip):
 **/
void
fu_struct_focal_touch_bin_length_req_set_size(FuStructFocalTouchBinLengthReq *st, guint32 value)
{
    g_return_if_fail(st != NULL);
    fu_memwrite_uint24(st->buf->data + 6, value, G_BIG_ENDIAN);
}
/**
 * fu_struct_focal_touch_bin_length_req_new: (skip):
 **/
FuStructFocalTouchBinLengthReq *
fu_struct_focal_touch_bin_length_req_new(void)
{
    FuStructFocalTouchBinLengthReq *st = fu_struct_focal_touch_bin_length_req_new_internal();
    st->buf = g_byte_array_sized_new(9);
    fu_byte_array_set_size(st->buf, 9, 0x0);
    fu_struct_focal_touch_bin_length_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_bin_length_req_set_len(st, 9);
    fu_struct_focal_touch_bin_length_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_WRITE_REGISTER);
    fu_struct_focal_touch_bin_length_req_set_reg(st, FU_FOCAL_TOUCH_CMD_BIN_LENGTH);
    return st;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_ref: (skip):
 **/
FuStructFocalTouchEnterUpgradeModeReq *
fu_struct_focal_touch_enter_upgrade_mode_req_ref(FuStructFocalTouchEnterUpgradeModeReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_unref: (skip):
 **/
void
fu_struct_focal_touch_enter_upgrade_mode_req_unref(FuStructFocalTouchEnterUpgradeModeReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchEnterUpgradeModeReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_new_internal: (skip):
 **/
static FuStructFocalTouchEnterUpgradeModeReq *
fu_struct_focal_touch_enter_upgrade_mode_req_new_internal(void)
{
    FuStructFocalTouchEnterUpgradeModeReq *st = g_new0(FuStructFocalTouchEnterUpgradeModeReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_enter_upgrade_mode_req_set_report_id(FuStructFocalTouchEnterUpgradeModeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_enter_upgrade_mode_req_set_len(FuStructFocalTouchEnterUpgradeModeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_enter_upgrade_mode_req_set_cmd(FuStructFocalTouchEnterUpgradeModeReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_req_new: (skip):
 **/
FuStructFocalTouchEnterUpgradeModeReq *
fu_struct_focal_touch_enter_upgrade_mode_req_new(void)
{
    FuStructFocalTouchEnterUpgradeModeReq *st = fu_struct_focal_touch_enter_upgrade_mode_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_enter_upgrade_mode_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_enter_upgrade_mode_req_set_len(st, 5);
    fu_struct_focal_touch_enter_upgrade_mode_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_ENTER_UPGRADE_MODE);
    return st;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_ref: (skip):
 **/
FuStructFocalTouchEnterUpgradeModeRes *
fu_struct_focal_touch_enter_upgrade_mode_res_ref(FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_unref: (skip):
 **/
void
fu_struct_focal_touch_enter_upgrade_mode_res_unref(FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchEnterUpgradeModeRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_new_internal: (skip):
 **/
static FuStructFocalTouchEnterUpgradeModeRes *
fu_struct_focal_touch_enter_upgrade_mode_res_new_internal(void)
{
    FuStructFocalTouchEnterUpgradeModeRes *st = g_new0(FuStructFocalTouchEnterUpgradeModeRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_enter_upgrade_mode_res_get_report_id(const FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_enter_upgrade_mode_res_get_len(const FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(const FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}

/* setters */
/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_enter_upgrade_mode_res_to_string(const FuStructFocalTouchEnterUpgradeModeRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchEnterUpgradeModeRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_enter_upgrade_mode_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_enter_upgrade_mode_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_enter_upgrade_mode_res_validate_internal(FuStructFocalTouchEnterUpgradeModeRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_enter_upgrade_mode_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchEnterUpgradeModeRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_enter_upgrade_mode_res_get_len(st) != 5) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchEnterUpgradeModeRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchEnterUpgradeModeRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_ACK' and got 0x%x '%s'",
                    fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_enter_upgrade_mode_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_enter_upgrade_mode_res_parse_internal(FuStructFocalTouchEnterUpgradeModeRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_enter_upgrade_mode_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_enter_upgrade_mode_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_enter_upgrade_mode_res_parse: (skip):
 **/
FuStructFocalTouchEnterUpgradeModeRes *
fu_struct_focal_touch_enter_upgrade_mode_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchEnterUpgradeModeRes) st = fu_struct_focal_touch_enter_upgrade_mode_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 5, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchEnterUpgradeModeRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 5);
    if (!fu_struct_focal_touch_enter_upgrade_mode_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_check_current_state_req_ref: (skip):
 **/
FuStructFocalTouchCheckCurrentStateReq *
fu_struct_focal_touch_check_current_state_req_ref(FuStructFocalTouchCheckCurrentStateReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_check_current_state_req_unref: (skip):
 **/
void
fu_struct_focal_touch_check_current_state_req_unref(FuStructFocalTouchCheckCurrentStateReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchCheckCurrentStateReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_check_current_state_req_new_internal: (skip):
 **/
static FuStructFocalTouchCheckCurrentStateReq *
fu_struct_focal_touch_check_current_state_req_new_internal(void)
{
    FuStructFocalTouchCheckCurrentStateReq *st = g_new0(FuStructFocalTouchCheckCurrentStateReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_check_current_state_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_check_current_state_req_set_report_id(FuStructFocalTouchCheckCurrentStateReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_check_current_state_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_check_current_state_req_set_len(FuStructFocalTouchCheckCurrentStateReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_check_current_state_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_check_current_state_req_set_cmd(FuStructFocalTouchCheckCurrentStateReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_check_current_state_req_new: (skip):
 **/
FuStructFocalTouchCheckCurrentStateReq *
fu_struct_focal_touch_check_current_state_req_new(void)
{
    FuStructFocalTouchCheckCurrentStateReq *st = fu_struct_focal_touch_check_current_state_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_check_current_state_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_check_current_state_req_set_len(st, 5);
    fu_struct_focal_touch_check_current_state_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_CHECK_CURRENT_STATE);
    return st;
}
/**
 * fu_struct_focal_touch_check_current_state_res_ref: (skip):
 **/
FuStructFocalTouchCheckCurrentStateRes *
fu_struct_focal_touch_check_current_state_res_ref(FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_check_current_state_res_unref: (skip):
 **/
void
fu_struct_focal_touch_check_current_state_res_unref(FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchCheckCurrentStateRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_check_current_state_res_new_internal: (skip):
 **/
static FuStructFocalTouchCheckCurrentStateRes *
fu_struct_focal_touch_check_current_state_res_new_internal(void)
{
    FuStructFocalTouchCheckCurrentStateRes *st = g_new0(FuStructFocalTouchCheckCurrentStateRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_check_current_state_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_check_current_state_res_get_report_id(const FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_check_current_state_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_check_current_state_res_get_len(const FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_check_current_state_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_check_current_state_res_get_cmd(const FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_check_current_state_res_get_mode: (skip):
 **/
FuFocalTouchUcMode
fu_struct_focal_touch_check_current_state_res_get_mode(const FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_focal_touch_check_current_state_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_check_current_state_res_to_string(const FuStructFocalTouchCheckCurrentStateRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchCheckCurrentStateRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_check_current_state_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_check_current_state_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_check_current_state_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_check_current_state_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_check_current_state_res_get_cmd(st));
        }
    }
    {
        const gchar *tmp = fu_focal_touch_uc_mode_to_string(fu_struct_focal_touch_check_current_state_res_get_mode(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  mode: 0x%x [%s]\n", (guint) fu_struct_focal_touch_check_current_state_res_get_mode(st), tmp);
        } else {
            g_string_append_printf(str, "  mode: 0x%x\n", (guint) fu_struct_focal_touch_check_current_state_res_get_mode(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_check_current_state_res_validate_internal(FuStructFocalTouchCheckCurrentStateRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_check_current_state_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchCheckCurrentStateRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_check_current_state_res_get_len(st) != 6) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchCheckCurrentStateRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_check_current_state_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_CHECK_CURRENT_STATE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchCheckCurrentStateRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_CHECK_CURRENT_STATE' and got 0x%x '%s'",
                    fu_struct_focal_touch_check_current_state_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_check_current_state_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_check_current_state_res_parse_internal(FuStructFocalTouchCheckCurrentStateRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_check_current_state_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_check_current_state_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_check_current_state_res_parse: (skip):
 **/
FuStructFocalTouchCheckCurrentStateRes *
fu_struct_focal_touch_check_current_state_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchCheckCurrentStateRes) st = fu_struct_focal_touch_check_current_state_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchCheckCurrentStateRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_focal_touch_check_current_state_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_ref: (skip):
 **/
FuStructFocalTouchUsbReadUpgradeIdReq *
fu_struct_focal_touch_usb_read_upgrade_id_req_ref(FuStructFocalTouchUsbReadUpgradeIdReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_unref: (skip):
 **/
void
fu_struct_focal_touch_usb_read_upgrade_id_req_unref(FuStructFocalTouchUsbReadUpgradeIdReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchUsbReadUpgradeIdReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_new_internal: (skip):
 **/
static FuStructFocalTouchUsbReadUpgradeIdReq *
fu_struct_focal_touch_usb_read_upgrade_id_req_new_internal(void)
{
    FuStructFocalTouchUsbReadUpgradeIdReq *st = g_new0(FuStructFocalTouchUsbReadUpgradeIdReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_usb_read_upgrade_id_req_set_report_id(FuStructFocalTouchUsbReadUpgradeIdReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_usb_read_upgrade_id_req_set_len(FuStructFocalTouchUsbReadUpgradeIdReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_usb_read_upgrade_id_req_set_cmd(FuStructFocalTouchUsbReadUpgradeIdReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_req_new: (skip):
 **/
FuStructFocalTouchUsbReadUpgradeIdReq *
fu_struct_focal_touch_usb_read_upgrade_id_req_new(void)
{
    FuStructFocalTouchUsbReadUpgradeIdReq *st = fu_struct_focal_touch_usb_read_upgrade_id_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_usb_read_upgrade_id_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_usb_read_upgrade_id_req_set_len(st, 5);
    fu_struct_focal_touch_usb_read_upgrade_id_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_USB_READ_UPGRADE_ID);
    return st;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_ref: (skip):
 **/
FuStructFocalTouchUsbReadUpgradeIdRes *
fu_struct_focal_touch_usb_read_upgrade_id_res_ref(FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_unref: (skip):
 **/
void
fu_struct_focal_touch_usb_read_upgrade_id_res_unref(FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchUsbReadUpgradeIdRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_new_internal: (skip):
 **/
static FuStructFocalTouchUsbReadUpgradeIdRes *
fu_struct_focal_touch_usb_read_upgrade_id_res_new_internal(void)
{
    FuStructFocalTouchUsbReadUpgradeIdRes *st = g_new0(FuStructFocalTouchUsbReadUpgradeIdRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_usb_read_upgrade_id_res_get_report_id(const FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_get_len: (skip):
 **/
guint8
fu_struct_focal_touch_usb_read_upgrade_id_res_get_len(const FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(const FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_get_upgrade_id: (skip):
 **/
guint16
fu_struct_focal_touch_usb_read_upgrade_id_res_get_upgrade_id(const FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint16(st->buf->data + 5, G_BIG_ENDIAN);
}

/* setters */
/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_usb_read_upgrade_id_res_to_string(const FuStructFocalTouchUsbReadUpgradeIdRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchUsbReadUpgradeIdRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_usb_read_upgrade_id_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_usb_read_upgrade_id_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  upgrade_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_usb_read_upgrade_id_res_get_upgrade_id(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_usb_read_upgrade_id_res_validate_internal(FuStructFocalTouchUsbReadUpgradeIdRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_usb_read_upgrade_id_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchUsbReadUpgradeIdRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_USB_READ_UPGRADE_ID) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchUsbReadUpgradeIdRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_USB_READ_UPGRADE_ID' and got 0x%x '%s'",
                    fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_usb_read_upgrade_id_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_usb_read_upgrade_id_res_parse_internal(FuStructFocalTouchUsbReadUpgradeIdRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_usb_read_upgrade_id_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_usb_read_upgrade_id_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_usb_read_upgrade_id_res_parse: (skip):
 **/
FuStructFocalTouchUsbReadUpgradeIdRes *
fu_struct_focal_touch_usb_read_upgrade_id_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchUsbReadUpgradeIdRes) st = fu_struct_focal_touch_usb_read_upgrade_id_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 7, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchUsbReadUpgradeIdRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 7);
    if (!fu_struct_focal_touch_usb_read_upgrade_id_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_ref: (skip):
 **/
FuStructFocalTouchUsbEraseFlashReq *
fu_struct_focal_touch_usb_erase_flash_req_ref(FuStructFocalTouchUsbEraseFlashReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_unref: (skip):
 **/
void
fu_struct_focal_touch_usb_erase_flash_req_unref(FuStructFocalTouchUsbEraseFlashReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchUsbEraseFlashReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_new_internal: (skip):
 **/
static FuStructFocalTouchUsbEraseFlashReq *
fu_struct_focal_touch_usb_erase_flash_req_new_internal(void)
{
    FuStructFocalTouchUsbEraseFlashReq *st = g_new0(FuStructFocalTouchUsbEraseFlashReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_usb_erase_flash_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_usb_erase_flash_req_set_report_id(FuStructFocalTouchUsbEraseFlashReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_usb_erase_flash_req_set_len(FuStructFocalTouchUsbEraseFlashReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_usb_erase_flash_req_set_cmd(FuStructFocalTouchUsbEraseFlashReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_usb_erase_flash_req_new: (skip):
 **/
FuStructFocalTouchUsbEraseFlashReq *
fu_struct_focal_touch_usb_erase_flash_req_new(void)
{
    FuStructFocalTouchUsbEraseFlashReq *st = fu_struct_focal_touch_usb_erase_flash_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_usb_erase_flash_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_usb_erase_flash_req_set_len(st, 5);
    fu_struct_focal_touch_usb_erase_flash_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_USB_ERASE_FLASH);
    return st;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_ref: (skip):
 **/
FuStructFocalTouchUpgradeChecksumReq *
fu_struct_focal_touch_upgrade_checksum_req_ref(FuStructFocalTouchUpgradeChecksumReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_unref: (skip):
 **/
void
fu_struct_focal_touch_upgrade_checksum_req_unref(FuStructFocalTouchUpgradeChecksumReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchUpgradeChecksumReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_new_internal: (skip):
 **/
static FuStructFocalTouchUpgradeChecksumReq *
fu_struct_focal_touch_upgrade_checksum_req_new_internal(void)
{
    FuStructFocalTouchUpgradeChecksumReq *st = g_new0(FuStructFocalTouchUpgradeChecksumReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_upgrade_checksum_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_upgrade_checksum_req_set_report_id(FuStructFocalTouchUpgradeChecksumReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_upgrade_checksum_req_set_len(FuStructFocalTouchUpgradeChecksumReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_upgrade_checksum_req_set_cmd(FuStructFocalTouchUpgradeChecksumReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_req_new: (skip):
 **/
FuStructFocalTouchUpgradeChecksumReq *
fu_struct_focal_touch_upgrade_checksum_req_new(void)
{
    FuStructFocalTouchUpgradeChecksumReq *st = fu_struct_focal_touch_upgrade_checksum_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_upgrade_checksum_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_upgrade_checksum_req_set_len(st, 5);
    fu_struct_focal_touch_upgrade_checksum_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_UPGRADE_CHECKSUM);
    return st;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_ref: (skip):
 **/
FuStructFocalTouchUpgradeChecksumRes *
fu_struct_focal_touch_upgrade_checksum_res_ref(FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_unref: (skip):
 **/
void
fu_struct_focal_touch_upgrade_checksum_res_unref(FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchUpgradeChecksumRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_new_internal: (skip):
 **/
static FuStructFocalTouchUpgradeChecksumRes *
fu_struct_focal_touch_upgrade_checksum_res_new_internal(void)
{
    FuStructFocalTouchUpgradeChecksumRes *st = g_new0(FuStructFocalTouchUpgradeChecksumRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_upgrade_checksum_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_upgrade_checksum_res_get_report_id(const FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_upgrade_checksum_res_get_len(const FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_upgrade_checksum_res_get_cmd(const FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_upgrade_checksum_res_get_value: (skip):
 **/
guint32
fu_struct_focal_touch_upgrade_checksum_res_get_value(const FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return fu_memread_uint32(st->buf->data + 5, G_LITTLE_ENDIAN);
}

/* setters */
/**
 * fu_struct_focal_touch_upgrade_checksum_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_upgrade_checksum_res_to_string(const FuStructFocalTouchUpgradeChecksumRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchUpgradeChecksumRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_upgrade_checksum_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_upgrade_checksum_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  value: 0x%x\n",
                           (guint) fu_struct_focal_touch_upgrade_checksum_res_get_value(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_upgrade_checksum_res_validate_internal(FuStructFocalTouchUpgradeChecksumRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_upgrade_checksum_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchUpgradeChecksumRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_upgrade_checksum_res_get_len(st) != 9) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchUpgradeChecksumRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_UPGRADE_CHECKSUM) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchUpgradeChecksumRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_UPGRADE_CHECKSUM' and got 0x%x '%s'",
                    fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_upgrade_checksum_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_upgrade_checksum_res_parse_internal(FuStructFocalTouchUpgradeChecksumRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_upgrade_checksum_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_upgrade_checksum_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_upgrade_checksum_res_parse: (skip):
 **/
FuStructFocalTouchUpgradeChecksumRes *
fu_struct_focal_touch_upgrade_checksum_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchUpgradeChecksumRes) st = fu_struct_focal_touch_upgrade_checksum_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 9, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchUpgradeChecksumRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 9);
    if (!fu_struct_focal_touch_upgrade_checksum_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_ref: (skip):
 **/
FuStructFocalTouchExitUpgradeModeReq *
fu_struct_focal_touch_exit_upgrade_mode_req_ref(FuStructFocalTouchExitUpgradeModeReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_unref: (skip):
 **/
void
fu_struct_focal_touch_exit_upgrade_mode_req_unref(FuStructFocalTouchExitUpgradeModeReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchExitUpgradeModeReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_new_internal: (skip):
 **/
static FuStructFocalTouchExitUpgradeModeReq *
fu_struct_focal_touch_exit_upgrade_mode_req_new_internal(void)
{
    FuStructFocalTouchExitUpgradeModeReq *st = g_new0(FuStructFocalTouchExitUpgradeModeReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_exit_upgrade_mode_req_set_report_id(FuStructFocalTouchExitUpgradeModeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_exit_upgrade_mode_req_set_len(FuStructFocalTouchExitUpgradeModeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_exit_upgrade_mode_req_set_cmd(FuStructFocalTouchExitUpgradeModeReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_req_new: (skip):
 **/
FuStructFocalTouchExitUpgradeModeReq *
fu_struct_focal_touch_exit_upgrade_mode_req_new(void)
{
    FuStructFocalTouchExitUpgradeModeReq *st = fu_struct_focal_touch_exit_upgrade_mode_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_exit_upgrade_mode_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_exit_upgrade_mode_req_set_len(st, 5);
    fu_struct_focal_touch_exit_upgrade_mode_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_EXIT_UPGRADE_MODE);
    return st;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_ref: (skip):
 **/
FuStructFocalTouchExitUpgradeModeRes *
fu_struct_focal_touch_exit_upgrade_mode_res_ref(FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_unref: (skip):
 **/
void
fu_struct_focal_touch_exit_upgrade_mode_res_unref(FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchExitUpgradeModeRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_new_internal: (skip):
 **/
static FuStructFocalTouchExitUpgradeModeRes *
fu_struct_focal_touch_exit_upgrade_mode_res_new_internal(void)
{
    FuStructFocalTouchExitUpgradeModeRes *st = g_new0(FuStructFocalTouchExitUpgradeModeRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_exit_upgrade_mode_res_get_report_id(const FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_get_len: (skip):
 **/
static guint8
fu_struct_focal_touch_exit_upgrade_mode_res_get_len(const FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(const FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}

/* setters */
/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_exit_upgrade_mode_res_to_string(const FuStructFocalTouchExitUpgradeModeRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchExitUpgradeModeRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_exit_upgrade_mode_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_exit_upgrade_mode_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st));
        }
    }
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_exit_upgrade_mode_res_validate_internal(FuStructFocalTouchExitUpgradeModeRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_exit_upgrade_mode_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchExitUpgradeModeRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_exit_upgrade_mode_res_get_len(st) != 5) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchExitUpgradeModeRes.len was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_ACK) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchExitUpgradeModeRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_ACK' and got 0x%x '%s'",
                    fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_exit_upgrade_mode_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_exit_upgrade_mode_res_parse_internal(FuStructFocalTouchExitUpgradeModeRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_exit_upgrade_mode_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_exit_upgrade_mode_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_exit_upgrade_mode_res_parse: (skip):
 **/
FuStructFocalTouchExitUpgradeModeRes *
fu_struct_focal_touch_exit_upgrade_mode_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchExitUpgradeModeRes) st = fu_struct_focal_touch_exit_upgrade_mode_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 5, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchExitUpgradeModeRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 5);
    if (!fu_struct_focal_touch_exit_upgrade_mode_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_ref: (skip):
 **/
FuStructFocalTouchReadyForUpgradeReq *
fu_struct_focal_touch_ready_for_upgrade_req_ref(FuStructFocalTouchReadyForUpgradeReq *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_unref: (skip):
 **/
void
fu_struct_focal_touch_ready_for_upgrade_req_unref(FuStructFocalTouchReadyForUpgradeReq *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchReadyForUpgradeReq refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_new_internal: (skip):
 **/
static FuStructFocalTouchReadyForUpgradeReq *
fu_struct_focal_touch_ready_for_upgrade_req_new_internal(void)
{
    FuStructFocalTouchReadyForUpgradeReq *st = g_new0(FuStructFocalTouchReadyForUpgradeReq, 1);
    st->refcount = 1;
    return st;
}

/* getters */

/* setters */
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_set_report_id: (skip):
 **/
static void
fu_struct_focal_touch_ready_for_upgrade_req_set_report_id(FuStructFocalTouchReadyForUpgradeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[0] = value;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_set_len: (skip):
 **/
static void
fu_struct_focal_touch_ready_for_upgrade_req_set_len(FuStructFocalTouchReadyForUpgradeReq *st, guint8 value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[3] = value;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_set_cmd: (skip):
 **/
static void
fu_struct_focal_touch_ready_for_upgrade_req_set_cmd(FuStructFocalTouchReadyForUpgradeReq *st, FuFocalTouchCmd value)
{
    g_return_if_fail(st != NULL);
    st->buf->data[4] = value;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_req_new: (skip):
 **/
FuStructFocalTouchReadyForUpgradeReq *
fu_struct_focal_touch_ready_for_upgrade_req_new(void)
{
    FuStructFocalTouchReadyForUpgradeReq *st = fu_struct_focal_touch_ready_for_upgrade_req_new_internal();
    st->buf = g_byte_array_sized_new(5);
    fu_byte_array_set_size(st->buf, 5, 0x0);
    fu_struct_focal_touch_ready_for_upgrade_req_set_report_id(st, 0x06);
    memcpy(st->buf->data + 0x1, "\xFF\xFF", 2); /* nocheck:blocked */
    fu_struct_focal_touch_ready_for_upgrade_req_set_len(st, 5);
    fu_struct_focal_touch_ready_for_upgrade_req_set_cmd(st, FU_FOCAL_TOUCH_CMD_READY_FOR_UPGRADE);
    return st;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_ref: (skip):
 **/
FuStructFocalTouchReadyForUpgradeRes *
fu_struct_focal_touch_ready_for_upgrade_res_ref(FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_val_if_fail(st != NULL, NULL);
    st->refcount++;
    return st;
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_unref: (skip):
 **/
void
fu_struct_focal_touch_ready_for_upgrade_res_unref(FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_if_fail(st != NULL);
    if (st->refcount == 0) {
        g_critical("FuStructFocalTouchReadyForUpgradeRes refcount already zero");
        return;
    }
    if (--st->refcount > 0)
        return;
    if (st->buf != NULL)
        g_byte_array_unref(st->buf);
    g_free(st);
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_new_internal: (skip):
 **/
static FuStructFocalTouchReadyForUpgradeRes *
fu_struct_focal_touch_ready_for_upgrade_res_new_internal(void)
{
    FuStructFocalTouchReadyForUpgradeRes *st = g_new0(FuStructFocalTouchReadyForUpgradeRes, 1);
    st->refcount = 1;
    return st;
}

/* getters */
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_get_report_id: (skip):
 **/
static guint8
fu_struct_focal_touch_ready_for_upgrade_res_get_report_id(const FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[0];
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_get_len: (skip):
 **/
guint8
fu_struct_focal_touch_ready_for_upgrade_res_get_len(const FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[3];
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_get_cmd: (skip):
 **/
static FuFocalTouchCmd
fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(const FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[4];
}
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_get_status: (skip):
 **/
guint8
fu_struct_focal_touch_ready_for_upgrade_res_get_status(const FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_return_val_if_fail(st != NULL, 0x0);
    return st->buf->data[5];
}

/* setters */
/**
 * fu_struct_focal_touch_ready_for_upgrade_res_to_string: (skip):
 **/
static gchar *
fu_struct_focal_touch_ready_for_upgrade_res_to_string(const FuStructFocalTouchReadyForUpgradeRes *st)
{
    g_autoptr(GString) str = g_string_new("FuStructFocalTouchReadyForUpgradeRes:\n");
    g_return_val_if_fail(st != NULL, NULL);
    g_string_append_printf(str, "  report_id: 0x%x\n",
                           (guint) fu_struct_focal_touch_ready_for_upgrade_res_get_report_id(st));
    g_string_append_printf(str, "  len: 0x%x\n",
                           (guint) fu_struct_focal_touch_ready_for_upgrade_res_get_len(st));
    {
        const gchar *tmp = fu_focal_touch_cmd_to_string(fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st));
        if (tmp != NULL) {
            g_string_append_printf(str, "  cmd: 0x%x [%s]\n", (guint) fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st), tmp);
        } else {
            g_string_append_printf(str, "  cmd: 0x%x\n", (guint) fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st));
        }
    }
    g_string_append_printf(str, "  status: 0x%x\n",
                           (guint) fu_struct_focal_touch_ready_for_upgrade_res_get_status(st));
    if (str->len > 0)
        g_string_set_size(str, str->len - 1);
    return g_string_free(g_steal_pointer(&str), FALSE);
}
static gboolean
fu_struct_focal_touch_ready_for_upgrade_res_validate_internal(FuStructFocalTouchReadyForUpgradeRes *st, GError **error)
{
    g_return_val_if_fail(st != NULL, FALSE);
    if (fu_struct_focal_touch_ready_for_upgrade_res_get_report_id(st) != 0x06) {
        g_set_error_literal(error,
                            FWUPD_ERROR,
                            FWUPD_ERROR_INVALID_DATA,
                            "constant FuStructFocalTouchReadyForUpgradeRes.report_id was not valid");
        return FALSE;
    }
    if (fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st) != FU_FOCAL_TOUCH_CMD_READY_FOR_UPGRADE) {
        g_set_error(error,
                    FWUPD_ERROR,
                    FWUPD_ERROR_INVALID_DATA,
                    "constant FuStructFocalTouchReadyForUpgradeRes.cmd was not valid, "
                    "expected 'FU_FOCAL_TOUCH_CMD_READY_FOR_UPGRADE' and got 0x%x '%s'",
                    fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st),
                    fu_focal_touch_cmd_to_string(fu_struct_focal_touch_ready_for_upgrade_res_get_cmd(st)));
        return FALSE;
    }
    return TRUE;
}
static gboolean
fu_struct_focal_touch_ready_for_upgrade_res_parse_internal(FuStructFocalTouchReadyForUpgradeRes *st, GError **error)
{
    if (g_log_get_debug_enabled()) {
        g_autofree gchar *str = fu_struct_focal_touch_ready_for_upgrade_res_to_string(st);
        g_debug("%s", str);
    }
    if (!fu_struct_focal_touch_ready_for_upgrade_res_validate_internal(st, error))
        return FALSE;
    return TRUE;
}

/**
 * fu_struct_focal_touch_ready_for_upgrade_res_parse: (skip):
 **/
FuStructFocalTouchReadyForUpgradeRes *
fu_struct_focal_touch_ready_for_upgrade_res_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{
    g_autoptr(FuStructFocalTouchReadyForUpgradeRes) st = fu_struct_focal_touch_ready_for_upgrade_res_new_internal();
    g_return_val_if_fail(buf != NULL, NULL);
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
    if (!fu_memchk_read(bufsz, offset, 6, error)) {
        g_prefix_error_literal(error, "invalid struct FuStructFocalTouchReadyForUpgradeRes: ");
        return NULL;
    }
    st->buf = g_byte_array_new();
    g_byte_array_append(st->buf, buf + offset, 6);
    if (!fu_struct_focal_touch_ready_for_upgrade_res_parse_internal(st, error))
        return NULL;
    return g_steal_pointer(&st);
}
