trouble using _lwlog_write() in a loop with a _time_delay()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

trouble using _lwlog_write() in a loop with a _time_delay()

979 次查看
georgejoseph
Contributor III

I'm trying to use the log feature of MQX. I'm finding that when I use the _time_delay() function inside my loop the _lwlog_write() function fails. The 2nd time through the loop the log_component_ptr->LOGS[log_number].FLAGS in the function _lwlog_write_internal(...) indicates that the log is disabled. I don't understand why. If don't use the time delay it works fine.

void * snapshot_data_ptr = 0x60000000;

/* Create the lightweight log component */
result = _lwlog_create_component();
if (result != MQX_OK)
{
_task_block();
}
/* Create a log */
result = _lwlog_create_at(SNAPSHOT_LOG, 1000, LOG_OVERWRITE, snapshot_data_ptr);
if (result != MQX_OK)
{
_task_block();
}
/* Write data to the log */
while(1) // main task loop
{
_time_delay(1);

// Write to log
result = _lwlog_write(SNAPSHOT_LOG, p1, p2, p3, p4, p5, p6  p7);

}

0 项奖励
回复
2 回复数

837 次查看
georgejoseph
Contributor III

Yes I have used  _lwlog_create() successfully as well, but I have a lot of data, and I need to put the log in external ram, so I need the  _lwlog_create_at() to put the log in external ram. I don't know what the difference is. Perhaps it's a memory allocation issue.

0 项奖励
回复

837 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi

I modified the lwlog demo under the MQX installation folder (C:\Freescale\Freescale_MQX_4_2\mqx\examples\lwlog), put _lwlog_write in a while loop. My result is it can work with time_delay. The only difference is I use _lwlog_create ,  and you use _lwlog_create_at.

  /* Create the lightweight log component */
   result = _lwlog_create_component();
   if (result != MQX_OK) {
      printf("Main task: _lwlog_create_component failed.");
      _task_block();
   }

 
   /* Create a log */
   result = _lwlog_create(MY_LOG, 10, LOG_OVERWRITE );
   if (result != MQX_OK) {
      printf("Main task: _lwlog_create failed.");   
      _task_block();  
   }

    c = 'd';
    while (1)
     {  
          result = _lwlog_write(MY_LOG, (_mqx_max_type)c,
         (_mqx_max_type)i, 0, 0, 0, 0, 0);
        if (result != MQX_OK)
               printf("write failed.\r\n");
       else
            printf("  write success!! \r\n");

       _time_delay(1000);      
 
     }
     

Regards

Daniel

0 项奖励
回复