Events keep on generating | developer.brewmp.com Events keep on generating | developer.brewmp.com

Developer

Events keep on generating

Forums:

Hi Friends,
I am developing an application using 3.1.5 SDK and the simulator. I am facing an issue which looks very weird for me, please excuse.
When I press a soft key or any key the event generates EVT_KEY.But instead of generating only once It keeps on generating many times ( counted not less than 25)and the whole implementation I have written crashes. The same Evt with same wParam and dwParam is auto generated again. I checked with the code and tried a sample C file there too I get the same error.
As far as I know from my past experiance only one EVT_KEY event with the same wParam and dwParam should be generated. Is this problem a desired feature or I am making some settings wrong. All the apps which I have developed is giving the same error . So I do really think I am not setting something right. The apps which I believed working fine is also getting the same issues.
I hope some of them will be facing the same problem as I have written a simple menu program and there too the same problem is encoutered. If this is desired then how to handle the app events?
Please suggest how to handle this situvation.

Thanks in Advance
Jacob

Abraham Jacob M wrote:Hi Friends,
I am developing an application using 3.1.5 SDK and the simulator. I am facing an issue which looks very weird for me, please excuse.
When I press a soft key or any key the event generates EVT_KEY.But instead of generating only once It keeps on generating many times ( counted not less than 25)and the whole implementation I have written crashes. The same Evt with same wParam and dwParam is auto generated again. I checked with the code and tried a sample C file there too I get the same error.
As far as I know from my past experiance only one EVT_KEY event with the same wParam and dwParam should be generated. Is this problem a desired feature or I am making some settings wrong. All the apps which I have developed is giving the same error . So I do really think I am not setting something right. The apps which I believed working fine is also getting the same issues.
I hope some of them will be facing the same problem as I have written a simple menu program and there too the same problem is encoutered. If this is desired then how to handle the app events?
Please suggest how to handle this situvation.
Thanks in Advance
Jacob
You need to handle the event faster. If you spend too long handling an EVT_KEY then the OS will not get round to processing the key up, and consequently will generate another EVT_KEY, because it looks like a long keypress.
If you breakpoint your handling of EVT_KEY, then you're taking an effectively infinite time to process it, so unfortunately the problem gets worse the more you look at it.

Abraham Jacob M wrote:Hi Friends,
I am developing an application using 3.1.5 SDK and the simulator. I am facing an issue which looks very weird for me, please excuse.
When I press a soft key or any key the event generates EVT_KEY.But instead of generating only once It keeps on generating many times ( counted not less than 25)and the whole implementation I have written crashes. The same Evt with same wParam and dwParam is auto generated again. I checked with the code and tried a sample C file there too I get the same error.
As far as I know from my past experiance only one EVT_KEY event with the same wParam and dwParam should be generated. Is this problem a desired feature or I am making some settings wrong. All the apps which I have developed is giving the same error . So I do really think I am not setting something right. The apps which I believed working fine is also getting the same issues.
I hope some of them will be facing the same problem as I have written a simple menu program and there too the same problem is encoutered. If this is desired then how to handle the app events?
Please suggest how to handle this situvation.
Thanks in Advance
Jacob
You need to handle the event faster. If you spend too long handling an EVT_KEY then the OS will not get round to processing the key up, and consequently will generate another EVT_KEY, because it looks like a long keypress.
If you breakpoint your handling of EVT_KEY, then you're taking an effectively infinite time to process it, so unfortunately the problem gets worse the more you look at it.

But my event is connecting to a socket and writing into it after getting some information from some database which leads to opening of a file from where the data is read to send thru the connection. So do you mean like I cannot use so long procedure to get it written in the Handle Event. I never faced this problem before. This is my first app with 3.x
Then how do I implement this logic
Thanks for suggestions in Adavance
Jacob

But my event is connecting to a socket and writing into it after getting some information from some database which leads to opening of a file from where the data is read to send thru the connection. So do you mean like I cannot use so long procedure to get it written in the Handle Event. I never faced this problem before. This is my first app with 3.x
Then how do I implement this logic
Thanks for suggestions in Adavance
Jacob

