Problem with events using demo hvac for M52259EVB.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problem with events using demo hvac for M52259EVB.

1,609件の閲覧回数
d_vara
Contributor III

I am working with hvac_demo in my M52259EVB.

 

I have a idea to add a extra event and a new task. 

 

I program the new task correctly(TASK_A), and one event to managment any aplication.

I can create the event.

I can open a pointer to set this event from TASK_B. All is right.

But, from TASK_C, I can open pointer and set event, but it does not cause any change in TASK_A. I use the debug aplication, and I can see how the pointer open in TASK_B have a different value with regard to pointer opern in TASK_C.

All can be due to demo program, my eval-license or MQX 3.2 have a bug?

 

If you need the code, said me and I will put it.

Thank you.

0 件の賞賛
3 返答(返信)

510件の閲覧回数
EAI
Contributor IV

Have you looked at the event or lwevent examples in the mqx\examples directory?

 

If that does not help, post your code.

 

0 件の賞賛

510件の閲覧回数
d_vara
Contributor III

Well, my program have 3 task and 2 events.

The first task is "task_shell".

Second task is "task_adc", that manages the eight adc channels.

And  third task is "task_supervise", that manages input datas from eight adc channels, and create log files in USB mass storage.

 

The first event is "event.adc", that connect the three task.

And the second event is "event.supervise", that connect "task_shell" with "task_shell".

 

This is "task_adc" :

 

void adc_task(uint_32 initial_data)
{

 ADC_RESULT_STRUCT data;
 FILE_PTR  f,fadc, fadc0, fadc1, fadc2, fadc3, fadc4, fadc5, fadc6, fadc7;
    //para manejar los canales
    int canal,accion;
    int prueba_mensaje;
    pointer event_ptr;



   
    //inicializa el adc
    printf("\n\n-------------- Begin ADC  --------------\n\n");
    printf("Inicializando dispositivo adc....");
    f = fopen("adc:",&adc_init);
    if(f != NULL)
    {   
        printf("OK.\n");
    }
    else
    {   
        printf("Fallo en la inicialización del dispositivo adc.\n");
        _task_block();//bloqueamos la tarea en caso de fallo.
        fclose(f);
 }

 //arrancamos los punteros a los ficheros
 for (canal=0;canal!=8;canal++)
 {
  printf("Abriendo canal #%d...",canal);
  switch (canal)
     {
    
  case ADC_SOURCE_AN0: fadc=fopen("adc:0",&adc_channel_param0); 
         fadc0=fadc;
         break;
      case ADC_SOURCE_AN1: fadc = fopen("adc:1",&adc_channel_param1);
         fadc1=fadc;
         break;
      case ADC_SOURCE_AN2: fadc = fopen("adc:2",&adc_channel_param2);
         fadc2=fadc;
         break;
      case ADC_SOURCE_AN3: fadc = fopen("adc:3",&adc_channel_param3);
         fadc3=fadc;
         break;
      case ADC_SOURCE_AN4: fadc = fopen("adc:4",&adc_channel_param4);
         fadc4=fadc;
         break;
      case ADC_SOURCE_AN5: fadc = fopen("adc:5",&adc_channel_param5);
         fadc5=fadc;
         break;
      case ADC_SOURCE_AN6: fadc = fopen("adc:6",&adc_channel_param6);
         fadc6=fadc;
         break;
      case ADC_SOURCE_AN7: fadc = fopen("adc:7",&adc_channel_param7);
         fadc7=fadc;
         break;
     }
     if(fadc != NULL)
     {
      printf("correcto, puntero asociado a canal %d OK.\n",canal);
     }
     else
     {
      printf("error, nose ha podido asociar puntero al canal %d",canal);
     }
 }//del for

 //manejamos las peticiones de lectura de los adc´s
 //consideramos que ésta es la función principal donde crear el evento
 //asi se si intenta leer un canal, no se podrá al no existir el evento.
 //usamos el grupo event.adc
 
 // Creamos y abrimos el evento. //Create and open event.
    if (_event_create_auto_clear("event.adc") != MQX_OK)
     {
  printf("\nMake event failed");
  _mqx_exit(0);
 }
   
  if (_event_open("event.adc", &event_ptr) != MQX_OK)
      {
   printf("\nOpen event failed");
   _mqx_exit(0);
  }
 
  //Entremos en bucle infinito hasta la espera de eventos que soliciten una lectura
 while (TRUE)
  {
  prueba_mensaje=_event_wait_any(event_ptr, 0x03, 0);
  if (prueba_mensaje != MQX_OK)
   {
   printf("\nEvento espera   Wait failed");
   if (prueba_mensaje== EVENT_DELETED) printf("Event delete");
   if (prueba_mensaje== EVENT_INVALID_EVENT) printf("Event INVALID");
   if (prueba_mensaje== EVENT_INVALID_EVENT_HANDLE) printf("Event INVALID HANDLE");
   if (prueba_mensaje== EVENT_WAIT_TIMEOUT) printf("Event time out");
   if (prueba_mensaje== MQX_CANNOT_CALL_FUNCTION_FROM_ISR) printf("MQX fallo de ISR");
  
   
    //_mqx_exit(0);
  }
   
 
 ................................................
 
   }//del while

}

