Help me this NMEA parser written in C

Microcontroller Topics
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Help me this NMEA parser written in C

Post by Neo » Fri Jul 29, 2011 9:28 pm

All contents in header should go inside the #ifndef block.
Function prototypes should have extern as well.
extern tells the compiler that either the function or variable is defined somewhere in the project and the linker should find them in the symbol table at the end.

Code: Select all

#ifndef NMEA_H
#define NMEA_H

//#include "buffer.h"
#include<stdio.h>

extern char longitude[10];
extern char lattitude[10];
extern char lon_;
extern char lat_;
extern char utcTime[10];
extern short fixMode;
extern short satsUsed;
extern float MSL_Altitude;
extern float course;
extern float speed;
extern short day;
extern short month;
extern short year;


/*extern void init_NMEA_Engine();*/
extern void parseNMEA();
extern void processGGA();
extern void processGLL();
extern void processVTG();
extern char readFromBuffer();
extern void readNextParameter(char* store);

#endif
User avatar
Herath
Major
Major
Posts: 417
Joined: Thu Aug 05, 2010 7:09 pm

Re: Help me this NMEA parser written in C

Post by Herath » Fri Jul 29, 2011 9:31 pm

I read that functions have extern in front of them automatically. That's why I did not bother using it. :)
By default, the declaration and definition of a C function have “extern” prepended with them. It means even though we don’t use extern with the declaration/definition of C functions, it is present there.
http://geeksforgeeks.org/?p=840
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Help me this NMEA parser written in C

Post by Neo » Fri Jul 29, 2011 10:04 pm

I'm a classic C developer Herath. I started computing at a time where things were not this developed. With Turbo C then Borland C++, it was required to write everything by ourself. Nothing comes automatically as such ;)

I guess you better use it so you are fully sure what's going on.
User avatar
Herath
Major
Major
Posts: 417
Joined: Thu Aug 05, 2010 7:09 pm

Re: Help me this NMEA parser written in C

Post by Herath » Fri Jul 29, 2011 10:16 pm

Yes. I think it's good and I am using it. Thanks for the guidance.I have not used C much. Just few coding to understand the basics. Then moved to the Java and .NET era. :D .And it sucks sometimes because I can write code that has no problem while still not knowing the insight.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Help me this NMEA parser written in C

Post by Neo » Sat Jul 30, 2011 9:08 am

No problem at all. You are welcome. I'm happy to have you here to share my knowledge. As you said I had to move to Java just a few years after its introduction. After that lots of things has happened. Even the owner is different now ;) . I use C# as well. I write all PC test applications in C# just because it is too easy to create GUI, etc...

But to be honest with you Herath, I have never seen such a beautiful language like C/C++. Basically I will not compare anything to it. It is so flexible especially on hardware control which made it to be chosen as the ONLY language used to code both computer & embedded OSs. Due to this flexibility C/C++ need to be used in a correct way. For example, pointers need to be handled correctly, volatile addresses need to be pointed correctly (otherwise a disaster), etc... All these things are blocked by Java and other languages. This is where C/C++ and ASM is chosen to develop on embedded systems (especially the ones without a platform).

So for you, I recommend to learn C/C++ also some ASM (Atmel ASM if you use Atmel, PIC ASM if you use PIC.. both are RISC so it is easy) if you really want to live in the embedded world.
Post Reply

Return to “Microcontrollers”