Abraham Jacob M wrote:But my event is connecting to a socket and writing into it after getting some information from some database which leads to opening of a file from where the data is read to send thru the connection. So do you mean like I cannot use so long procedure to get it written in the Handle Event. I never faced this problem before. This is my first app with 3.x
Then how do I implement this logic
Thanks for suggestions in Adavance
Jacob
You could run this code in a callback, start a thread, or throw yourself another event in the EVT_USER range. It doesn't matter how you do it, so long as you return from the EVT_KEY handler fast enough.

Abraham Jacob M wrote:But my event is connecting to a socket and writing into it after getting some information from some database which leads to opening of a file from where the data is read to send thru the connection. So do you mean like I cannot use so long procedure to get it written in the Handle Event. I never faced this problem before. This is my first app with 3.x
Then how do I implement this logic
Thanks for suggestions in Adavance
Jacob
You could run this code in a callback, start a thread, or throw yourself another event in the EVT_USER range. It doesn't matter how you do it, so long as you return from the EVT_KEY handler fast enough.

Thanks Ben
But will it be the same in the device too?.
This sounds little abnormal. Already my code is quite big with around 40 files and pretty much number of user events too.And this makes it more complex as it is difficult to handle and give them names which is always confusing.
I am surprised that I never come across such a situvation during the previous applications. So do I have to go there too and change them like Ben has suggested?.
Thank you very much Ben for your quick response
Jacob

Thanks Ben
But will it be the same in the device too?.
This sounds little abnormal. Already my code is quite big with around 40 files and pretty much number of user events too.And this makes it more complex as it is difficult to handle and give them names which is always confusing.
I am surprised that I never come across such a situvation during the previous applications. So do I have to go there too and change them like Ben has suggested?.
Thank you very much Ben for your quick response
Jacob

Also another issue is that the events are carried over to the new forms where it is just created and the next form is tried to create and everything crashes. How to handle those situvations.
I dont know this feature looks very weird and I never experianced this feature before except now. I feel so strange.
Please help to get thru this predicaments
I hope I have to change the whole event handling part of my code
Thanks
Jacob

Also another issue is that the events are carried over to the new forms where it is just created and the next form is tried to create and everything crashes. How to handle those situvations.
I dont know this feature looks very weird and I never experianced this feature before except now. I feel so strange.
Please help to get thru this predicaments
I hope I have to change the whole event handling part of my code
Thanks
Jacob

Just use ISHELL_Resume().

Just use ISHELL_Resume().

I feel I should explan the whole situvation.This is what I am facing...
I am in a form. Say start form. When I click on the AVK SOFT 1 ( Left Soft key) as (I am using UI forms and widgets) the app connects to the server. As Ben has suggested I am immediately returning after registering(ISHELL_PostEvent) a user event from the SOFT KEY 1and this event takes care of the connection and sending of data.
In the call back I am listening for data and once data arrived another user event called DataarrivedEvent is generated from where I am calling another form say MainMenuForm.
Now the problem is immedialtely after the MainMenuform is created ( constructor called) the EVT_KEY , AVK_SOFT key1 is generated automatically without the any key intervension. and the code which I have written for AVK_SOFT key 1 in handle event of the MainMenuForm is called and everytime the first item value of the mainMenu Form will be send which too will return False at some point as some variables are empty.
Where is this EVT_KEY , AVK_SOFT key1 is getting generated in the MainMenuForm?.Is it from the start form? But I have already returned from the AVK_SOFT key1 of the start form :confused:
I written the ISHELL_Resume as Max has suggested before creation of the Main Form but still the same.Where should I write the ISHELL_Resume?. Please help with your suggestions how to proceed
Thanks in Advance
Jacob

I feel I should explan the whole situvation.This is what I am facing...
I am in a form. Say start form. When I click on the AVK SOFT 1 ( Left Soft key) as (I am using UI forms and widgets) the app connects to the server. As Ben has suggested I am immediately returning after registering(ISHELL_PostEvent) a user event from the SOFT KEY 1and this event takes care of the connection and sending of data.
In the call back I am listening for data and once data arrived another user event called DataarrivedEvent is generated from where I am calling another form say MainMenuForm.
Now the problem is immedialtely after the MainMenuform is created ( constructor called) the EVT_KEY , AVK_SOFT key1 is generated automatically without the any key intervension. and the code which I have written for AVK_SOFT key 1 in handle event of the MainMenuForm is called and everytime the first item value of the mainMenu Form will be send which too will return False at some point as some variables are empty.
Where is this EVT_KEY , AVK_SOFT key1 is getting generated in the MainMenuForm?.Is it from the start form? But I have already returned from the AVK_SOFT key1 of the start form :confused:
I written the ISHELL_Resume as Max has suggested before creation of the Main Form but still the same.Where should I write the ISHELL_Resume?. Please help with your suggestions how to proceed
Thanks in Advance
Jacob

