00001 /* 00002 MobileRobots Advanced Robotics Interface for Applications (ARIA) 00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC 00004 Copyright (C) 2006, 2007 MobileRobots Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 If you wish to redistribute ARIA under different terms, contact 00021 MobileRobots for information about a commercial version of ARIA at 00022 robots@mobilerobots.com or 00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481 00024 */ 00025 00026 00027 #include "ArExport.h" 00028 #include "ariaOSDef.h" 00029 #include "ArNovatelGPS.h" 00030 #include "ArDeviceConnection.h" 00031 00032 00033 AREXPORT bool ArNovatelGPS::connect() 00034 { 00035 if (!ArGPS::connect()) return false; 00036 char cmd[32]; 00037 memset(cmd, 0, 32); 00038 00039 myDevice->write("\r\n", 2); // prod the connection and end any previous commands it was waiting for, errors OK 00040 00041 // Enable WAAS/EGNOS/MSAS/etc satellite-based correction: 00042 const char* const sbasCmd = "sbascontrol enable auto 0 zerototwo\r\n"; 00043 if (myDevice->write(sbasCmd, strlen(sbasCmd)) < strlen(sbasCmd)) 00044 return false; 00045 00046 // Send a command to start sending data for each message type in the ArGPS 00047 // handlers map: 00048 for(HandlerMap::iterator i = myHandlers.begin(); i != myHandlers.end(); i++) 00049 { 00050 float interval = 1; 00051 if( (*i).first == "GPRMC") interval = 0.25; //special case, make this come faster 00052 snprintf(cmd, 32, "log thisport %s ontime %g\r\n", (*i).first.c_str(), interval); 00053 //ArLog::log(ArLog::Verbose, "ArNovatelGPS: sending command: %s", cmd); 00054 if (myDevice->write(cmd, strlen(cmd)) != strlen(cmd)) return false; 00055 } 00056 00057 return true; 00058 } 00059 00060 00061 AREXPORT ArNovatelGPS::~ArNovatelGPS() { 00062 if(!myDevice) return; 00063 myDevice->write("unlogall\r\n", strlen("unlogall\r\n")); // don't worry about errors 00064 } 00065