How to understand log_service_add_table?

Hi,

At mmf2_video_example_vipnn_rtsp_init.c, there is a function log_service_add_table which will be called before setup RTSP streaming. My questions are

  1. log_service_add_table is?
  2. what time fUC will be called?
  3. how to test fUC?
static void fUC(void *arg)
{
    static uint32_t user_cmd = 0;

    if (!strcmp(arg, "TD")) {
        if (user_cmd & USR_CMD_EXAMPLE_DEINIT) {
            printf("invalid state, can not do %s deinit!\r\n", example);
        } else {
            example_deinit();
            user_cmd = USR_CMD_EXAMPLE_DEINIT;
            printf("deinit %s\r\n", example);
        }
    } else if (!strcmp(arg, "TSR")) {
        if (user_cmd & USR_CMD_EXAMPLE_DEINIT) {
            printf("reinit %s\r\n", example);
            sys_reset();
        } else {
            printf("invalid state, can not do %s reinit!\r\n", example);
        }
    } else {
        printf("invalid cmd");
    }
    
    printf("user command 0x%lx\r\n", user_cmd);
}
    
static log_item_t userctrl_items[] = {
    {"UC", fUC, },
};

static void atcmd_userctrl_init(void)
{
    log_service_add_table(userctrl_items, sizeof(userctrl_items) / sizeof(userctrl_items[0]));
}

Please help. Thanks.

Hi @Hsieh_Eric ,

From the source code “mmf2_video_example_vipnn_rtsp_init.c”, it indicates that you currently using code from ambpro2_sdk: ambpro2_sdk/mmf2_video_example_vipnn_rtsp_init.c at main · ambiot/ambpro2_sdk · GitHub.

  1. log_service_add_table is an array for users to store the customized ATCMDs in this example. It’s a method for standard SDK users not for Arduino.

  2. fUC is an API for users to create customized AT Commands. It will be called once when the user key in the customized AT Commands in the terminal.

  3. Currently you need to build your environment for Ameba Pro2 SDK first, creating the example binary image, then creating customized AT Command following the fUC() style that will execute your commands in the terminal.

For further inquiries, please raise GitHub Issue here since this SDK is currently not maintained by us.

Thank you.