BUG REPORT multi periodic app_easy_timer callback bug

12 posts / 0 new
Last post
toughworld
Offline
Last seen:3 years 4 months ago
加入:2015-05-12 09:55
BUG REPORT multi periodic app_easy_timer callback bug

I have 3 Timer declared by app_easy_time.one is periodic by one second , the second one is called in some occasion, the last one is call evey 30 second at random time.
With this three timer,the second timer callback is called not correctly ocassionly .I believe it is called by the first periodic timer.
If i use only the first two timer ,eveything seems ok.

update: some simplified code ilustrting my timer setup,the wrongly triggerd hanler problem was my fault,but another problem occurs.

static void app_watchdog_second_timer_handler() //call every second,
{
second_coun++;
APP_WATCHDOG_SECOND_TIMER = app_easy_timer(100 , app_watchdog_second_timer_handler); //1000 ms

if(second_count == 10)
{
uint32_t delay = (co_rand_byte() % 20) * 10 + 30 ;
APP_SEND_DATA_TIMER = app_easy_timer( delay, sendSensorDataHandler);

}

if(second_count == 30) // a period is 30 second
{
second_coun = 0;
}

}

void sendSensorDataHandler(void) // call once in a period
{
APP_SEND_DATA_TIMER = EASY_TIMER_INVALID_TIMER; //this line address my previous problem ,now timer trigger the correct handler
}

void resetSendData(void) //triggerd in some conditon
{
if( APP_SEND_DATA_TIMER != EASY_TIMER_INVALID_TIMER) //this line address my previous problem ,now timer trigger the correct handler
{
// ----------another problem occur here ,this functionocassionly delete my APP_WATCHDOG_SECOND_TIMER resulting no timers running ,and I check the timer_callbacks[APP_TIMER_MAX_NUM] ,empty

APP_SEND_DATA_TIMER = app_easy_timer_modify(APP_SEND_DATA_TIMER , RESET_SEND_DATA_TIME + (co_rand_byte() % 20) * 10);
}

}

Keywords:
Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi toughworld,

Hi toughworld,

Can you give me some more details about your setup? I set 3 timers 1) 60 seconds, 2) 30 seconds and 3) incremented delay. All of them seem to went of on time. In your test, if i undestood correctly it seems that one timer triggers the wrong handler, is that correct ?

Thanks MT_dialog

toughworld
Offline
Last seen:3 years 4 months ago
加入:2015-05-12 09:55
thank you ,I have upload some

thank you ,I have upload some simplified code ilustrting my timer setup,the wrongly triggerd hanler problem was my fault,but another problem occurs,
by the way,in csr api, callback have timerid parameter for avoid racing coditon,in easy timer,is it ok without this?
typedef void( * timer_callback_arg)(timer_id const )
timer_id TimerCreate ( uint32 const time,bool const relative,timer_callback_arg handler )

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi toughworld,

Hi toughworld,

If i undestood correctly the app_easy_timer_modify(); instead of modifying your timer it deletes another timer ? Are you able to verify the value that passes to the app_easy_timer_modify and check the id of the handler passed to function. I ve tried the app_easy_timer_modify, it doesn't cancel the timer. You can try implement something simpler in order to try like this:

void testing_timer_handler1(void)
{
testing_timer1 = EASY_TIMER_INVALID_TIMER;
if (testing_timer!=EASY_TIMER_INVALID_TIMER)
{
testing_timer = app_easy_timer_modify(testing_timer, RESET_SEND_DATA_TIME + (co_rand_byte()%20)*10);
}
testing_timer1 = app_easy_timer(60,testing_timer_handler1);
}

void testing_timer_handler(void)
{
if (testing_timer!=EASY_TIMER_INVALID_TIMER)
{
testing_timer = EASY_TIMER_INVALID_TIMER;
arch_set_pxact_gpio();
}
}

Thanks MT_dialog

Mahesh
Offline
Last seen:3 years 3 months ago
加入:2016-01-04 14:03
Hi,

