[plug] C help (only slightly Linux)

Shackleton, Kevin kshackleton at agric.wa.gov.au
Sun Jul 19 20:39:24 WST 1998


I tried your phone at 19:20 tonight and did not get an a reply.

If you could steer me along that would be great.  I think it will
probably take a week or two to get the program in reasonable form, with
you developing and me steering, via emails.  If you can handle that . .?

Here's a start.

We want a program that monitors the GPS traffic and prompts you for an
input every 1 km (there's 1852 m per minute of angle by the way).  We
could input the data as a line of text, but really it's about five or
six items, like "condition score", which have allowable inputs  ({0..4}
in this case) plus probably a comment line.

I don't know if window management (using Borland's gotoxy() or Turbo
Vision) is really worthwhile.

So there needs to be a startup situation which sets a "last location"
position, a loop that computes current distance to last location, and a
data input part.

I wrote this to read through the data file:

#include <stdio.h>
#include <string.h>

int main() {
  char string[80];
  char header[6];
  do {
    gets(string);
    strncpy(header,string,6);
    if(strcmp(header,"$GPRMC"))
      printf(string);
  } while (!eof());
  return 0;
}

However this doesn't work undet linux (core dump).  I assume that it's
because there's no null termination on header.

You also have to be sure that you've got a whole line so it's a good
idea to do a gets() first, then a repeat gets() until youve got an RMC
line.

Looking forward to hearing from you.

Kevin Shackleton
Agriculture WA
Ph work 08 9956 3329  Home 08 9941 8258  Fax 08 9941 8334




> ----------
> From: 	Navarre[SMTP:navarre at omen.net.au]
> Reply To: 	plug at linux.org.au
> Sent: 	Tuesday, 14 July 1998 15:13
> To: 	plug at linux.org.au
> Subject: 	Re: [plug] C help (only slightly Linux)
> 
> Shackleton, Kevin wrote:
> > 
> > I sent this yesterday but it disappeared . .
> > 
> > I have a project to program an HP200LX to read GPS data files that
> look
> > like this:
> > $GPXTE,A,A,,,N*3C
> > $GPBWC,051808,,,,,,T,,M,,N,*12
> > $GPRMC,051809,A,2451.22,S,11343.69,E,001.6,284.7,030798,,*07
> > $GPRMB,A,,,,,,,,,,,,V*71
> > $GPR00,,,,,,,,,,,,,,*45
> > $GPGLL,2451.22,S,11343.69,E*7F
> > $PGRMZ,-499,f,2*33
> > 
> > I have a program for DOS in Pascal but the async library locks the
> HP.
> > A C
> > async library I've got works OK.
> > 
> > However I'm not a C programmer.  I tried the P2C utility to convert
> my
> > program
> > to C but that didn't cut the mustard in this case.
> > 
> > The main trouble I'm having is finding the best way to cut out the
> bits
> > of data I want.  In Pascal I'd do a copy() (which is a mid$() in
> Basic).
> > P2C helpfully converted copy() to strsub(), which does not exist in
> > Borland C.
> > 
> > Is anyone interested in a Borland C co-development (ie you do it, I
> take
> > the credit), or can someone recommend a C book that deals with
> string
> > handling - the couple I've got practically ignore this area.
> > 
> > K.
> 
> Hello Kevin
> 
> I have a good knowledge of programming in C and done a fair bit of
> reading and analysing data. What your have shown as a sample look
> simple. Call me on 018 909 695.
> -- 
> 
> - Regards Navarre -
> <navarre at omen.com.au>
> ---------------------
> 


More information about the plug mailing list