Skip to main content
Version: v2.4.0 (Current)

API Status Codes

Artok uses a standardized set of status codes across the C Widget API, the Lua Engine, and the Connect Protocol. These codes allow your master firmware to handle errorsβ€”such as missing assets or hardware failuresβ€”gracefully.


🟒 1. Success Codes (0x00 - 0x0F)​

These codes indicate that the requested operation was completed successfully or that the system is in an optimal state.

ConstantValueDescription
ATK_API_OK0x00The command was executed and acknowledged.
ATK_CONN_SYNCED0x01Handshake complete; Runtime is linked with Artok Studio.

🟑 2. Widget & Logic Errors (0x10 - 0x2F)​

These codes are returned by atk_api.c functions when the request is valid but cannot be executed due to the current UI state.

ConstantValueDescriptionRecovery Step
ATK_API_ERR_INVALID0x01Malformed request or missing JSON fields.Verify your JSON payload structure.
ATK_API_ERR_NOT_FOUND0x02The UUID does not exist in the loaded ui.bin.Check the spelling in Artok Studio and re-flash.
ATK_API_ERR_TYPE0x03Operation mismatch (e.g., set_text on a Gauge).Use the correct API setter for the widget type.
ATK_API_ERR_BUSY0x12The UI thread is currently locked or transitioning.Retry the operation in the next ART_MainLoop.

πŸ”΄ 3. System & Transport Errors (0x40 - 0x5F)​

These codes indicate a failure at the hardware or protocol level. They are often logged to the System Output in Artok Studio.

ConstantValueDescriptionRecovery Step
ATK_ERR_PROTOCOL0x40Framing error or Start-of-Frame (SOF) mismatch.Check for UART wiring noise or baud rate mismatch.
ATK_ERR_CRC0x41The packet payload was corrupted during transit.Ensure you are using shielded cables for long runs.
ATK_ERR_FLASH_CRC0x42The ui.bin header CRC does not match the data.Re-flash the device from Artok Studio.
ATK_ERR_MALLOC0x43The HMI failed to allocate memory for a widget.Reduce image asset sizes or increase heap size.

πŸ› οΈ Handling Errors in C​

Always check the return status of an API call. For non-critical UI updates, a simple log is sufficient; for critical systems, you may want to trigger a retry.

atk_api_status_t status = atk_api_set_value("UUID_PUMP_SPEED", 85);

if (status != ATK_API_OK) {
// Log the error for debugging
printf("HMI Error: %s (0x%02X)\n", atk_status_to_str(status), status);

if (status == ATK_API_ERR_NOT_FOUND) {
// Handle missing UI component gracefully
emergency_shutdown();
}
}