/* Start Poll */ void esif_poll_start( struct esif_lp_domain *lpd_ptr ) { enum esif_rc rc = ESIF_OK; if (ESIF_TRUE == lpd_ptr->poll || 0 == g_background) return; lpd_ptr->timer_period_msec = g_background; rc = esif_ccb_timer_init(&lpd_ptr->timer); if (ESIF_OK != rc) goto exit; rc = esif_ccb_timer_set_msec(&lpd_ptr->timer, lpd_ptr->timer_period_msec, ESIF_TRUE, esif_poll, lpd_ptr); if (ESIF_OK != rc) goto exit; ESIF_TRACE_DYN_POLL("Timer started for %s period %d\n", lpd_ptr->name_ptr, g_background); lpd_ptr->poll = ESIF_TRUE; exit: return; }
// // PUBLIC INTERFACE--------------------------------------------------------------------- // char *EsifShellCmdDataLog(EsifShellCmdPtr shell) { eEsifError rc = ESIF_OK; int argc = shell->argc; char **argv = shell->argv; char *output = shell->outbuf; char participantList[MAX_LOG_LINE] = { 0 }; /* * Serialize access to the datalog state. */ while (atomic_set(&g_dataLogLock, ESIF_TRUE)) { esif_ccb_sleep_msec(ESIF_DATALOG_LOCK_SLEEP_MS); } if (argc < 2) { esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging is: %s\n", (EsifDataIsLogStarted() ? "started" : "stopped")); } else if (esif_ccb_stricmp(argv[1], "start") == 0) { if (EsifDataIsLogStarted()){ esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging is already started.\n"); goto exit; } g_dataLogInterval = DEFAULT_STATUS_LOG_INTERVAL; if (argc > 2) { if ((int)esif_atoi(argv[2]) >= MIN_STATUS_LOG_INTERVAL) { g_dataLogInterval = (esif_ccb_time_t)esif_atoi(argv[2]); } else { esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid sampling period specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL); goto exit; } } if (argc > 3) { esif_ccb_sprintf(sizeof(participantList), participantList, "%s", argv[3]); } rc = EsifDataLogValidateParticipantList(participantList); if (rc != ESIF_OK) { esif_ccb_sprintf(OUT_BUF_LEN, output, "There was a problem with your participant list. You may have selected invalid participants, or too many participants. \n"); goto exit; } rc = EsifDataLogOpenLogFile(); if (rc != ESIF_OK) { esif_ccb_sprintf(OUT_BUF_LEN, output, "Error opening log file... \n"); goto exit; } esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging starting... \n"); EsifDataLogStart(); } else if (esif_ccb_stricmp(argv[1], "schedule") == 0) { UInt32 startTime = 1000; /* initialize */ if (dataLogContextPtr == NULL) { dataLogContextPtr = (struct dataLogContext *)esif_ccb_malloc(sizeof(struct dataLogContext)); if (dataLogContextPtr == NULL) { rc = ESIF_E_NO_MEMORY; goto exit; } dataLogContextPtr->dataLogScheduleTimer = (esif_ccb_timer_t *) esif_ccb_malloc(sizeof(esif_ccb_timer_t)); if (dataLogContextPtr->dataLogScheduleTimer == NULL) { rc = ESIF_E_NO_MEMORY; goto exit; } dataLogContextPtr->dataLogParticipantList = NULL; } dataLogContextPtr->dataLogInterval = DEFAULT_STATUS_LOG_INTERVAL; /* start time (in ms from now) */ if (argc > 2) { if ((int) esif_atoi(argv[2]) >= MIN_STATUS_LOG_SCHEDULE) { startTime = (esif_ccb_time_t) esif_atoi(argv[2]); } else { esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid schedule time specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL); goto exit; } } /* log interval */ if (argc > 3) { if ((int) esif_atoi(argv[3]) >= MIN_STATUS_LOG_INTERVAL) { dataLogContextPtr->dataLogInterval = (esif_ccb_time_t) esif_atoi(argv[3]); } else { esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid sampling period specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL); goto exit; } } if (argc > 4) { dataLogContextPtr->dataLogParticipantList = esif_ccb_strdup(argv[4]); if (dataLogContextPtr->dataLogParticipantList == NULL) { rc = ESIF_E_NO_MEMORY; goto exit; } } rc = esif_ccb_timer_init(dataLogContextPtr->dataLogScheduleTimer, (esif_ccb_timer_cb) EsifDataLogSchedule, NULL); if (ESIF_OK != rc) { esif_ccb_sprintf(OUT_BUF_LEN, output, "Error starting timer... \n"); goto exit; } rc = esif_ccb_timer_set_msec(dataLogContextPtr->dataLogScheduleTimer, startTime); esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging scheduled for start in %d ms at an interval of %d... \n", startTime, dataLogContextPtr->dataLogInterval); } else if (esif_ccb_stricmp(argv[1], "stop") == 0) { EsifDataLogStop(); esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging stopped...\n"); g_dataLogActive = ESIF_FALSE; } else { esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid parameter specified\n"); } exit: atomic_set(&g_dataLogLock, ESIF_FALSE); return output; }