I create and open "event.adc". I use "event.ptr". You can view it in colour green.

 

In the "task_supervise", I create "event.sv"

 

void supervise_task(uint_32 initial_data)
{
 ...............
 ADC_RESULT_STRUCT data;

    pointer event_ptr1=0;
    pointer event_ptr2=0;
    int prueba_mensaje;
    data.result=VALOR_NO_VALIDO;
   

 //use event.adc

 // Creamos y abrimos el evento.//Create and open event.sv
     if (_event_create_auto_clear("event.sv") != MQX_OK)
     {
  printf("\nMake event failed");
  _mqx_exit(0);
 }
    if (_event_open("event.sv", &event_ptr1) != MQX_OK)
     {
  printf("\nOpen event failed");
  _mqx_exit(0);
 }
 //Only open "event.adc"
  if (_event_open("event.adc", &event_ptr2) != MQX_OK) //puntero para el evento del adc
 {
  printf("\nOpen Event failed");
  //_mqx_exit(0);
 }
 //Entremos en bucle infinito hasta la espera de eventos que soliciten una lectura
 while (TRUE)
  {
   if (estado==APAGADO)
  {
    prueba_mensaje=_event_wait_all(event_ptr1, 0x01, 0);
   ............................
.......................................................
 

   }//del while

}

 

In this task, I have two pointer to event, event_ptr1 and event_ptr2.

 

In the task_shell, I have another two pointers that open, set and cleart correctly with  "event.adc" and "event.sv".

 

My problem is "even_ptr2" in "task_supervise". I open it (in task_supervise). It does not show error. But it does not set or clear action. I use Debug, and I can see that event_ptr2(of task_supervise) do not point at the same direction of the event: event.ptr(from task_adc).

I think that when I open a event using: 

if (_event_open("event.adc", &event_ptrx) != MQX_OK)

 event_ptrx point at event "event.adc".

And if I use again

if (_event_open("event.adc", &event_ptr_probe) != MQX_OK)

 

 event_ptr_probe point at event "event.adc". I think that both have the same direction in their values.

 

 

 

My problem is that I can set "event.adc" from "task_shell", but I don´t it form "task_supervise". 

 

Very thanks.

 

 

 

0 件の賞賛

510件の閲覧回数
PetrM
Senior Contributor I

Hello,

 

if I understand it right, you create "auto-clear" event and you are trying to react to it in two separate tasks. But since it is "auto-clear" event, only one task catches it (and then clears it). I think, the order is by default FIFO.

 

Regards,

PetrM

 

0 件の賞賛