To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 2134
2133  |  2135
Subject: 
GPS Sample Code
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Mon, 12 May 1997 23:11:46 GMT
Original-From: 
Curt Mills <hacker@tc.+stopspammers+fluke.com>
Viewed: 
1364 times
  
Here is code I have used to talk between a GPS and a HandyBoard.  I clipped
these routines out of an old version of the code I currently use, so I can't
verify that there aren't any bugs in this stuff, but it is simple code.
Several people on the Handyboard mailing list were interested in it.
The code may look strange, because I deleted portions that I didn't want
published on the net.  This should get people started with receiving
the NMEA strings though.  Parsing is your own problem (and a fun? one).

First thing to try is just to get each string and display it as it is
received.  Then try displaying only certain strings.  Then try parsing
for only the items you are interested in, and displaying those.  If you
try to do much floating point math, you'll quickly run out of processing
power with Interactive C.

Have fun!

Curt, WE7U.
hacker@tc.fluke.com





/* At this point, the serial port is set to 9600 8N1 by Interactive-C.
   Must change it to 4800 N81 for communications with GPS */
void disable_pcode_serial()     /* necessary to receive characters using
   serial_getchar */
{
    poke(0x3c, 1); /* Disable Interactive C's use of serial port */
    poke(0x102B, 0x31); /* Set the port to 4800 N81 */

    /* 0x30 9600 Baud
0x31 4800 Baud
0x32 2400 Baud
0x33 1200 Baud
0x34 600 Baud
0x35 300 Baud
0x36 150 Baud
0x37   75 Baud
    */
}





void reenable_pcode_serial()    /* necessary for IC to interact with board again */
{
    poke(0x102B, 0x30); /* Set the port back to 9600N81 */
    poke(0x3c, 0); /* Enable Interactive C's use of the port */
}





/* Blocking serial transmit routine */
void serial_putchar(int c)
{
    while (!(peek(0x102e) & 0x80)); /* wait until serial transmit empty */
    poke(0x102f, c);                /* send character */
}





/* Blocking serial receive routine */
int serial_getchar(void)
{
    while (!(peek(0x102e) & 0x20)); /* wait for received character */
    return peek(0x102f);
}





/* Non-blocking serial receive routine.
   Returns -1 if no character is available */
int serial_getchar_nowait(void)
{
  if ( (peek(0x102e) & 0x20) )
    return peek(0x102f);
  else
    return -1;
}





/* Check for rx char ready */
int serial_char_stat(void)
{
  return( peek(0x102e) & 0x20 );
}





/* Serial send string routine */
void serial_put_string(char c[])
{
  int i;

  while (c[i] != 0)
  {
    serial_putchar(c[i]);
    i++;
  }
}





void initialize(void)
{
  disable_pcode_serial();
}





void main(void)
{
  int i;

  initialize();

  while (1)
  {
    for (i=0; i<13; i++)
      parse_nmea();
    display_position();
  }

  # Note that we should never reach this code
  printf("\nDone with main");
  reenable_pcode_serial();
}



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR