|
From: <rus...@us...> - 2008-06-09 10:47:35
|
Revision: 177
http://gearbox.svn.sourceforge.net/gearbox/?rev=177&view=rev
Author: russo2503v
Date: 2008-06-09 03:47:43 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
stripping the traling \n
Modified Paths:
--------------
gearbox/trunk/src/gbxgarminacfr/driver.cpp
gearbox/trunk/src/gbxgarminacfr/nmea.cpp
Modified: gearbox/trunk/src/gbxgarminacfr/driver.cpp
===================================================================
--- gearbox/trunk/src/gbxgarminacfr/driver.cpp 2008-06-09 10:29:55 UTC (rev 176)
+++ gearbox/trunk/src/gbxgarminacfr/driver.cpp 2008-06-09 10:47:43 UTC (rev 177)
@@ -305,10 +305,13 @@
// We successfully read something from the serial port
//
tracer_.debug( serialData, 10 );
+
+ // remove the trailing new line character
+ assert( *serialData.end() == '\n' && "Driver: Serial data did not end in '\n'" );
+ serialData.erase( serialData.end() );
// dealing with unexplained cntrl characters in the message
- // don't check the last 2 characters: they're \0 and \n
- for ( string::iterator it=serialData.begin(); it!=serialData.end()-2; ++it ) {
+ for ( string::iterator it=serialData.begin(); it!=serialData.end(); ++it ) {
if ( iscntrl( *it ) ) {
// debug
cout<<now.tv_sec<<" "<<now.tv_usec<<" "<<" before='"<<serialData<<"'"<<endl;
Modified: gearbox/trunk/src/gbxgarminacfr/nmea.cpp
===================================================================
--- gearbox/trunk/src/gbxgarminacfr/nmea.cpp 2008-06-09 10:29:55 UTC (rev 176)
+++ gearbox/trunk/src/gbxgarminacfr/nmea.cpp 2008-06-09 10:47:43 UTC (rev 177)
@@ -166,7 +166,7 @@
haveCheckSum_ = true;
//check that we have the '$' at the start
- if(sentence_[0]!= NMEAStartOfSentence) {
+ if ( sentence_[0]!= NMEAStartOfSentence ) {
throw NmeaException("cannot calculate checksum, missing leading '$'");
}
@@ -176,7 +176,7 @@
unsigned char nextChar;
// we start from 1 to skip the leading '$'
for( loopCount=1; loopCount<MAX_SENTENCE_LEN; ++loopCount )
- {
+ {
nextChar = static_cast<unsigned char>(sentence_[loopCount]);
// no delimiter uh oh
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|