option(test_plugin "Test Plugin" ON)
option(bluemonkey_plugin "bluemonkey plugin" OFF)
option(gpsnmea_plugin "gps NMEA location plugin" OFF)
+option(chrony_plugin "chrony plugin" OFF)
option(openxc_plugin "OpenXC plugin" OFF)
option(bluetooth_plugin "bluetooth plugin" OFF)
option(cansim_plugin "Can simulator plugin" OFF)
${CMAKE_CURRENT_BINARY_DIR}/websocketsource2
${CMAKE_CURRENT_BINARY_DIR}/testsourceconfig
${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig
- ${CMAKE_CURRENT_BINARY_DIR}/bluetooth)
+ ${CMAKE_CURRENT_BINARY_DIR}/bluetooth
+ ${CMAKE_CURRENT_BINARY_DIR}/chrony)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/configwheel.in.json ${CMAKE_CURRENT_BINARY_DIR}/configwheel @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/databasesource.in.json ${CMAKE_CURRENT_BINARY_DIR}/databasesource @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluemonkey/bluemonkeyconfig.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluemonkey/bluemonkeyconfig @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/bluetooth.in.json ${CMAKE_CURRENT_BINARY_DIR}/bluetooth @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/testplugins.d.in.json ${CMAKE_CURRENT_SOURCE_DIR}/testplugins.d.json @ONLY)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/chrony.in.json ${CMAKE_CURRENT_BINARY_DIR}/chrony @ONLY)
install (FILES ${amb_examples} DESTINATION /etc/ambd/examples)
--- /dev/null
+{
+ "sources" : [
+ {
+ "name" : "gps nmea plugin",
+ "path" : "@PLUGIN_INSTALL_PATH@/gpsnmea.so",
+ "device" : "/dev/ttyUSB0",
+ "baudrate" : "4800"
+ }
+ ],
+ "sinks": [
+ {
+ "path" : "@PLUGIN_INSTALL_PATH@/chrony.so"
+ }
+ ]
+}
+
add_subdirectory(bluetooth)
add_subdirectory(cansimplugin)
add_subdirectory(cangenplugin)
+add_subdirectory(chrony)
--- /dev/null
+if(chrony_plugin)
+
+set(chrony_headers chrony.h)
+set(chrony_sources chrony.cpp )
+
+add_library(chrony MODULE ${chrony_sources})
+set_target_properties(chrony PROPERTIES PREFIX "")
+target_link_libraries(chrony amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${link_libraries} ${gio_LIBRARIES})
+
+install(TARGETS chrony LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_BINARY_DIR}/chrony.README @ONLY)
+
+install (FILES ${CMAKE_CURRENT_BINARY_DIR}/chrony.README DESTINATION ${DOC_INSTALL_DIR}/plugins)
+
+endif(chrony_plugin)
--- /dev/null
+CHRONY plugin
+Version: @PROJECT_VERSION@
+
+This plugin will forward the GpsTime property to the CHRONYD daemon.
+
+To enable the CHRONY plugin, run cmake and enable the chrony_plugin option:
+
+cmake -Dchrony_plugin=On ..
+
+To use this plugin, add the following to the "sinks" array in /etc/ambd/config:
+
+{
+ "name" : "chrony",
+ "path" : "@PLUGIN_INSTALL_PATH@/chrony.so",
+}
+
+Configuration Key Definitions:
+
+"name"
+name of plugin. This key is not used by the plugin at this moment.
+
+"path"
+path to plugin on the filesystem.
+
--- /dev/null
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library 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 2.1 of the License, or (at your option) any later version.
+
+ This library 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 this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "chrony.h"
+#include "abstractroutingengine.h"
+#include "debugout.h"
+#include "listplusplus.h"
+
+#include <glib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/time.h>
+#include <math.h>
+
+#define GPSTIME "GpsTime"
+
+extern "C" void create(AbstractRoutingEngine* routingEngine, map<string, string> config)
+{
+ new ChronySink(routingEngine, config);
+}
+
+ChronySink::ChronySink(AbstractRoutingEngine* engine, map<string, string> config): AbstractSink(engine, config)
+{
+ routingEngine->subscribeToProperty(GPSTIME, this);
+ supportedChanged(engine->supported());
+}
+
+PropertyList ChronySink::subscriptions()
+{
+}
+
+void ChronySink::supportedChanged(const PropertyList & supportedProperties)
+{
+ DebugOut()<<"Support changed!"<<endl;
+}
+
+void ChronySink::propertyChanged(AbstractPropertyType *value)
+{
+ int sockfd;
+ struct sockaddr_un s;
+ struct chrony_sock_sample chronydata;
+
+ sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (sockfd < 0) return;
+
+ s.sun_family = AF_UNIX;
+ strcpy(s.sun_path, CHRONYD_SOCKET );
+
+ if(connect(sockfd, (struct sockaddr *)&s, sizeof(s)) == -1)
+ {
+ return;
+ }
+
+ gettimeofday(&(chronydata.tv), NULL);
+ chronydata.offset = (value->value<double>() - chronydata.tv.tv_sec) - (chronydata.tv.tv_usec / 1000000.0);
+ chronydata.offset -= (amb::currentTime()-value->timestamp);
+ chronydata.pulse = 0;
+ chronydata.leap = 0;
+ chronydata.magic = 0x534f434b;
+ send(sockfd,&chronydata,sizeof(chronydata),0);
+
+ close(sockfd);
+}
+
+const string ChronySink::uuid()
+{
+ return "35324592-db72-11e4-b432-0022684a4a24";
+}
--- /dev/null
+/*
+ Copyright (C) 2012 Intel Corporation
+
+ This library 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 2.1 of the License, or (at your option) any later version.
+
+ This library 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 this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#ifndef CHRONYSINK_H
+#define CHRONYSINK_H
+
+#include "abstractsink.h"
+
+#define CHRONYD_SOCKET "/tmp/chrony.gps.sock"
+
+struct chrony_sock_sample {
+ struct timeval tv;
+ double offset;
+ int pulse;
+ int leap;
+ int _pad;
+ int magic;
+};
+
+class ChronySink : public AbstractSink
+{
+
+public:
+ ChronySink(AbstractRoutingEngine* engine, map<string, string> config);
+ virtual PropertyList subscriptions();
+ virtual void supportedChanged(const PropertyList & supportedProperties);
+ virtual void propertyChanged( AbstractPropertyType* value);
+ virtual const std::string uuid();
+};
+
+#endif // CHRONYSINK_H