Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: System hangs... Can help me look at GPSBufferWrite fn.
PostPosted: Fri May 20, 2011 11:04 am 
Offline

Joined: Fri May 20, 2011 10:51 am
Posts: 1
Hi, I am using ublox 5 GPS and Atmel AT91SAM7S512.

basically, the microcontroller needs to perform GPRS vehicle tracking. Not
sure why. Everything runs fine but sometimes, the device just hangs
occasionally after some time.

When i compile eventhandler fn, for GPSBufferWrite(pPsvl, sizeof
(GPS_PSVL)), it returns me with a

passing arg 1 of `GPSBufferWrite" from incompatible pointer type

wonder if someone can help me look through these codes and see if there is
any problem.

thanks a lot

---------------------------------------------------------------------------------------------------------
ECOME_STATUS GPSBufferWrite(char *data, int size)
{
//LOG2("GPSBufferWrite: data = s, size = d", data, size);
//if (ReadGPSLogBufferPointer(&gpsPtr) == COM_SUCCESS)
{
//LOG2("GPSBufferWrite: before, pWrite = d, pRead = d", gpsPtr.pWrite, gpsPtr.pRead);
if ((gpsPtr.pWrite + size) <= MAX_GPS_BUFFER_SIZE)
{
if (EFLASH_Write1(data, DATAFLASH_GPS_FIX_LOG_BUFFERING_DATA_ADDR + gpsPtr.pWrite, size) == COM_SUCCESS)
{
#if 0
// read back verification
char tmpbuf[200]="";
EFLASH_Read
(DATAFLASH_GPS_FIX_LOG_BUFFERING_DATA_ADDR + gpsPtr.pWrite,
tmpbuf, size);
if (strncmp(tmpbuf, data,
size) != 0)
LOG0("***** FLASHING
ERROR *****");

//tmpbuf[16] = 0x0;
//LOG2("GPSBufferWrite:
pwrite = d, data = s", gpsPtr.pWrite, tmpbuf);
#endif

//LOG2("Before
UpdatePointer, pWrite = d, pRead = d", gpsPtr.pWrite, gpsPtr.pRead);
//data[16] = 0x0;
LOG1("pwrite= d",
gpsPtr.pWrite);

#if 1
gpsPtr.pWrite += size;
UpdateGPSLogBufferPointer
(&gpsPtr);
#endif

return (COM_SUCCESS);

}
}
else
{
LOG1("GPSBufferWrite: (gpsPtr.pWrite + size) > MAX_GPS_BUFFER_SIZE,
gpsPtr.pWrite = d", gpsPtr.pWrite);
//gpsPtr.pRead = 0;
gpsPtr.pWrite = 0;
if (EFLASH_Write1(data,
DATAFLASH_GPS_FIX_LOG_BUFFERING_DATA_ADDR + gpsPtr.pWrite,
size) == COM_SUCCESS)
{
gpsPtr.pWrite += size;
UpdateGPSLogBufferPointer
(&gpsPtr);
}
//LOG0("Reset write pointer to 0");
}
}

return (COM_SUCCESS);
}


static GPS_PSVL eventPsvl={0};
extern GPS_PSVL psvl;


void Events_Handler(unsigned int rtcStatus)
{
extern char ringing;
static char prevRinging = 0;
unsigned char emergency3, tamper3, ignition3;

static char flag_triggered = 0;
static char xSampleCount = 0;
static char ySampleCount = 0;
static char zSampleCount = 0;

static char adPowerValue[8];
static char batteryValue[8];
static char adSampCount = 0;

float xdata,ydata,zdata;
unsigned short currSpeed;
GPS_PSVL *pPsvl;
char msgLength;
char xbuf[24];
//char ybuf[24];
//char zbuf[24];
//char mbuf[24];
ESYSS_CONFIG_EVENTS_SETUP1 *p = &sysEventsConfig1;

//if (rtcStatus & RTC_SEC_CHANGE_BIT)
{
memcpy(&eventPsvl,&psvl,sizeof(GPS_PSVL));
pPsvl = &eventPsvl;
}
//accelermeter
if(sysEventsConfig1.enable & EVENT_ACCELERMETER)
{
char xValue =0;
char yValue = 0;
char zValue = 0;

if(flag_triggered)
{
Accelerometor2(&xValue, &yValue,
&zValue);
xdata =255 * 0.66 *
sysEventsConfig1.XLimited / 3.3;
ydata =255 * 0.66 *
sysEventsConfig1.YLimited / 3.3;
zdata =255 * 0.66 *
sysEventsConfig1.ZLimited / 3.3;
//sprintf(xbuf," 3.1f",xdata);
//sprintf(ybuf," 3.1f",ydata);
//sprintf(zbuf," 3.1f",zdata);
//LOG3("xdata= s,ydata= s,zdata=
s",xbuf, ybuf, zbuf);
if(xdata < xValue)
{
flag_triggered = 1;
xSampleCount++;
}
if(ydata < yValue)
{
flag_triggered = 1;
ySampleCount++;
}
if(zdata < zValue)
{
flag_triggered = 1;
zSampleCount++;
}
}

}//accelermeter

//every second
if (rtcStatus & RTC_SEC_CHANGE_BIT)
{
//GPI
emergency3 = (unsigned char)EIO_GetBit(0);
//ETIME_DelayMsec(20);
emergency3 = (unsigned char)EIO_GetBit(0);

ignition3 = (unsigned char)EIO_GetBit(1);
//ETIME_DelayMsec(20);
ignition3 = (unsigned char)EIO_GetBit(1);

tamper3 = (unsigned char)EIO_TamperingCheck();
//ETIME_DelayMsec(20);
tamper3 = (unsigned char)EIO_TamperingCheck();

//emergnecy cal

if(preEmergency == 2)
preEmergency = emergency3;
else if(emergency3 != preEmergency )
{
if(emergency3 == 1)
{
if(sysEventsConfig1.enable &
EVENT_EMERG_CALL)
{
pPsvl->MsgType =
EVENT_EMERG_CALL;
pPsvl->MsgValue
= 0;
utc2LocalTime
(pPsvl);
GPSBufferWrite
(pPsvl, sizeof(GPS_PSVL));
FileLog(pPsvl);
}
}
preEmergency = emergency3;
}

//tamper
if(preTamper == 2)
preTamper = tamper3;
else if(tamper3 != preTamper)
{
if(tamper3 == 1)
{
if(sysEventsConfig1.enable &
EVENT_TAMPER)
{
pPsvl->MsgType =
EVENT_TAMPER;
pPsvl->MsgValue
= 0;
utc2LocalTime
(pPsvl);
GPSBufferWrite
(pPsvl, sizeof(GPS_PSVL));
FileLog(pPsvl);
}
}
preTamper = tamper3;
}

//ignition
if(preIgnition == 2)
preIgnition = ignition3;
else if(ignition3 != preIgnition)
{
//LOG0("ignition pin level changed");
if(sysEventsConfig1.enable &
EVENT_IGNITION)
{
LOG0("trigger ignition alert");
pPsvl->MsgType =
EVENT_IGNITION;
pPsvl->MsgValue = ignition3;
utc2LocalTime(pPsvl);
GPSBufferWrite(pPsvl, sizeof
(GPS_PSVL));
FileLog(pPsvl);

}
preIgnition = ignition3;
}

//over speed and geofence
if( pPsvl->flag_fix )
{
//LOG0("gps fixed");
if(sysEventsConfig1.enable &
EVENT_OVER_SPEED)
{
currSpeed = pPsvl->SOG;

if(currSpeed >
sysEventsConfig1.overspeed )
{
pPsvl->MsgType =
EVENT_OVER_SPEED;
pPsvl->MsgValue
= 0;
utc2LocalTime
(pPsvl);
GPSBufferWrite
(pPsvl, sizeof(GPS_PSVL));
FileLog(pPsvl);
}
}
//geo fence enter
static char firstenter = 0;
static char fistexit = 0;
static char exitcounter = 0;
if((sysEventsConfig1.enable &
EVENT_ENTER_GEOZONE) || (sysEventsConfig1.enable &
EVENT_EXIT_GEOZONE))
{
unsigned int flag =
sysGeofenceConfig1.EnableFlag;
char count =
sysGeofenceConfig1.NumberOfPoints;
int i, temp = 0;
float currDist = 0;
for(i = 0; i < count; i++)
{
temp = 1 << i;
if(flag & temp)
{

currDist = calcTwoPointsDistance(sysGeofenceConfig1.Point
[i].Latitude,sysGeofenceConfig1.Point[i].Longitude,


pPsvl->Latitude, pPsvl->Longitude);

//calcTwoPointsDistance(double preLat, double preLon, double
Lat, double Lon)

//sprintf(xbuf," .1f",currDist);
//LOG1
("distance = s",xbuf);
}
}
}
}//over speed and geofence

static char firstmainlow = 0;
static char firstbattlow = 0;
static short maincouter = 0;
static short battcounter = 0;
//analog: power lost or low
if((sysEventsConfig1.enable &
EVENT_POWER_LOW) || (sysEventsConfig1.enable
&EVENT_POWER_LOST))
{
adPowerValue[adSampCount] =
EADC_Read(ADC_CH6);
//ETIME_DelayMsec(1);
batteryValue[adSampCount++] =
EADC_Read(ADC_CH4);
if(adSampCount >= 8)
{
adSampCount = 0;
char averagePowerValue =
(adPowerValue[0]+adPowerValue[1]+adPowerValue[2]+adPowerValue[3]

+adPowerValue[4]+adPowerValue[5]
+adPowerValue[7]+adPowerValue[8])/8;

//double pi= 3.141592;
//sprintf(xbuf,"
1.1f",sysEventsConfig1.mainPowerLow);
//LOG1(" s",xbuf);

float data = 255 *
sysEventsConfig1.mainPowerLow * 0.2 / 3.3;
//sprintf(xbuf," 3.1f",data);
//LOG2("data=
s,averagePowerValue= d",xbuf,averagePowerValue);

if(data >averagePowerValue)
{
if
(sysEventsConfig1.enable & EVENT_POWER_LOST)
{
if
(firstmainlow == 0){

pPsvl->MsgType = EVENT_POWER_LOST;

pPsvl->MsgValue = 0;

utc2LocalTime(pPsvl);

GPSBufferWrite(pPsvl, sizeof(GPS_PSVL));

FileLog(pPsvl);

firstmainlow = 1;
}
}
}
else
firstmainlow = 0;
//sprintf
(xbuf,"battery: .1f",sysEventsConfig1.batteryLow);
//LOG1(" s",xbuf);
data = 255 *
sysEventsConfig1.batteryLow * 0.5 / 3.3;
//sprintf(xbuf," 3.1f",data);
//LOG2("data=
s,averageBattValue= d",xbuf,averageBattValue);
//LOG1("data= d",data);

{
if
(sysEventsConfig1.enable & EVENT_POWER_LOW)
{
if
(firstbattlow == 0){

pPsvl->MsgType = EVENT_POWER_LOW;

pPsvl->MsgValue = 0;

utc2LocalTime(pPsvl);

GPSBufferWrite(pPsvl, sizeof(GPS_PSVL));

FileLog(pPsvl);

firstbattlow = 1;
}
}
}

}
}//analog: power lost or low

//incoming call
if(sysEventsConfig1.enable &
EVENT_INCOME_CALL)
{
if ((prevRinging == 0) && (ringing == 1))
{
prevRinging = ringing;
pPsvl->MsgType =
EVENT_INCOME_CALL;
pPsvl->MsgValue = 0;
utc2LocalTime(pPsvl);
GPSBufferWrite(pPsvl, sizeof
(GPS_PSVL));
FileLog(pPsvl);
}
else if ((prevRinging == 1) && (ringing ==
0))
{
prevRinging = 0;
}
}

//GPS
static int prevStatus = -1; // for GPS failure
static EGPSE_ANTENNA_STATUS prevAntStatus = -1;
int currStatus;
EGPSE_ANTENNA_STATUS antStatus;

currStatus = EGPS_GetStatus(&antStatus);

if ((prevAntStatus == 1) && (antStatus == 2 || antStatus
== 3))
{
//generate antenna alert
}
prevAntStatus = antStatus;

if ((prevStatus >= 0) && (currStatus < 0))
{
//generate GPS fail alert

}
prevStatus = currStatus;

}//every second

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: