You can subscribe to this list here.
| 2008 |
Jan
|
Feb
(58) |
Mar
(15) |
Apr
(23) |
May
(8) |
Jun
(92) |
Jul
(66) |
Aug
(6) |
Sep
(9) |
Oct
(44) |
Nov
(8) |
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(10) |
Feb
(8) |
Mar
(2) |
Apr
(8) |
May
(19) |
Jun
(11) |
Jul
(8) |
Aug
(6) |
Sep
(5) |
Oct
(4) |
Nov
(26) |
Dec
(4) |
| 2010 |
Jan
(5) |
Feb
(3) |
Mar
(4) |
Apr
(3) |
May
(4) |
Jun
|
Jul
(1) |
Aug
(16) |
Sep
(7) |
Oct
(3) |
Nov
(7) |
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <gb...@us...> - 2008-07-03 05:58:16
|
Revision: 257
http://gearbox.svn.sourceforge.net/gearbox/?rev=257&view=rev
Author: gbiggs
Date: 2008-07-02 22:58:24 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Moving some types around
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/CMakeLists.txt
gearbox/trunk/submitted/flexiport/logfile.cpp
gearbox/trunk/submitted/flexiport/logfile.h
gearbox/trunk/submitted/flexiport/port.h
gearbox/trunk/submitted/flexiport/timeout.h
Added Paths:
-----------
gearbox/trunk/submitted/flexiport/flexiport_types.h
Modified: gearbox/trunk/submitted/flexiport/CMakeLists.txt
===================================================================
--- gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-03 05:23:03 UTC (rev 256)
+++ gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-03 05:58:24 UTC (rev 257)
@@ -17,7 +17,7 @@
CONFIGURE_FILE (${flexiport_config_h_in} ${flexiport_config_h})
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR})
- SET (hdrs flexiport.h port.h timeout.h ${flexiport_config_h})
+ SET (hdrs flexiport.h port.h timeout.h flexiport_types.h ${flexiport_config_h})
SET (srcs flexiport.cpp port.cpp timeout.cpp ${flexiport_config_h})
IF (FLEXIPORT_INCLUDE_SERIAL)
SET (hdrs ${hdrs} serialport.h)
Added: gearbox/trunk/submitted/flexiport/flexiport_types.h
===================================================================
--- gearbox/trunk/submitted/flexiport/flexiport_types.h (rev 0)
+++ gearbox/trunk/submitted/flexiport/flexiport_types.h 2008-07-03 05:58:24 UTC (rev 257)
@@ -0,0 +1,43 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2008 Geoffrey Biggs
+ *
+ * flexiport flexible hardware data communications library.
+ *
+ * This distribution is licensed to you under the terms described in the LICENSE file included in
+ * this distribution.
+ *
+ * This work is a product of the National Institute of Advanced Industrial Science and Technology,
+ * Japan. Registration number: ___
+ *
+ * This file is part of flexiport.
+ *
+ * flexiport is free software: you can redistribute it and/or modify it under the terms of the GNU
+ * Lesser General Public License as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * flexiport is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with flexiport.
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FLEXIPORT_TYPES_H
+#define __FLEXIPORT_TYPES_H
+
+#if defined (WIN32)
+ typedef unsigned char uint8_t;
+ typedef unsigned int uint32_t;
+ #if defined (_WIN64)
+ typedef __int64 ssize_t;
+ #else
+ typedef _W64 int ssize_t;
+ #endif
+#else
+ #include <stdint.h>
+#endif
+
+#endif // __FLEXIPORT_TYPES_H
Modified: gearbox/trunk/submitted/flexiport/logfile.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-03 05:23:03 UTC (rev 256)
+++ gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-03 05:58:24 UTC (rev 257)
@@ -42,7 +42,6 @@
using namespace std;
#if defined (WIN32)
- #include <winsock2.h> // For htnol, etc
#define __func__ __FUNCTION__
#define timercmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? \
Modified: gearbox/trunk/submitted/flexiport/logfile.h
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.h 2008-07-03 05:23:03 UTC (rev 256)
+++ gearbox/trunk/submitted/flexiport/logfile.h 2008-07-03 05:58:24 UTC (rev 257)
@@ -28,7 +28,11 @@
#ifndef __LOGFILE_H
#define __LOGFILE_H
-#include <sys/time.h>
+#if defined (WIN32)
+ #include <winsock2.h> // For timeval
+#else
+ #include <sys/time.h>
+#endif
#include <string>
#include <vector>
Modified: gearbox/trunk/submitted/flexiport/port.h
===================================================================
--- gearbox/trunk/submitted/flexiport/port.h 2008-07-03 05:23:03 UTC (rev 256)
+++ gearbox/trunk/submitted/flexiport/port.h 2008-07-03 05:58:24 UTC (rev 257)
@@ -32,23 +32,16 @@
#include <map>
#if defined (WIN32)
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #if defined (_WIN64)
- typedef __int64 ssize_t;
- #else
- typedef _W64 int ssize_t;
- #endif
#if defined (FLEXIPORT_EXPORTS)
#define FLEXIPORT_EXPORT __declspec (dllexport)
#else
#define FLEXIPORT_EXPORT __declspec (dllimport)
#endif
#else
- #include <stdint.h>
#define FLEXIPORT_EXPORT
#endif
+#include "flexiport_types.h"
#include "timeout.h"
/** @ingroup gbx_library_flexiport
Modified: gearbox/trunk/submitted/flexiport/timeout.h
===================================================================
--- gearbox/trunk/submitted/flexiport/timeout.h 2008-07-03 05:23:03 UTC (rev 256)
+++ gearbox/trunk/submitted/flexiport/timeout.h 2008-07-03 05:58:24 UTC (rev 257)
@@ -32,17 +32,17 @@
#include <string>
#if defined (WIN32)
+ #if defined (FLEXIPORT_EXPORTS)
+ #define FLEXIPORT_EXPORT __declspec (dllexport)
+ #else
+ #define FLEXIPORT_EXPORT __declspec (dllimport)
+ #endif
// No timespec on Windows
typedef struct timespec
{
int tv_sec;
int tv_nsec;
} timespec;
- #if defined (FLEXIPORT_EXPORTS)
- #define FLEXIPORT_EXPORT __declspec (dllexport)
- #else
- #define FLEXIPORT_EXPORT __declspec (dllimport)
- #endif
#else
#define FLEXIPORT_EXPORT
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-03 05:23:05
|
Revision: 256
http://gearbox.svn.sourceforge.net/gearbox/?rev=256&view=rev
Author: gbiggs
Date: 2008-07-02 22:23:03 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Making the log file part of flexiport cross-platform
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/CMakeLists.txt
gearbox/trunk/submitted/flexiport/logfile.cpp
gearbox/trunk/submitted/flexiport/logfile.h
gearbox/trunk/submitted/flexiport/logreaderport.h
gearbox/trunk/submitted/flexiport/logwriterport.h
Modified: gearbox/trunk/submitted/flexiport/CMakeLists.txt
===================================================================
--- gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-03 02:01:02 UTC (rev 255)
+++ gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-03 05:23:03 UTC (rev 256)
@@ -9,12 +9,7 @@
OPTION (FLEXIPORT_INCLUDE_SERIAL "Include the serial port in FlexiPort" ON)
OPTION (FLEXIPORT_INCLUDE_TCP "Include the TCP network port in FlexiPort" ON)
- IF (GBX_OS_WIN)
- SET (FLEXIPORT_INCLUDE_LOGGING OFF)
- MESSAGE (STATUS "Flexiport log file system is not currently supported on Windows.")
- ELSE (GBX_OS_WIN)
- OPTION (FLEXIPORT_INCLUDE_LOGGING "Include the log reader/writer ports in FlexiPort" ON)
- ENDIF (GBX_OS_WIN)
+ OPTION (FLEXIPORT_INCLUDE_LOGGING "Include the log reader/writer ports in FlexiPort" ON)
MARK_AS_ADVANCED (FLEXIPORT_INCLUDE_SERIAL FLEXIPORT_INCLUDE_TCP)
SET (flexiport_config_h_in ${CMAKE_CURRENT_SOURCE_DIR}/flexiport_config.h.in)
Modified: gearbox/trunk/submitted/flexiport/logfile.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-03 02:01:02 UTC (rev 255)
+++ gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-03 05:23:03 UTC (rev 256)
@@ -42,7 +42,32 @@
using namespace std;
#if defined (WIN32)
+ #include <winsock2.h> // For htnol, etc
#define __func__ __FUNCTION__
+ #define timercmp(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) ? \
+ ((a)->tv_usec CMP (b)->tv_usec) : \
+ ((a)->tv_sec CMP (b)->tv_sec))
+ #define timeradd(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) \
+ { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+ #define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+ #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
#endif
namespace flexiport
@@ -84,7 +109,6 @@
: _read (false), _readFile (NULL), _writeFile (NULL), _readFileSize (0), _writeFileSize (0),
_debug (debug), _readUsage (0), _writeUsage (0), _readSize (0), _writeSize (0),
_readBuffer (NULL), _writeBuffer (NULL), _ignoreTimes (false)
-// _bufferSize (0),
{
timerclear (&_openTime);
}
@@ -228,13 +252,6 @@
return true;
}
-//void LogFile::SetBufferSize (unsigned int bufferSize)
-//{
-// _bufferSize = bufferSize;
-// AllocateReadBuffer (_bufferSize);
-// AllocateWriteBuffer (_bufferSize);
-//}
-
void LogFile::ResetFile (void)
{
// Rewind file positions
@@ -258,6 +275,12 @@
DeallocateWriteBuffer ();
// Reset file open time
+#if defined (WIN32)
+ SYSTEMTIME sysTime;
+ GetSystemTime (&sysTime);
+ _openTime.tv_sec = sysTime.wSecond;
+ _openTime.tv_usec = sysTime.wMilliseconds * 1000;
+#else
if (gettimeofday (&_openTime, NULL) < 0)
{
stringstream ss;
@@ -265,6 +288,7 @@
StrError (ErrNo ());
throw PortException (ss.str ());
}
+#endif
if (_debug >= 1)
cerr << "LogFile::" << __func__ << "() Reset file." << endl;
@@ -970,6 +994,12 @@
{
struct timeval now;
+#if defined (WIN32)
+ SYSTEMTIME sysTime;
+ GetSystemTime (&sysTime);
+ now.tv_sec = sysTime.wSecond;
+ now.tv_usec = sysTime.wMilliseconds * 1000;
+#else
if (gettimeofday (&now, NULL) < 0)
{
stringstream ss;
@@ -977,6 +1007,7 @@
StrError (ErrNo ());
throw PortException (ss.str ());
}
+#endif
timersub (&now, &_openTime, &dest);
if (_debug >= 3)
@@ -1308,6 +1339,12 @@
{
// Calculate the time difference between now and the time the file was opened
struct timeval now, diff;
+#if defined (WIN32)
+ SYSTEMTIME sysTime;
+ GetSystemTime (&sysTime);
+ now.tv_sec = sysTime.wSecond;
+ now.tv_usec = sysTime.wMilliseconds * 1000;
+#else
if (gettimeofday (&now, NULL) < 0)
{
stringstream ss;
@@ -1315,6 +1352,7 @@
StrError (ErrNo ());
throw PortException (ss.str ());
}
+#endif
timersub (&now, &_openTime, &diff);
uint32_t secs, usecs;
secs = htonl (static_cast<uint32_t> (diff.tv_sec));
Modified: gearbox/trunk/submitted/flexiport/logfile.h
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.h 2008-07-03 02:01:02 UTC (rev 255)
+++ gearbox/trunk/submitted/flexiport/logfile.h 2008-07-03 05:23:03 UTC (rev 256)
@@ -34,11 +34,6 @@
#include "timeout.h"
-#if defined (WIN32)
- // We're passing FILE types all over the place so easier to #define it for Win32
- #define FILE HANDLE
-#endif
-
namespace flexiport
{
Modified: gearbox/trunk/submitted/flexiport/logreaderport.h
===================================================================
--- gearbox/trunk/submitted/flexiport/logreaderport.h 2008-07-03 02:01:02 UTC (rev 255)
+++ gearbox/trunk/submitted/flexiport/logreaderport.h 2008-07-03 05:23:03 UTC (rev 256)
@@ -47,6 +47,11 @@
Uses a log file created by the @ref LogWriterPort port type to simulate the data transfer over a
@ref Port object.
+@note Log files greater than 2GB in size are not supported.
+
+@note The timer resolution under Windows is milliseconds, not microseconds. This may result in
+inaccurate replay when using a log file created on a POSIX-compatible operating system.
+
See the @ref Port class documentation for how to use the common API.
@par Options
Modified: gearbox/trunk/submitted/flexiport/logwriterport.h
===================================================================
--- gearbox/trunk/submitted/flexiport/logwriterport.h 2008-07-03 02:01:02 UTC (rev 255)
+++ gearbox/trunk/submitted/flexiport/logwriterport.h 2008-07-03 05:23:03 UTC (rev 256)
@@ -51,6 +51,11 @@
@ref CreatePort. For example, a log writer that uses a serial port would be specified as the type
"seriallog". Similarly, for a TCP port, use "tcplog".
+@note Log files greater than 2GB in size are not supported.
+
+@note The timer resolution under Windows is milliseconds, not microseconds. This may result in
+inaccurate replay when using a log file created on a POSIX-compatible operating system.
+
See the @ref Port class documentation for how to use the common API.
@par Options
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-03 02:00:53
|
Revision: 255
http://gearbox.svn.sourceforge.net/gearbox/?rev=255&view=rev
Author: gbiggs
Date: 2008-07-02 19:01:02 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Added a note about MD/ME commands turning the laser off
Modified Paths:
--------------
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-03 01:58:41 UTC (rev 254)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-03 02:01:02 UTC (rev 255)
@@ -389,9 +389,15 @@
Unlike @ref GetRanges, which returns the most recent scan the scanner took, this function
will request a new scan. This means it will wait while the scanner performs the scan.
Otherwise behaves identicallty to @ref GetRanges.
-
+
Not available with the SCIP v1 protocol.
+ @note The command used to retrieve a fresh scan is also used for the continuous scanning
+ mode (not yet supported by this library). After completing a scan, it will turn the laser
+ off (in anticipation of another continuous scan command being sent, which will automatically
+ turn the laser back on again). If you want to mix @ref GetNewRanges and @ref GetRanges, you
+ will need to turn the laser on after each call to @ref GetNewRanges.
+
@param data Pointer to a @ref HokuyoData object to store the range readings in.
@param clusterCount The number of readings to cluster together into a single reading. The
minimum value from a cluster is returned as the range for that cluster.
@@ -424,6 +430,12 @@
Not available with the SCIP v1 protocol.
+ @note The command used to retrieve a fresh scan is also used for the continuous scanning
+ mode (not yet supported by this library). After completing a scan, it will turn the laser
+ off (in anticipation of another continuous scan command being sent, which will automatically
+ turn the laser back on again). If you want to mix @ref GetNewRanges and @ref GetRanges, you
+ will need to turn the laser on after each call to @ref GetNewRanges.
+
@param data Pointer to a @ref HokuyoData object to store the range readings in.
@param clusterCount The number of readings to cluster together into a single reading. The
minimum value from a cluster is returned as the range for that cluster.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-03 01:58:32
|
Revision: 254
http://gearbox.svn.sourceforge.net/gearbox/?rev=254&view=rev
Author: gbiggs
Date: 2008-07-02 18:58:41 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Fixed MD and ME commands, error in flexiport.h comment, flush before sending a command to the scanner
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/flexiport.h
gearbox/trunk/submitted/flexiport/logfile.h
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
Modified: gearbox/trunk/submitted/flexiport/flexiport.h
===================================================================
--- gearbox/trunk/submitted/flexiport/flexiport.h 2008-07-02 11:18:04 UTC (rev 253)
+++ gearbox/trunk/submitted/flexiport/flexiport.h 2008-07-03 01:58:41 UTC (rev 254)
@@ -88,7 +88,7 @@
/** @brief Overloaded factory function. Accepts options as a string.
This overload accepts the options as a string. For example:
-"type=serial device=/dev/ttyS0 baudrate=4800 readwrite"
+"type=serial device=/dev/ttyS0 baud=4800 readwrite"
Options may be separated by any of: spaces, tabs, new lines or commas. Do not put whitespace around
an equals sign.
Modified: gearbox/trunk/submitted/flexiport/logfile.h
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.h 2008-07-02 11:18:04 UTC (rev 253)
+++ gearbox/trunk/submitted/flexiport/logfile.h 2008-07-03 01:58:41 UTC (rev 254)
@@ -34,6 +34,11 @@
#include "timeout.h"
+#if defined (WIN32)
+ // We're passing FILE types all over the place so easier to #define it for Win32
+ #define FILE HANDLE
+#endif
+
namespace flexiport
{
@@ -47,7 +52,6 @@
void Open (std::string fileName, bool read, bool ignoreTimes = false);
void Close (void);
bool IsOpen (void) const;
-// void SetBufferSize (unsigned int bufferSize);
void ResetFile (void);
// File reading
@@ -70,7 +74,6 @@
// When writing, this is the time the file was opened. When reading, it's the reset time.
struct timeval _openTime;
unsigned int _debug;
-// unsigned int _bufferSize;
size_t _readUsage, _writeUsage;
size_t _readSize, _writeSize;
uint8_t *_readBuffer, *_writeBuffer;
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-02 11:18:04 UTC (rev 253)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-03 01:58:41 UTC (rev 254)
@@ -1494,6 +1494,43 @@
NumberToString (1, &buffer[10], 1);
NumberToString (1, &buffer[11], 2);
SendCommand ("MD", buffer, 13, NULL);
+ // Mx commands will perform a scan, then send the data prefixed with another command echo
+ // Read back the command echo (minimum of 3 bytes, maximum of 16 bytes)
+ char response[17];
+ SkipLines (1); // End of the command echo message
+ ReadLine (response, 16); // Size is command (2) + params (13) + new line (1)
+ // Check the echo is correct
+ if (response[0] != 'M' || response[1] != 'D')
+ {
+ stringstream ss;
+ ss << "Incorrect data prefix: MD" << " != " << response[0] << response[1];
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+ // Then compare the parameters
+ buffer[12] = '0'; // There will be zero scans remaining after this one
+ if (memcmp (&response[2], buffer, 13) != 0)
+ {
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Incorrect paramaters prefix for MD data.");
+ }
+ // The next line should be the status line
+ ReadLineWithCheck (response, 4);
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() MD data prefix status: " << response[0] <<
+ response[1] << endl;
+ }
+ // Check the status code is OK - should only get 99 here
+ if (response[0] != '9' || response[1] != '9')
+ {
+ // There is an extra line feed after an error status (signalling end of message)
+ SkipLines (1);
+ stringstream ss;
+ ss << "Bad status for MD data: " << response[0] << response[1] <<
+ " " << SCIP2ErrorToString (response, "MD");
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+
+ // Now the actual data will arrive
// There will be a timestamp before the data (if there is data)
// Normally we would send 6 for the expected length, but we may get no timestamp back if
// there was no data.
@@ -1578,6 +1615,43 @@
NumberToString (1, &buffer[10], 1);
NumberToString (1, &buffer[11], 2);
SendCommand ("ME", buffer, 13, NULL);
+ // Mx commands will perform a scan, then send the data prefixed with another command echo
+ // Read back the command echo (minimum of 3 bytes, maximum of 16 bytes)
+ char response[17];
+ SkipLines (1); // End of the command echo message
+ ReadLine (response, 16); // Size is command (2) + params (13) + new line (1)
+ // Check the echo is correct
+ if (response[0] != 'M' || response[1] != 'E')
+ {
+ stringstream ss;
+ ss << "Incorrect data prefix: ME" << " != " << response[0] << response[1];
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+ // Then compare the parameters
+ buffer[12] = '0'; // There will be zero scans remaining after this one
+ if (memcmp (&response[2], buffer, 13) != 0)
+ {
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Incorrect paramaters prefix for ME data.");
+ }
+ // The next line should be the status line
+ ReadLineWithCheck (response, 4);
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() ME data prefix status: " << response[0] <<
+ response[1] << endl;
+ }
+ // Check the status code is OK - should only get 99 here
+ if (response[0] != '9' || response[1] != '9')
+ {
+ // There is an extra line feed after an error status (signalling end of message)
+ SkipLines (1);
+ stringstream ss;
+ ss << "Bad status for ME data: " << response[0] << response[1] <<
+ " " << SCIP2ErrorToString (response, "MD");
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+
+ // Now the actual data will arrive
// There will be a timestamp before the data (if there is data)
// Normally we would send 6 for the expected length, but we may get no timestamp back if
// there was no data.
@@ -1648,9 +1722,21 @@
// Private functions
////////////////////////////////////////////////////////////////////////////////////////////////////
+// Sometimes, just flushing isn't enough, as it appears the scanner will wait when the buffer gets
+// full, then continue sending data. If we flush, we get rid of what was sent, and the scanner just
+// sends more. This is a problem if we're trying to clear the result of a previous command.
+// To get around this, keep flushing until the port reports there is no data left after a timeout.
+// This shouldn't be called too much, as it introduces a delay as big as the timeout (which may be
+// infinite).
+void HokuyoLaser::ClearReadBuffer (void)
+{
+ while (_port->BytesAvailableWait () > 0)
+ _port->Flush ();
+}
+
// If expectedLength is not -1, it should include the terminating line feed but not the NULL
// (although the buffer still has to include this).
-// If expectedLenght is -1, this function expects buffer to be a certain length to allow up to the
+// If expectedLength is -1, this function expects buffer to be a certain length to allow up to the
// maximum line length to be read. See SCIP1_LINE_LENGTH and SCIP2_LINE_LENGTH.
// The line feed that terminates a line will be replaced with a NULL.
// The return value is the number of bytes received, not including the NULL byte or the line feed.
@@ -1793,7 +1879,11 @@
int paramLength, const char *extraOK)
{
int statusCode = -1;
- char response[16];
+ char response[17];
+
+ // Flush first to clear out the dregs of any previous commands
+ _port->Flush ();
+
if (_scipVersion == 1)
{
if (_verbose)
@@ -1948,6 +2038,7 @@
void HokuyoLaser::GetAndSetSCIPVersion (void)
{
bool scip1Failed = false;
+
if (_verbose)
cerr << "HokuyoLaser::" << __func__ << "() Testing SCIP protocol version." << endl;
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-02 11:18:04 UTC (rev 253)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-03 01:58:41 UTC (rev 254)
@@ -469,6 +469,7 @@
int _firstStep, _lastStep, _frontStep;
unsigned int _maxRange;
+ void ClearReadBuffer (void);
int ReadLine (char *buffer, int expectedLength = -1);
int ReadLineWithCheck (char *buffer, int expectedLength = -1, bool hasSemicolon = false);
void SkipLines (int count);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-02 11:18:04
|
Revision: 253
http://gearbox.svn.sourceforge.net/gearbox/?rev=253&view=rev
Author: tobasco
Date: 2008-07-02 04:18:04 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
gearbox/trunk/doc/todo.dox
Modified: gearbox/trunk/doc/todo.dox
===================================================================
--- gearbox/trunk/doc/todo.dox 2008-07-02 11:13:10 UTC (rev 252)
+++ gearbox/trunk/doc/todo.dox 2008-07-02 11:18:04 UTC (rev 253)
@@ -28,10 +28,18 @@
- Build system
- cmake files updated for cmake 2.6
+
+- Compiler
+ - compiles cleanly under gcc43
@par New libraries
- libGbxGarminAcfr
+- libGbxUtilAcfr
+- libGbxNovatelAcfr
+- flexiport
+- libGbxSmartBatteryAcfr
+- hokuyo_aist
@par Updated libraries
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-02 11:13:12
|
Revision: 252
http://gearbox.svn.sourceforge.net/gearbox/?rev=252&view=rev
Author: tobasco
Date: 2008-07-02 04:13:10 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
added category hardware
Modified Paths:
--------------
gearbox/trunk/src/gbxgarminacfr/doc.dox
gearbox/trunk/src/gbxserialacfr/doc.dox
gearbox/trunk/src/gbxsickacfr/doc.dox
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
Modified: gearbox/trunk/src/gbxgarminacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxgarminacfr/doc.dox 2008-07-02 08:28:13 UTC (rev 251)
+++ gearbox/trunk/src/gbxgarminacfr/doc.dox 2008-07-02 11:13:10 UTC (rev 252)
@@ -10,6 +10,7 @@
/*!
@ingroup gbx_libs
+@ingroup gbx_hardware
@ingroup gbx_cpp
@ingroup gbx_linux
@defgroup gbx_library_gbxgarminacfr GbxGarminAcfr
Modified: gearbox/trunk/src/gbxserialacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxserialacfr/doc.dox 2008-07-02 08:28:13 UTC (rev 251)
+++ gearbox/trunk/src/gbxserialacfr/doc.dox 2008-07-02 11:13:10 UTC (rev 252)
@@ -10,6 +10,7 @@
/*!
@ingroup gbx_libs
+@ingroup gbx_hardware
@ingroup gbx_cpp
@ingroup gbx_linux
@defgroup gbx_library_gbxserialacfr libGbxSerialAcfr
Modified: gearbox/trunk/src/gbxsickacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxsickacfr/doc.dox 2008-07-02 08:28:13 UTC (rev 251)
+++ gearbox/trunk/src/gbxsickacfr/doc.dox 2008-07-02 11:13:10 UTC (rev 252)
@@ -10,6 +10,7 @@
/*!
@ingroup gbx_libs
+@ingroup gbx_hardware
@ingroup gbx_cpp
@ingroup gbx_linux
@defgroup gbx_library_gbxsickacfr GbxSickAcfr
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-02 08:28:13 UTC (rev 251)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-02 11:13:10 UTC (rev 252)
@@ -10,6 +10,7 @@
/*!
@ingroup gbx_libs
+@ingroup gbx_hardware
@ingroup gbx_cpp
@ingroup gbx_linux
@defgroup gbx_library_gbxsmartbatteryacfr GbxSmartBatteryAcfr
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-02 08:28:04
|
Revision: 251
http://gearbox.svn.sourceforge.net/gearbox/?rev=251&view=rev
Author: gbiggs
Date: 2008-07-02 01:28:13 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Fixed a couple of windows compile errors
Modified Paths:
--------------
gearbox/trunk/src/gbxutilacfr/exceptions.cpp
gearbox/trunk/src/gbxutilacfr/tokenise.cpp
Modified: gearbox/trunk/src/gbxutilacfr/exceptions.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/exceptions.cpp 2008-07-02 08:27:03 UTC (rev 250)
+++ gearbox/trunk/src/gbxutilacfr/exceptions.cpp 2008-07-02 08:28:13 UTC (rev 251)
@@ -49,7 +49,7 @@
message_ += this->basename(file);
message_ += ":";
message_ += line;
- message_ += +"): " + msgString + "\n";
+ message_ += "): " + msgString + "\n";
}
} // namespace
Modified: gearbox/trunk/src/gbxutilacfr/tokenise.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/tokenise.cpp 2008-07-02 08:27:03 UTC (rev 250)
+++ gearbox/trunk/src/gbxutilacfr/tokenise.cpp 2008-07-02 08:28:13 UTC (rev 251)
@@ -17,7 +17,7 @@
std::vector<string> tokenise( const string &str, const string &delimiter )
{
-#define SKIP_DELIMS false
+#define SKIP_DELIMS 0
#if !SKIP_DELIMS
std::vector<std::string> tokens;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-02 08:26:58
|
Revision: 250
http://gearbox.svn.sourceforge.net/gearbox/?rev=250&view=rev
Author: gbiggs
Date: 2008-07-02 01:27:03 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
Fixed compilation of flexiport and hokuyo_aist on Windows and with GCC 4.3.
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/CMakeLists.txt
gearbox/trunk/submitted/flexiport/logfile.cpp
gearbox/trunk/submitted/flexiport/port.cpp
gearbox/trunk/submitted/flexiport/port.h
gearbox/trunk/submitted/flexiport/serialport.cpp
gearbox/trunk/submitted/flexiport/tcpport.cpp
gearbox/trunk/submitted/flexiport/test/serial_example.cpp
gearbox/trunk/submitted/flexiport/test/tcp_example.cpp
gearbox/trunk/submitted/flexiport/timeout.cpp
gearbox/trunk/submitted/flexiport/timeout.h
gearbox/trunk/submitted/flexiport/utils/porttoport.cpp
gearbox/trunk/submitted/hokuyo_aist/CMakeLists.txt
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
Modified: gearbox/trunk/submitted/flexiport/CMakeLists.txt
===================================================================
--- gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/CMakeLists.txt 2008-07-02 08:27:03 UTC (rev 250)
@@ -9,7 +9,12 @@
OPTION (FLEXIPORT_INCLUDE_SERIAL "Include the serial port in FlexiPort" ON)
OPTION (FLEXIPORT_INCLUDE_TCP "Include the TCP network port in FlexiPort" ON)
- OPTION (FLEXIPORT_INCLUDE_LOGGING "Include the log reader/writer ports in FlexiPort" ON)
+ IF (GBX_OS_WIN)
+ SET (FLEXIPORT_INCLUDE_LOGGING OFF)
+ MESSAGE (STATUS "Flexiport log file system is not currently supported on Windows.")
+ ELSE (GBX_OS_WIN)
+ OPTION (FLEXIPORT_INCLUDE_LOGGING "Include the log reader/writer ports in FlexiPort" ON)
+ ENDIF (GBX_OS_WIN)
MARK_AS_ADVANCED (FLEXIPORT_INCLUDE_SERIAL FLEXIPORT_INCLUDE_TCP)
SET (flexiport_config_h_in ${CMAKE_CURRENT_SOURCE_DIR}/flexiport_config.h.in)
@@ -28,12 +33,8 @@
SET (srcs ${srcs} tcpport.cpp)
ENDIF (FLEXIPORT_INCLUDE_TCP)
IF (FLEXIPORT_INCLUDE_LOGGING)
- IF (NOT GBX_OS_WIN)
- SET (hdrs ${hdrs} logwriterport.h logreaderport.h)
- SET (srcs ${srcs} logwriterport.cpp logreaderport.cpp logfile.cpp)
- ELSE (NOT GBX_OS_WIN)
- MESSAGE (STATUS "Flexiport log file system is not currently supported on Windows.")
- ENDIF (NOT GBX_OS_WIN)
+ SET (hdrs ${hdrs} logwriterport.h logreaderport.h)
+ SET (srcs ${srcs} logwriterport.cpp logreaderport.cpp logfile.cpp)
ENDIF (FLEXIPORT_INCLUDE_LOGGING)
IF (WIN32)
Modified: gearbox/trunk/submitted/flexiport/logfile.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -28,6 +28,8 @@
#include "flexiport.h"
#include "logfile.h"
+#include <cstdlib>
+#include <cstring>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/stat.h>
Modified: gearbox/trunk/submitted/flexiport/port.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/port.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/port.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -28,6 +28,7 @@
#include "port.h"
#include "flexiport.h"
+#include <cstring>
#include <assert.h>
#include <errno.h>
#include <time.h>
Modified: gearbox/trunk/submitted/flexiport/port.h
===================================================================
--- gearbox/trunk/submitted/flexiport/port.h 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/port.h 2008-07-02 08:27:03 UTC (rev 250)
@@ -33,6 +33,12 @@
#if defined (WIN32)
typedef unsigned char uint8_t;
+ typedef unsigned int uint32_t;
+ #if defined (_WIN64)
+ typedef __int64 ssize_t;
+ #else
+ typedef _W64 int ssize_t;
+ #endif
#if defined (FLEXIPORT_EXPORTS)
#define FLEXIPORT_EXPORT __declspec (dllexport)
#else
Modified: gearbox/trunk/submitted/flexiport/serialport.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/serialport.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/serialport.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -40,6 +40,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <cstring>
#include <sstream>
#include <iostream>
using namespace std;
Modified: gearbox/trunk/submitted/flexiport/tcpport.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/tcpport.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/tcpport.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -264,8 +264,13 @@
while (receivedBytes < count)
{
+#if defined (WIN32)
numReceived = recv (_sock, &(reinterpret_cast<char*> (buffer)[receivedBytes]),
+ count, 0); // No MSG_WAITALL on older versions of visual c, it seems
+#else
+ numReceived = recv (_sock, &(reinterpret_cast<char*> (buffer)[receivedBytes]),
count, MSG_WAITALL);
+#endif
if (_debug >= 2)
cerr << "TCPPort::" << __func__ << "() Received " << numReceived << " bytes" << endl;
if (numReceived < 0)
Modified: gearbox/trunk/submitted/flexiport/test/serial_example.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/test/serial_example.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/test/serial_example.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -54,12 +54,12 @@
int main (int argc, char **argv)
{
- int opt;
string portOptions = "type=serial,device=/dev/ttyS0,timeout=1";
#if defined (WIN32)
portOptions = "type=serial,device=COM1,timeout=1";
#else
+ int opt;
// Get some options from the command line
while ((opt = getopt (argc, argv, "o:")) != -1)
{
Modified: gearbox/trunk/submitted/flexiport/test/tcp_example.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/test/tcp_example.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/test/tcp_example.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -180,12 +180,12 @@
int main (int argc, char **argv)
{
- int opt;
string portOptions;
#if defined (WIN32)
portOptions = "";
#else
+ int opt;
// Get some options from the command line
while ((opt = getopt (argc, argv, "o:")) != -1)
{
Modified: gearbox/trunk/submitted/flexiport/timeout.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/timeout.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/timeout.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -25,7 +25,13 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
-#include <time.h>
+#if defined (WIN32)
+ #include <time.h>
+ // timeval is only in WinSock (stupidity)
+ #include <winsock2.h>
+#else
+ #include <sys/time.h>
+#endif
#include "timeout.h"
Modified: gearbox/trunk/submitted/flexiport/timeout.h
===================================================================
--- gearbox/trunk/submitted/flexiport/timeout.h 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/timeout.h 2008-07-02 08:27:03 UTC (rev 250)
@@ -32,6 +32,12 @@
#include <string>
#if defined (WIN32)
+ // No timespec on Windows
+ typedef struct timespec
+ {
+ int tv_sec;
+ int tv_nsec;
+ } timespec;
#if defined (FLEXIPORT_EXPORTS)
#define FLEXIPORT_EXPORT __declspec (dllexport)
#else
Modified: gearbox/trunk/submitted/flexiport/utils/porttoport.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/utils/porttoport.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/flexiport/utils/porttoport.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -25,6 +25,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
+#include <cstdlib>
#include <unistd.h>
#include <iostream>
#include <sstream>
Modified: gearbox/trunk/submitted/hokuyo_aist/CMakeLists.txt
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/CMakeLists.txt 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/hokuyo_aist/CMakeLists.txt 2008-07-02 08:27:03 UTC (rev 250)
@@ -12,10 +12,10 @@
INCLUDE (${GBX_CMAKE_DIR}/UseBasicRules.cmake)
SET (hdrs hokuyo_aist.h)
- SET (srcs hokuyo_aist.cpp)
+ SET (srcs hokuyo_aist.cpp)
IF (WIN32)
- ADD_DEFINITIONS (-DURG_NZ_EXPORTS)
+ ADD_DEFINITIONS (-DHOKUYO_AIST_EXPORTS)
ENDIF (WIN32)
GBX_ADD_LIBRARY (${libName} SHARED ${srcs})
TARGET_LINK_LIBRARIES (${libName} ${reqLibs})
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -31,6 +31,8 @@
#include <flexiport/flexiport.h>
#include <flexiport/port.h>
#include <flexiport/serialport.h>
+
+#include <cstring>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
@@ -1053,7 +1055,7 @@
else if (_scipVersion == 2)
{
// Sanity check the value
- if (speed > 10 & speed != 99)
+ if (speed > 10 && speed != 99)
throw HokuyoError (HOKUYO_ERR_BADARG, "Invalid motor speed.");
char buffer[3];
if (speed == 0)
@@ -1954,7 +1956,7 @@
{
SendCommand ("V", NULL, 0, NULL);
}
- catch (HokuyoError &e)
+ catch (HokuyoError)
{
// That didn't work too well...
if (_verbose)
@@ -1973,7 +1975,7 @@
{
SendCommand ("VV", NULL, 0, NULL);
}
- catch (HokuyoError &e)
+ catch (HokuyoError)
{
throw HokuyoError (HOKUYO_ERR_SCIPVERSION, "SCIP versions 1 and 2 failed.");
}
@@ -2068,7 +2070,7 @@
{
SendCommand ("S", "CIP2.0", 6, NULL);
}
- catch (HokuyoError &e)
+ catch (HokuyoError)
{
if (_verbose)
cerr << "HokuyoLaser::" << __func__ <<
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-02 08:27:03 UTC (rev 250)
@@ -33,6 +33,7 @@
#if defined (WIN32)
typedef unsigned char uint8_t;
+ typedef unsigned int uint32_t;
#if defined (HOKUYO_AIST_EXPORTS)
#define HOKUYO_AIST_EXPORT __declspec (dllexport)
#else
Modified: gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-02 05:06:14 UTC (rev 249)
+++ gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-02 08:27:03 UTC (rev 250)
@@ -35,13 +35,14 @@
{
string portOptions = "type=serial,device=/dev/ttyACM0,timeout=1";
double startAngle = 0.0, endAngle = 0.0;
- int opt, firstStep = -1, lastStep = -1;
+ int firstStep = -1, lastStep = -1;
unsigned int baud = 19200, speed = 0, clusterCount = 1;
bool getNew = false, verbose = false;
#if defined (WIN32)
portOptions = "type=serial,device=COM3,timeout=1";
#else
+ int opt;
// Get some options from the command line
while ((opt = getopt(argc, argv, "b:c:e:f:l:m:no:s:vh")) != -1)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-02 05:06:16
|
Revision: 249
http://gearbox.svn.sourceforge.net/gearbox/?rev=249&view=rev
Author: tobasco
Date: 2008-07-01 22:06:14 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Alex's comments II
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp 2008-07-02 05:06:14 UTC (rev 249)
@@ -13,21 +13,30 @@
#include "oceanserver.h"
namespace gbxsmartbatteryacfr {
+
+static const int MAX_EXCEPTIONS_ROW = 10;
OceanServer::OceanServer( const std::string &port,
gbxutilacfr::Tracer &tracer)
- : tracer_(tracer)
+ : tracer_(tracer),
+ exceptionCounter_(0)
{
reader_.reset(new gbxsmartbatteryacfr::OceanServerReader( port, tracer_ ));
}
-void
-OceanServer::read()
+const gbxsmartbatteryacfr::OceanServerSystem&
+OceanServer::getData()
{
try
{
+ // read new data, this may throw
gbxsmartbatteryacfr::OceanServerSystem data;
reader_->read(data);
+
+ // if successful, reset counter
+ exceptionCounter_ = 0;
+
+ // update internal (full) record
gbxsmartbatteryacfr::updateWithNewData( data, data_ );
}
catch ( gbxsmartbatteryacfr::ParsingException &e )
@@ -37,12 +46,19 @@
<< e.what() << endl
<< "This can happen sometimes. Will continue regardless.";
tracer_.info( ss.str() );
+
+ exceptionCounter_++;
+ if (exceptionCounter_ >= MAX_EXCEPTIONS_ROW)
+ {
+ ss.str("");
+ ss << "OceanServer: " << __func__ << ": Caught " << MAX_EXCEPTIONS_ROW
+ << " ParsingExceptions in a row. Something must be wrong";
+ throw gbxutilacfr::Exception( ERROR_INFO, ss.str() );
+ }
}
-}
-
-const gbxsmartbatteryacfr::OceanServerSystem&
-OceanServer::getData() const
-{
+
+ // return updated internal storage
+ // if there was an exception on read, we just return the previous record
return data_;
}
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h 2008-07-02 05:06:14 UTC (rev 249)
@@ -33,18 +33,19 @@
OceanServer( const std::string &port,
gbxutilacfr::Tracer &tracer);
- //! Reads data from OceanServer and incrementally updates internal storage
- void read();
+ //! Reads data from OceanServer, incrementally updates internal storage
+ //! Returns a reference to the internal storage
+ //! May throw gbxutilacfr::Exception
+ const gbxsmartbatteryacfr::OceanServerSystem& getData();
- //! Returns a reference to the current (incrementally updated) OceanServer data
- const gbxsmartbatteryacfr::OceanServerSystem& getData() const;
-
private:
gbxsmartbatteryacfr::OceanServerSystem data_;
gbxutilacfr::Tracer& tracer_;
auto_ptr<gbxsmartbatteryacfr::OceanServerReader> reader_;
+ int exceptionCounter_;
+
};
} //namespace
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-02 05:06:14 UTC (rev 249)
@@ -18,16 +18,45 @@
namespace gbxsmartbatteryacfr {
-// baudrate is fixed
-static const int BAUDRATE = 19200;
+namespace {
+
+ // baudrate is fixed
+ static const int BAUDRATE = 19200;
+
+ // timeout for reading from the serial port
+ static const int TIMEOUT_SEC = 2;
+
+ // the maximum number of lines to read until we are confident that we are not
+ // connected to an OceanServer system
+ static const int MAX_TRIES = 50;
+
+ // Returns true if 100% sure that we are connected to an OceanServer system, otherwise false
+ bool isOceanServerSystem( const string &candidateString )
+ {
+ // number of characters which we require to match
+ // if they match, we are pretty sure we have an OceanServerSystem
+ unsigned int numCharRequired = 8;
+ if ( candidateString.size()<numCharRequired ) return false;
+
+ // some menu entries from the OceanServer system - used to recognize whether
+ // we are connected to the right device
+ std::vector<std::string> oceanServerStrings;
+ oceanServerStrings.push_back(" S - Setup Controller");
+ oceanServerStrings.push_back(" B - Battery Status");
+ oceanServerStrings.push_back(" X - Host HEX");
+ oceanServerStrings.push_back(" H - Help");
+ oceanServerStrings.push_back(" www.ocean-server.com");
+
+ for (unsigned int i=0; i<oceanServerStrings.size(); i++)
+ {
+ if ( strncmp(oceanServerStrings[i].c_str(),candidateString.c_str(),numCharRequired)==0 )
+ return true;
+ }
+ return false;
+ }
-// timeout for reading from the serial port
-static const int TIMEOUT_SEC = 2;
+}
-// the maximum number of lines to read until we are confident that we are not
-// connected to an OceanServer system
-static const int MAX_TRIES = 50;
-
OceanServerReader::OceanServerReader( const string &serialPort,
gbxutilacfr::Tracer &tracer )
@@ -35,15 +64,7 @@
tracer_(tracer),
parser_(tracer),
firstTime_(true)
-{
- // some menu entries from the OceanServer system - used to recognize whether
- // we are connected to the right device
- oceanServerStrings_.push_back(" S - Setup Controller");
- oceanServerStrings_.push_back(" B - Battery Status");
- oceanServerStrings_.push_back(" X - Host HEX");
- oceanServerStrings_.push_back(" H - Help");
- oceanServerStrings_.push_back(" www.ocean-server.com");
-
+{
checkConnection();
// send the command to start reading data
@@ -52,23 +73,6 @@
serial_.write(&startReading, 1);
}
-bool
-OceanServerReader::isOceanServerSystem( string &oceanServerString )
-{
- // number of characters which we require to match
- // if they match, we are pretty sure we have an OceanServerSystem
- unsigned int numCharRequired = 8;
-
- if ( oceanServerString.size()<numCharRequired ) return false;
-
- for (unsigned int i=0; i<oceanServerStrings_.size(); i++)
- {
- if ( strncmp(oceanServerStrings_[i].c_str(),oceanServerString.c_str(),numCharRequired)==0 )
- return true;
- }
- return false;
-}
-
void
OceanServerReader::checkConnection()
{
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h 2008-07-02 05:06:14 UTC (rev 249)
@@ -42,11 +42,6 @@
private:
- // Returns true if 100% sure that we are connected to an OceanServer system, otherwise false
- bool isOceanServerSystem( std::string &oceanServerString );
-
- std::vector<std::string> oceanServerStrings_;
-
gbxserialacfr::Serial serial_;
gbxutilacfr::Tracer& tracer_;
gbxsmartbatteryacfr::OceanServerParser parser_;
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h 2008-07-02 05:06:14 UTC (rev 249)
@@ -47,8 +47,8 @@
int minToEmpty;
std::string messageToSystem;
- //! Battery module states
- //! Each vector is always of size 8 because oceanserver system has 8 slots
+ //! Battery module states.
+ //! Each vector is always of size 8 because OceanServer's MP08 battery management module has 8 slots
std::vector<bool> availableBatteries;
std::vector<bool> chargingStates;
std::vector<bool> supplyingPowerStates;
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp 2008-07-02 05:03:13 UTC (rev 248)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp 2008-07-02 05:06:14 UTC (rev 249)
@@ -39,7 +39,6 @@
for (unsigned int i=0; i<=numRecords; i++)
{
- oceanserver.read();
gbxsmartbatteryacfr::OceanServerSystem data = oceanserver.getData();
cout << "TRACE(test): Reading record " << i << ": " << endl
@@ -54,11 +53,18 @@
<< "This shouldn't happen!" << endl;
return 1;
}
+ catch ( gbxutilacfr::Exception &e )
+ {
+ cout << "ERROR(test): Caught a gbxutilacfr::Exception: "
+ << e.what() << endl
+ << "This shouldn't happen!" << endl;
+ return 1;
+ }
catch ( std::exception &e )
{
cout << "ERROR(test): Caught an unknown exception: "
- << e.what() << endl
- << "This shouldn't happen!" << endl;
+ << e.what() << endl
+ << "This shouldn't happen!" << endl;
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-02 05:03:05
|
Revision: 248
http://gearbox.svn.sourceforge.net/gearbox/?rev=248&view=rev
Author: gbiggs
Date: 2008-07-01 22:03:13 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Updated supported hardware
Modified Paths:
--------------
gearbox/trunk/submitted/hokuyo_aist/doc.dox
Modified: gearbox/trunk/submitted/hokuyo_aist/doc.dox
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/doc.dox 2008-07-02 03:52:06 UTC (rev 247)
+++ gearbox/trunk/submitted/hokuyo_aist/doc.dox 2008-07-02 05:03:13 UTC (rev 248)
@@ -8,8 +8,8 @@
This library provides a driver for Hokuyo laser scanner devices using the SCIP protocol version 1 or
2. It has been tested with the Hokuyo URG-04LX and UHG-08LX, but it should work with any scanner
-that conforms to these protocol versions. For a full list of functions and classes see
-@ref hokuyo_aist.
+that conforms to these protocol versions, including the URG-04LX-F01 and UTM-30LX. For a full list
+of functions and classes, see @ref hokuyo_aist.
For a full list of classes and functions, see @ref hokuyo_aist.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bo...@us...> - 2008-07-02 03:52:00
|
Revision: 247
http://gearbox.svn.sourceforge.net/gearbox/?rev=247&view=rev
Author: borax00
Date: 2008-07-01 20:52:06 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
changed text of printouts only
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-02 03:17:57 UTC (rev 246)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-02 03:52:06 UTC (rev 247)
@@ -171,12 +171,12 @@
while(true)
{
if ( numTries > MAX_TRIES )
- throw gbxutilacfr::Exception( ERROR_INFO, "Couldn't find the beginning of a valid OceanServer record" );
+ throw gbxutilacfr::Exception( ERROR_INFO, "Couldn't find the beginning of a SUBSEQUENT valid OceanServer record" );
numTries++;
serialData = tryToReadLineFromSerialPort();
if ( parser_.atBeginningOfRecord( serialData ) )
{
- tracer_.debug( "OceanServerReader: End of the record (beginning of the NEXT record)", 5 );
+ tracer_.debug( "OceanServerReader: End of the record (beginning of a SUBSEQUENT record)", 5 );
parser_.parse( stringList, system );
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-02 03:17:49
|
Revision: 246
http://gearbox.svn.sourceforge.net/gearbox/?rev=246&view=rev
Author: tobasco
Date: 2008-07-01 20:17:57 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Added wrapper class, down to a single example now
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/gbxsmartbatteryacfr.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/CMakeLists.txt
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.cmake.in
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.readme
Added Paths:
-----------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp
Removed Paths:
-------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/fancytest.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/gbxsmartbatteryacfr.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/gbxsmartbatteryacfr.h 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/gbxsmartbatteryacfr.h 2008-07-02 03:17:57 UTC (rev 246)
@@ -11,6 +11,7 @@
#ifndef GBX_SMARTBATTERY_ACFR_H
#define GBX_SMARTBATTERY_ACFR_H
+#include <gbxsmartbatteryacfr/oceanserver.h>
#include <gbxsmartbatteryacfr/oceanserverparser.h>
#include <gbxsmartbatteryacfr/oceanserverreader.h>
#include <gbxsmartbatteryacfr/exceptions.h>
Added: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp (rev 0)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.cpp 2008-07-02 03:17:57 UTC (rev 246)
@@ -0,0 +1,49 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2008 Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#include <sstream>
+#include <gbxsmartbatteryacfr/exceptions.h>
+#include "oceanserver.h"
+
+namespace gbxsmartbatteryacfr {
+
+OceanServer::OceanServer( const std::string &port,
+ gbxutilacfr::Tracer &tracer)
+ : tracer_(tracer)
+{
+ reader_.reset(new gbxsmartbatteryacfr::OceanServerReader( port, tracer_ ));
+}
+
+void
+OceanServer::read()
+{
+ try
+ {
+ gbxsmartbatteryacfr::OceanServerSystem data;
+ reader_->read(data);
+ gbxsmartbatteryacfr::updateWithNewData( data, data_ );
+ }
+ catch ( gbxsmartbatteryacfr::ParsingException &e )
+ {
+ stringstream ss;
+ ss << "OceanServer: " << __func__ << ": Caught a parsing exception: "
+ << e.what() << endl
+ << "This can happen sometimes. Will continue regardless.";
+ tracer_.info( ss.str() );
+ }
+}
+
+const gbxsmartbatteryacfr::OceanServerSystem&
+OceanServer::getData() const
+{
+ return data_;
+}
+
+}
Added: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h (rev 0)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserver.h 2008-07-02 03:17:57 UTC (rev 246)
@@ -0,0 +1,55 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2004-2008 Tobias Kaupp
+ *
+ * This distribution is licensed to you under the terms described in
+ * the LICENSE file included in this distribution.
+ *
+ */
+
+#ifndef GBX_OCEANSERVER_H
+#define GBX_OCEANSERVER_H
+
+#include <memory>
+#include <gbxutilacfr/tracer.h>
+#include <gbxsmartbatteryacfr/oceanserverreader.h>
+
+using namespace std;
+
+namespace gbxsmartbatteryacfr {
+
+//! Class for reading data from an OceanServer battery system.
+//! Wraps up all the logic required to read from the system and
+//! maintain some incremental internal data storage.
+//! Also handles all ParsingExceptions.
+//!
+//! @author Tobias Kaupp
+//!
+class OceanServer
+{
+public:
+
+ OceanServer( const std::string &port,
+ gbxutilacfr::Tracer &tracer);
+
+ //! Reads data from OceanServer and incrementally updates internal storage
+ void read();
+
+ //! Returns a reference to the current (incrementally updated) OceanServer data
+ const gbxsmartbatteryacfr::OceanServerSystem& getData() const;
+
+private:
+
+ gbxsmartbatteryacfr::OceanServerSystem data_;
+ gbxutilacfr::Tracer& tracer_;
+ auto_ptr<gbxsmartbatteryacfr::OceanServerReader> reader_;
+
+};
+
+} //namespace
+
+#endif
+
+
+
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-02 03:17:57 UTC (rev 246)
@@ -26,8 +26,7 @@
@endverbatim
@par Examples
-- See 'test/simpletest.cpp' for a simple example of how to use the library. The test reads a few records from the oceanserver system and prints the results on the screen.
-- See 'test/fancytest.cpp' for a more advanced example. The test uses a class to read a few records from the oceanserver system and stores an internal (full) record which gets incrementally updated with new data.
+- See 'test/test.cpp' for a simple example of how to use the library. The test makes use of the 'oceanserver' class to read a few records from the oceanserver system and prints the results on the screen.
@par Style
See http://orca-robotics.sourceforge.net/orca/orca_doc_style.html
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h 2008-07-02 03:17:57 UTC (rev 246)
@@ -40,11 +40,11 @@
//! May throw ParsingException
int readNumBatteries( const std::string &str );
-//! Expects 4 hex characters, returns percentage
+//! Expects 4 hex characters, returns percentage [%]
//! May throw ParsingException
int readPercentWord( const std::string &str );
-//! Expects 2 hex characters, returns percentage
+//! Expects 2 hex characters, returns percentage [%]
//! May throw ParsingException
int readPercentByte( const std::string &str );
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/CMakeLists.txt
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/CMakeLists.txt 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/CMakeLists.txt 2008-07-02 03:17:57 UTC (rev 246)
@@ -1,13 +1,10 @@
INCLUDE( ${GBX_CMAKE_DIR}/UseBasicRules.cmake )
-GBX_ADD_EXECUTABLE( gbxsmartbatterysimpletest simpletest.cpp )
-TARGET_LINK_LIBRARIES( gbxsmartbatterysimpletest GbxSmartBatteryAcfr )
+GBX_ADD_EXECUTABLE( gbxsmartbatteryacfrtest test.cpp )
+TARGET_LINK_LIBRARIES( gbxsmartbatteryacfrtest GbxSmartBatteryAcfr )
-GBX_ADD_EXECUTABLE( gbxsmartbatteryfancytest fancytest.cpp )
-TARGET_LINK_LIBRARIES( gbxsmartbatteryfancytest GbxSmartBatteryAcfr )
+GBX_ADD_EXAMPLE( gbxsmartbatteryacfrtest example.cmake.in example.cmake test.cpp example.readme )
-GBX_ADD_EXAMPLE( gbxsmartbatteryacfr example.cmake.in example.cmake simpletest.cpp fancytest.cpp example.readme )
-
IF( GBX_BUILD_TESTS )
ADD_SUBDIRECTORY( darttest )
ENDIF( GBX_BUILD_TESTS )
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.cmake.in
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.cmake.in 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.cmake.in 2008-07-02 03:17:57 UTC (rev 246)
@@ -2,18 +2,11 @@
INCLUDE_DIRECTORIES( @CMAKE_INSTALL_PREFIX@/include/gearbox )
-ADD_EXECUTABLE( gbxsmartbatteryacfrsimple simpletest.cpp )
-TARGET_LINK_LIBRARIES( gbxsmartbatteryacfrsimple GbxSmartBatteryAcfr )
-SET_TARGET_PROPERTIES( gbxsmartbatteryacfrsimple PROPERTIES
+ADD_EXECUTABLE( gbxsmartbatteryacfrtest test.cpp )
+TARGET_LINK_LIBRARIES( gbxsmartbatteryacfrtest GbxSmartBatteryAcfr )
+SET_TARGET_PROPERTIES( gbxsmartbatteryacfrtest PROPERTIES
LINK_FLAGS "-L@CMAKE_INSTALL_PREFIX@/lib/gearbox"
INSTALL_RPATH "${INSTALL_RPATH};@CMAKE_INSTALL_PREFIX@/lib/gearbox"
BUILD_WITH_INSTALL_RPATH TRUE )
-
-ADD_EXECUTABLE( gbxsmartbatteryacfrfancy fancytest.cpp )
-TARGET_LINK_LIBRARIES( gbxsmartbatteryacfrfancy GbxSmartBatteryAcfr )
-SET_TARGET_PROPERTIES( gbxsmartbatteryacfrfancy PROPERTIES
- LINK_FLAGS "-L@CMAKE_INSTALL_PREFIX@/lib/gearbox"
- INSTALL_RPATH "${INSTALL_RPATH};@CMAKE_INSTALL_PREFIX@/lib/gearbox"
- BUILD_WITH_INSTALL_RPATH TRUE )
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.readme
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.readme 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/example.readme 2008-07-02 03:17:57 UTC (rev 246)
@@ -1,7 +1,7 @@
Building
--------
-The examples can be built by making a directory (anywhere on your system where
+The example can be built by making a directory (anywhere on your system where
you have write permissions will do), changing to that directory and executing
CMake with the example's source directory as an argument. For example, if you
have installed GearBox into /usr/local, you could do the following:
@@ -12,7 +12,6 @@
$ ccmake /usr/local/share/gearbox/gbxsmartbatteryacfr
(press 'c' and 'g')
$ make
-$ ./gbxsmartbatteryacfrsimple
-$ ./gbxsmartbatteryacfrfancy
+$ ./gbxsmartbatteryacfrtest
-See the library documentation (smartbatteryacfr.dox) for a description of the tests.
+See the library documentation (smartbatteryacfr.dox) for a description of the test.
Deleted: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/fancytest.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/fancytest.cpp 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/fancytest.cpp 2008-07-02 03:17:57 UTC (rev 246)
@@ -1,115 +0,0 @@
-#include <iostream>
-#include <memory>
-#include <cstdlib>
-#include <gbxutilacfr/trivialtracer.h>
-#include <gbxsmartbatteryacfr/gbxsmartbatteryacfr.h>
-
-using namespace std;
-
-class MyClass
-{
-public:
- MyClass(const std::string &port, bool debug);
- ~MyClass() {};
- void read();
-private:
- gbxsmartbatteryacfr::OceanServerSystem data_;
- gbxutilacfr::TrivialTracer tracer_;
- auto_ptr<gbxsmartbatteryacfr::OceanServerReader> reader_;
-};
-
-MyClass::MyClass(const std::string &port, bool debug)
- : tracer_(debug)
-{
- try
- {
- reader_.reset(new gbxsmartbatteryacfr::OceanServerReader( port, tracer_ ));
- }
- catch ( gbxsmartbatteryacfr::HardwareReadingException &e )
- {
- cout << "ERROR(fancy_test): Caught a hardware reading exception when initialising reader: "
- << e.what() << endl;
- exit(1);
- }
-}
-
-void
-MyClass::read()
-{
- gbxsmartbatteryacfr::OceanServerSystem data;
- reader_->read(data);
- gbxsmartbatteryacfr::updateWithNewData( data, data_ );
-
- cout << "Current data:" << endl
- << "=============" << endl
- << gbxsmartbatteryacfr::toString( data ) << endl;
- cout << "Stored data:" << endl
- << "============" << endl
- << gbxsmartbatteryacfr::toString( data_ ) << endl;
-}
-
-int main( int argc, char **argv )
-{
- int opt;
- std::string port = "/dev/ttyS0";
- bool debug = false;
-
- // Get some options from the command line
- while ((opt = getopt(argc, argv, "p:")) != -1)
- {
- switch ( opt )
- {
- case 'p':
- port = optarg;
- break;
- case 'v':
- debug = true;
- break;
- default:
- cout << "Usage: " << argv[0] << " [-p port] [-v(erbose)]" << endl
- << "-p port\tPort the oceanserver battery system is connected to. E.g. /dev/ttyS0" << endl;
- return 1;
- }
- }
-
- const unsigned int numRecords = 5;
- MyClass myClass( port, debug );
-
- for (unsigned int i=0; i<=numRecords; i++)
- {
- cout << "TRACE(fancy_test): Reading record " << i << ": " << endl
- << "====================================" << endl << endl;
-
- try
- {
- myClass.read();
- }
- catch ( gbxsmartbatteryacfr::ParsingException &e )
- {
- cout << "INFO(fancy_test): Caught a parsing exception: "
- << e.what() << endl
- << "This can happen sometimes. Not a problem of the driver." << endl
- << "The higher level program which uses the driver has to deal with this situation." << endl;
- continue;
- }
- catch ( gbxsmartbatteryacfr::HardwareReadingException &e )
- {
- cout << "ERROR(fancy_test): Caught a hardware reading exception: "
- << e.what() << endl
- << "This shouldn't happen!" << endl;
- return 1;
- }
- catch(std::exception &e)
- {
- cout << "ERROR(fancy_test): Caught an unknown exception: "
- << e.what() << endl
- << "This shouldn't happen!" << endl;
- return 1;
- }
- } // end of for loop
-
- cout << "INFO(fancy_test): Successfully read " << numRecords << " records." << endl;
-
- return 0;
-}
-
Deleted: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp 2008-07-02 00:06:06 UTC (rev 245)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp 2008-07-02 03:17:57 UTC (rev 246)
@@ -1,93 +0,0 @@
-#include <iostream>
-#include <gbxutilacfr/trivialtracer.h>
-#include <gbxsmartbatteryacfr/gbxsmartbatteryacfr.h>
-
-using namespace std;
-
-int main( int argc, char **argv )
-{
- int opt;
- std::string port = "/dev/ttyS0";
- bool debug = false;
-
- // Get some options from the command line
- while ((opt = getopt(argc, argv, "p:")) != -1)
- {
- switch ( opt )
- {
- case 'p':
- port = optarg;
- break;
- case 'v':
- debug = true;
- break;
- default:
- cout << "Usage: " << argv[0] << " [-p port] [-v(erbose)]" << endl
- << "-p port\tPort the oceanserver battery system is connected to. E.g. /dev/ttyS0" << endl;
- return 1;
- }
- }
-
- const unsigned int numRecords = 5;
- cout << "INFO(simple_test): The plan is to read " << numRecords << " records from the oceanserver system and display the results." << endl << endl;
-
- // instantiate reader
- gbxutilacfr::TrivialTracer tracer( debug );
-
- gbxsmartbatteryacfr::OceanServerReader *reader;
-
- try
- {
- reader = new gbxsmartbatteryacfr::OceanServerReader( port, tracer );
- }
- catch ( gbxsmartbatteryacfr::HardwareReadingException &e )
- {
- cout << "ERROR(simple_test): Caught a hardware reading exception when initialising reader: "
- << e.what() << endl;
- return 1;
- }
-
- // data storage
- gbxsmartbatteryacfr::OceanServerSystem data;
-
- for (unsigned int i=0; i<=numRecords; i++)
- {
- try
- {
- reader->read( data );
- cout << "TRACE(simple_test): Reading record " << i << ": " << endl
- << "=====================================" << endl << endl
- << gbxsmartbatteryacfr::toString( data ) << endl;
- }
- catch ( gbxsmartbatteryacfr::ParsingException &e )
- {
- cout << "INFO(simple_test): Caught a parsing exception: "
- << e.what() << endl
- << "This can happen sometimes. Not a problem of the driver." << endl
- << "The higher level program which uses the driver has to deal with this situation." << endl;
- continue;
- }
- catch ( gbxsmartbatteryacfr::HardwareReadingException &e )
- {
- cout << "ERROR(simple_test): Caught a hardware reading exception: "
- << e.what() << endl
- << "This shouldn't happen!" << endl;
- delete reader;
- return 1;
- }
- catch(std::exception &e)
- {
- cout << "ERROR(simple_test): Caught an unknown exception: "
- << e.what() << endl
- << "This shouldn't happen!" << endl;
- delete reader;
- return 1;
- }
- } //end of for loop
-
-
- cout << "INFO(simple_test): Successfully read " << numRecords << " records." << endl;
-
- delete reader;
- return 0;
-}
Added: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp (rev 0)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/test.cpp 2008-07-02 03:17:57 UTC (rev 246)
@@ -0,0 +1,69 @@
+#include <iostream>
+#include <gbxutilacfr/trivialtracer.h>
+#include <gbxsmartbatteryacfr/gbxsmartbatteryacfr.h>
+
+using namespace std;
+
+int main( int argc, char **argv )
+{
+ int opt;
+ std::string port = "/dev/ttyS0";
+ bool debug = false;
+
+ // Get some options from the command line
+ while ((opt = getopt(argc, argv, "p:")) != -1)
+ {
+ switch ( opt )
+ {
+ case 'p':
+ port = optarg;
+ break;
+ case 'v':
+ debug = true;
+ break;
+ default:
+ cout << "Usage: " << argv[0] << " [-p port] [-v(erbose)]" << endl
+ << "-p port\tPort the oceanserver battery system is connected to. E.g. /dev/ttyS0" << endl;
+ return 1;
+ }
+ }
+
+ const unsigned int numRecords = 5;
+ cout << "INFO(test): The plan is to read " << numRecords << " records from the oceanserver system and display the results." << endl << endl;
+
+ gbxutilacfr::TrivialTracer tracer( debug );
+
+ try
+ {
+ gbxsmartbatteryacfr::OceanServer oceanserver( port, tracer );
+
+ for (unsigned int i=0; i<=numRecords; i++)
+ {
+ oceanserver.read();
+ gbxsmartbatteryacfr::OceanServerSystem data = oceanserver.getData();
+
+ cout << "TRACE(test): Reading record " << i << ": " << endl
+ << "=================================" << endl << endl
+ << gbxsmartbatteryacfr::toString( data ) << endl;
+ }
+ }
+ catch ( gbxsmartbatteryacfr::HardwareReadingException &e )
+ {
+ cout << "ERROR(test): Caught a hardware reading exception: "
+ << e.what() << endl
+ << "This shouldn't happen!" << endl;
+ return 1;
+ }
+ catch ( std::exception &e )
+ {
+ cout << "ERROR(test): Caught an unknown exception: "
+ << e.what() << endl
+ << "This shouldn't happen!" << endl;
+ return 1;
+ }
+
+ cout << "INFO(test): Successfully read " << numRecords << " records." << endl;
+
+ return 0;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-02 00:05:58
|
Revision: 245
http://gearbox.svn.sourceforge.net/gearbox/?rev=245&view=rev
Author: gbiggs
Date: 2008-07-01 17:06:06 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Added links to classes
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/doc.dox
gearbox/trunk/submitted/hokuyo_aist/doc.dox
Modified: gearbox/trunk/submitted/flexiport/doc.dox
===================================================================
--- gearbox/trunk/submitted/flexiport/doc.dox 2008-07-01 23:50:31 UTC (rev 244)
+++ gearbox/trunk/submitted/flexiport/doc.dox 2008-07-02 00:06:06 UTC (rev 245)
@@ -25,6 +25,8 @@
The @ref SerialPort and @ref TCPPort port types are cross-platform, usable on Linux, Mac OSX and
Microsoft Windows.
+For a full list of classes and functions, see @ref flexiport.
+
@par Header file
Necessary:
Modified: gearbox/trunk/submitted/hokuyo_aist/doc.dox
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/doc.dox 2008-07-01 23:50:31 UTC (rev 244)
+++ gearbox/trunk/submitted/hokuyo_aist/doc.dox 2008-07-02 00:06:06 UTC (rev 245)
@@ -11,6 +11,8 @@
that conforms to these protocol versions. For a full list of functions and classes see
@ref hokuyo_aist.
+For a full list of classes and functions, see @ref hokuyo_aist.
+
Header file:
@verbatim
#include <hokuyo_aist/hokuyo_aist.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-01 23:50:22
|
Revision: 244
http://gearbox.svn.sourceforge.net/gearbox/?rev=244&view=rev
Author: gbiggs
Date: 2008-07-01 16:50:31 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Changed install location of pkg-config files to be easier to use.
Modified Paths:
--------------
gearbox/trunk/cmake/TargetUtils.cmake
Modified: gearbox/trunk/cmake/TargetUtils.cmake
===================================================================
--- gearbox/trunk/cmake/TargetUtils.cmake 2008-07-01 23:20:14 UTC (rev 243)
+++ gearbox/trunk/cmake/TargetUtils.cmake 2008-07-01 23:50:31 UTC (rev 244)
@@ -99,7 +99,7 @@
ENDIF( ${int_deps} )
CONFIGURE_FILE( ${GBX_CMAKE_DIR}/pkgconfig.in ${CMAKE_CURRENT_BINARY_DIR}/${name}.pc @ONLY)
- INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.pc DESTINATION lib/pkgconfig/${PROJECT_NAME}/ )
+ INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.pc DESTINATION lib/pkgconfig/ )
ENDMACRO( GBX_ADD_PKGCONFIG name desc cflags deps libflags libs )
#
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-01 23:20:08
|
Revision: 243
http://gearbox.svn.sourceforge.net/gearbox/?rev=243&view=rev
Author: tobasco
Date: 2008-07-01 16:20:14 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
missing link in docco
Modified Paths:
--------------
gearbox/trunk/src/gbxgarminacfr/doc.dox
Modified: gearbox/trunk/src/gbxgarminacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxgarminacfr/doc.dox 2008-07-01 23:19:43 UTC (rev 242)
+++ gearbox/trunk/src/gbxgarminacfr/doc.dox 2008-07-01 23:20:14 UTC (rev 243)
@@ -18,6 +18,8 @@
Uses Garmin serial implementation. Written for Garmin-GPS15L.
Tries to establish communication at 4800 baud (non-configurable).
+For a full list of classes and functions, see @ref gbxgarminacfr.
+
@par Header file
@verbatim
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-01 23:19:33
|
Revision: 242
http://gearbox.svn.sourceforge.net/gearbox/?rev=242&view=rev
Author: tobasco
Date: 2008-07-01 16:19:43 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
missing link to classes
Modified Paths:
--------------
gearbox/trunk/src/gbxutilacfr/doc.dox
Modified: gearbox/trunk/src/gbxutilacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxutilacfr/doc.dox 2008-07-01 14:14:36 UTC (rev 241)
+++ gearbox/trunk/src/gbxutilacfr/doc.dox 2008-07-01 23:19:43 UTC (rev 242)
@@ -16,6 +16,7 @@
@brief ACFR utility functions and drivers
Utility functions and objects used accross ACFR libraries and drivers. For a full list of classes and functions, see @ref gbxutilacfr.
+For a full list of classes and functions, see @ref gbxutilacfr.
@par Header file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-01 14:14:27
|
Revision: 241
http://gearbox.svn.sourceforge.net/gearbox/?rev=241&view=rev
Author: tobasco
Date: 2008-07-01 07:14:36 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Done most of the changes after Alex's comments except for the tests
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.cpp
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp
Removed Paths:
-------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/test/serialtest.cpp
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -9,6 +9,7 @@
*/
#include <sstream>
+#include <gbxutilacfr/tokenise.h>
#include <gbxsmartbatteryacfr/exceptions.h>
#include <gbxsmartbatteryacfr/smartbatteryparsing.h>
@@ -63,30 +64,30 @@
vector<bool> states;
if (it->first=="01") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.availableBatteries = states;
}
else if (it->first=="02") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.chargingStates = states;
}
else if (it->first=="03") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.supplyingPowerStates = states;
}
else if (it->first=="04") {
// reserved, do nothing
}
else if (it->first=="05") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.chargePowerPresentStates = states;
}
else if (it->first=="06") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.powerNoGoodStates = states;
}
else if (it->first=="07") {
- readSingleByte(it->second, states);
+ readFlags(it->second, states);
batterySystem.chargeInhibitedStates = states;
}
else
@@ -112,7 +113,7 @@
for (it=keyValuePairs.begin(); it!=keyValuePairs.end(); it++)
{
- SmartBatteryDataField smartField = stringToSmartField( it->first );
+ SmartBatteryDataField smartField = keyToSmartField( it->first );
switch( smartField )
{
@@ -131,7 +132,7 @@
case AtRateTimeToEmpty:
bat.setAtRateTimeToEmpty( readMinutes( it->second ) ); break;
case AtRateOk:
- bat.setAtRateOk( readBool( it->second ) ); break;
+ bat.setAtRateOk( readRate( it->second ) ); break;
case Temperature:
bat.setTemperature( readTemperature( it->second ) ); break;
case Voltage:
@@ -233,10 +234,9 @@
}
bool
-OceanServerParser::atBeginningOfRecord( const char* line )
+OceanServerParser::atBeginningOfRecord( const std::string &line )
{
- vector<string> tokens;
- splitIntoFields( line, tokens, ",");
+ vector<string> tokens = gbxutilacfr::tokenise( line, ",");
if (tokens.size()>0) {
if (tokens[0]!="$S") {
@@ -246,19 +246,7 @@
return true;
}
-bool
-OceanServerParser::atEndOfRecord( const char* line )
-{
- vector<string> tokens;
- splitIntoFields( line, tokens, ",");
-
- if (tokens.size()>0) {
- if (tokens[0]=="$S") return true;
- }
- return false;
-}
-
void
OceanServerParser::parse( vector<string> &stringList,
OceanServerSystem &batterySystem )
@@ -308,8 +296,7 @@
}
// divide the line into 2 parts: data and checksum (if present)
- vector<string> checksumList;
- splitIntoFields(line, checksumList, "%" );
+ vector<string> checksumList = gbxutilacfr::tokenise( line, "%" );
if (checksumList.size()==2)
{
// we have a checksum, is it correct?
@@ -320,8 +307,7 @@
// divide the data into individual fields and parse
if (checksumList.size()==0)
throw ParsingException( ERROR_INFO, "String length is 0" );
- vector<string> fields;
- splitIntoFields( checksumList[0], fields, ",");
+ vector<string> fields = gbxutilacfr::tokenise( checksumList[0], "," );
parseFields( fields, batterySystem );
}
}
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.h 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverparser.h 2008-07-01 14:14:36 UTC (rev 241)
@@ -27,8 +27,7 @@
{
public:
- OceanServerParser( gbxutilacfr::Tracer &tracer );
- ~OceanServerParser() {};
+ OceanServerParser( gbxutilacfr::Tracer &tracer );
//! Expects a full record of batterydata as a stringList (one line per string) produced by the oceanserver controller.
//! Parses each line and sets corresponding fields in batterySystem
@@ -36,10 +35,7 @@
OceanServerSystem &batterySystem );
//! Checks whether the passed string (one line) is the first line of the record
- bool atBeginningOfRecord( const char *string );
-
- //! Checks whether the passed string (one line) is the end of the record
- bool atEndOfRecord( const char *string );
+ bool atBeginningOfRecord( const std::string &line );
private:
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -18,12 +18,20 @@
namespace gbxsmartbatteryacfr {
+// baudrate is fixed
static const int BAUDRATE = 19200;
+
+// timeout for reading from the serial port
static const int TIMEOUT_SEC = 2;
+
+// the maximum number of lines to read until we are confident that we are not
+// connected to an OceanServer system
+static const int MAX_TRIES = 50;
+
-OceanServerReader::OceanServerReader( const string &device,
+OceanServerReader::OceanServerReader( const string &serialPort,
gbxutilacfr::Tracer &tracer )
- : serial_( device, BAUDRATE, gbxserialacfr::Serial::Timeout(TIMEOUT_SEC,0) ),
+ : serial_( serialPort, BAUDRATE, gbxserialacfr::Serial::Timeout(TIMEOUT_SEC,0) ),
tracer_(tracer),
parser_(tracer),
firstTime_(true)
@@ -45,12 +53,18 @@
}
bool
-OceanServerReader::isOceanServerSystem( const char* oceanServerString )
-{
- for (unsigned int i=0; i<oceanServerStrings_.size(); i++)
+OceanServerReader::isOceanServerSystem( string &oceanServerString )
+{
+ // number of characters which we require to match
+ // if they match, we are pretty sure we have an OceanServerSystem
+ unsigned int numCharRequired = 8;
+
+ if ( oceanServerString.size()<numCharRequired ) return false;
+
+ for (unsigned int i=0; i<oceanServerStrings_.size(); i++)
{
- // if the first 8 characters agree we are pretty sure we have an OceanServerSystem
- if (strncmp(oceanServerStrings_[i].c_str(),oceanServerString,8)==0) return true;
+ if ( strncmp(oceanServerStrings_[i].c_str(),oceanServerString.c_str(),numCharRequired)==0 )
+ return true;
}
return false;
}
@@ -64,42 +78,44 @@
const char menuMode = ' ';
serial_.write(&menuMode, 1);
- // if we were in battery reading mode before, we might have to skip quite
- // a few lines until we get something from the menu
- const int maxTries = 40;
int numTries=0;
-
- // for tracer output
stringstream ss;
while(true)
{
- ss.str(""); ss << "OceanServerReader: Trying to read from serial port with timeout of " << TIMEOUT_SEC << "s" << endl;
+ ss.str(""); ss << "OceanServerReader: " << __func__ << ": Trying to read from serial port with timeout of " << TIMEOUT_SEC << "s" << endl;
tracer_.info( ss.str() );
+ // reading from serial port
string serialData;
int ret = serial_.readLine( serialData );
- if (ret<0) {
- throw HardwareReadingException( ERROR_INFO, "Connected to the wrong serial port. Timed out while trying to read a line.");
+ if ( ret<0 ) {
+ throw HardwareReadingException( ERROR_INFO, "Timed out while trying to read a line from serial port.");
}
- if ( isOceanServerSystem(serialData.c_str()) ) {
- tracer_.info( "Oceanserverreader.cpp: We are connected to an Oceanserver system. Good." );
+
+ // checking whether we are connected to an oceanserver system
+ if ( isOceanServerSystem(serialData) ) {
+ tracer_.info( "OceanServerReader: We are connected to an Oceanserver system. Good." );
break;
}
+
+ // count the number of tries
numTries++;
- ss.str(""); ss << "OceanServerReader: Trying to find out whether this is an oceanserver system. Attempt number " << numTries << "/" << maxTries << ".";
+ ss.str(""); ss << "OceanServerReader: Trying to find out whether this is an oceanserver system. Attempt number " << numTries << "/" << MAX_TRIES << ".";
tracer_.info( ss.str() );
- if (numTries>=maxTries) {
- throw HardwareReadingException( ERROR_INFO, "Connected to the wrong serial port. Didn't recognize any of the strings.");
+
+ if ( numTries >= MAX_TRIES ) {
+ throw HardwareReadingException( ERROR_INFO, "Didn't recognize any of the strings. We may be connected to the wrong serial port.");
}
}
}
-void
-OceanServerReader::tryToReadLineFromSerialPort( std::string &serialData )
+std::string
+OceanServerReader::tryToReadLineFromSerialPort()
{
const int maxTries=5;
int numTries=0;
+ string serialData;
while(true)
{
@@ -114,6 +130,8 @@
throw HardwareReadingException( ERROR_INFO, ss.str().c_str() );
}
}
+
+ return serialData;
}
void
@@ -125,10 +143,14 @@
if (firstTime_)
{
// (1) Wait until we got the beginning of the record
+ int numTries=0;
while(true)
{
- tryToReadLineFromSerialPort( serialData );
- if (parser_.atBeginningOfRecord( serialData.c_str() )) break;
+ if ( numTries > MAX_TRIES )
+ throw gbxutilacfr::Exception( ERROR_INFO, "Couldn't find the beginning of a valid OceanServer record" );
+ numTries++;
+ serialData = tryToReadLineFromSerialPort();
+ if (parser_.atBeginningOfRecord( serialData )) break;
}
tracer_.debug( "OceanServerReader: Beginning of a new record", 5 );
@@ -145,19 +167,23 @@
try {
// (3) Read the rest of the record line-by-line
+ int numTries=0;
while(true)
{
- tryToReadLineFromSerialPort( serialData );
- if ( parser_.atEndOfRecord( serialData.c_str() ) )
+ if ( numTries > MAX_TRIES )
+ throw gbxutilacfr::Exception( ERROR_INFO, "Couldn't find the beginning of a valid OceanServer record" );
+ numTries++;
+ serialData = tryToReadLineFromSerialPort();
+ if ( parser_.atBeginningOfRecord( serialData ) )
{
- tracer_.debug( "OceanServerReader: End of record", 5 );
+ tracer_.debug( "OceanServerReader: End of the record (beginning of the NEXT record)", 5 );
parser_.parse( stringList, system );
break;
}
stringList.push_back(serialData);
}
- // (4) Save the last line: it is the beginning of the next record
+ // (4) Save the beginning of the next record
beginningRecordLine_ = serialData;
if (firstTime_) {
firstTime_ = false;
@@ -167,7 +193,7 @@
{
stringstream ss;
ss << "OceanServerReader: Caught ParsingException: " << e.what() << ". ";
- ss << "It's not critical, we are trying to find the beginning of a new record.";
+ ss << "It's not critical, we will try to find the beginning of a new record.";
tracer_.warning( ss.str() );
firstTime_ = true;
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserverreader.h 2008-07-01 14:14:36 UTC (rev 241)
@@ -31,18 +31,20 @@
{
public:
- //! May throw HardwareReadingException
- OceanServerReader( const std::string &device,
+ //! Connects to the serial port (e.g. /dev/ttyS0) and checks
+ //! whether we are connected to an OceanServer system.
+ //! Throws a HardwareReadingException if any of the above goes wrong.
+ OceanServerReader( const std::string &serialPort,
gbxutilacfr::Tracer &tracer );
-
- ~OceanServerReader() {};
- //! May throw HardwareReadingException
+ //! May throw HardwareReadingExceptions and ParsingExceptions
void read( OceanServerSystem &system );
private:
- bool isOceanServerSystem( const char* oceanServerString );
+ // Returns true if 100% sure that we are connected to an OceanServer system, otherwise false
+ bool isOceanServerSystem( std::string &oceanServerString );
+
std::vector<std::string> oceanServerStrings_;
gbxserialacfr::Serial serial_;
@@ -50,7 +52,7 @@
gbxsmartbatteryacfr::OceanServerParser parser_;
void checkConnection();
- void tryToReadLineFromSerialPort( std::string &serialData );
+ std::string tryToReadLineFromSerialPort();
std::string beginningRecordLine_;
bool firstTime_;
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -21,6 +21,7 @@
//
// Helper functions
//
+namespace {
string toString( const vector<bool> &flags )
{
@@ -41,12 +42,13 @@
}
return ss.str();
}
+
+}
//
// Non-member functions
//
-
string toString( const OceanServerSystem &system )
{
stringstream ss;
@@ -177,7 +179,6 @@
//
// Member functions
//
-
OceanServerSystem::OceanServerSystem()
: percentCharge(0),
minToEmpty(0),
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -18,48 +18,47 @@
namespace gbxsmartbatteryacfr {
-SmartBatteryDataField stringToSmartField( const string &fieldStr )
+SmartBatteryDataField keyToSmartField( const string &key )
{
- if (fieldStr=="00") return ManufacturerAccess;
- else if (fieldStr=="01") return RemainingCapacityAlarm;
- else if (fieldStr=="02") return RemainingTimeAlarm;
- else if (fieldStr=="03") return BatteryMode;
- else if (fieldStr=="04") return AtRate;
- else if (fieldStr=="05") return AtRateTimeToFull;
- else if (fieldStr=="06") return AtRateTimeToEmpty;
- else if (fieldStr=="07") return AtRateOk;
- else if (fieldStr=="08") return Temperature;
- else if (fieldStr=="09") return Voltage;
- else if (fieldStr=="0A") return Current;
- else if (fieldStr=="0B") return AverageCurrent;
- else if (fieldStr=="0C") return MaxError;
- else if (fieldStr=="0D") return RelativeStateOfCharge;
- else if (fieldStr=="0E") return AbsoluteStateOfCharge;
- else if (fieldStr=="0F") return RemainingCapacity;
- else if (fieldStr=="10") return FullChargeCapacity;
- else if (fieldStr=="11") return RunTimeToEmpty;
- else if (fieldStr=="12") return AverageTimeToEmpty;
- else if (fieldStr=="13") return AverageTimeToFull;
- else if (fieldStr=="14") return ChargingCurrent;
- else if (fieldStr=="15") return ChargingVoltage;
- else if (fieldStr=="16") return BatteryStatus;
- else if (fieldStr=="17") return CycleCount;
- else if (fieldStr=="18") return DesignCapacity;
- else if (fieldStr=="19") return DesignVoltage;
- else if (fieldStr=="1A") return SpecificationInfo;
- else if (fieldStr=="1B") return ManufactureDate;
- else if (fieldStr=="1C") return SerialNumber;
- else if (fieldStr=="20") return ManufacturerName;
- else if (fieldStr=="21") return DeviceName;
- else if (fieldStr=="22") return DeviceChemistry;
- else if (fieldStr=="23") return ManufacturerData;
+ if (key=="00") return ManufacturerAccess;
+ else if (key=="01") return RemainingCapacityAlarm;
+ else if (key=="02") return RemainingTimeAlarm;
+ else if (key=="03") return BatteryMode;
+ else if (key=="04") return AtRate;
+ else if (key=="05") return AtRateTimeToFull;
+ else if (key=="06") return AtRateTimeToEmpty;
+ else if (key=="07") return AtRateOk;
+ else if (key=="08") return Temperature;
+ else if (key=="09") return Voltage;
+ else if (key=="0A") return Current;
+ else if (key=="0B") return AverageCurrent;
+ else if (key=="0C") return MaxError;
+ else if (key=="0D") return RelativeStateOfCharge;
+ else if (key=="0E") return AbsoluteStateOfCharge;
+ else if (key=="0F") return RemainingCapacity;
+ else if (key=="10") return FullChargeCapacity;
+ else if (key=="11") return RunTimeToEmpty;
+ else if (key=="12") return AverageTimeToEmpty;
+ else if (key=="13") return AverageTimeToFull;
+ else if (key=="14") return ChargingCurrent;
+ else if (key=="15") return ChargingVoltage;
+ else if (key=="16") return BatteryStatus;
+ else if (key=="17") return CycleCount;
+ else if (key=="18") return DesignCapacity;
+ else if (key=="19") return DesignVoltage;
+ else if (key=="1A") return SpecificationInfo;
+ else if (key=="1B") return ManufactureDate;
+ else if (key=="1C") return SerialNumber;
+ else if (key=="20") return ManufacturerName;
+ else if (key=="21") return DeviceName;
+ else if (key=="22") return DeviceChemistry;
+ else if (key=="23") return ManufacturerData;
else
{
stringstream ss;
- ss << "Unknown field: " << fieldStr;
+ ss << "Unknown field: " << key;
throw ParsingException( ERROR_INFO, ss.str().c_str() );
- }
- return NUM_SMARTBATTERY_FIELDS;
+ }
}
string toString( const SmartBattery &b )
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.h 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbattery.h 2008-07-01 14:14:36 UTC (rev 241)
@@ -57,8 +57,9 @@
NUM_SMARTBATTERY_FIELDS
};
-//! Converts a string to a SmartBatteryDataField, returns NUM_SMARTBATTERY_FIELDS if string is not valid
-SmartBatteryDataField stringToSmartField( const std::string &fieldStr );
+//! Converts a key (string) to a SmartBatteryDataField.
+//! Throws a ParsingException if key is unknown.
+SmartBatteryDataField keyToSmartField( const std::string &key );
//! SmartBattery class holds all the data of a single smart battery.
//! Since not all data is always present, access to data needs to be done as follows:
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-01 14:14:36 UTC (rev 241)
@@ -52,11 +52,12 @@
- This is a Linux-only implementation (due to the Linux-only serial library).
- It works with those serial devices which @ref gbx_library_gbxserialacfr supports.
- The library is tailored to the OceanServer battery system.
+- Has been tested with the following hardware configuration: battery management module MP08SR, DC/DC converter module DC123SR, and a variable number of battery modules of type BA95HC-FL (can be added and removed at runtime)
- Has been tested with the following firmware: V2.10 (2007)
-@par OceanServer Layout
+@par MP08SR Layout
-The battery number reported by the driver corresponds to the following connectors on the Battery Management Module board:
+The battery number reported by the driver corresponds to the following connectors on the Battery Management Module board MP08SR:
@verbatim
Level 1 (lower level):
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -17,14 +17,12 @@
namespace gbxsmartbatteryacfr {
-//
-// Not part of the public interface
-//
-
+namespace {
+
int readNumPositiveFlags(const string &str)
{
vector<bool> flags;
- readSingleByte( str, flags );
+ readFlags( str, flags );
int numPositiveFlags=0;
@@ -74,10 +72,8 @@
return value16;
}
+} // end of namespace
-//
-// Public interface functions
-//
double readTemperature( const string &str )
{
@@ -137,12 +133,6 @@
return readUnsignedInt16( str );
}
-bool readBool( const string &str )
-{
- return readUnsignedInt16( str );
-}
-
-
int readRate( const string &str )
{
return readUnsignedInt16( str );
@@ -199,35 +189,11 @@
}
-void splitIntoFields( const string &str,
- vector<string> &fields,
- const string &delimiter)
+void readFlags( const string &str,
+ vector<bool> &flags )
{
- // Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of(delimiter, 0);
-
- // Find first "non-delimiter".
- string::size_type pos = str.find_first_of(delimiter, lastPos);
-
- while (string::npos != pos || string::npos != lastPos)
- {
- // Found a token, add it to the vector.
- fields.push_back(str.substr(lastPos, pos - lastPos));
-
- // Skip delimiters. Note the "not_of"
- lastPos = str.find_first_not_of(delimiter, pos);
-
- // Find next "non-delimiter"
- pos = str.find_first_of(delimiter, lastPos);
- }
-}
-
-
-void readSingleByte( const string &str,
- vector<bool> &flags )
-{
if (str.size()!=2)
- throw ParsingException( ERROR_INFO, "readSingleByte called with string size != 2" );
+ throw ParsingException( ERROR_INFO, "readFlags called with string size != 2" );
stringstream ss(str);
int allFlags;
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryparsing.h 2008-07-01 14:14:36 UTC (rev 241)
@@ -19,38 +19,66 @@
namespace gbxsmartbatteryacfr
{
-//!
-//! Functions to parse SmartBattery data
-//! and some helper functions
-//!
-//! @author Tobias Kaupp
-//!
-
-// Reading data
-void readSingleByte( const std::string &str,
- std::vector<bool> &flags );
+//! Expects 2 hex characters and translates them into a vector of boolean flags
+//! May throw ParsingException
+void readFlags( const std::string &str,
+ std::vector<bool> &flags );
+
+//! Expects 4 hex characters, returns temperature [degC]
+//! May throw ParsingException
double readTemperature( const std::string &str );
+
+//! Expects 4 hex characters, returns current [A]
+//! May throw ParsingException
double readCurrent( const std::string &str );
+
+//! Expects 4 hex characters, returns voltage [V]
+//! May throw ParsingException
double readVoltage( const std::string &str );
+
+//! Expects 2 hex characters, returns number of batteries
+//! May throw ParsingException
int readNumBatteries( const std::string &str );
+
+//! Expects 4 hex characters, returns percentage
+//! May throw ParsingException
int readPercentWord( const std::string &str );
+
+//! Expects 2 hex characters, returns percentage
+//! May throw ParsingException
int readPercentByte( const std::string &str );
+
+//! Expects 4 hex characters, returns minutes
+//! May throw ParsingException
int readMinutes( const std::string &str );
+
+//! Expects 4 hex characters, returns capacity [%]
+//! May throw ParsingException
int readCapacity( const std::string &str );
+
+//! Expects 4 hex characters, translates them into uint16_t
+//! May throw ParsingException
uint16_t read16Flags( const std::string &str );
+
+//! Expects 4 hex characters, returns a count
+//! May throw ParsingException
int readCount( const std::string &str );
+
+//! Expects 4 hex characters, returns a number
+//! May throw ParsingException
int readNumber( const std::string &str );
-bool readBool( const std::string &str );
+
+//! Expects 4 hex characters, returns a rate
+//! May throw ParsingException
int readRate( const std::string &str );
-// Other helper functions
-bool isChecksumValid( const std::string &data,
- const std::string &checksumStr );
-
-void splitIntoFields( const std::string &str,
- std::vector<std::string> &fields,
- const std::string &delimiter);
+//! Computes an XOR checksum from 'input' (skips the first character).
+//! Returns true if it matches with 'expected', otherwise false
+bool isChecksumValid( const std::string &input,
+ const std::string &expected );
+//! Decomposes 'fields' (a flat list of keys and values) into 'pairs'
+//! (a map of keys and values). May throw ParsingException.
void toKeyValuePairs( const std::vector<std::string> &fields,
std::map<std::string,std::string> &pairs,
gbxutilacfr::Tracer &tracer );
Deleted: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/serialtest.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/serialtest.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/serialtest.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -1,96 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <sys/time.h>
-#include <vector>
-#include <string>
-
-#include <gbxserialacfr/serial.h>
-
-using namespace std;
-
-static const unsigned int BUFFER_SIZE = 1024;
-static const int BAUDRATE = 19200;
-static const int TIMEOUT_SEC = 30;
-static string DEVICE="/dev/ttyS3";
-
-// ofstream* createFile()
-// {
-// string filename="/home/mrsys/tmp/ocean/serialtest.txt";
-// ofstream *file = new ofstream( filename.c_str(), ios::app );
-// if ( !file->is_open() ) {
-// cout << "Could not create file " << filename << endl;
-// exit(1);
-// }
-// struct timeval now;
-// gettimeofday( &now, 0 );
-// (*file) << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
-// (*file) << "Start time (sec): " << now.tv_sec << endl << endl;
-
-// return file;
-// }
-
-bool isOceanServerSystem( const char* oceanServerString, gbxserialacfr::Serial &serial_ )
-{
- vector<string> oceanServerStrings_;
- oceanServerStrings_.push_back(" S - Setup Controller");
- oceanServerStrings_.push_back(" B - Battery Status");
- oceanServerStrings_.push_back(" X - Host HEX");
- oceanServerStrings_.push_back(" H - Help");
- oceanServerStrings_.push_back(" www.ocean-server.com");
-
- for (unsigned int i=0; i<oceanServerStrings_.size(); i++)
- {
- // if the first 8 characters agree we are pretty sure we have an OceanServerSystem
- if (strncmp(oceanServerStrings_[i].c_str(),oceanServerString,8)==0) return true;
- }
- return false;
-}
-
-int main( int argc, char **argv )
-{
- gbxserialacfr::Serial serial_( DEVICE, BAUDRATE, gbxserialacfr::Serial::Timeout(TIMEOUT_SEC,0) );
-
- const char menuMode = ' ';
- serial_.write(&menuMode, 1);
-
- const int maxTries = 40;
- int numTries=0;
-
- while(true)
- {
- cout << "INFO(oceanserverreader.cpp): Trying to read from serial port with timeout of " << TIMEOUT_SEC << "s" << endl;
- string serialData;
- int ret = serial_.readLine( serialData );
- if (ret<0) {
- cout << "Connected to the wrong serial port. Timed out while trying to read a line." << endl;
- }
- if ( isOceanServerSystem( serialData.c_str(), serial_ ) ) {
- cout << "INFO(oceanserverreader.cpp): We are connected to an Oceanserver system. Good." << endl;
- break;
- }
- numTries++;
- cout << "Trying to find out whether this is an oceanserver system. Attempt number " << numTries << "/" << maxTries << "." << endl;
- if (numTries>=maxTries) {
- cout << "Connected to the wrong serial port. Didn't recognize any of the strings." << endl;
- }
- }
-
- // send an X
- serial_.flush();
- const char startReading = 'X';
- serial_.write(&startReading, 1);
-
- // ofstream* file = createFile();
-
- while(true)
- {
- std::string serialData;
-
- int ret = serial_.readLine( serialData );
-
- cout << "Ret: " << ret << " " << serialData << flush;
- }
-
- return 0;
-}
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp 2008-07-01 13:35:32 UTC (rev 240)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/test/simpletest.cpp 2008-07-01 14:14:36 UTC (rev 241)
@@ -72,6 +72,7 @@
cout << "ERROR(simple_test): Caught a hardware reading exception: "
<< e.what() << endl
<< "This shouldn't happen!" << endl;
+ delete reader;
return 1;
}
catch(std::exception &e)
@@ -79,6 +80,7 @@
cout << "ERROR(simple_test): Caught an unknown exception: "
<< e.what() << endl
<< "This shouldn't happen!" << endl;
+ delete reader;
return 1;
}
} //end of for loop
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-01 13:35:27
|
Revision: 240
http://gearbox.svn.sourceforge.net/gearbox/?rev=240&view=rev
Author: tobasco
Date: 2008-07-01 06:35:32 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
docco
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-01 13:32:16 UTC (rev 239)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-01 13:35:32 UTC (rev 240)
@@ -17,6 +17,8 @@
This library provides a set of classes and functions to read data from a Smart Battery System (SBS). SBS is a specification for determining accurate battery readings. The library also contains classes which are specialised to a battery system provided by OceanServer Technologies Inc.
+For a full list of classes and functions, see @ref gbxsmartbatteryacfr.
+
@par Header file
@verbatim
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-07-01 13:32:08
|
Revision: 239
http://gearbox.svn.sourceforge.net/gearbox/?rev=239&view=rev
Author: tobasco
Date: 2008-07-01 06:32:16 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
link to class docco was missing
Modified Paths:
--------------
gearbox/trunk/src/gbxsickacfr/doc.dox
gearbox/trunk/src/gbxutilacfr/doc.dox
Modified: gearbox/trunk/src/gbxsickacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxsickacfr/doc.dox 2008-07-01 07:07:37 UTC (rev 238)
+++ gearbox/trunk/src/gbxsickacfr/doc.dox 2008-07-01 13:32:16 UTC (rev 239)
@@ -15,7 +15,7 @@
@defgroup gbx_library_gbxsickacfr GbxSickAcfr
@brief ACFR driver for SICK laser range-finder.
-Drives SICK hardware, directly connected to the computer.
+Drives SICK hardware, directly connected to the computer. For a full list of classes and functions, see @ref gbxsickacfr.
@par Header file
Modified: gearbox/trunk/src/gbxutilacfr/doc.dox
===================================================================
--- gearbox/trunk/src/gbxutilacfr/doc.dox 2008-07-01 07:07:37 UTC (rev 238)
+++ gearbox/trunk/src/gbxutilacfr/doc.dox 2008-07-01 13:32:16 UTC (rev 239)
@@ -15,7 +15,7 @@
@defgroup gbx_library_gbxutilacfr GbxUtilAcfr
@brief ACFR utility functions and drivers
-Utility functions and objects used accross ACFR libraries and drivers.
+Utility functions and objects used accross ACFR libraries and drivers. For a full list of classes and functions, see @ref gbxutilacfr.
@par Header file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-01 07:07:32
|
Revision: 238
http://gearbox.svn.sourceforge.net/gearbox/?rev=238&view=rev
Author: gbiggs
Date: 2008-07-01 00:07:37 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
Added -v to usage
Modified Paths:
--------------
gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
Modified: gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-01 06:54:09 UTC (rev 237)
+++ gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-01 07:07:37 UTC (rev 238)
@@ -90,6 +90,7 @@
cout << "-n\t\tGet new ranges instead of latest ranges." << endl;
cout << "-o options\tPort options (see flexiport library)." << endl;
cout << "-s angle\tStart angle to get ranges from." << endl;
+ cout << "-v\t\tPut the hokuyo_aist library into verbose mode." << endl;
return 1;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gb...@us...> - 2008-07-01 06:54:03
|
Revision: 237
http://gearbox.svn.sourceforge.net/gearbox/?rev=237&view=rev
Author: gbiggs
Date: 2008-06-30 23:54:09 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Added support for UTM-30LX (aka Top-URG) and updated SCIP v2 support. Fixed bugs in logfile introduced by change in data type sizes to make log files cross-platform.
Modified Paths:
--------------
gearbox/trunk/submitted/flexiport/logfile.cpp
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
gearbox/trunk/submitted/hokuyo_aist/test/example.logr
gearbox/trunk/submitted/hokuyo_aist/test/example.logw
Modified: gearbox/trunk/submitted/flexiport/logfile.cpp
===================================================================
--- gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-01 06:19:50 UTC (rev 236)
+++ gearbox/trunk/submitted/flexiport/logfile.cpp 2008-07-01 06:54:09 UTC (rev 237)
@@ -69,7 +69,9 @@
#endif
}
-const size_t CHUNK_HEADER_SIZE = sizeof (size_t) + sizeof (struct timeval);
+// Chunk header is two uint32_t's for the time stamp (seconds and microseconds) + one uint32_t for
+// the data length.
+const size_t CHUNK_HEADER_SIZE = (sizeof (uint32_t) * 2) + sizeof (uint32_t);
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -165,6 +167,7 @@
StrError (ErrNo ());
throw PortException (ss.str ());
}
+ _readFile = NULL;
}
if (_writeFile != NULL)
{
@@ -176,6 +179,7 @@
StrError (ErrNo ());
throw PortException (ss.str ());
}
+ _writeFile = NULL;
}
if (_readBuffer != NULL)
@@ -994,8 +998,14 @@
void LogFile::GetNextChunkInfo (FILE * const file, struct timeval &timeStamp, size_t &size)
{
// Read the chunk info
- ReadFromFile (file, &timeStamp, sizeof (timeStamp));
- ReadFromFile (file, &size, sizeof (size));
+ uint32_t secs, usecs, tempSize;
+ ReadFromFile (file, &secs, sizeof (secs));
+ ReadFromFile (file, &usecs, sizeof (usecs));
+ timeStamp.tv_sec = ntohl (secs);
+ timeStamp.tv_usec = ntohl (usecs);
+ ReadFromFile (file, &tempSize, sizeof (tempSize));
+ size = ntohl (tempSize);
+
// Rewind the file back to the beginning of the chunk header
if (fseek (file, -1 * CHUNK_HEADER_SIZE, SEEK_CUR) < 0)
{
@@ -1228,15 +1238,19 @@
}
// Test if this file is actually open
- if (file == NULL || ftell (file) < 0)
+ if (file == NULL)
throw PortException (string ("LogFile::") + __func__ + string ("() Log file is not open."));
+ else if (ftell (file) < 0)
+ throw PortException (string ("LogFile::") + __func__ + string ("() Log file is not open."));
+
if (dest == NULL)
throw PortException (string ("LogFile::") + __func__ + string ("() No destination."));
size_t numRead;
if ((numRead = fread (dest, 1, count, file)) < count)
{
- cerr << "Only read " << numRead << " of " << count << " bytes" << endl;
+ cerr << "LogFile::" << __func__ << "() Only read " << numRead << " of " << count <<
+ " bytes" << endl;
if (feof (file))
{
// Close the files
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-01 06:19:50 UTC (rev 236)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.cpp 2008-07-01 06:54:09 UTC (rev 237)
@@ -178,22 +178,28 @@
{
stringstream ss;
- // Check for universal errors first
- if (error[1] == 'A')
+ // Check for non-errors
+ if (error[0] == '0' && error[1] == '0')
+ return "Status OK - 00";
+ else if (error[0] == '9' && error[1] == '9')
+ return "Status OK - 99";
+
+ // Check for universal errors
+ if (error[0] == '0' && error[1] == 'A')
return "Unable to create transmission data or reply command internally";
- else if (error[1] == 'B')
+ else if (error[0] == '0' && error[1] == 'B')
return "Buffer shortage or command repeated that is already processed";
- else if (error[1] == 'C')
+ else if (error[0] == '0' && error[1] == 'C')
return "Command with insufficient parameters 1";
- else if (error[1] == 'D')
+ else if (error[0] == '0' && error[1] == 'D')
return "Undefined command 1";
- else if (error[1] == 'E')
+ else if (error[0] == '0' && error[1] == 'E')
return "Undefined command 2";
- else if (error[1] == 'F')
+ else if (error[0] == '0' && error[1] == 'F')
return "Command with insufficient parameters 2";
- else if (error[1] == 'G')
+ else if (error[0] == '0' && error[1] == 'G')
return "String character in command exceeds 16 letters";
- else if (error[1] == 'H')
+ else if (error[0] == '0' && error[1] == 'H')
return "String character has invalid letters";
else if (error[0] == '0' && error[1] == 'I')
return "Sensor is now in firmware update mode";
@@ -236,10 +242,8 @@
return "Ending step is out of range";
case 5:
return "Ending step is smaller than start step";
- case 6:
- return "Scan interval is greater than 9";
- case 7:
- return "Number of scans is greater than 99";
+ case 10:
+ return "Laser is off";
default:
if (errorCode >= 50)
ss << "Hardware error: " << errorCode;
@@ -265,12 +269,22 @@
case 5:
return "Ending step is smaller than start step";
case 6:
- return "Scan interval is greater than 9";
+ return "Scan interval has non-numeric value";
case 7:
- return "Number of scans is greater than 99";
+ return "Number of scans is non-numeric";
default:
- if (errorCode >= 50)
+ if (errorCode >= 21 && errorCode <= 49)
+ {
+ return "Processing stopped to verify error. "
+ "This function is not yet supported by hokuyo_aist.";
+ }
+ else if (errorCode >= 50 && errorCode <= 97)
ss << "Hardware error: " << errorCode;
+ else if (errorCode == 98)
+ {
+ return "Resumption of processing after confirming normal laser opteration. "
+ "This function is not yet supported by hokuyo_aist.";
+ }
else
ss << "Unknown error code " << errorCode << " for command " << cmd[0] << cmd[1];
@@ -301,6 +315,8 @@
return "Invalid baud rate";
case 3:
return "Sensor is already running at that baud rate";
+ case 4:
+ return "Not compatible with the sensor model";
}
}
else if (cmd[0] == 'C' && cmd[1] == 'R')
@@ -313,8 +329,22 @@
return "Speed is out of range";
case 3:
return "Motor is already running at that speed";
+ case 4:
+ return "Not compatible with the sensor model";
}
}
+ else if (cmd[0] == 'H' && cmd[1] == 'S')
+ {
+ switch (errorCode)
+ {
+ case 1:
+ return "Parameter error";
+ case 2:
+ return "Already running in the set mode";
+ case 3:
+ return "Not compatible with the sensor model";
+ }
+ }
// No info in the manual for this.
// else if (cmd[0] == 'R' && cmd[1] == 'S')
// {
@@ -457,8 +487,8 @@
HokuyoSensorInfo::HokuyoSensorInfo (void)
: minRange (0), maxRange (0), steps (0), firstStep (0), lastStep (0), frontStep (0),
- standardSpeed (0), power (false), speed (0), baud (0), time (0), minAngle (0.0), maxAngle (0.0),
- resolution (0.0), scanableSteps (0)
+ standardSpeed (0), power (false), speed (0), speedLevel (0), baud (0), time (0), minAngle (0.0),
+ maxAngle (0.0), resolution (0.0), scanableSteps (0)
{
}
@@ -504,8 +534,9 @@
ss << "Standard motor speed: " << standardSpeed << "rpm" << endl;
ss << "Power status: " << (power ? "On" : "Off") << "\tMeasurement state: " <<
- measureState << endl;
- ss << "Motor speed: " << speed << "rpm\tBaud rate: " << baud << "bps" << endl;
+ measureState << endl;
+ ss << "Motor speed: " << speed << "rpm (level " << speedLevel << ")\tBaud rate: " << baud <<
+ "bps" << endl;
ss << "Time stamp: " << time << "ms" << endl;
ss << "Sensor diagnostic: " << sensorDiagnostic << endl;
@@ -517,102 +548,171 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
HokuyoData::HokuyoData (void)
- : _data (NULL), _length (0), _error (-1), _time (0)
+ : _ranges (NULL), _intensities (NULL), _length (0),
+ _error (false), _time (0), _sensorIsUTM30LX (false)
{
}
-HokuyoData::HokuyoData (unsigned short *data, unsigned int length, short error, unsigned int time)
+HokuyoData::HokuyoData (uint32_t *ranges, unsigned int length, bool error, unsigned int time)
: _error (error), _time (time)
{
_length = length;
if (_length == 0)
- _data = NULL;
+ {
+ _ranges = NULL;
+ _intensities = NULL;
+ }
else
{
- if ((_data = new unsigned short[_length]) == NULL)
+ if ((_ranges = new uint32_t[_length]) == NULL)
{
_length = 0;
- throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy data.");
+ throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy range data.");
}
- memcpy (_data, data, sizeof (unsigned short) * _length);
+ memcpy (_ranges, ranges, sizeof (uint32_t) * _length);
+
+ _intensities = NULL; // No intensity data to copy
}
}
+HokuyoData::HokuyoData (uint32_t *ranges, uint32_t *intensities, unsigned int length, bool error,
+ unsigned int time)
+ : _error (error), _time (time)
+{
+ _length = length;
+ if (_length == 0)
+ {
+ _ranges = NULL;
+ _intensities = NULL;
+ }
+ else
+ {
+ if ((_ranges = new uint32_t[_length]) == NULL)
+ {
+ _length = 0;
+ throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy range data.");
+ }
+ memcpy (_ranges, ranges, sizeof (uint32_t) * _length);
+
+ if ((_intensities = new uint32_t[_length]) == NULL)
+ {
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space to copy intensity data.");
+ }
+ memcpy (_intensities, intensities, sizeof (uint32_t) * _length);
+ }
+}
+
HokuyoData::HokuyoData (const HokuyoData &rhs)
{
_length = rhs.Length ();
if (_length == 0)
- _data = NULL;
+ _ranges = NULL;
else
{
- if ((_data = new unsigned short[_length]) == NULL)
+ if ((_ranges = new uint32_t[_length]) == NULL)
{
_length = 0;
throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy data.");
}
- memcpy (_data, rhs.Ranges (), sizeof (unsigned short) * _length);
+ memcpy (_ranges, rhs.Ranges (), sizeof (uint32_t) * _length);
+
+ if (rhs.Intensities () != NULL)
+ {
+ if ((_intensities = new uint32_t[_length]) == NULL)
+ {
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space to copy intensity data.");
+ }
+ memcpy (_intensities, rhs.Intensities (), sizeof (uint32_t) * _length);
+ }
}
- _error = rhs.GetErrorCode ();
+ _error = rhs.GetErrorStatus ();
_time = rhs.TimeStamp ();
}
HokuyoData::~HokuyoData (void)
{
- if (_data != NULL)
- delete[] _data;
+ if (_ranges != NULL)
+ delete[] _ranges;
}
-string HokuyoData::ErrorCodeToString (void)
+string HokuyoData::ErrorCodeToString (uint32_t errorCode)
{
- switch (_error)
+ if (_sensorIsUTM30LX)
{
- case -1:
- return "No error.";
- case 0:
- return "Possibility of detected object is at 22m.";
- case 1:
- return "Reflected light has low intensity.";
- case 2:
- return "Reflected light has low intensity.";
- case 3:
- return "Reflected light has low intensity.";
- case 4:
- return "Reflected light has low intensity.";
- case 5:
- return "Reflected light has low intensity.";
- case 6:
- return "Possibility of detected object is at 5.7m.";
- case 7:
- return "Distance data on the preceding and succeeding steps have errors.";
- case 8:
- return "Others.";
- case 9:
- return "The same step had error in the last two scan.";
- case 10:
- return "Others.";
- case 11:
- return "Others.";
- case 12:
- return "Others.";
- case 13:
- return "Others.";
- case 14:
- return "Others.";
- case 15:
- return "Others.";
- case 16:
- return "Possibility of detected object is in the range 4096mm.";
- case 17:
- return "Others.";
- case 18:
- return "Unspecified.";
- case 19:
- return "Non-measurable distance.";
- default:
- stringstream ss;
- ss << "Unknown error code: " << _error;
- return ss.str ();
+ switch (errorCode)
+ {
+ case -1:
+ return "No error.";
+ case 1:
+ return "No object in the range.";
+ case 2:
+ return "Object is too near (internal error).";
+ case 3:
+ return "Measurement error (may be due to interference).";
+ case 4:
+ return "Object out of range (at the near end).";
+ case 5:
+ return "Other error.";
+ default:
+ stringstream ss;
+ ss << "Unknown error code: " << errorCode;
+ return ss.str ();
+ }
}
+ else
+ {
+ switch (errorCode)
+ {
+ case -1:
+ return "No error.";
+ case 0:
+ return "Detected object is possibly at 22m.";
+ case 1:
+ return "Reflected light has low intensity.";
+ case 2:
+ return "Reflected light has low intensity.";
+ case 3:
+ return "Reflected light has low intensity.";
+ case 4:
+ return "Reflected light has low intensity.";
+ case 5:
+ return "Reflected light has low intensity.";
+ case 6:
+ return "Possibility of detected object is at 5.7m.";
+ case 7:
+ return "Distance data on the preceding and succeeding steps have errors.";
+ case 8:
+ return "Others.";
+ case 9:
+ return "The same step had error in the last two scan.";
+ case 10:
+ return "Others.";
+ case 11:
+ return "Others.";
+ case 12:
+ return "Others.";
+ case 13:
+ return "Others.";
+ case 14:
+ return "Others.";
+ case 15:
+ return "Others.";
+ case 16:
+ return "Possibility of detected object is in the range 4096mm.";
+ case 17:
+ return "Others.";
+ case 18:
+ return "Unspecified.";
+ case 19:
+ return "Non-measurable distance.";
+ default:
+ stringstream ss;
+ ss << "Unknown error code: " << errorCode;
+ return ss.str ();
+ }
+ }
}
HokuyoData& HokuyoData::operator= (const HokuyoData &rhs)
@@ -620,46 +720,71 @@
if (rhs.Length () == 0)
{
_length = 0;
- if (_data != NULL)
- delete[] _data;
- _data = NULL;
- _error = rhs.GetErrorCode ();
+ if (_ranges != NULL)
+ delete[] _ranges;
+ _ranges = NULL;
+ if (_intensities != NULL)
+ delete[] _intensities;
+ _intensities = NULL;
+ _error = rhs.GetErrorStatus ();
_time = rhs.TimeStamp ();
}
else
{
unsigned int rhsLength = rhs.Length ();
- unsigned short *newData;
+ uint32_t *newData;
if (rhsLength != _length)
{
// Copy the data into a temporary variable pointing to new space (prevents dangling
// pointers on allocation error and prevents self-assignment making a mess).
- if ((newData = new unsigned short[rhsLength]) == NULL)
- throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy data.");
- memcpy (newData, rhs.Ranges (), sizeof (unsigned short) * rhsLength);
- if (_data != NULL)
- delete[] _data;
- _data = newData;
+ if ((newData = new uint32_t[rhsLength]) == NULL)
+ {
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space to copy range data.");
+ }
+ memcpy (newData, rhs.Ranges (), sizeof (uint32_t) * rhsLength);
+ if (_ranges != NULL)
+ delete[] _ranges;
+ _ranges = newData;
_length = rhs.Length ();
+
+ if (rhs.Intensities () != NULL)
+ {
+ if ((newData = new uint32_t[rhsLength]) == NULL)
+ {
+ // We have to remove any old intensity data or the length won't match
+ if (_intensities != NULL)
+ delete[] _intensities;
+ _intensities = NULL;
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space to copy intensity data.");
+ }
+ memcpy (newData, rhs.Intensities (), sizeof (uint32_t) * rhsLength);
+ if (_intensities != NULL)
+ delete[] _intensities;
+ _intensities = newData;
+ }
}
else
{
// If lengths are the same, no need to reallocate
- memcpy (_data, rhs.Ranges (), sizeof (unsigned short) * _length);
+ memcpy (_ranges, rhs.Ranges (), sizeof (uint32_t) * _length);
+ if (rhs.Intensities () != NULL)
+ memcpy (_intensities, rhs.Intensities (), sizeof (uint32_t) * _length);
}
- _error = rhs.GetErrorCode ();
+ _error = rhs.GetErrorStatus ();
_time = rhs.TimeStamp ();
}
return *this;
}
-unsigned short HokuyoData::operator[] (unsigned int index)
+uint32_t HokuyoData::operator[] (unsigned int index)
{
if (index >= _length)
throw HokuyoError (HOKUYO_ERR_BADARG, "Invalid data index.");
- return _data[index];
+ return _ranges[index];
}
string HokuyoData::AsString (void)
@@ -668,8 +793,25 @@
ss << _length << " readings:" << endl;
for (unsigned int ii = 0; ii < _length; ii++)
- ss << _data[ii] << "\t";
- ss << endl << "Data error: (" << _error << ") " << ErrorCodeToString () << endl;
+ ss << _ranges[ii] << "\t";
+ if (_intensities != NULL)
+ {
+ ss << endl << _length << " intensities:" << endl;
+ for (unsigned int ii = 0; ii < _length; ii++)
+ ss << _intensities[ii] << "\t";
+ }
+ ss << endl;
+ if (_error)
+ {
+ ss << "Detected data errors:" << endl;
+ for (unsigned int ii = 0; ii < _length; ii++)
+ {
+ if (_ranges[ii] < 20)
+ ss << ii << ": " << ErrorCodeToString (_ranges[ii]) << endl;
+ }
+ }
+ else
+ ss << "No data errors." << endl;
ss << "Time stamp: " << _time << endl;
return ss.str ();
@@ -677,38 +819,71 @@
void HokuyoData::CleanUp (void)
{
- if (_data != NULL)
- delete[] _data;
- _data = NULL;
+ if (_ranges != NULL)
+ delete[] _ranges;
+ _ranges = NULL;
+ if (_intensities != NULL)
+ delete[] _intensities;
+ _intensities = NULL;
_length = 0;
- _error = 0;
+ _error = false;
_time = 0;
}
-void HokuyoData::AllocateData (unsigned int length)
+void HokuyoData::AllocateData (unsigned int length, bool includeIntensities)
{
// If no data yet, allocate new
- if (_data == NULL)
+ if (_ranges == NULL)
{
- if ((_data = new unsigned short[length]) == NULL)
+ if ((_ranges = new uint32_t[length]) == NULL)
{
_length = 0;
- throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy data.");
+ throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space for range data.");
}
_length = length;
}
// If there is data, reallocate only if the length is different
else if (length != _length)
{
- delete[] _data;
- if ((_data = new unsigned short[length]) == NULL)
+ delete[] _ranges;
+ if ((_ranges = new uint32_t[length]) == NULL)
{
_length = 0;
- throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space to copy data.");
+ throw HokuyoError (HOKUYO_ERR_MEMORY, "Failed to allocate space for range data.");
}
_length = length;
}
// Else data is already allocated to the right length, so do nothing
+
+ if (includeIntensities)
+ {
+ // If no data yet, allocate new
+ if (_intensities == NULL)
+ {
+ if ((_intensities = new uint32_t[length]) == NULL)
+ {
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space for intensity data.");
+ }
+ }
+ // If there is data, reallocate only if the length is different
+ else if (length != _length)
+ {
+ delete[] _intensities;
+ if ((_intensities = new uint32_t[length]) == NULL)
+ {
+ throw HokuyoError (HOKUYO_ERR_MEMORY,
+ "Failed to allocate space for intensity data.");
+ }
+ }
+ // Else data is already allocated to the right length, so do nothing
+ }
+ else if (_intensities != NULL)
+ {
+ // If not told to allocate space for intensity data and it exists, remove it
+ delete[] _intensities;
+ _intensities = NULL;
+ }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -719,8 +894,8 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
HokuyoLaser::HokuyoLaser (void)
- : _port (NULL), _scipVersion (1), _verbose (false), _minAngle (0.0), _maxAngle (0.0),
- _resolution (0.0), _firstStep (0), _lastStep (0), _frontStep (0)
+ : _port (NULL), _scipVersion (1), _verbose (false), _sensorIsUTM30LX (false),_minAngle (0.0),
+ _maxAngle (0.0), _resolution (0.0), _firstStep (0), _lastStep (0), _frontStep (0)
{
}
@@ -878,10 +1053,9 @@
else if (_scipVersion == 2)
{
// Sanity check the value
- if ((speed > 600 || speed < 540 || (speed % 6) != 0) && speed != 0)
+ if (speed > 10 & speed != 99)
throw HokuyoError (HOKUYO_ERR_BADARG, "Invalid motor speed.");
char buffer[3];
- buffer[2] = '\0';
if (speed == 0)
{
if (_verbose)
@@ -889,28 +1063,61 @@
cerr << "HokuyoLaser::" << __func__ << "() Reseting motor speed to default." <<
endl;
}
+ buffer[0] = '0';
+ buffer[1] = '0';
+ buffer[2] = '\0';
+ }
+ else if (speed == 99)
+ {
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() Reseting motor speed to default." <<
+ endl;
+ }
buffer[0] = '9';
buffer[1] = '9';
+ buffer[2] = '\0';
}
else
{
if (_verbose)
{
- cerr << "HokuyoLaser::" << __func__ << "() Setting motor speed to " <<
- speed << "rpm." << endl;
+ cerr << "HokuyoLaser::" << __func__ << "() Setting motor speed to ratio " <<
+ speed << endl;
}
- if (speed == 540)
+ NumberToString (speed, buffer, 2);
+ }
+ SendCommand ("CR", buffer, 2, "03");
+ SkipLines (1);
+ }
+ else
+ throw HokuyoError (HOKUYO_ERR_SCIPVERSION, "Unknown SCIP version.");
+}
+
+void HokuyoLaser::SetHighSensitivity (bool on)
+{
+ if (_scipVersion == 1)
+ {
+ throw HokuyoError (HOKUYO_ERR_UNSUPPORTED,
+ "SCIP version 1 does not support the set high sensitivity command.");
+ }
+ else if (_scipVersion == 2)
+ {
+ if (on)
+ {
+ if (_verbose)
+ cerr << "HokuyoLaser::" << __func__ << "() Switching to high sensitivity." << endl;
+ SendCommand ("HS", "1", 1, "02");
+ }
+ else
+ {
+ if (_verbose)
{
- buffer[0] = '1';
- buffer[1] = '0';
+ cerr << "HokuyoLaser::" << __func__ << "() Switching to normal sensitivity." <<
+ endl;
}
- else
- {
- buffer[0] = '0';
- buffer[1] = 100 - (speed / 6) + 0x30;
- }
+ SendCommand ("HS", "0", 1, "02");
}
- SendCommand ("CR", buffer, 2, "03");
SkipLines (1);
}
else
@@ -1080,9 +1287,28 @@
info->power = true;
// Motor speed
ReadLineWithCheck (buffer, -1, true);
- // TODO: check if the format of this line changes if the motor speed is changed
- if (sscanf (buffer, "SCSP:%*7s(%d[rpm]", &info->speed) != 1)
- throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Motor speed line parse failed.");
+ if (strncmp (&buffer[5], "Initial", 7) == 0)
+ {
+ // Unchanged motor speed
+ if (sscanf (buffer, "SCSP:%*7s(%d[rpm]", &info->speed) != 1)
+ {
+ stringstream ss;
+ ss << "Motor speed line parse failed: " << buffer;
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+ info->speedLevel = 0;
+ }
+ else
+ {
+ // Changed motor speed, format is:
+ // <level>%<ignored string>(<speed>[rpm])
+ if (sscanf (buffer, "SCSP:%hd%%%*4s(%d[rpm]", &info->speedLevel, &info->speed) != 2)
+ {
+ stringstream ss;
+ ss << "Motor speed line parse failed: " << buffer;
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
+ }
// Measuring state
ReadLineWithCheck (buffer, -1, true);
info->measureState = &buffer[5];
@@ -1094,11 +1320,19 @@
info->baud = 0;
}
else if (sscanf (buffer, "SBPS:%d[bps]", &info->baud) != 1)
- throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Baud rate line parse failed.");
+ {
+ stringstream ss;
+ ss << "Baud rate line parse failed: " << buffer;
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
// Time stamp
ReadLineWithCheck (buffer, -1, true);
if (sscanf (buffer, "TIME:%x", &info->time) != 1)
- throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Timestamp line parse failed.");
+ {
+ stringstream ss;
+ ss << "Timestamp line parse failed: " << buffer;
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, ss.str ());
+ }
// Diagnostic
ReadLineWithCheck (buffer, -1, true);
info->sensorDiagnostic = &buffer[5];
@@ -1169,7 +1403,7 @@
NumberToString (startStep, buffer, 3);
NumberToString (endStep, &buffer[3], 3);
NumberToString (clusterCount, &buffer[6], 2);
- data->_error = SendCommand ("G", buffer, 8, NULL);
+ SendCommand ("G", buffer, 8, NULL);
// In SCIP1 mode we're going to get back 2-byte data
Read2ByteRangeData (data, numSteps);
}
@@ -1179,7 +1413,7 @@
NumberToString (startStep, buffer, 4);
NumberToString (endStep, &buffer[4], 4);
NumberToString (clusterCount, &buffer[8], 2);
- data->_error = SendCommand ("GD", buffer, 10, NULL);
+ SendCommand ("GD", buffer, 10, NULL);
// There will be a timestamp before the data (if there is data)
// Normally we would send 6 for the expected length, but we may get no timestamp back if
// there was no data.
@@ -1257,7 +1491,7 @@
NumberToString (clusterCount, &buffer[8], 2);
NumberToString (1, &buffer[10], 1);
NumberToString (1, &buffer[11], 2);
- data->_error = SendCommand ("MD", buffer, 13, NULL);
+ SendCommand ("MD", buffer, 13, NULL);
// There will be a timestamp before the data (if there is data)
// Normally we would send 6 for the expected length, but we may get no timestamp back if
// there was no data.
@@ -1305,6 +1539,90 @@
return GetNewRanges (data, startStep, endStep, clusterCount);
}
+unsigned int HokuyoLaser::GetNewRangesAndIntensities (HokuyoData *data, int startStep, int endStep,
+ unsigned int clusterCount)
+{
+ if (data == NULL)
+ throw HokuyoError (HOKUYO_ERR_NODESTINATION, "No data destination provided.");
+
+ if (_scipVersion == 1)
+ {
+ throw HokuyoError (HOKUYO_ERR_UNSUPPORTED,
+ "SCIP version 1 does not support the get new ranges and intensities command.");
+ }
+ else if (_scipVersion == 2)
+ {
+ char buffer[14];
+ memset (buffer, 0, sizeof (char) * 14);
+
+ if (startStep < 0)
+ startStep = _firstStep;
+ if (endStep < 0)
+ endStep = _lastStep;
+
+ unsigned int numSteps = (endStep - startStep + 1) / clusterCount;
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() Reading " << numSteps <<
+ " new ranges between " << startStep << " and " << endStep <<
+ " with a cluster count of " << clusterCount << endl;
+ }
+
+ // Send the command to ask for the most recent range data with intensity data from startStep
+ // to endStep
+ NumberToString (startStep, buffer, 4);
+ NumberToString (endStep, &buffer[4], 4);
+ NumberToString (clusterCount, &buffer[8], 2);
+ NumberToString (1, &buffer[10], 1);
+ NumberToString (1, &buffer[11], 2);
+ SendCommand ("ME", buffer, 13, NULL);
+ // There will be a timestamp before the data (if there is data)
+ // Normally we would send 6 for the expected length, but we may get no timestamp back if
+ // there was no data.
+ if (ReadLineWithCheck (buffer) == 0)
+ throw HokuyoError (HOKUYO_ERR_NODATA, "No data received. Check data error code.");
+ data->_time = Decode4ByteValue (buffer);
+ // In SCIP2 mode we're going to get back 3-byte data because we're sending the ME command
+ Read3ByteRangeAndIntensityData (data, numSteps);
+ }
+ else
+ throw HokuyoError (HOKUYO_ERR_SCIPVERSION, "Unknown SCIP version.");
+
+ return data->_length;
+}
+
+unsigned int HokuyoLaser::GetNewRangesAndIntensities (HokuyoData *data, double startAngle,
+ double endAngle, unsigned int clusterCount)
+{
+ if (data == NULL)
+ throw HokuyoError (HOKUYO_ERR_NODESTINATION, "No data destination provided.");
+ if (_scipVersion == 1)
+ {
+ throw HokuyoError (HOKUYO_ERR_UNSUPPORTED,
+ "SCIP version 1 does not support the get new ranges and intensities command.");
+ }
+
+ // Calculate the given angles in steps, rounding towards _frontStep
+ int startStep, endStep;
+ startStep = AngleToStep (startAngle);
+ endStep = AngleToStep (endAngle);
+
+ // Check the steps are within the allowable range
+ if (startStep < _firstStep || startStep > _lastStep)
+ throw HokuyoError (HOKUYO_ERR_BADARG, "Start step is out of range.");
+ if (endStep < _firstStep || endStep > _lastStep)
+ throw HokuyoError (HOKUYO_ERR_BADARG, "End step is out of range.");
+
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() Start angle " << startAngle << " is step " <<
+ startStep << ", end angle " << endAngle << " is step " << endStep << endl;
+ }
+
+ // Get the data
+ return GetNewRangesAndIntensities (data, startStep, endStep, clusterCount);
+}
+
double HokuyoLaser::StepToAngle (unsigned int step)
{
return (static_cast<int> (step) - static_cast<int> (_frontStep)) * _resolution;
@@ -1803,6 +2121,8 @@
// This will automatically take care of whether it actually needs to (re)allocate or not.
data->AllocateData (numSteps);
+ data->_sensorIsUTM30LX = _sensorIsUTM30LX;
+ data->_error = false;
// 2 byte data is easy since it fits neatly in a 64-byte block
char buffer[SCIP2_LINE_LENGTH];
@@ -1820,10 +2140,12 @@
{
if (buffer[ii] == '\n' || buffer[ii + 1] == '\n')
{
- // Line feed in the middle of a line? Why?
+ // Line feed in the middle of a data block? Why?
throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Found line feed in a data block.");
}
- data->_data[currentStep] = Decode2ByteValue (&buffer[ii]);
+ data->_ranges[currentStep] = Decode2ByteValue (&buffer[ii]);
+ if (data->_ranges[currentStep] < 20)
+ data->_error = true;
}
// End of this line. Go around again.
}
@@ -1841,6 +2163,8 @@
// This will automatically take care of whether it actually needs to (re)allocate or not.
data->AllocateData (numSteps);
+ data->_sensorIsUTM30LX = _sensorIsUTM30LX;
+ data->_error = false;
// 3 byte data is a pain because it crosses the line boundary, it may overlap by 0, 1 or 2 bytes
char buffer[SCIP2_LINE_LENGTH];
@@ -1880,29 +2204,31 @@
if (splitCount == 1)
{
splitValue[2] = buffer[ii++];
- data->_data[currentStep] = Decode3ByteValue (splitValue);
+ data->_ranges[currentStep] = Decode3ByteValue (splitValue);
}
else if (splitCount == 2)
{
splitValue[1] = buffer[ii++];
splitValue[2] = buffer[ii++];
- data->_data[currentStep] = Decode3ByteValue (splitValue);
+ data->_ranges[currentStep] = Decode3ByteValue (splitValue);
}
else
{
- data->_data[currentStep] = Decode3ByteValue (&buffer[ii]);
+ data->_ranges[currentStep] = Decode3ByteValue (&buffer[ii]);
ii += 3;
}
- if (data->_data[currentStep] > _maxRange)
+ if (data->_ranges[currentStep] > _maxRange)
{
cerr << "WARNING: HokuyoLaser::" << __func__ <<
"() Value at step " << currentStep << " beyond maximum range: " <<
- data->_data[currentStep] << " (raw bytes: ";
+ data->_ranges[currentStep] << " (raw bytes: ";
if (splitCount != 0)
cerr << splitValue[0] << splitValue[1] << splitValue[2] << ")" << endl;
else
cerr << buffer[0] << buffer[1] << buffer[2] << ")" << endl;
}
+ else if (data->_ranges[currentStep] < 20)
+ data->_error = true;
currentStep++;
splitCount = 0; // Reset this here now that it's been used
}
@@ -1919,4 +2245,109 @@
}
}
+void HokuyoLaser::Read3ByteRangeAndIntensityData (HokuyoData *data, unsigned int numSteps)
+{
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() Reading " << numSteps <<
+ " ranges and intensities." << endl;
+ }
+
+ // This will automatically take care of whether it actually needs to (re)allocate or not.
+ data->AllocateData (numSteps, true);
+ data->_sensorIsUTM30LX = _sensorIsUTM30LX;
+
+ // 3 byte data is a pain because it crosses the line boundary, it may overlap by 0, 1 or 2 bytes
+ char buffer[SCIP2_LINE_LENGTH];
+ unsigned int currentStep = 0;
+ int numBytesInLine = 0, splitCount = 0;
+ char splitValue[3];
+ bool nextIsIntensity = false;
+ while (true)
+ {
+ // Read a line of data
+ numBytesInLine = ReadLineWithCheck (buffer);
+ // Check if we've reached the end of the data
+ if (numBytesInLine == 0)
+ break;
+ // Process triplets of bytes until we encounter or overrun the end of the line
+ for (int ii = 0; ii < numBytesInLine;)
+ {
+ if (buffer[ii] == '\n' || buffer[ii + 1] == '\n')
+ {
+ // Line feed in the middle of a line? Why?
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL, "Found line feed in a data block.");
+ }
+ if (ii == numBytesInLine - 2) // Short 1 byte
+ {
+ splitValue[0] = buffer[ii];
+ splitValue[1] = buffer[ii + 1];
+ splitCount = 1; // Will be reset on the next iteration, after it's used
+ ii += 2;
+ }
+ else if (ii == numBytesInLine - 1) // Short 2 bytes
+ {
+ splitValue[0] = buffer[ii];
+ splitCount = 2; // Will be reset on the next iteration, after it's used
+ ii += 1;
+ }
+ else
+ {
+ if (splitCount == 1)
+ {
+ splitValue[2] = buffer[ii++];
+ if (nextIsIntensity)
+ data->_intensities[currentStep] = Decode3ByteValue (splitValue);
+ else
+ data->_ranges[currentStep] = Decode3ByteValue (splitValue);
+ }
+ else if (splitCount == 2)
+ {
+ splitValue[1] = buffer[ii++];
+ splitValue[2] = buffer[ii++];
+ if (nextIsIntensity)
+ data->_intensities[currentStep] = Decode3ByteValue (splitValue);
+ else
+ data->_ranges[currentStep] = Decode3ByteValue (splitValue);
+ }
+ else
+ {
+ if (nextIsIntensity)
+ data->_intensities[currentStep] = Decode3ByteValue (&buffer[ii]);
+ else
+ data->_ranges[currentStep] = Decode3ByteValue (&buffer[ii]);
+ ii += 3;
+ }
+ if (data->_ranges[currentStep] > _maxRange && !nextIsIntensity)
+ {
+ cerr << "WARNING: HokuyoLaser::" << __func__ <<
+ "() Value at step " << currentStep << " beyond maximum range: " <<
+ data->_ranges[currentStep] << " (raw bytes: ";
+ if (splitCount != 0)
+ cerr << splitValue[0] << splitValue[1] << splitValue[2] << ")" << endl;
+ else
+ cerr << buffer[0] << buffer[1] << buffer[2] << ")" << endl;
+ }
+ else if (data->_ranges[currentStep] < 20)
+ data->_error = true;
+ currentStep++;
+ splitCount = 0; // Reset this here now that it's been used
+ nextIsIntensity = !nextIsIntensity; // Alternate between range and intensity values
+ }
+ }
+ // End of this line. Go around again.
+ }
+
+ if (_verbose)
+ {
+ cerr << "HokuyoLaser::" << __func__ << "() Read " << currentStep <<
+ " ranges and intensities." << endl;
+ }
+ if (currentStep != numSteps)
+ {
+ throw HokuyoError (HOKUYO_ERR_PROTOCOL,
+ "Read a different number of range and intensity readings than were asked for.");
+ }
+}
+
} // namespace hokuyo_aist
Modified: gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-01 06:19:50 UTC (rev 236)
+++ gearbox/trunk/submitted/hokuyo_aist/hokuyo_aist.h 2008-07-01 06:54:09 UTC (rev 237)
@@ -196,6 +196,8 @@
bool power;
/// Current motor speed (rpm).
unsigned int speed;
+ /// Speed level (0 for default)
+ unsigned short speedLevel;
/// Measurement state.
std::string measureState;
/// Baud rate.
@@ -230,9 +232,12 @@
/// This constructor creates an empty HokuyoData with no data currently allocated.
HokuyoData (void);
- /// This constructor performs a deep copy of data.
- HokuyoData (unsigned short *data, unsigned int length, short error, unsigned int time);
- /// This copy constructor performs a deep copy of data.
+ /// This constructor performs a deep copy of range data.
+ HokuyoData (uint32_t *ranges, unsigned int length, bool error, unsigned int time);
+ /// This constructor performs a deep copy of range and intensity data.
+ HokuyoData (uint32_t *ranges, uint32_t *intensities, unsigned int length,
+ bool error, unsigned int time);
+ /// This copy constructor performs a deep copy of present data.
HokuyoData (const HokuyoData &rhs);
~HokuyoData (void);
@@ -240,23 +245,26 @@
Values less than 20mm indicate an error. Check the error value for the data to see a
probable cause for the error. Most of the time, it will just be an out-of-range reading. */
- const unsigned short* Ranges (void) const { return _data; }
+ const uint32_t* Ranges (void) const { return _ranges; }
+ /// @brief Return a pointer to an array of intensity readings.
+ const uint32_t* Intensities (void) const { return _intensities; }
/// @brief Get the number of samples in the data.
unsigned int Length (void) const { return _length; }
- /** @brief Error code for the data (if any).
-
- @return -1 indicates no error. */
- short GetErrorCode (void) const { return _error; }
- /// @brief Return a string representing the error code for the data.
- std::string ErrorCodeToString (void);
+ /** @brief Indicates if one or more steps had an error.
+
+ A step's value will be less than 20 if it had an error. Use @ref ErrorCodeToString to get
+ a textual representation of the error. */
+ bool GetErrorStatus (void) const { return _error; }
+ /// @brief Return a string representing the error for the given error code.
+ std::string ErrorCodeToString (uint32_t errorCode);
/** @brief Get the time stamp of the data in milliseconds (only available using SCIP
version 2). */
unsigned int TimeStamp (void) const { return _time; }
/// @brief Assignment operator.
HokuyoData& operator= (const HokuyoData &rhs);
- /// @brief Subscript operator.
- unsigned short operator[] (unsigned int index);
+ /// @brief Subscript operator. Provides direct access to an element of the range data.
+ uint32_t operator[] (unsigned int index);
/// @brief Format the entire object into a string.
std::string AsString (void);
@@ -265,12 +273,14 @@
void CleanUp (void);
private:
- unsigned short *_data;
+ uint32_t *_ranges;
+ uint32_t *_intensities;
unsigned int _length;
- short _error;
+ bool _error;
unsigned int _time;
+ bool _sensorIsUTM30LX;
- void AllocateData (unsigned int length);
+ void AllocateData (unsigned int length, bool includeIntensities = false);
};
/** @brief Hokuyo laser scanner class.
@@ -313,14 +323,20 @@
Not available with the SCIP v1 protocol. */
void Reset (void);
- /** @brief Set the speed at which the scanner's sensor spins in revolutions per minute.
+ /** @brief Set the speed at which the scanner's sensor spins.
- Valid speeds are: 540, 546, 552, 558, 564, 570, 576, 582, 588, 594, 600. Set the speed to 0
- to have it reset to the default value.
+ Set the speed to 0 to have it reset to the default value, and 99 to reset it to the initial
+ (startup) value. Values between 1 and 10 specify a ratio of the default speed. The speeds in
+ revolutions per minute that these correspond to will depend on the scanner model. For
+ example, for a URG-04LX, they are (from 1 to 10) 594, 588, 576, 570, 564, 558, 552, 546, and
+ 540 rpm.
Not available with the SCIP v1 protocol. */
void SetMotorSpeed (unsigned int speed);
+ /// @brief Switch the scanner between normal and high sensitivity modes.
+ void SetHighSensitivity (bool on);
+
/** @brief Get various information about the scanner.
Much of the information is not available with the SCIP v1 protocol. */
@@ -399,6 +415,38 @@
unsigned int GetNewRanges (HokuyoData *data, double startAngle, double endAngle,
unsigned int clusterCount = 1);
+ /** @brief Get a new scan from the scanner with intensity data.
+
+ Unlike @ref GetRanges, which returns the most recent scan the scanner took, this function
+ will request a new scan. This means it will wait while the scanner performs the scan.
+ Otherwise behaves identicallty to @ref GetRanges.
+
+ Not available with the SCIP v1 protocol.
+
+ @param data Pointer to a @ref HokuyoData object to store the range readings in.
+ @param clusterCount The number of readings to cluster together into a single reading. The
+ minimum value from a cluster is returned as the range for that cluster.
+ @param startStep The first step to get ranges from. Set to -1 for the first scannable step.
+ @param endStep The last step to get ranges from. Set to -1 for the last scannable step.
+ @return The number of range readings read into @ref data. */
+ unsigned int GetNewRangesAndIntensities (HokuyoData *data, int startStep = -1,
+ int endStep = -1, unsigned int clusterCount = 1);
+
+ /** @brief Get a new scan from the scanner with intensity data.
+
+ Not available with the SCIP v1 protocol.
+
+ @param data Pointer to a @ref HokuyoData object to store the range readings in.
+ @param startAngle The angle to get range readings from. Exclusive; if this falls between two
+ steps the step inside the angle will be returned, but the step outside won't.
+ @param endAngle The angle to get range readings to. Exclusive; if this falls between two
+ steps the step inside the angle will be returned, but the step outside won't.
+ @param clusterCount The number of readings to cluster together into a single reading. The
+ minimum value from a cluster is returned as the range for that cluster.
+ @return The number of range readings read into @ref data. */
+ unsigned int GetNewRangesAndIntensities (HokuyoData *data, double startAngle,
+ double endAngle, unsigned int clusterCount = 1);
+
/// @brief Return the major version of the SCIP protocol in use.
uint8_t SCIPVersion (void) const { return _scipVersion; }
@@ -415,7 +463,7 @@
flexiport::Port *_port;
uint8_t _scipVersion;
- bool _verbose;
+ bool _verbose, _sensorIsUTM30LX;
double _minAngle, _maxAngle, _resolution;
int _firstStep, _lastStep, _frontStep;
unsigned int _maxRange;
@@ -429,6 +477,7 @@
void GetDefaults (void);
void Read2ByteRangeData (HokuyoData *data, unsigned int numSteps);
void Read3ByteRangeData (HokuyoData *data, unsigned int numSteps);
+ void Read3ByteRangeAndIntensityData (HokuyoData *data, unsigned int numSteps);
};
} // namespace hokuyo_aist
Modified: gearbox/trunk/submitted/hokuyo_aist/test/example.cpp
===================================================================
--- gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-01 06:19:50 UTC (rev 236)
+++ gearbox/trunk/submitted/hokuyo_aist/test/example.cpp 2008-07-01 06:54:09 UTC (rev 237)
@@ -36,7 +36,7 @@
string portOptions = "type=serial,device=/dev/ttyACM0,timeout=1";
double startAngle = 0.0, endAngle = 0.0;
int opt, firstStep = -1, lastStep = -1;
- unsigned int baud = 19200, speed = 600, clusterCount = 1;
+ unsigned int baud = 19200, speed = 0, clusterCount = 1;
bool getNew = false, verbose = false;
#if defined (WIN32)
Modified: gearbox/trunk/submitted/hokuyo_aist/test/example.logr
===================================================================
(Binary files differ)
Modified: gearbox/trunk/submitted/hokuyo_aist/test/example.logw
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bo...@us...> - 2008-07-01 06:19:51
|
Revision: 236
http://gearbox.svn.sourceforge.net/gearbox/?rev=236&view=rev
Author: borax00
Date: 2008-06-30 23:19:50 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
fixed typo in comment
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h 2008-07-01 06:12:43 UTC (rev 235)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.h 2008-07-01 06:19:50 UTC (rev 236)
@@ -68,7 +68,7 @@
//! Puts OceanServerSystem data into a machine-readable ASCII string
std::string toLogString( const OceanServerSystem &system );
-//! Updates all fields in 'to' with data from 'from'. Also reapes batteries in 'to' if they are not in 'from'.
+//! Updates all fields in 'to' with data from 'from'. Also reaps batteries in 'to' if they are not in 'from'.
//! Has persistence capabilities: if fields in 'from' are not set and corresponding fields in 'to' are set, the ones in 'to' are kept.
//! Use case: a class stores 'to' as a member variable, receives the latest records into 'from', calls this function to update 'to'.
//! The reaping capability makes sure that battery modules which are no longer connected don't persist.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bo...@us...> - 2008-07-01 06:12:36
|
Revision: 235
http://gearbox.svn.sourceforge.net/gearbox/?rev=235&view=rev
Author: borax00
Date: 2008-06-30 23:12:43 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
added test.
Modified Paths:
--------------
gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt
Added Paths:
-----------
gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp
Modified: gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt
===================================================================
--- gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt 2008-07-01 05:38:58 UTC (rev 234)
+++ gearbox/trunk/src/gbxutilacfr/test/CMakeLists.txt 2008-07-01 06:12:43 UTC (rev 235)
@@ -4,3 +4,6 @@
ADD_EXECUTABLE( mathtest mathtest.cpp )
GBX_ADD_TEST( GbxUtilAcfrMathTest mathtest )
+
+ADD_EXECUTABLE( tokenisetest tokenisetest.cpp )
+GBX_ADD_TEST( GbxUtilAcfrTokeniseTest tokenisetest )
Added: gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp (rev 0)
+++ gearbox/trunk/src/gbxutilacfr/test/tokenisetest.cpp 2008-07-01 06:12:43 UTC (rev 235)
@@ -0,0 +1,60 @@
+#include <gbxutilacfr/tokenise.h>
+#include <iostream>
+#include <assert.h>
+#include <cstdlib>
+
+// Make sure assertions are on
+#undef NDEBUG
+
+using namespace std;
+using namespace gbxutilacfr;
+
+int main()
+{
+ {
+ string str = "asdf,hjkl";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "asdf" );
+ assert( tokens[1] == "hjkl" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ {
+ string str = ",asdf,hjkl,";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "" );
+ assert( tokens[1] == "asdf" );
+ assert( tokens[2] == "hjkl" );
+ assert( tokens[3] == "" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ {
+ string str = ",asdf,,hjkl,";
+ vector<string> tokens = tokenise(str,",");
+ assert( tokens[0] == "" );
+ assert( tokens[1] == "asdf" );
+ assert( tokens[2] == "" );
+ assert( tokens[3] == "hjkl" );
+ assert( tokens[4] == "" );
+ cout<<"TRACE(tokenisetest.cpp): str: " << str << endl;
+ cout<<"TRACE(tokenisetest.cpp): tokens: " << endl;
+ for ( size_t i=0; i < tokens.size(); i++)
+ {
+ cout << " " << i << ": " << tokens[i] << endl;
+ }
+ }
+
+ cout<<"TRACE(tokenisetest.cpp): test PASSED" << endl;
+ exit(0);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bo...@us...> - 2008-07-01 05:38:52
|
Revision: 234
http://gearbox.svn.sourceforge.net/gearbox/?rev=234&view=rev
Author: borax00
Date: 2008-06-30 22:38:58 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
minor.
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-06-30 12:04:53 UTC (rev 233)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/smartbatteryacfr.dox 2008-07-01 05:38:58 UTC (rev 234)
@@ -25,7 +25,7 @@
@par Examples
- See 'test/simpletest.cpp' for a simple example of how to use the library. The test reads a few records from the oceanserver system and prints the results on the screen.
-- See 'test/fancytest.cpp' for a more advanced example. The test uses a class to read a few records from the oceanserver system and stores an internal (full) record which only gets updated with new data.
+- See 'test/fancytest.cpp' for a more advanced example. The test uses a class to read a few records from the oceanserver system and stores an internal (full) record which gets incrementally updated with new data.
@par Style
See http://orca-robotics.sourceforge.net/orca/orca_doc_style.html
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <to...@us...> - 2008-06-30 12:04:45
|
Revision: 233
http://gearbox.svn.sourceforge.net/gearbox/?rev=233&view=rev
Author: tobasco
Date: 2008-06-30 05:04:53 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp
Modified: gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp 2008-06-30 12:01:10 UTC (rev 232)
+++ gearbox/trunk/submitted/gbxsmartbatteryacfr/oceanserversystem.cpp 2008-06-30 12:04:53 UTC (rev 233)
@@ -236,4 +236,4 @@
batteries_.erase( batteries_.find( batteryNumber ) );
}
-} //namespace
\ No newline at end of file
+} //namespace
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|