SET(CPACK_PACKAGE_CONTACT "tripzero.kev@gmail.com")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
-
# Always build .tar.gz and .sh files
SET(CPACK_GENERATOR "STGZ;TGZ;TBZ2")
-SET(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
-SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libopencv, libjson0, libltdl7")
-SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
-SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "tripzero.kev@gmail.com")
-
-find_program(rpmbuild rpmbuild /usr/bin)
-if(rpmbuild)
- SET(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
- SET(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_SOURCE_DIR}/packaging/automotive-message-broker.spec")
- SET(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
-endif(rpmbuild)
-INCLUDE(CPack)
-
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/packaging.in/config.tizen.in ${CMAKE_CURRENT_BINARY_DIR}/packaging.in/config.tizen @ONLY)
-
add_subdirectory(lib)
add_subdirectory(plugins)
add_subdirectory(ambd)
add_subdirectory(tools)
add_subdirectory(examples)
add_subdirectory(xwalk)
-add_subdirectory(packaging)
+add_subdirectory(packaging.in)
--- /dev/null
+
+find_program(rpmbuild rpmbuild /usr/bin)
+if(rpmbuild)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/automotive-message-broker.spec.in ${CMAKE_SOURCE_DIR}/packaging/automotive-message-broker.spec @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.tizen.in ${CMAKE_SOURCE_DIR}/packaging/config.tizen @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/automotive-message-broker.changes.in ${CMAKE_SOURCE_DIR}/packaging/automotive-message-broker.changes @ONLY)
+endif(rpmbuild)
+
+find_program(debuild debuild /usr/bin)
+if(debuild)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/control.debian.in ${CMAKE_SOURCE_DIR}/debian/control @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/libamb.debian.install ${CMAKE_SOURCE_DIR}/debian/libamb.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/libamb-dev.debian.install ${CMAKE_SOURCE_DIR}/debian/libamb-dev.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker.debian.install ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/automotive-message-broker-plugins.debian.install ${CMAKE_SOURCE_DIR}/debian/automotive-message-broker-plugins.install @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog ${CMAKE_SOURCE_DIR}/debian/changelog @ONLY)
+ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/debian/rules ${CMAKE_SOURCE_DIR}/debian/rules @ONLY)
+endif(debuild)
--- /dev/null
+debian/tmp/@PLUGIN_INSTALL_PATH@/examplesourceplugin.so
+debian/tmp/@PLUGIN_INSTALL_PATH@/examplesinkplugin.so
+debian/tmp/@PLUGIN_INSTALL_PATH@/dbussinkplugin.so
+debian/tmp/@PLUGIN_INSTALL_PATH@/demosinkplugin.so
+debian/tmp/etc/dbus-1/system.d/amb.conf
--- /dev/null
+debian/tmp/usr/bin/ambd
+debian/tmp/usr/bin/ambctl
+debian/tmp/etc/ambd/config
--- /dev/null
+automotive-message-broker (@PROJECT_VERSION@) utopic; urgency=low
+
+ * @PROJECT_VERSION@ release
+
+ -- Kevron Rees <tripzero.kev@gmail.com> Tue, 30 Dec 2014 15:17:51 -0700
--- /dev/null
+Source: automotive-message-broker
+Section: Utilities
+Priority: extra
+Maintainer: Kevron Rees <tripzero.kev@gmail.com>
+Build-Depends: build-essential, debhelper (>= 8.0.0), cdbs, pkg-config, libltdl-dev, cmake, libboost-dev, uuid-dev, libjson-c-dev, libglib2.0-dev
+Standards-Version: 3.9.2
+Homepage: https://01.org/automotive-message-broker
+Vcs-Git: git@github.com:otcshare/automotive-message-broker.git
+Vcs-Browser: http://github.com/otcshare/automotive-message-broker.git
+
+Package: libamb
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: ${shlibs:Depends}, ${misc:Despends}
+Description: Supporting amb library
+
+Package: libamb-dev
+Section: devel
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: libamb, uuid-dev, libjson-c-dev
+Description: Vehicle data abstraction and multiplexing daemon
+ Vehicle data abstraction and multiplexing plugin framework
+ which provides a communications interface to CAN, OBDII and GPS devices using
+ TCP, bluetooth or USB
+
+Package: automotive-message-broker
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: ${shlibs:Depends}, ${misc:Depends}, libamb
+Description: Vehicle data abstraction and multiplexing daemon
+ Vehicle data abstraction and multiplexing daemon implemented as
+ plugin framework that communicates to OBDII and GPS devices
+
+Package: automotive-message-broker-plugins
+Architecture: i386
+Version: @PROJECT_VERSION@
+Depends: ${shlibs:Depends}, ${misc:Depends}, libamb
+Description: Vehicle data abstraction and multiplexing daemon
+ Vehicle data abstraction and multiplexing daemon implemented as
+ plugin framework that communicates to OBDII and GPS devices
--- /dev/null
+debian/tmp/@INCLUDE_INSTALL_DIR@/amb/*.h
+debian/tmp/@INCLUDE_INSTALL_DIR@/amb/*.hpp
+debian/tmp/@LIB_INSTALL_DIR@/pkgconfig/*.pc
--- /dev/null
+debian/tmp/@LIB_INSTALL_DIR@/libamb.so*
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+# in template file --AC
+#%:
+# dh $@
+
+#all the rest copied from trip0's libobd debian/rules file --AC
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/cmake.mk
+
+++ /dev/null
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/automotive-message-broker.spec.in ${CMAKE_SOURCE_DIR}/packaging/automotive-message-broker.spec @ONLY)
-configure_file (${CMAKE_SOURCE_DIR}/packaging.in/config.tizen.in ${CMAKE_SOURCE_DIR}/packaging/config.tizen @ONLY)
+++ /dev/null
-%bcond_without qt5
-
-Name: automotive-message-broker
-Summary: Automotive Message Broker is a vehicle network abstraction system
-Version: @PROJECT_VERSION@
-Release: 0
-Group: Automotive/Service
-License: LGPL-2.1
-URL: https://github.com/otcshare/automotive-message-broker
-Source0: %{name}-%{version}.tar.bz2
-Requires: automotive-message-broker-plugins
-Requires: automotive-message-broker-plugins-murphy
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-Requires: default-ac-domains
-Requires: dbus-python
-BuildRequires: cmake
-BuildRequires: boost-devel
-BuildRequires: pkgconfig(json)
-BuildRequires: libtool-ltdl-devel
-BuildRequires: pkgconfig(libwebsockets)
-BuildRequires: pkgconfig(uuid)
-BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(opencv)
-BuildRequires: murphy
-BuildRequires: pkgconfig(murphy-glib)
-BuildRequires: pkgconfig(dbus-1)
-%if %{with qt5}
-BuildRequires: qt5-qtcore-devel
-BuildRequires: qt5-qtconcurrent-devel
-BuildRequires: qt5-qtdbus-devel
-BuildRequires: qt5-qtnetwork-devel
-BuildRequires: qt5-qtdeclarative-devel
-BuildRequires: qt5-plugin-bearer-generic
-BuildRequires: qt5-plugin-bearer-connman
-BuildRequires: qt5-plugin-bearer-nm
-BuildRequires: qt5-plugin-sqldriver-sqlite
-%endif
-
-%description
-Automotive Message Broker is a vehicle network abstraction system.
-It brokers information from the vehicle to applications.
-
-%package devel
-Summary: Automotive Message Broker development files
-Group: Automotive/API
-Requires: %{name} = %{version}-%{release}
-Requires: libuuid-devel
-Requires: boost-devel
-
-%description devel
-Development files for the automotive-message-broker
-
-%package doc
-Summary: Documentation for the automotive-message-broker API
-Group: Automotive/Documentation
-Requires: %{name} = %{version}-%{release}
-
-%description doc
-Document files that describe the D-Bus API exposed by automotive-message-broker
-
-%if %{with qt5}
-%package plugins-qtmainloop
-Summary: qt5 mainloop plugin
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: qt5-qtcore
-
-%description plugins-qtmainloop
-Qt mainloop plugin enables qt-based source and sink plugins to run using qt mainloop
-
-%package plugins-websocket
-Summary: Websocket source and sink plugins
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: libwebsockets
-Requires: qt5-qtcore
-
-%description plugins-websocket
-websocket source and sink plugins
-
-%package plugins-opencvlux
-Summary: Plugin for simulating ExteriorBrightness using a common webcam
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: opencv
-
-%description plugins-opencvlux
-Plugin for simulating ExteriorBrightness using a common webcam
-
-%package plugins-bluetooth
-Summary: Interface to AMB over bluetooth
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-bluetooth
-Bluetooth SPP server interface
-%endif
-
-%package plugins
-Summary: Various plugins for automotive-message-broker
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins
-Collection of plugins for automotive-message-broker. Contains example, demo and dbus plugins.
-
-%package plugins-common
-Summary: Common plugin library
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-common
-library containing a kitchen-sink of common utility functions
-
-%package plugins-obd2
-Summary: OBD-II plugin
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: %{name}-plugins-common = %{version}-%{release}
-
-%description plugins-obd2
-OBD-II plugin that uses ELM 327-compatible scantools to access vehicle data
-
-%package plugins-wheel
-Summary: Source plugin for using the Logitech G27 racing wheel
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-wheel
-source plugin for using the Logitech G27 racing wheel package
-
-%package plugins-database
-Summary: Database logging plugin for automotive-message-broker
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: sqlite
-
-%description plugins-database
-Database logging plugin for automotive-message-broker package
-
-%package plugins-murphy
-Summary: Plugin for integration with the murphy policy system
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: murphy
-
-%description plugins-murphy
-Plugin for integration with the murphy policy system package
-
-%package plugins-gpsnmea
-Summary: Plugin that provides gps data from nmea devices
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-gpsnmea
-Plugin that provides location data from nmea devices including bluetooth
-
-%package plugins-test
-Summary: Plugin that tests AMB code
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-test
-Plugin that tests some internal AMB code and plugin functionality. This plugin will assert if something is wrong.
-
-%package plugins-cangen
-Summary: Plugin that generates CAN data
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-cangen
-CAN frames generator plug-in for the AMB CAN Simulator
-
-%package plugins-cansim
-Summary: CAN frames listener plug-in for the AMB CAN Simulator
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description plugins-cansim
-CAN frames listener plug-in for the AMB CAN Simulator package
-
-%if %{with qt5}
-%package plugins-bluemonkey
-Summary: javascript plugin engine
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: qt5-qtdeclarative
-Requires: %{name}-plugins-qtmainloop
-
-%description plugins-bluemonkey
-Engine for creating scriptable plugins for AMB
-
-%package -n bluemonkey-modules-db
-Summary: javascript plugin engine db module
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: qt5-plugin-sqldriver-sqlite
-
-%description -n bluemonkey-modules-db
-Engine for creating scriptable plugins for AMB
-
-%endif
-
-%package xwalk-vehicle-extension
-Summary: crosswalk vehicle API extension
-Group: Automotive/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: crosswalk
-
-%description xwalk-vehicle-extension
-Crosswalk vehicle API extension based on the W3C Automotive Business Group Vehicle and Data API Specification
-
-%prep
-%setup -q -n %{name}-%{version}
-
-%build
-%cmake \
- -Dxwalk_vehicle_extension=ON \
- -DXWALK_EXTENSION_PATH=/tizen-extensions-crosswalk \
-%if %{with qt5}
- -Dqtmainloop=ON \
- -Dopencvlux_plugin=ON \
- -Dwebsocket_plugin=ON \
- -Dbluetooth_plugin=ON \
- -Dbluemonkey_plugin=ON \
-%endif
- -Ddatabase_plugin=ON \
- -Dmurphy_plugin=ON \
- -Dobd2_plugin=ON \
- -Dtest_plugin=ON \
- -Dgpsnmea_plugin=ON \
- -Dcangen_plugin=ON \
- -Dcansim_plugin=ON \
- -Dusebluez5=ON \
- -Denable_docs=ON
-
-
-%__make %{?jobs:-j%jobs}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-mkdir -p %{buildroot}%{_unitdir}/network.target.wants
-cp packaging.in/ambd.service.systemd.tizen %{buildroot}%{_unitdir}/ambd.service
-ln -s ../ambd.service %{buildroot}%{_unitdir}/network.target.wants/ambd.service
-%install_service multi-user.target.wants ambd.service
-
-cp packaging.in/config.tizen %{buildroot}%{_sysconfdir}/ambd/
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%post plugins -p /sbin/ldconfig
-%postun plugins -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest
-%config %{_sysconfdir}/ambd/config
-%config %{_sysconfdir}/ambd/config.tizen
-%config %{_sysconfdir}/ambd/examples/*
-%{_bindir}/ambd
-%{_libdir}/libamb.so*
-%{_unitdir}/ambd.service
-%{_unitdir}/network.target.wants/ambd.service
-%{_unitdir}/multi-user.target.wants/ambd.service
-%{_bindir}/amb-get
-%{_bindir}/amb-get-history
-%{_bindir}/amb-set
-%{_bindir}/amb-listen
-%{_bindir}/ambctl
-
-%files devel
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_includedir}/amb/*.h
-%{_includedir}/amb/*.hpp
-%{_libdir}/pkgconfig/*.pc
-
-%if %{with qt5}
-%files plugins-qtmainloop
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/qtmainloopplugin.so
-
-%files plugins-websocket
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/websocketsource.so
-%{_libdir}/%{name}/websocketsink.so
-
-%files plugins-opencvlux
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/opencvluxplugin.so
-
-%files plugins-bluetooth
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/bluetoothplugin.so
-%config %{_sysconfdir}/dbus-1/system.d/ambbt.conf
-%endif
-
-%files plugins
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/examplesourceplugin.so
-%{_libdir}/%{name}/examplesinkplugin.so
-%{_libdir}/%{name}/dbussinkplugin.so
-%{_libdir}/%{name}/demosinkplugin.so
-%config %{_sysconfdir}/dbus-1/system.d/amb.conf
-
-%files plugins-common
-%manifest packaging.in/amb.manifest.plugins
-%defattr(-,root,root,-)
-%{_libdir}/libamb-plugins-common.so
-
-%files plugins-wheel
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/wheelsourceplugin.so
-
-%files plugins-obd2
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/obd2sourceplugin.so
-
-%files plugins-database
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/databasesinkplugin.so
-
-%files plugins-murphy
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/murphysourceplugin.so
-
-%files plugins-gpsnmea
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/gpsnmea.so
-
-%files doc
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%doc %{_docdir}/%{name}/*
-
-%files plugins-test
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/testplugin.so
-
-%files plugins-cangen
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/cangenplugin.so
-%{_bindir}/gen-set
-
-%files plugins-cansim
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/cansimplugin.so
-
-
-%if %{with qt5}
-
-%files plugins-bluemonkey
-%defattr(-,root,root,-)
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/bluemonkeyplugin.so
-%config %{_sysconfdir}/ambd/bluemonkey
-
-%files -n bluemonkey-modules-db
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/%{name}/bluemonkeyDbModule.so
-
-%endif
-
-%files xwalk-vehicle-extension
-%manifest packaging.in/amb.manifest.plugins
-%{_libdir}/tizen-extensions-crosswalk/*
-%{_datadir}/%{name}/xwalk/examples/*
* //VehicleSpeed
* speedProperty.value = Math.floor((Math.random() * 100) + 1);
* });
+ * testTimer.start();
* \endcode
* \section Javascript API documentation
* Javascript API documentation is found in bluemonkey.idl and is described using WebIDL. Plugin configuration documentation can be found in bluemonkey.README.
* \see Qt's QMetaObject system for additional details
*/
-
+/*!
+ * \brief Entry point for bluemonkey
+ */
partial interface Navigator {
readonly attribute Bluemonkey bluemonkey;
};
+/*!
+ * \brief Bluemonkey interface
+ * Bluemonkey provides AMB plugin-like interfaces and allows the loading of other modules, timers, and QObject creation.
+ * Typical usage is such:
+ * \code
+ * var speedProperty = bluemonkey.subscribeTo("VehicleSpeed");
+ * bluemonkey.log("Current speed: " + speedProperty.value);
+ * \endcode
+ */
interface Bluemonkey {
/*!
* \brief subscribe to a property
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/genmapping.py ${CMAKE_CURRENT_SOURCE_DIR}/genmapping @ONLY)
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/ambctl.py ${CMAKE_CURRENT_SOURCE_DIR}/ambctl @ONLY)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/ambctl.py ${CMAKE_CURRENT_BINARY_DIR}/ambctl @ONLY)
-install (PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/ambctl DESTINATION bin)
+install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ambctl DESTINATION bin)
+++ /dev/null
-#!/usr/bin/python
-
-import argparse
-import dbus
-import sys
-import json
-import gobject
-import fileinput
-import termios, fcntl, os
-import glib
-import curses.ascii
-from dbus.mainloop.glib import DBusGMainLoop
-
-class bcolors:
- HEADER = '\x1b[95m'
- OKBLUE = '\x1b[94m'
- OKGREEN = '\x1b[92m'
- WARNING = '\x1b[93m'
- FAIL = '\x1b[91m'
- ENDC = '\x1b[0m'
- GREEN = '\x1b[32m'
- WHITE = '\x1b[37m'
- BLUE = '\x1b[34m'
-
-def help():
- help = ("Available commands:\n"
- +bcolors.HEADER+ "help" +bcolors.WHITE+ " Prints help data\n"
- +bcolors.HEADER+ "list" +bcolors.WHITE+ " List supported ObjectNames\n"
- +bcolors.HEADER+ "get" +bcolors.WHITE+ " Get properties from an ObjectName\n"
- +bcolors.HEADER+ "listen" +bcolors.WHITE+ " Listen for changes on an ObjectName\n"
- +bcolors.HEADER+ "set" +bcolors.WHITE+ " Set a property for an ObjectName\n"
- +bcolors.HEADER+ "getHistory" +bcolors.WHITE+ " Get logged data within a time range\n"
- +bcolors.HEADER+ "quit" +bcolors.WHITE+ " Exit ambctl\n")
- return help
-
-def changed(interface, properties, invalidated):
- print json.dumps(properties, indent=2)
-
-def processCommand(command, commandArgs, noMain=True):
-
- if command == 'help':
- print help()
- return 1
-
- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- try:
- managerObject = bus.get_object("org.automotive.message.broker", "/");
- managerInterface = dbus.Interface(managerObject, "org.automotive.Manager")
- except:
- print "Error connecting to AMB. is AMB running?"
- return 1
-
- if command == "list" :
- supportedList = managerInterface.List()
- for objectName in supportedList:
- print objectName
- return 1
- elif command == "get":
- if commandArgs[0] == "help":
- print "ObjectName [ObjectName...]"
- return 1
-
- for objectName in commandArgs:
- objects = managerInterface.FindObject(objectName)
- print objectName
- for o in objects:
- propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", o),"org.freedesktop.DBus.Properties")
- print json.dumps(propertiesInterface.GetAll("org.automotive."+objectName), indent=2)
- return 1
- elif command == "listen":
- if len(commandArgs) == 0:
- commandArgs = ['help']
- if commandArgs[0] == "help":
- print "ObjectName [ObjectName...]"
- return 1
- for objectName in commandArgs:
- objects = managerInterface.FindObject(objectName)
- for o in objects:
- bus.add_signal_receiver(changed,
- dbus_interface="org.freedesktop.DBus.Properties",
- signal_name="PropertiesChanged", path=o)
- if noMain != True:
- try:
- main_loop = gobject.MainLoop(None, False)
- main_loop.run()
- except KeyboardInterrupt:
- return 1
- elif command == "set":
- if len(commandArgs) == 0:
- commandArgs = ['help']
- if len(commandArgs) and commandArgs[0] == "help":
- print "ObjectName PropertyName VALUE [ZONE]"
- return 1
- if len(commandArgs) < 3:
- print "set requires more arguments (see set help)"
- return 1
- objectName = commandArgs[0]
- propertyName = commandArgs[1]
- value = commandArgs[2]
- zone = 0
- if len(commandArgs) == 4:
- zone = int(commandArgs[3])
- object = managerInterface.FindObjectForZone(objectName, zone)
- propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", object),"org.freedesktop.DBus.Properties")
- property = propertiesInterface.Get("org.automotive."+objectName, propertyName)
- realValue = property.__class__(value)
- propertiesInterface.Set("org.automotive."+objectName, propertyName, realValue)
- property = propertiesInterface.Get("org.automotive."+objectName, propertyName)
- if property == realValue:
- print propertyName + " = ", property
- else:
- print "Error setting property"
- return 1
- elif command == "getHistory":
- if len(commandArgs) == 0:
- commandArgs = ['help']
- if commandArgs[0] == "help":
- print "ObjectName [ZONE] [STARTTIME] [ENDTIME] "
- return 1
- if len(commandArgs) < 1:
- print "getHistory requires more arguments (see getHistory help)"
- return 1
- objectName = commandArgs[0]
- start = 1
- if len(commandArgs) >= 3:
- start = float(commandArgs[2])
- end = 9999999999
- if len(commandArgs) >= 4:
- end = float(commandArgs[3])
- zone = 0
- if len(commandArgs) >= 2:
- zone = int(commandArgs[1])
- object = managerInterface.FindObjectForZone(objectName, zone);
- propertiesInterface = dbus.Interface(bus.get_object("org.automotive.message.broker", object),"org.automotive."+objectName)
- print json.dumps(propertiesInterface.GetHistory(start, end), indent=2)
- else:
- print "Invalid command"
- return 1
-
-
-
-parser = argparse.ArgumentParser(description='Process DBus mappings.', add_help=False)
-parser.add_argument('command', metavar='COMMAND [help]', nargs='?', default='stdin', help='amb dbus command')
-parser.add_argument('commandArgs', metavar='ARG', nargs='*',
- help='amb dbus command arguments')
-parser.add_argument('-h', '--help', help='print help', action='store_true')
-
-args = parser.parse_args()
-
-if args.help:
- parser.print_help()
- print
- print help()
- sys.exit()
-
-if args.command == "stdin":
-<<<<<<< HEAD
- class Data:
- history = []
- line = ""
- templine = ""
- promptAmbctl = "[ambctl]"
- promptEnd = "# "
- fullprompt = promptAmbctl + promptEnd
- curpos = 0
- historypos = -1
- def full_line_len(self):
- return len(self.fullprompt) + len(self.line)
- def insert(self, str):
- if self.curpos == len(self.line):
- self.line+=str
- self.curpos = len(self.line)
- else:
- self.line = self.line[:self.curpos] + str + self.line[self.curpos:]
- self.curpos+=1
- def arrow_back(self):
- if self.curpos > 0:
- self.curpos-=1
- return True
- return False
-
- def arrow_forward(self):
- if self.curpos < len(self.line):
- self.curpos+=1
- return True
- return False
-
- def back_space(self):
- if self.curpos > 0:
- self.curpos-=1
- self.line = self.line[:self.curpos] + self.line[self.curpos+1:]
- return True
- return False
- def delete(self):
- if self.curpos < len(self.line):
- self.line = self.line[:self.curpos] + self.line[self.curpos+2:]
- return True
- return False
-
- def save_temp(self):
- if len(self.history)-1 == 0 or len(self.history)-1 != self.historypos:
- return
- self.templine = self.line
-=======
- while True:
- line = input("ambctl>> ")
- if line == 'quit':
- sys.exit()
- words = line.split(' ')
- processCommand(words[0], words[1:])
-else:
- processCommand(args.command, args.commandArgs)
->>>>>>> use input instead of raw_input
-
- def push(self):
- self.history.append(self.line)
- self.historypos = len(self.history)-1
- self.clear()
-
- def set(self, str):
- self.line = str
- self.curpos = len(self.line)
-
- def history_up(self):
- if self.historypos >= 0:
- self.line = self.history[self.historypos]
- if self.historypos != 0:
- self.historypos-=1
- return True
- return False
-
- def history_down(self):
- if self.historypos >= 0 and self.historypos < len(self.history)-1:
- self.historypos+=1
- self.line = self.history[self.historypos]
-
- else:
- self.historypos = len(self.history)-1
- self.set(self.templine)
-
- return True
-
- def clear(self):
- self.set("")
- templist = ""
-
- def erase_line():
- sys.stdout.write('\x1b[2K\x1b[80D')
-
- def cursor_left():
- sys.stdout.write('\x1b[1D')
-
- def cursor_right():
- sys.stdout.write('\x1b[1C')
-
- def display_prompt():
- sys.stdout.write(bcolors.OKBLUE+Data.promptAmbctl+bcolors.WHITE+Data.promptEnd);
-
- def redraw(data):
- erase_line()
- display_prompt()
- sys.stdout.write(data.line)
- cursorpos = len(data.line) - data.curpos
- for x in xrange(cursorpos):
- cursor_left()
- sys.stdout.flush()
-
- def handle_keyboard(source, cond, data):
- str = source.read()
- #print "char: ", ord(str)
-
- if len(str) > 1:
- if ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 68: #left arrow
- if data.arrow_back():
- cursor_left()
- sys.stdout.flush()
- elif ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 67: #right arrow
- if data.arrow_forward():
- cursor_right()
- sys.stdout.flush()
- elif ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 70: #end
- while data.arrow_forward():
- cursor_right()
- sys.stdout.flush()
- elif ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 72: #home
- while data.arrow_back():
- cursor_left()
- sys.stdout.flush()
- elif len(str) == 4 and ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 51 and ord(str[3]) == 126: #del
- data.delete()
- redraw(data)
- elif ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 65:
- #up arrow
- data.save_temp()
- data.history_up()
- while data.arrow_forward():
- cursor_right()
- redraw(data)
- elif ord(str[0]) == 27 and ord(str[1]) == 91 and ord(str[2]) == 66:
- #down arrow
- data.history_down()
- while data.arrow_forward():
- cursor_right()
- redraw(data)
- elif ord(str) == 10: #enter
- if data.line == "":
- return True
- print ""
- words = data.line.split(' ')
- if words[0] == "quit":
- sys.exit()
- try:
- if len(words) > 1:
- processCommand(words[0], words[1:])
- else:
- processCommand(words[0], [])
- except dbus.exceptions.DBusException, error:
- print error
- except:
- print "Error running command ", sys.exc_info()[0]
- data.push();
- data.clear()
- redraw(data)
- elif ord(str) == 127: #backspace
- data.back_space()
- redraw(data)
- elif curses.ascii.isalnum(ord(str)) or ord(str) == curses.ascii.SP: #regular text
- data.insert(str)
- redraw(data)
-
- return True
- print "@PROJECT_PRETTY_NAME@ @PROJECT_VERSION@"
-
- data = Data()
- fd = sys.stdin.fileno()
- old = termios.tcgetattr(fd)
- new = termios.tcgetattr(fd)
- new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
- termios.tcsetattr(fd, termios.TCSANOW, new)
-
- oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
- fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
-
- io_stdin = glib.IOChannel(fd)
- io_stdin.add_watch(glib.IO_IN, handle_keyboard, data)
-
- try:
- erase_line()
- display_prompt()
- sys.stdout.flush()
- main_loop = gobject.MainLoop(None, False)
- main_loop.run()
- except KeyboardInterrupt:
- sys.exit()
- finally:
- termios.tcsetattr(fd, termios.TCSAFLUSH, old)
- fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
- sys.exit()
-
-else:
- try:
- processCommand(args.command, args.commandArgs, False)
- except dbus.exceptions.DBusException, error:
- print error