Sorry, you need to enable JavaScript to visit this website.

Feedback

Your feedback is important to keep improving our website and offer you a more reliable experience.

Automotive Message Broker

Automotive Message Broker is a framework for getting vehicle sensor data from the vehicle networks and making it available to applications. It allows applications to be developed independently of the differences in vehicle networks used in different automotive vehicle designs.

Introducing ambctl

BY Kevron Rees ON Dec 29, 2014

Starting in 0.12, AMB has included several command line tools to make debugging and testing easier.  These tools where amb-get, amb-listen, amb-set and amb-get-history.  However, these tools were to be a stop-gap measure until we could create a tool more like connmanctl or bluetoothctl.  One tool to rule them all.  That tool is ambctl and is available now in the latest git master or AMB version 0.13.  It will be the preferred tool for testing moving forward.  Here's how to use it.

The version of ambctl used in this blog is from AMB 0.12.903

Let's see what is available:

% ambctl -h
usage: ambctl.py [-h] [COMMAND [help]] [ARG [ARG ...]]
 
positional arguments:
  COMMAND [help]  amb dbus command
  ARG             amb dbus command arguments
 
optional arguments:
  -h, --help      print help
 
Available commands:
help           Prints help data
list           List supported ObjectNames
get            Get properties from an ObjectName
listen         Listen for changes on an ObjectName
set            Set a property for an ObjectName
getHistory     Get logged data within a time range
quit           Exit ambctl
 
Each command that has arguments accepts the "help' argument.  For example: 
 
%ambctl get help
ObjectName [ObjectName...]
 

Setup ambd

To test out ambctl, we need to set AMB up to support data.  This can be done with almost any of the AMB plugins, but for this example we will use the bluemonkey plugin which has lots of data support and the database plugin (for getHistory).  Please see plugin documentation for setting up the bluemonkey and database plugins found in: file:///usr/share/doc/packages/automotive-message-broker/plugins/bluemonkey.README and database.README after installing the automotive-message-broker-doc package or the latest plugin doc for bluemonkey and database if using git.  

On Tizen IVI please install the following packages:

% zypper in automotive-message-broker-doc automotive-message-broker-plugins-bluemonkey automotive-message-broker-plugins-database
 
Now edit your /etc/ambd/config to look like this (NOTE that in tizen, the default config is "/etc/ambd/config.tizen"):
 
{
  "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/qtmainloopplugin.so",
 
  "sources" : [
    {
      "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/bluemonkeyplugin.so",
      "config" : "/etc/ambd/bluemonkey/config.js"
    },
    { 
      "name" : "Database Source",
      "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/databasesinkplugin.so",
      "databaseFile" : "/tmp/storage",
      "properties" : "{ 'properties' : ['TargetTemperature'] }",
      "startOnLoad" : "true",
      "bufferLength" : 1
    }
  ],
 
  "sinks" : [
    {
      "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/dbussinkplugin.so"
    }
  ]
}
 
ambctl list

list allows us to see what ObjectNames are supported.  An ObjectName corresponds do the DBus interface org.automotive.ObjectName.  For example VehicleSpeed is the ObjectName for org.automotive.VehicleSpeed.  A complete list of interfaces and documentation on what these interfaces represent can be found in the AMB DBus documents.  Please note that online docs reflect the last stable release of AMB.  So you may want to generate your own docs from source if using a version from git or install the automotive-message-broker-doc package if using Tizen IVI.  The documents will install to /usr/share/doc/packages/automotive-message-broker/dbus/html/.

To use ambctl list, type:
 

% ambctl list
Acceleration
AcceleratorPedalPosition
AirbagStatus
Alarm
AntilockBrakingSystem
AntilockBreakingSystem
AntilockBreakingSystemEnabled
AtmosphericPressure
Battery
...
 

ambctl get

get gets values for the given ObjectName or ObjectNames.  It supports N number of ObjectNames so you can get multiple values at the same time.  get will return all values for all supported zones.  So for example, ClimateControl returns:

% ambctl get ClimateControl
ClimateControl
{
  "Heater": 0, 
  "TargetTemperatureSequence": -1, 
  "Zone": 0, 
  "AirConditioningSequence": -1, 
  "TargetTemperature": 20, 
  "AirRecirculationSequence": -1, 
  "AirRecirculation": 0, 
  "HeaterSequence": -1, 
  "Time": dbus.Double(1032530.202, variant_level=1), 
  "FanSpeedLevelSequence": -1, 
  "AirConditioning": 0, 
  "FanSpeedLevel": 1
}
{
  "SteeringWheelHeaterSequence": -1, 
  "TargetTemperatureSequence": -1, 
  "Zone": 9, 
  "SeatCooler": 0, 
  "SeatCoolerSequence": -1, 
  "SeatHeater": 0, 
  "SeatHeaterSequence": -1, 
  "TargetTemperature": 20, 
  "AirRecirculationSequence": -1, 
  "AirRecirculation": 0, 
  "Time": dbus.Double(1032530.2, variant_level=1), 
  "SteeringWheelHeater": 0
}
{
  "TargetTemperatureSequence": -1, 
  "SeatHeater": 0, 
  "SeatCooler": 0, 
  "SeatCoolerSequence": -1, 
  "Zone": 5, 
  "SeatHeaterSequence": -1, 
  "TargetTemperature": 25, 
  "Time": dbus.Double(1032530.201, variant_level=1)
}

