now using the libserial library (part of #722)

This commit is contained in:
fgerlits 2007-01-23 13:33:06 +00:00
parent 7b79a6835e
commit 99c182d179
5 changed files with 73 additions and 5 deletions

View file

@ -304,7 +304,7 @@ G_LIVESUPPORT_EXE_LIBS = -l${PLAYLIST_EXECUTOR_LIB} \
-l${SCHEDULER_CLIENT_LIB} \
-l${CORE_LIB} \
${BOOST_DATE_TIME_LIB} \
-lxmlrpc++ -lssl -ltar
-lxmlrpc++ -lssl -ltar -lserial
TEST_RUNNER_OBJS = ${G_LIVESUPPORT_OBJS} \
${TMP_DIR}/TestRunner.o \

View file

@ -182,6 +182,11 @@ const std::string authenticationNotReachableKey =
*----------------------------------------------------------------------------*/
const std::string localeNotAvailableKey = "localeNotAvailableMsg";
/*------------------------------------------------------------------------------
* The default serial device
*----------------------------------------------------------------------------*/
const std::string defaultSerialDevice = "/dev/ttyS0";
}
/* =============================================== local function prototypes */
@ -396,6 +401,9 @@ GLiveSupport :: configure(const xmlpp::Element & element)
testAudioUrl.reset(new Glib::ustring(
testAudioUrlElement->get_attribute("path")
->get_value() ));
// TODO: make this configurable
serialDevice.reset(new std::string(defaultSerialDevice));
}
@ -1781,3 +1789,23 @@ GLiveSupport :: createScratchpadWindow(void)
}
}
/*------------------------------------------------------------------------------
* Write a string to the serial device.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: writeToSerial(Ptr<const std::string>::Ref message)
throw ()
{
try {
serialStream->Open(*serialDevice);
(*serialStream) << *message;
serialStream->flush();
serialStream->Close();
} catch (...) {
// TODO: handle this somehow
std::cerr << "IO error in GLiveSupport::writeToSerial()" << std::endl;
}
}

View file

@ -45,6 +45,7 @@
#include <map>
#include <boost/enable_shared_from_this.hpp>
#include <unicode/resbund.h>
#include <SerialStream.h>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/LocalizedConfigurable.h"
@ -253,17 +254,27 @@ class GLiveSupport : public LocalizedConfigurable,
/**
* The location of the test audio file.
*/
Ptr<Glib::ustring>::Ref testAudioUrl;
Ptr<Glib::ustring>::Ref testAudioUrl;
/**
* The command which starts the scheduler daemon.
*/
Ptr<Glib::ustring>::Ref schedulerDaemonStartCommand;
Ptr<Glib::ustring>::Ref schedulerDaemonStartCommand;
/**
* The command which stops the scheduler daemon.
*/
Ptr<Glib::ustring>::Ref schedulerDaemonStopCommand;
Ptr<Glib::ustring>::Ref schedulerDaemonStopCommand;
/**
* The serial device.
*/
Ptr<std::string>::Ref serialDevice;
/**
* The serial stream object.
*/
Ptr<LibSerial::SerialStream>::Ref serialStream;
/**
* Read a supportedLanguages configuration element,
@ -375,6 +386,7 @@ class GLiveSupport : public LocalizedConfigurable,
{
openedAudioClips.reset(new AudioClipMap());
openedPlaylists.reset(new PlaylistMap());
serialStream.reset(new LibSerial::SerialStream());
}
/**
@ -1277,6 +1289,12 @@ class GLiveSupport : public LocalizedConfigurable,
*/
void
createScratchpadWindow(void) throw ();
/**
* Write a string to the serial device.
*/
void
writeToSerial(Ptr<const std::string>::Ref message) throw ();
};
/* ================================================= external data structures */

View file

@ -48,6 +48,7 @@ cd ${tmpdir}
if [ ! -d $product ]; then
tar xfz ${tar}
cd $product
# put patches here
# patch not submitted yet
patch -p1 < $etcdir/libserial-gcc-4.0-fix.patch
fi

View file

@ -0,0 +1,21 @@
diff -aur libserial-0.5.2 libserial-0.5.2-gcc-4.0
--- libserial-0.5.2/src/SerialStreamBuf.h 2005-10-17 02:19:12.000000000 +0200
+++ libserial-0.5.2-gcc-4.0/src/SerialStreamBuf.h 2007-01-23 14:16:18.000000000 +0100
@@ -568,6 +568,6 @@
return next_ch ;
}
- } ; // namespace LibSerial
+ } // namespace LibSerial
} // extern "C++"
#endif // #ifndef _SerialStreamBuf_h_
--- libserial-0.5.2/src/SerialStream.h 2005-10-01 23:24:21.000000000 +0200
+++ libserial-0.5.2-gcc-4.0/src/SerialStream.h 2007-01-23 14:16:23.000000000 +0100
@@ -346,6 +346,6 @@
return mIOBuffer->is_open() ;
}
- } ; // namespace LibSerial
+ } // namespace LibSerial
} // extern "C++"
#endif // #ifndef _SerialStream_h_