Hi I'm working on this GPS project for microcontroller, I'm getting an error with the strstr function saying it is a type mismatch. I not sure if the error is because it is not fully ANSI compliant. are there any ideas what to do to make it compile?
Compiler is Microchip C18
if I take out the string.h library it will compile if I change the line
found = strstr(gpsbuff, "$GPRMC"); to this
*found=strstr(gpsbuff, "$GPRMC");
it will compile but is this really doing anything different?
Thank you
Code:
#include <p18cxxx.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <delays.h>
#include "usart.h"
#include "lcdInit.h"
#include "MainScreen.h"
#define BUFFER_SIZE 100
//**********************CONFUGURATION BITS***********************
#pragma config OSC = HS
#pragma config LVP = OFF
#pragma config WDT = OFF
#pragma config BOR = OFF
#pragma config PWRT = ON
#pragma config STVR = ON
//***************************************************************
//******************** INTERUPT ROUTINE STUFF********************
int gps_buffa_rx_count = 0;
unsigned char gpsbuff[BUFFER_SIZE] = {NULL};
//************** GPS PARSING STUFF ******************************
void parsenmea(void);
unsigned char *found;
unsigned int incomplete = 0;
unsigned int length =0;
unsigned int done =0;
unsigned int i =0;
unsigned char GPRMCbuff[BUFFER_SIZE] = {NULL};
unsigned char UTC[10] = {NULL};
unsigned char LAT[9] = {NULL};
unsigned char LONG[10] = {NULL};
unsigned char NS[2] = {NULL};
unsigned char EW[2] = {NULL};
//***************************************************************
void high_isr(void);
#pragma code high_vector = 0x08 // high priority interrupt vector
void interrupt_at_high_vector(void){
_asm goto high_isr _endasm // assembly language instructions to jump
}
#pragma code
#pragma interrupt high_isr
void high_isr(void) {
if(PIR1bits.RCIF = 1) {
PIE1bits.RCIE =0;
gpsbuff[gps_buffa_rx_count] = RCREG;
if(gps_buffa_rx_count>210){
gps_buffa_rx_count=0;
}else{
gps_buffa_rx_count++;
}
}
gpsbuff[gps_buffa_rx_count]=0x00;
PIR1bits.RCIF = 0;
USARTReset();
PIE1bits.RCIE = 1;
}
// Main routine
void main(){
INTCONbits.GIE = 1; //enable all interupts
INTCONbits.PEIE = 1; //enable peripherial interupts
ADCON1 = 0x0F; //all ports digital
TRISC = 0b10000000; //RC7(RX) as input & RC6(TX) as output
SPBRG = 0x40; //baud rate = 4800
RCSTA = 0b10010110; //serial port enable, 8-bit data
OpenUSART(USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_LOW,64);
PIE1bits.RCIE = 0; // disables receive interrupt
PIR1bits.RCIF = 0; // clear interupt flag if set
PIE1bits.RCIE = 1; // enables receive interrupt
USARTReset(); // sets CREN to 0 and back to 1
lcd_Init();
while(1)
{
if(gps_buffa_rx_count>=100) {
parsenmea();
gps_buffa_rx_count = 0;
}
}
} //end main
void parsenmea(void)
{
// GPRMC sentence parse
//
// go through buffer looking for a $ start command....
found=strstr(gpsbuff,"$GPRMC");
incomplete=0;
if(found!=0x00)
{
for (i=0;i<100;i++)
{
//if we find a null then incomplete sentence mark incomplete=1
if (*found==0x00)
{
incomplete=1;
i=169;
}
// if we find this then end of string, incomplete=0
if ((*found==0x0d)|(*found==0x2a))
{
incomplete=0;
i=169;
}
if ((*found !=0x00)&(*found !=0x0d)&(*found!=0x2a))
{
GPRMCbuff[i]=*found;
DrawMainScreen(1,1,1,1);
*found++;
}
}
}
gps_buffa_rx_count = 0;
}