We can also get ClimateControl with VehicleSpeed:
 

% ambctl get ClimateControl VehicleSpeed
ClimateControl                                                                                                                       
{                                                                                                                                    
  "Heater": 0,                                                                                                                       
  "TargetTemperatureSequence": -1,                                                                                                   
  "Zone": 0,                                                                                                                         
  ...
}
...
VehicleSpeed
{
  "VehicleSpeed": 10, 
  "Zone": 0, 
  "SpeedSequence": -1, 
  "Time": dbus.Double(1032530.182, variant_level=1), 
  "VehicleSpeedSequence": -1, 
  "Speed": 10
}
 

ambctl set

set sets a property on an interface.  The improvement over amb-set is that it automatically deduces the value type and zone is optional.  Let's look at the help to get started:
 

% ambctl set help
ObjectName PropertyName VALUE [ZONE]
 
ObjectName is the interface name listed in list.  PropertyName is the name of the property you want to set.  For example, the ClimateControl interface has the Property TargetTemperature.  To set TargetTemperature run:
 
% ambctl set ClimateControl TargetTemperature 22
TargetTemperature =  22

This set TargetTemperature in the default zone: zone 0.  To change the value for another zone, we include the zone argument.  From the get command we know that TargetTemperature is also available in zones 5 and 9.  Let's set it for zone 5:

% ambctl set ClimateControl TargetTemperature 13 5
TargetTemperature =  13
 
Using get we can see the new values:
 
% ambctl get ClimateControl
ClimateControl
{
  "Zone": 0, 
  "TargetTemperature": 22
...
}
{
  "Zone": 9, 
  "TargetTemperature": 20, 
...
}
{
  "Zone": 5, 
  "TargetTemperature": 13,
...
}
 

ambctl listen

listen subscribes to the interface identified by "ObjectName" for any changes in value.  Like get it supports all zones and multiple interfaces:
 

% ambctl listen help
ObjectName [ObjectName...]
 
Let's listen for climate control and then use set in another terminal to trigger a change value signal.  In the first terminal, run:

% ambctl listen ClimateControl

Then in a second terminal, run set to change the value of TargetTemperature in the default zone again:
 

% ambctl set ClimateControl TargetTemperature 30
TargetTemperature =  30
 
In the first terminal, we should now see the new value:

{
  "TargetTemperature": 30, 
  "TargetTemperatureSequence": -1, 
  "Zone": 0, 
  "Time": dbus.Double(1450893.92, variant_level=1)
}
 

listen will keep listenting until you tell it to stop.  To stop at any time, hit Ctrl + C.

 

ambctl getHistory

getHistory returns an array of object values logged by the system.  You can get a value for a zone (default zone is 0) and between a specified time period.  Here are the possible arguments you can pass to getHistory:

% ambctl getHistory help
ObjectName [ZONE] [STARTTIME] [ENDTIME]

If no zone argument is passed, the default zone of 0 will be used.  STARTTIME and ENDTIME are specified in unix time format (seconds since the unix EPOC).  The default values are 1 and 9999999999 respectively.  These defaults will return all available data history for the interface.  Since we've been changing ClimateControl.TargetTemperature and that happens to be the property we are logging in our config, let's get all the history for ClimateControl:
 

% ambctl getHistory ClimateControl
[
  [
    "TargetTemperature", 
    20, 
    dbus.Double(1541943.33)
  ], 
  [
    "TargetTemperature", 
    22, 
    dbus.Double(1541965.106)
  ]
]
 
Since we did not specify a zone, 0 was used.  The data collected was the initial value of 20 and 22 when we changed it.  We can also check zone 5 since we changed that as well:

% ambctl getHistory ClimateControl 5
[
  [
    "TargetTemperature", 
    25, 
    dbus.Double(1541943.337)
  ], 
  [
    "TargetTemperature", 
    13, 
    dbus.Double(1541969.352)
  ]
]
 

Terminal Mode

ambctl supports terminal mode.  This mode gives you a command prompt-like interface which can come in handy.  It supports basic editing so you can use the left or right arrow keys to move the cursor and edit text as well as Home and End keys.  ambctl also remembers recent history so you can use the up and down arrow keys to view previously executed commands.  The commands available are just like the ones listed above.  If you need help, just type "help".  To quit, type "quit" or press Ctrl + c.

 

Conclusion

ambctl is an enhanced tool for testing AMB.  It provides a number of new commands over the previous tools and enhanced many of the older commands.