|
From: <rum...@us...> - 2008-07-12 07:12:49
|
Revision: 285
http://gearbox.svn.sourceforge.net/gearbox/?rev=285&view=rev
Author: rumataxyz
Date: 2008-07-12 00:12:56 -0700 (Sat, 12 Jul 2008)
Log Message:
-----------
sendCmdWaitForResponse() works now even if it reads binary data along with an ack (somewhat hackish).
Modified Paths:
--------------
gearbox/trunk/submitted/gbxnovatelacfr/gbxnovatelutilacfr/serialconnectivity.cpp
Modified: gearbox/trunk/submitted/gbxnovatelacfr/gbxnovatelutilacfr/serialconnectivity.cpp
===================================================================
--- gearbox/trunk/submitted/gbxnovatelacfr/gbxnovatelutilacfr/serialconnectivity.cpp 2008-07-11 07:19:30 UTC (rev 284)
+++ gearbox/trunk/submitted/gbxnovatelacfr/gbxnovatelutilacfr/serialconnectivity.cpp 2008-07-12 07:12:56 UTC (rev 285)
@@ -94,7 +94,14 @@
assert( read != -1 );
//and look for an ACK
+ //it's possible that we have read binary data with embedded '\0'; we want one at the end (string delimeter), but replace the rest with '\1'
buf[read] = '\0';
+ while(0<read){
+ read--;
+ if('\0' == buf[read]){
+ buf[read] = '\1';
+ }
+ }
std::string response(buf);
size_t found = response.find(ack);
if(std::string::npos != found){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|