An unhandled win32 exception occurred in BREW_Simulator | developer.brewmp.com An unhandled win32 exception occurred in BREW_Simulator | developer.brewmp.com

Developer

An unhandled win32 exception occurred in BREW_Simulator

Forums:

Hi,

While running the code below, I got the error message. Any thoughts?

Thanks,

Tulio

errro*********************************************

---------------------------
Visual Studio Just-In-Time Debugger
---------------------------
An unhandled win32 exception occurred in BREW_Simulator.exe [2432]. Just-In-Time debugging this exception failed with the following error: No installed debugger has Just-In-Time debugging enabled. In Visual Studio, Just-In-Time debugging can be enabled from Tools/Options/Debugging/Just-In-Time.

Check the documentation index for 'Just-in-time debugging, errors' for more information.
---------------------------
error ends*********************************************

Code starts*******************************************

#include "AEEAppGen.h"
#include "helloworld.bid"
#include "AEEFile.h"
#include "AEEImageCtl.h"
#include "AEEPosDet.h"
#include "AEEWeb.h"
#include "AEEStdLib.h"
#include "stdio.h"

#define FORALL(p,a) for (p = (a) + ARRAY_SIZE(a) - 1; p >= (a); --p)
#define FOR_ALL_WEBACTIONS(pApp, var, exp) {WebAction *var; FORALL(var, (pApp)->m_awa) { exp; } }

typedef struct _CHelloWorldApp CHelloWorldApp;

typedef struct WebAction
{
CHelloWorldApp * pParent;
AEECallback cb;

IWebResp * piWResp;
IGetLine * piGetLine;
int nLines;
int nBytes;

uint32 uStart;
uint32 uRecvStart;

IPeek *pipPostData;
char *pszPostData;

} WebAction;

