Go to Post If Andy asked y'all to stand on your head, would you do that, too? ;) - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 30-05-2013, 13:19
ktrobotcreator's Avatar
ktrobotcreator ktrobotcreator is offline
Programmer
FRC #1245 (Shazbots)
Team Role: Programmer
 
Join Date: Jul 2012
Rookie Year: 2007
Location: Colorado
Posts: 38
ktrobotcreator is an unknown quantity at this point
Read a GPS through a Serial Port

Hi Chief Delphi Community!

For a separate robotics competition (The Sparkfun Autonomous Vehicle Competition, if you were wondering) we are using the FRC control system. For the competition we have to autonomously navigate a course and race other robots around a parking lot, and we aim to do so by using GPS. We have a working GPS chip on an Arduino system that can output to a serial port, and so we would like to use the one on the cRIO to get the data. We have verified the chip can output the correct data using other software, but when we try to read it from the code, we get a bunch of nonsense. The baud rate is correct, so we don't know why we are getting this data. Any help is appreciated! Thanks!

-Katy

Code:
 
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.SerialPort;
import edu.wpi.first.wpilibj.visa.VisaException;

public class RobotTemplate extends IterativeRobot {
    
    SerialPort gps;
    
    int dataCount;
        
    public void robotInit() {
        try {
            gps = new SerialPort(9600);
            this.gps.disableTermination();
        }
        catch (Exception e) {
            System.out.println("something went wrong, " + e.getMessage());
        }
    }
    
    public void autonomousInit() {
        dataCount = 0;
        
        try {
            gps.reset();
        } catch (VisaException ex) {}
    }
    
    public void autonomousPeriodic() {
        
        try {
            System.out.println("DC " + dataCount + " " + gps.readString());
        } catch (VisaException ex) {}
        
        dataCount ++; //this is just to make sure our output is updating
    }   
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi