CAN DragonEmSA
functionSerial Number and Firmware

EmSACAN_FirmwareUpdateBegin

Prototype

emsacan_result_t EmSACAN_FirmwareUpdateBegin(
    emsacan_handle_t Handle,
    emsacan_firmware_type_t FirmwareType,
    const uint8_t *DownloadData,
    uint32_t DownloadLength,
    emsacan_fwupdate_callback_fn Callback,
    void *UserContext );

Description

Starts the CAN Dragon firmware update sequence (non-secure application image).

Parameters

ParameterDirectionTypeDescription
Handleinemsacan_handle_tSession handle from EmSACAN_Connect.
FirmwareTypeinemsacan_firmware_type_tMust be EMSACAN_FWTYPE_DEVICE for supported updates.
DownloadDatainconst uint8_tImage bytes; must remain valid until the callback reports a terminal phase (completed, failed, or cancelled).
DownloadLengthinuint32_tSize of DownloadData in bytes.
Callbackinemsacan_fwupdate_callback_fnProgress and phase notifications.
UserContextinvoidOpaque pointer passed to Callback.

Return value

EMSACAN_OK if the worker started, or another emsacan_result_t code on failure.

Example

void __cdecl FwCb(void *ctx, emsacan_fwupdate_phase_t phase,
                  emsacan_result_t step, uint32_t done, uint32_t total)
{
    if (phase == EMSACAN_FWUPDATE_PHASE_DOWNLOADING)
        printf("Download %u / %u\n", done, total);
    if (phase == EMSACAN_FWUPDATE_PHASE_COMPLETED ||
        phase == EMSACAN_FWUPDATE_PHASE_FAILED)
        { /* terminal — image buffer may be freed */ }
}

/* image[] must stay valid until callback reports terminal phase */
emsacan_result_t rc = EmSACAN_FirmwareUpdateBegin(
    handle, EMSACAN_FWTYPE_DEVICE, image, image_len, FwCb, NULL);

See also