This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Set Osal Events

Hi all, I´m trying to set diferent Osal events, but when I set the first event, I can´t set the other events, my idea is set the second event inside of different .c archive that is called by the first event:

In SampleApp.c

osal_set_event ( PUBLIC_task_id_contratador, EVENT_contratation_start); // event of contratador.c

In contratador.c

osal_set_event ( PUBLIC_task_id_comunicador, EVENT_comunication_start);

  • I would like to help you but do not understand your problem. Could you explain it more specifically?

  • Hi my problem is:

    1. I have to active a OsalEvent (I´m using SampleApp of Zstack), I´m doing that using: osal_set_event ( PUBLIC_task_id_contratador, EVENT_contratation_start). This event is in contratador.c file.


    2. Once I active this event, inside of the event I have to do something like that:

    if (events & EVENT_contratation_start){

            osal_set_event ( PUBLIC_task_id_comunicador, EVENT_comunication_start) // this event is in comunicador.c file

    return ( events ^ EVENT_contratation_start);

    }

    3. Inside of comunicador.c file, I have to do a similar proccess.

    Only the first event is set.

    This is the problem.

  • This is because that your "osal_set_event ( PUBLIC_task_id_comunicador, EVENT_comunication_start) // this event is in comunicador.c file" in EVENT_contratation_start event will be reset right after "return ( events ^ EVENT_contratation_start);".  Try to replace the following codes in your event.

    if (events & EVENT_contratation_start){

            osal_start_timerEX( PUBLIC_task_id_comunicador, EVENT_comunication_start, 500);

    return ( events ^ EVENT_contratation_start);

    }

  • Hi Yikai, so, I have to do that:

    In SampleApp.c

    osal_set_event ( PUBLIC_task_id_contratador, EVENT_contratation_start);

    In contratador.c

    if (events & EVENT_contratation_start){

            osal_start_timerEX( PUBLIC_task_id_comunicador, EVENT_comunication_start, 500);

    return ( events ^ EVENT_contratation_start);

    }

    And again in sampleApp.c if I want to do something with EVENT_contratation_start, I have to do:

    SampleaApp.c

    if (EVENT_contratation_start)==1{

     HalLcdWriteString (" It Works     ", HAL_LCD_LINE_1);

    }else

    {

     HalLcdWriteString ("     =(   ", HAL_LCD_LINE_1);

    }

    Is correct???

    It doesn´t work, any Idea?

  • According to TI osal infrastructure, all events should be handled insides SampleApp_ProcessEvent in SampleApp.c. How could you put your event handling in another C, which is contratador.c in your case? These fragment source codes are not sufficient for me to help you.

  • I want to do a process inside of different .c archives, for example:

    in SampleApp.c, I want to active a osal event , and then, using the return ( events ^ EVENT_........................); active a process in SampleApp.c

    Is posible???

    What I have to change???

    In Zip Archive is the code.7534.Yikai Code.zip

  • I just have a look at your attachment and your codes are just too erratic. I have no idea about your intention. Could you describe why you want to do that? Maybe we can find out another approach to do that.

  • I´m trying to do the first phase of a control aplication, I need to make pieces of code that can to be independent, I need to manage code like components. 

  • The whole infrastructure of ZStack has already been broken down into components already. SimpleApp.c is the component for application and SampleApp_ProcessEvent is for application to handle events.

  • Is true, though I´m not sure how can I do to add code automatically. My idea is that the sw can change depending on the purpose of it, I want to make a software that allows for control over different applications, this sw has to add components when required by each application.

  • I still don't understand your intention. There is nothing wrong with the infrastructure of TI ZStack. I have looked at other ZStack implementation and all are similar. I would suggest you to study deeply into the documents and examples. Try to be familiar with and get used to TI ZStack.

  • Well, maybe is the way that I´m trying to work, please help me with this:

    if ( keys & HAL_KEY_SW_4 )
    {

    SampleApp_SendPeriodicMessage();

    }

    uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )
    {

          if ( events & EVENT_contratation_start )
          {

                HalLcdWriteString ("CONTRATANDO ", HAL_LCD_LINE_1);

               SampleApp_ComPeriodicMessage( );

                return ( events ^ EVENT_contratation_start);

        }

       if ( events & EVENT_comunication_start )
       {

           HalLcdWriteString ("COMUNICANDO", HAL_LCD_LINE_3);

          return ( events ^ EVENT_comunication_start);

       }

    }

    void SampleApp_SendPeriodicMessage(void )
    {

              if (SampleApp_NwkState == DEV_END_DEVICE){
                     osal_start_timerEx (SampleApp_TaskID, EVENT_contratation_start, 300);

    }       

    void SampleApp_ComPeriodicMessage(void ){

       osal_stop_timerEx (SampleApp_TaskID, EVENT_contratation_start);
       osal_start_timerEx (SampleApp_TaskID, EVENT_comunication_start, 300);

    }

    I want to set diferent flags, but I'm not sure that's the right way...

  • After having a look at your code, I conjecture that it would work like the followings:

    Once SW key 4 is pressed, it will trigger EVENT_contratation_start event after 300ms. Then, EVENT_comunication_start event will triggered after 300 ms once EVENT_contratation_start is triggered.

    Is this the behavior you expected?

  • Then, what do you need next?

  • I have to set different events, in each event I present some message and calculate the value of different variables, later I send messages using AF_Data_Request...

  • You can do that in the source codes that you posted. Is there any further problem?

  • Yes, I just can set the first event, when I try to set the second event (Event_comunication_start), it is not activate.

  • What are your definition of EVENT_contratation_start and  EVENT_comunication_start? 

  • #define EVENT_comunication_start 0x0001

    #define EVENT_contratation_start 0x0002

    This events are defined in comunicador.h and contratador.h

  • I don't see any reason why it does not work. By the way, what do you mean Event_comunication_start is not activated? Do you want to attaced whole source code to me to analyze?

  • The code... Some things still in development.

    8510.SampleApp.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /**************************************************************************************************
    Filename: SampleApp.c
    Revised: $Date: 2009-03-18 15:56:27 -0700 (Wed, 18 Mar 2009) $
    Revision: $Revision: 19453 $
    Description: Sample Application (no Profile).
    Copyright 2007 Texas Instruments Incorporated. All rights reserved.
    IMPORTANT: Your use of this Software is limited to those specific rights
    granted under the terms of a software license agreement between the user
    who downloaded the software, his/her employer (which must be your employer)
    and Texas Instruments Incorporated (the "License"). You may not use this
    Software unless you agree to abide by the terms of the License. The License
    limits your use, and you acknowledge, that the Software may not be modified,
    copied or distributed unless embedded on a Texas Instruments microcontroller
    or used solely and exclusively in conjunction with a Texas Instruments radio
    frequency transceiver, which is integrated into your product. Other than for
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • You only call SampleApp_ComPeriodicMessage when "if (w == w1) " and "if (w > T[p])". If these two rules are not meet, the EVENT_comunication_start won't be triggered. Could you set break points inside these two rules and make sure your code will call SampleApp_ComPeriodicMessage?