That should work...are you doing anything on EVT_KEY_PRESS?

That should work...are you doing anything on EVT_KEY_PRESS?

I am returning true for KEY_PRESS if it is AVK_SELECT
This is my code
Quote:void MyApp::FormCB(void * pdata)//call back function
{
MyApp * pMe = (MyApp*)pdata;
if( pMe->formStack->GetTop()->GetFormID() == ProgressFormID)
pMe->SendEvent(EvtCloseForm, NULL, NULL);
pMe->formStack->Push(new MainMenuForm(pMe->m_pIShell, "Baytracker", "Select","Options"));

This is how I am using the ISHELL_Resume when I get an event from the server.
Quote:
boolean MainMenuForm::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
MyApp * pMe = (MyApp*)GETAPPINSTANCE();
switch(eCode)
{
case EVT_KEY:
switch(wParam)
{
case AVK_SOFT1:
{
pMe->PostEvent(EvtKeyListRequest, itemid, NULL);
return TRUE;
}
case AVK_SOFT2:
{
char * MainMenuFormPopUpMenu[3] = { "Refresh", "Logout", "Help"};
pMe->formStack->Push(new PopUpMenuForm(pMe->m_pIShell, &MainMenuFormPopUpMenu[0], 3, (PFNSELECT)MainFormPopUpHandler, (void*)this));
return TRUE;
}
default:
break;
}
case EVT_KEY_PRESS:
{
if( wParam == AVK_SELECT)
return TRUE;
break;
}
default:
break;
}
return Form::HandleEvent(eCode, wParam, dwParam);

Form is a class from which all the custom forms are derived( using UI forms and widgets).
When the first function is executed the control directly ( without any key intervension comes to the MainMenuForm::HandleEvent immediatly after the constructor is called and the first menu item where the current focus is, its item id is send to EvtKeyListRequest where it returns false as some variables in the form is NULL.
This is what I am facing now
I dont understand where that key event is being generated
Also please say whether the way I am using the ISHELL_Resume is correct or not
Thanks in Advance
Jacob

I am returning true for KEY_PRESS if it is AVK_SELECT
This is my code
Quote:void MyApp::FormCB(void * pdata)//call back function
{
MyApp * pMe = (MyApp*)pdata;
if( pMe->formStack->GetTop()->GetFormID() == ProgressFormID)
pMe->SendEvent(EvtCloseForm, NULL, NULL);
pMe->formStack->Push(new MainMenuForm(pMe->m_pIShell, "Baytracker", "Select","Options"));

This is how I am using the ISHELL_Resume when I get an event from the server.
Quote:
boolean MainMenuForm::HandleEvent(AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
MyApp * pMe = (MyApp*)GETAPPINSTANCE();
switch(eCode)
{
case EVT_KEY:
switch(wParam)
{
case AVK_SOFT1:
{
pMe->PostEvent(EvtKeyListRequest, itemid, NULL);
return TRUE;
}
case AVK_SOFT2:
{
char * MainMenuFormPopUpMenu[3] = { "Refresh", "Logout", "Help"};
pMe->formStack->Push(new PopUpMenuForm(pMe->m_pIShell, &MainMenuFormPopUpMenu[0], 3, (PFNSELECT)MainFormPopUpHandler, (void*)this));
return TRUE;
}
default:
break;
}
case EVT_KEY_PRESS:
{
if( wParam == AVK_SELECT)
return TRUE;
break;
}
default:
break;
}
return Form::HandleEvent(eCode, wParam, dwParam);

Form is a class from which all the custom forms are derived( using UI forms and widgets).
When the first function is executed the control directly ( without any key intervension comes to the MainMenuForm::HandleEvent immediatly after the constructor is called and the first menu item where the current focus is, its item id is send to EvtKeyListRequest where it returns false as some variables in the form is NULL.
This is what I am facing now
I dont understand where that key event is being generated
Also please say whether the way I am using the ISHELL_Resume is correct or not
Thanks in Advance
Jacob