|
From: <rum...@us...> - 2008-06-25 09:07:16
|
Revision: 214
http://gearbox.svn.sourceforge.net/gearbox/?rev=214&view=rev
Author: rumataxyz
Date: 2008-06-25 02:07:15 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
changes due to Alex Brook's code-review
Modified Paths:
--------------
gearbox/trunk/submitted/gbxnovatelacfr/driver.cpp
gearbox/trunk/submitted/gbxnovatelacfr/driver.h
gearbox/trunk/submitted/gbxnovatelacfr/novatel.dox
Modified: gearbox/trunk/submitted/gbxnovatelacfr/driver.cpp
===================================================================
--- gearbox/trunk/submitted/gbxnovatelacfr/driver.cpp 2008-06-25 07:27:56 UTC (rev 213)
+++ gearbox/trunk/submitted/gbxnovatelacfr/driver.cpp 2008-06-25 09:07:15 UTC (rev 214)
@@ -69,14 +69,13 @@
std::auto_ptr<gna::GenericData> createExternalMsg(gnua::RawImuLogSB &rawImu, struct timeval &timeStamp, gnua::ImuDecoder *imuDecoder);
//helper functions for the toString() gear
- std::string statusToString(gna::StatusMessagetype statusMessageType, std::string statusMessage);
+ std::string statusToString(gna::StatusMessageType statusMessageType, std::string statusMessage);
std::string doubleVectorToString(vector<double > &vec, std::string seperator = std::string(" "));
}
namespace gbxnovatelacfr
{
Driver::Driver( const Config& cfg) :
- serial_(0),
baud_(115200),
config_(cfg),
tracer_(new gbxutilacfr::TrivialTracer())
@@ -88,7 +87,6 @@
Driver::Driver( const Config& cfg,
gbxutilacfr::Tracer* tracer) :
- serial_(0),
baud_(115200),
config_(cfg),
tracer_(tracer)
@@ -109,9 +107,7 @@
std::string serialDevice = config_.serialDevice_;
serial_.reset(new Serial( serialDevice, baud_, Serial::Timeout(1,0) ));
serial_->setDebugLevel(0);
- if(0 != connectToHardware() ){
- throw (gua::Exception(ERROR_INFO, "failed to connect to receiver!"));
- }
+ connectToHardware();
// just in case something is running... stops the novatel logging any messages
serial_->writeString( "unlogall\r\n" );
@@ -139,7 +135,7 @@
}
}
-int
+void
Driver::connectToHardware() {
// baudrates we test for; this is
// _not_ all the baudrates the receiver
@@ -155,7 +151,7 @@
int currentBaudrate = 0;
bool correctBaudrate = false;
- std::cout << "Trying to hook up to receiver at different Baudrates\n";
+ tracer_->info( "Trying to hook up to receiver at different Baudrates" );
int maxTry = 4;
int successThresh = 4;
int timeOutMsec = 150;
@@ -168,25 +164,26 @@
i++;
}
if(false == correctBaudrate){
- std::cout << "\n!Failed to establish a connection to the receiver!\n";
- std::cout << "Check physical connections; Check manually (minicom) for Baudrates < 9600kb/s.\n\n";
- return -1;
+ std::stringstream ss;
+ ss << "!Failed to establish a connection to the receiver! Check physical connections; Check manually (minicom) for Baudrates < 9600kb/s.";
+ throw ( gua::Exception(ERROR_INFO, ss.str()) );
}
+ // ok, we've got a working link
+ std::stringstream ss;
+ ss << "Established connection at "
+ << currentBaudrate << "bps; "
+ << "Resetting to configured speed: "
+ << baud_ << "bps";
+ tracer_->info(ss.str());
char str[256];
sprintf( str,"com com1 %d n 8 1 n off on\r\n", baud_ );
serial_->writeString( str );
- std::cout << "*******************************\n"
- << "** Current Speed " << currentBaudrate << "\n"
- << "** Resetting to " << baud_ << "\n"
- << "*******************************\n";
- std::cout << "** Testing new setting\n** ";
- if(true == gnua::testConnectivity( challenge, ack, *(serial_.get()), timeOutMsec, maxTry, successThresh, baud_)){
- std::cout << "*******************************\n";
- return 0;
- }else{
- std::cout << "*******************************\n";
- return -1;
+ if(false == gnua::testConnectivity( challenge, ack, *(serial_.get()), timeOutMsec, maxTry, successThresh, baud_)){
+ std::stringstream ss;
+ ss << "!Failed to reset connection to configured baudrate!";
+ throw ( gua::Exception(ERROR_INFO, ss.str()) );
}
+ return;
}
void
@@ -400,7 +397,7 @@
if(config_.ignoreUnknownMessages_){
tracer_->warning(ss.str());
}else{
- gua::Exception(ERROR_INFO, ss.str() );
+ throw ( gua::Exception(ERROR_INFO, ss.str()) );
}
}
break;
@@ -410,7 +407,7 @@
std::stringstream ss;
ss << "Warning("<<__FILE__<<":"<< __LINE__
<< "Timed out while waiting for data";
- gua::Exception(ERROR_INFO, ss.str());
+ throw ( gua::Exception(ERROR_INFO, ss.str()) );
}
}while(NULL == data.get()); // repeat till we get valid data
@@ -836,7 +833,7 @@
if(in_crc != crc) {
fprintf( stderr,"CRC Error: 0x%lx, 0x%lx\n",in_crc,crc );
- gua::Exception(ERROR_INFO, "CRC Error" );
+ throw ( gua::Exception(ERROR_INFO, "CRC Error" ) );
return -1;
}
@@ -1072,7 +1069,7 @@
return ss.str();
}
- std::string statusToString(gna::StatusMessagetype statusMessageType, std::string statusMessage){
+ std::string statusToString(gna::StatusMessageType statusMessageType, std::string statusMessage){
std::stringstream ss;
switch(statusMessageType){
case gna::NoMsg:
Modified: gearbox/trunk/submitted/gbxnovatelacfr/driver.h
===================================================================
--- gearbox/trunk/submitted/gbxnovatelacfr/driver.h 2008-06-25 07:27:56 UTC (rev 213)
+++ gearbox/trunk/submitted/gbxnovatelacfr/driver.h 2008-06-25 09:07:15 UTC (rev 214)
@@ -188,7 +188,7 @@
};
//! possible Status Messages GenericData can contain
-enum StatusMessagetype {
+enum StatusMessageType {
NoMsg, //!< Nothing new, no message
Initialising,//!< Nothing wrong, just not quite ready
Ok, //!< All good, but something to say
@@ -285,8 +285,8 @@
return InsPva;
}
std::string toString();
- int gpsWeekNr; //
- double secIntoWeek; //
+ int gpsWeekNr; //!< number of full weeks since midnight 05/Jan/1980 (UTC)
+ double secIntoWeek; //!< yields GPS-time (together with @ref gpsWeekNr); continous (contrary to UTC which uses leapseconds)
double latitude; //!< [deg] north positive WGS84
double longitude; //!< [deg] east positive WGS84
double height; //!< [m] above ellipsoid WGS84 (heigth_ellipsoid - undulation == height_geoid (aka AMSL)
@@ -311,7 +311,7 @@
//@}
- StatusMessagetype statusMessageType;
+ StatusMessageType statusMessageType;
std::string statusMessage;
int timeStampSec; //!< in Computer time, beginning of message at serial port
@@ -325,8 +325,8 @@
return BestGpsPos;
}
std::string toString();
- int gpsWeekNr; //
- unsigned int msIntoWeek; //!< milliseconds from beginning of week
+ int gpsWeekNr; //!< number of full weeks since midnight 05/Jan/1980 (UTC)
+ unsigned int msIntoWeek; //!< yields GPS-time (together with @ref gpsWeekNr); continous (contrary to UTC which uses leapseconds)
GpsSolutionStatusType solutionStatus; //
GpsPosVelType positionType; //
double latitude; //!< [deg] north positive
@@ -345,7 +345,7 @@
int numL1RangesRTK; //!< number of L1 ranges above the RTK mask angle (??) number of L1 carrier ranges used?
int numL2RangesRTK; //!< number of L2 ranges above the RTK mask angle (??) number of L2 carrier ranges used?
- StatusMessagetype statusMessageType;
+ StatusMessageType statusMessageType;
std::string statusMessage;
int timeStampSec; //!< in Computer time, beginning of message at serial port
@@ -359,8 +359,8 @@
return BestGpsVel;
}
std::string toString();
- int gpsWeekNr; //
- unsigned int msIntoWeek; //!< milliseconds from beginning of week
+ int gpsWeekNr; //!< number of full weeks since midnight 05/Jan/1980 (UTC)
+ unsigned int msIntoWeek; //!< yields GPS-time (together with @ref gpsWeekNr); continous (contrary to UTC which uses leapseconds)
GpsSolutionStatusType solutionStatus; //
GpsPosVelType positionType; //
float latency; //!< [s] gps speed can be calculated from instantanious or integrated doppler. The latter refers to the average speed over the last interval -> is delayed by half an interval
@@ -369,7 +369,7 @@
double trackOverGround; //!< [deg] "heading" of the speed vector w. respect to true North
double verticalSpeed; //!< [m/s]
- StatusMessagetype statusMessageType;
+ StatusMessageType statusMessageType;
std::string statusMessage;
int timeStampSec; //!< in Computer time, beginning of message at serial port
@@ -383,8 +383,8 @@
return RawImu;
}
std::string toString();
- int gpsWeekNr;
- double secIntoWeek;
+ int gpsWeekNr; //!< number of full weeks since midnight 05/Jan/1980 (UTC)
+ double secIntoWeek; //!< yields GPS-time (together with @ref gpsWeekNr); continous (contrary to UTC which uses leapseconds)
//!@name Change in speed
//!Divide by dt to get accelerations.
//!The default IMU axis definitions are: Y - forward, Z - up, X - right hand side
@@ -407,7 +407,7 @@
//@}
- StatusMessagetype statusMessageType;
+ StatusMessageType statusMessageType;
std::string statusMessage;
int timeStampSec; //!< in Computer time, beginning of message at serial port
@@ -438,49 +438,22 @@
Throws gbxutilacfr::Exception when a problem is encountered (derives from std::exception).
Throws gbxutilacfr::HardwareException when a (fatal) problem with the hardware is encountered
- @verbatim
- std::auto_ptr<gbxnovatelacfr::GenericData> data;
-
- while(1) { // read forever
- try {
- data = device->read();
- }
- catch ( const gbxutilacfr::HardwareException& e ) {
- cout <<"Something wrong with the hardware: "<<e.what()<<endl;
- cout <<"Giving up!\n";
- throw e;
- }
- catch ( const std::exception& e ) {
- cout <<"Failed to read data: "<<e.what()<<endl;
- continue;
- }
- switch( data.type() ){
- case InsPvaData:
- InsData *insData = dynamic_cast<InsData *>(data.get());
- assert(insData);
- // process insData
- break;
- default:
- // don't handle the other guys
- break;
- }
- }
- @endverbatim */
+ */
std::auto_ptr<GenericData> read();
private:
- //! does the leg-work for the constructor (via the following guys)
+ // does the leg-work for the constructor (via the following guys)
void configure();
- //! establish a serial connection to the receiver
- int connectToHardware();
- //! set parameters related to the IMU
+ // establish a serial connection to the receiver
+ void connectToHardware();
+ // set parameters related to the IMU
void configureImu();
- //! set parameters related to the INS
+ // set parameters related to the INS
void configureIns();
- //! set parameters related to GPS
+ // set parameters related to GPS
void configureGps();
- //! turn on data messages we are interested in
+ // turn on data messages we are interested in
void requestData();
std::auto_ptr<gbxnovatelutilacfr::ImuDecoder> imuDecoder_;
Modified: gearbox/trunk/submitted/gbxnovatelacfr/novatel.dox
===================================================================
--- gearbox/trunk/submitted/gbxnovatelacfr/novatel.dox 2008-06-25 07:27:56 UTC (rev 213)
+++ gearbox/trunk/submitted/gbxnovatelacfr/novatel.dox 2008-06-25 09:07:15 UTC (rev 214)
@@ -122,7 +122,13 @@
}
break;
default:
- std::cout << "Got unknown message!\n";
+ if(0 == generic.get()){
+ std::cout << "Got NULL message!\n";
+ }
+ else{
+ std::cout << "Got unknown message!\n";
+ std::cout << generic->toString() << "\n"; // yes this works, since toString() is a member of the base class
+ }
break;
}
}
@@ -147,6 +153,7 @@
- This is a Linux-only implementation (because of the serial library and the system-calls for timestamps)
- Only supports a subset of the messages a NovatelSPAN system can provide.
- Driver currently treats the hardware as data-source only, communication _to_ the hardware is possible only during initialization.
+- Driver doesn't check if configuring the receiver was successful/as-intended
*/
/*!
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|