Guido Ottaviani / Mbed 2 deprecated LeonardoMbos

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LeonardoMbos.cpp Source File

LeonardoMbos.cpp

00001 /* ////////////////////////////////////////////////////////////////////////////
00002 ** File:      LeonardoMbos.cpp
00003 */    
00004 /*               12345678901234567890                                        */                               
00005  char  Ver1[] = "Leonardo's GPS 0.1.0";
00006  char  Ver2[] = "  by Guiott  01-12";
00007 /**
00008 * @mainpage Leonardo.cpp
00009 * @author   Guido Ottaviani-->guido@guiott.com<--
00010 * @version  0.1.0
00011 * @date     01/2012
00012 * @details This is a test program to study the capability of a GPS module to
00013    control navigation of a robot in an outdoor environment.
00014         
00015    This version is developed within the mbos RTOS:
00016    http://mbed.org/users/AndrewL/libraries/mbos/lqn3ca
00017         
00018    It uses NMEA library by Tim (xtimor@gmail.com) 
00019    available on public mbed library or http://nmea.sourceforge.net
00020         
00021  The original gmath.c has been modified to fix a bug in nmea_distance_ellipsoid() function
00022  according to bug report ID: 2945855
00023  
00024  http://sourceforge.net/tracker/?func=detail&aid=2945855&group_id=192054&atid=939854
00025  
00026     // while ((delta_lambda > 1e-12) && (remaining_steps > 0))  original by xtimor
00027     while (( remaining_steps == 20 ) || ((fabs(delta_lambda) > 1e-12) && (remaining_steps > 0)))
00028     
00029  the original code always returns a zero distance if the arrival point longitude
00030  is equal or smaller than the starting point one.
00031     
00032  The mbed module is interfaced with a Garmin GPS sensor (used in standard mode)
00033  with an external antenna, a 20x4 LCD text display and a 5 keys keypad.
00034  A curiosity:
00035  All the hardware components of the test set are mounted on the top of a wooden 
00036  box, looking like a kind of a steampunk navigator. When my daughter looked at 
00037  the box she said: "it looks alike the navigator of the da Vinci car".
00038  This is the reason why the name of this project is "Leonardo".
00039 **
00040 -------------------------------------------------------------------------------
00041 * @copyright 2012 Guido Ottaviani
00042 guido@guiott.com
00043 
00044     LeonardoMbos is free software: you can redistribute it and/or modify
00045     it under the terms of the GNU General Public License as published by
00046     the Free Software Foundation, either version 3 of the License, or
00047     (at your option) any later version.
00048 
00049     LeonardoMbos is distributed in the hope that it will be useful,
00050     but WITHOUT ANY WARRANTY; without even the implied warranty of
00051     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00052     GNU General Public License for more details.
00053 
00054     You should have received a copy of the GNU General Public License
00055     along with LeonardoMbos.cpp.  If not, see <http://www.gnu.org/licenses/>.
00056     
00057 -------------------------------------------------------------------------------      
00058 */
00059 #include "Common.h"
00060 #include "mbed.h"
00061 #include <string>
00062 #include "TextLCD.h"
00063 #include "nmea/nmea.h"
00064 #include <Watchdog.h>
00065 #include "ConfigFile.h"
00066 #include "Init.h" 
00067 #include "Prototype.h"
00068 #include "mbos.h"
00069 #include "Tasks.h"
00070 
00071 // Set up RTOS;
00072 mbos os(NUM_TASKS, NUM_TIMERS, NUM_RESOURCES);
00073 
00074 int main() 
00075 {
00076     Initialize();
00077     if (wd.WatchdogCausedReset())
00078     {
00079         pc.printf("Watchdog caused reset**********************************\r\n");
00080     }
00081     wd.Configure(WDT_TIMEOUT);       // sets the timeout interval
00082 
00083     os.Start(); // the RTOS starts now
00084 }
00085 
00086 //functions =====================================================================
00087 
00088 void mbosIdleTask(void)
00089 {/**
00090  *@brief TASK 0 watchdog kick
00091  */
00092  while(1)
00093  {
00094 
00095  }
00096 }
00097 
00098 int CmpRead(void)
00099 {/**
00100  *@brief Magnetic Compass reading 
00101  */
00102     int Cmp;
00103 
00104     // To Be Done
00105     Cmp = 0; // ************debug
00106     return(Cmp);
00107 }
00108 
00109 void ReadCfg(char *Config[])
00110 {/**
00111  *@brief Read a configuration file from a mbed filesystem
00112  */
00113     char value[BUFSIZ];
00114     
00115     if (!cfg.read("/local/input.cfg")) 
00116     {
00117         pc.printf("Failure to read a configuration file.\n");
00118     }
00119       
00120     if (cfg.getValue(Config[0], &value[0], sizeof(value))) 
00121     {
00122         pc.printf("'%s'='%s'\n", Config[0], value);
00123     }
00124  
00125      if (cfg.getValue(Config[1], &value[0], sizeof(value))) 
00126     {
00127         pc.printf("'%s'='%s'\n", Config[1], value);
00128     }
00129 }
00130 
00131 void WriteCfg()
00132 {/**
00133  *@brief Write configurations to mbed filesystem
00134  */
00135      cfg.setValue("LonStart", "lon");
00136      cfg.setValue("LatStart", "lat");
00137 
00138      cfg.write("/local/input.cfg", "# Configuration file for LeonardoGps.");
00139  }