Hi,
I am using SDK 5.0.3 software on DA14583DEVKT-B board.
I have taken the "ble_app_peripheral" (BLE example projects given).

Modified to support two characteristics. Need to send the data at every 10 milli seconds and 30 milli seconds through characteristics 1 and characteristics 2 respectively to the mobile.

In every one cycle operation, I need to get the 1 packet of data-I and 3 packets of data-II (i.e. for the duration of 30 milli seconds). But I am receiving 1 packet of data-1 and 2 packets of data-II.
"app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY, DataVal1TimerCbHandler)"" and "app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY2, DataVal2TimerCbHandler)" are used to trigger the periodic call.

Please help me to resolve the issue.

Regards,
Mahesh Chandana.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Mahesh,

Hi Mahesh,

Please check the following posthttp://support.dialog-semiconductor.com/whats-kernel-timer-accuracy.

Thanks MT_dialog

Mahesh
Offline
Last seen:3 years 3 months ago
加入:2016-01-04 14:03
Hi,

Hi,
I am using "ble_app_peripheral" (BLE example projects given) code.
I need following information which will be useful
1. As of now I can able achieve minimum 10 millisecond only. Is there any possibility to increase the scheduling frequency of the kernel timer (i.e. app_easy_timer() ).
2. I wish to use the queue implementation in my application. Please guide me how to create and use the queue.
3.As per my application requirement, I need to send the sensor data to to Kernel (for transmission through BLE), when ever the data is available. whether I can call "ke_msg_send(req)" when ever I have the sensor data. Is any constrains and limitation are there. What is the minimum time required between two successive packet or message to the kernel.

Regards,
Mahesh Chandana.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Mahesh,

Hi Mahesh,

1. I dont get what you mean by scheduling frequency, all the messages are scheduled when the code goes through the rwip_schedule() in the main loop. There is no way to increase the resolution of the kernel timer at the moment, if that is what you mean.

2. You can find information regarding the RW kernel in the RW-BT-KERNEL-SW-FS.

3.正如上面我已经提到,消息the kernel are scheduled through the rwip_schedule(), how frequent this function executes depends on the that loop, if the system decides to go to sleep or not and the functionallity of the app_asynch_trm() function (app_on_ble_powered). If the app_on_ble_powered return GOTO_SLEEP the device will continue, make the appropriate sleep checks and go into sleep, if it returns KEEP_POWERED this will force the scheduler to run again.

Thanks MT_dialog

Mahesh
Offline
Last seen:3 years 3 months ago
加入:2016-01-04 14:03
Hi,

Hi,
Thank you for quick response.
Is it possible to send multiple (i.e. more than one) notification data in single connection interval.

Regards,
Mahesh Chandana.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Mahesh,

Hi Mahesh,

Yes its possible, you dont have to do anything special, just send the notifications in the interval you would like and the stack will send more that one packets if more than one notifications are available in the queue. Regarding how many packets can be sent in one connection interval please check the next threadhttp://support.dialog-semiconductor.com/number-packets-connection-event.

Thanks MT_dialog

Mahesh
Offline
Last seen:3 years 3 months ago
加入:2016-01-04 14:03
Hi,

Hi,
when ever I am sending enable Notification (ie. write request (ie. 1 value)from the mobile to the server), it is receivable at the server side (i.e. at user_catch_rest_hndl() ). but when ever I am sending the disable notification (i.e. Write request (i.e. 0 value) from mobile to server), I am not able to receive at server side (i.e. user_catch_rest_hndl() ).

I need indication (at server side) when ever I am receiving disable notification. I am suspecting it is handling in the kernel level itself.
How I can identify the reception of disable notification.

Regards,
Mahesh Chandana.

MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi Mahesh,

Hi Mahesh,

When a central writes on a characteristic you get an indication at the application, for example in the ble_app_peripheral project you should be able to catch the CUST1_IDX_ADC_VAL_1_NTF_CFG case in the user_catch_rest_hndl() function, when you get this indication to your application you can check if the value of the parameter has a PRF_CLI_START_NTF or a PRF_CLI_STOP_NTFIND.

Thanks MT_dialog