static ICACHE_FLASH_ATTR void check_input(void *pvParameters) { char ch; xQueueHandle xUARTQueue = *(xQueueHandle *)pvParameters; for(;;) { wifi_status = wifi_station_get_connect_status(); if (wifi_status == STATION_GOT_IP) { printf("Hit 'c' to configure, 't' to test\r\n"); } else { printf("Hit 'c' to configure\r\n"); } // ch = uart_getchar(); // wait forever xQueueReceive(xUARTQueue, &ch, -1); // wifi_station_set_auto_connect(0); // printf("lololol"); switch(ch) { case 'c': case 'C': configure(); break; case 't': case 'T': if (wifi_status == STATION_GOT_IP) { printf("connected!\n"); // if(send_command()) // { // printf("Send command failed!\r\n"); // } } else { printf("Not connected\r\n"); TASK_DELAY_MS(500); } break; case 0: // This shouldn't happen? printf("Error reading serial data\r\n"); break; default: printf("Invalid key %d %c\r\n", ch, ch); // uart_rx_flush(); TASK_DELAY_MS(500); } } }
void delay_ms(unsigned long delay) { #if (defined FREERTOS_USED) vTaskDelay( (portTickType)TASK_DELAY_MS(delay) ); #elif (defined NUTOS_USED) NutSleep(delay); #else cpu_delay_ms(delay, s_fcpu_hz); #endif }
/*! * \brief If the log file descriptor is valid, pop the oldest logs from the logs * queue into the current log file until the low threshold of the logs queue is * reached; then close the current log file. If the log file descriptor is * invalid, simply pop the oldest logs from the logs queue until the low * threshold of the logs queue is reached. * * \param fd_current_logfile The file descriptor of the current log file. * */ static void prv_vsave_logs( int fd_current_logfile ) { xLogDef *pxLog; int iLogStringLen; portTickType xLastFocusTime; // We need to initialise xLastFocusTime prior to the first call to vTaskDelayUntil(). xLastFocusTime = xTaskGetTickCount(); // NOTE: do not fully flush the xLogsQueue at once because it will take too // much time? // Issue vTaskDelayUntil({10,100}) upon each log pop? while( DATALOG_LOGSQUEUE_LOTHRESHOLD < ( uxNbMsgsInLogsQueue = uxQueueMessagesWaiting( xLogsQueue ) ) ) { // Get the oldest log from the queue. // NOTE: we are sure there is an item to get => no block time. if( pdTRUE == xQueueReceive( xLogsQueue, &pxLog, ( portTickType ) 0 ) ) { if( -1 == fd_current_logfile ) { // Special case: simply pop the logs. vdatalog_log_free( pxLog ); // Free the log. } else { /* 1) Build the log string to write in the file. */ vdatalog_make_logstring( pxLog, (signed portCHAR *)acLogString ); /* 2) Free the log structure. */ vdatalog_log_free( pxLog ); // Free the log. /* 3) Write the log to the file. */ iLogStringLen = strlen( acLogString ); if( iLogStringLen != write( fd_current_logfile, acLogString, iLogStringLen ) ) break; // NOTE: if the write failed, we'd rather stop the current write session // and start on solid ground later. } } // Give processor time to the other tasks. vTaskDelayUntil( &xLastFocusTime, ( portTickType )TASK_DELAY_MS(20) ); } if( -1 != fd_current_logfile ) { // Get the current time in the "YYYYMMDDHHMMSSMS" string format. v_cptime_GetDateInFatStringFormat( pcTempoDate ); // Set the file date. nav_file_dateset( (FS_STRING)pcTempoDate, FS_DATE_LAST_WRITE ); close( fd_current_logfile ); // Close the log file. } }