struct _CHelloWorldApp
{
AEEApplet a;
IFileMgr * m_pFileMgr;
IWeb * m_pIWeb;
IPosDet * m_pIPosDet;
ISource * m_pISource;
IImageCtl * m_pIImage;
AEEGPSInfo * m_pGPSinfo;
AEECallback m_cbgps;
AEECallback m_cbimg;
WebAction m_awa[1];
;

char serviceURL[100];
IFile * file;

static boolean HelloWorld_HandleEvent(CHelloWorldApp * pme, AEEEvent eCode,uint16 wParam, uint32 dwParam);

static boolean InitAppData(CHelloWorldApp * pApp)
{
IShell * pIShell = pApp->a.m_pIShell;
int code = 0;

if( (ISHELL_CreateInstance(pIShell, AEECLSID_FILEMGR, (void**)(&pApp->m_pFileMgr)) != SUCCESS) ||
(ISHELL_CreateInstance(pIShell, AEECLSID_WEB, (void **)(&pApp->m_pIWeb)) != SUCCESS) ||
(ISHELL_CreateInstance(pIShell, AEECLSID_POSDET, (void **)(&pApp->m_pIPosDet)) != SUCCESS) ||
(ISHELL_CreateInstance(pIShell, AEECLSID_IMAGECTL, (void**)(&pApp->m_pIImage)) != SUCCESS))
{
IAPPLET_Release((IApplet*)pApp);
return FALSE;
}

{
int i = 0;
WebOpt awo[10];

awo[i].nId = WEBOPT_CONNECTTIMEOUT;
awo[i].pVal = (void *)10000;
i++;

awo[i].nId = WEBOPT_FLAGS;
awo[i].pVal = (void *)WEBREQUEST_NOWAITCONN;
i++;

awo[i].nId = WEBOPT_PROXYSPEC;
awo[i].pVal = (void *)"http:///";
i++;

awo[i].nId = WEBOPT_PROXYSPEC;
awo[i].pVal = (void *)"*:///http://webproxy.yourdomain.com:8080";
i++;

awo[i].nId = WEBOPT_END;

IWEB_AddOpt(pApp->m_pIWeb,awo);
}

FOR_ALL_WEBACTIONS(pApp, p, p->pParent = pApp);

return TRUE;

int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * pMod,void ** ppObj)
{
CHelloWorldApp * pApp = NULL;
*ppObj = NULL;

if(!AEEApplet_New( sizeof(CHelloWorldApp),
ClsId,
pIShell,
pMod,
(IApplet**)ppObj,
(AEEHANDLER)HelloWorld_HandleEvent,
NULL))
return(ENOMEMORY);

pApp = (CHelloWorldApp *)*ppObj;

if (!InitAppData(pApp)) {
*ppObj = NULL;
return EFAILED;
}

return(AEE_SUCCESS);

static void imgCallback(void * p) {

int bytesRead;
char x[100];
IImage* pSplash = NULL;
AEEImageInfo rImageInfo;
CtlAddItem ci;
AEERect rc;
CHelloWorldApp * pApp = (CHelloWorldApp *)p;

bytesRead = ISOURCE_Read(pApp->m_pISource, x, 100);

while (bytesRead != ISOURCE_END && bytesRead != ISOURCE_ERROR) {

if (bytesRead != ISOURCE_WAIT)
IFILE_Write(file, x, bytesRead);
else {
ISOURCE_Readable(pApp->m_pISource, &pApp->m_cbimg);
return;
}

bytesRead = ISOURCE_Read(pApp->m_pISource, x, 100);

}

IFILE_Release(file);

if (bytesRead != ISOURCE_ERROR) {
if( (pSplash = ISHELL_LoadImage(pApp->a.m_pIShell,"map.png") ) != NULL)
{
IIMAGE_GetInfo(pSplash, &rImageInfo);
IDISPLAY_ClearScreen(pApp->a.m_pIDisplay);

MEMSET(&ci,0,sizeof(ci));
ci.pImage = pSplash;
rc.x = 0;
rc.y = 0;
rc.dx = 120;
rc.dy = 140;

IIMAGECTL_SetProperties(pApp->m_pIImage,CP_BORDER);
IIMAGECTL_SetRect(pApp->m_pIImage, &rc);
IIMAGECTL_SetImage(pApp->m_pIImage,pSplash);
IIMAGECTL_SetActive(pApp->m_pIImage,TRUE);
IIMAGECTL_Redraw(pApp->m_pIImage);

IIMAGE_Release(pSplash);
IDISPLAY_Update(pApp->a.m_pIDisplay);

return;
}
}

}

static void WebAction_GotResp(void *p)
{
WebAction *pwa = (WebAction *)p;
CHelloWorldApp * pApp = pwa->pParent;
WebRespInfo *pwri;

pwri = IWEBRESP_GetInfo(pwa->piWResp);

pApp->m_pISource = pwri->pisMessage;

IFILEMGR_Remove(pApp->m_pFileMgr, "map.png");
file = IFILEMGR_OpenFile(pApp->m_pFileMgr, "map.png", _OFM_CREATE);

CALLBACK_Init(&pApp->m_cbimg,imgCallback,pApp);
ISOURCE_Readable(pApp->m_pISource, &pApp->m_cbimg);

static void WebAction_Start(WebAction *pwa, char *pszUrl)
{
CHelloWorldApp * pApp = pwa->pParent;

CALLBACK_Init(&pwa->cb, WebAction_GotResp, pwa);

IWEB_GetResponse(pApp->m_pIWeb,
(pApp->m_pIWeb, &pwa->piWResp, &pwa->cb, pszUrl,
WEBOPT_HANDLERDATA, pwa,
WEBOPT_HEADER, "X-Method: GET\r\n",
WEBOPT_END));

static void gpsCallback (void * p) {

CHelloWorldApp * pApp = (CHelloWorldApp *)p;

sprintf(serviceURL, "http://localhost/BREWServer/WebForm1.aspx?latlon=%u^%u", pApp->m_pGPSinfo->dwLat, pApp->m_pGPSinfo->dwLon);

FOR_ALL_WEBACTIONS( pApp, p, WebAction_Start(p, serviceURL) );

}

static boolean HelloWorld_HandleEvent(CHelloWorldApp * pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int code = 0;
AECHAR szText[24];
STR_TO_WSTR("Please Wait", szText, 24);

if (IIMAGECTL_HandleEvent(pMe->m_pIImage, eCode, wParam, dwParam))
return TRUE;

switch (eCode){
case EVT_APP_START:

CALLBACK_Init(&pMe->m_cbgps,gpsCallback,pMe);
pMe->m_pGPSinfo = MALLOC(sizeof(AEEGPSInfo));

code = IPOSDET_GetGPSInfo(pMe->m_pIPosDet,
AEEGPS_GETINFO_LOCATION,
AEEGPS_ACCURACY_HIGHEST,
pMe->m_pGPSinfo,
&pMe->m_cbgps);

IDISPLAY_DrawText(pMe->a.m_pIDisplay,
AEE_FONT_BOLD,
szText,
-1,
0,
0,
NULL,
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->a.m_pIDisplay);

return(TRUE);

case EVT_APP_STOP:
return(TRUE);

default:
break;
}
return(FALSE);

---------------------------

would be easier for you to find the exact line where exception occurs and check the parameters and the pointers, rather than posting wall of text, hoping that someone will go deep into it.

would be easier for you to find the exact line where exception occurs and check the parameters and the pointers, rather than posting wall of text, hoping that someone will go deep into it.

Here is where the error is:
the m_pISource is NULL.
Any thoughts?
ISOURCE_Readable(pApp->m_pISource, &pApp->m_cbimg);

Here is where the error is:
the m_pISource is NULL.
Any thoughts?
ISOURCE_Readable(pApp->m_pISource, &pApp->m_cbimg);

you got some kind of error during communication, no response returned.
check pwri->nCode for the code.

you got some kind of error during communication, no response returned.
check pwri->nCode for the code.