wiki:Software/GatewayDBus
Last modified 7 years ago

Software

PLEASE NOTE

The first version of OpenBM-Gateway v0.9 is not longer supported. I abandoned the use of D-Bus for interproccess communication. The reason is that D-Bus just s... I would say, don't work well. I had so much of crashes with that piece of software, that I decided to throw it far far away and not to use it in my applications for at least next year until it get more stable (used version was 1.3.6). So now OpenBM-Gateway is implemented as a TCP server allowing multiple clients (mostly only local) to connect to it, to receive and transmit messages from/to IBus(RS232). Please visit this page for more information about new gateway.


IBus Gateway

OpenBM-Gateway is a linux daemon running in the background and acting as a gateway between BMW's IBus and the D-Bus. In this case an IBus interface is connected to the PC's serial port. The interface must support CTS line. Hence some hardware collision detection, or at least a simple bit comparator must be implemented. This function is provided for example by the  TH3122 ic, which I am also using in this project.

 D-Bus is an interprocess communication message system. Any other application can connect to D-Bus in order to communicate with the OpenBM gateway. Messages received over IBus are transferred to D-Bus and vice versa.

The software exists as a Debian package for simple installation in my own small repository. In order to install it, either download it directly from the repository or add the repository address into the list of repository servers on your system. Currently there is only Debian packages available. The package consists of only one executable file.

The repository where to find the openbm-gateway package is (or download it  here):

deb http://deb.tevs.eu/ binary/

For information about parameters use

openbm-gateway -h

When the daemon is running you can test forwarding of D-Bus messages to the IBus by sending a test message over the D-Bus, for example:

dbus-send /openbm/ibus/BMW openbm.ibus.RawMessage byte:0xC0 byte:0x68 uint32:2 array:byte:0x32,0x11

Features

  • low CPU and memory usage
  • forward IBus messages to D-Bus and vice versa
  • retransmit messages on collision
  • completely asynchronous (receive and send messages over IBus and D-Bus without blocking or intercepting)
  • act as a simple IBus logger
  • code is actually platform independent (except of some extensions I had to made for  boost's asio library). So there is a possibility to implement this on Windows too.

IBus logger functionality

The daemon can also act as a simple IBus logger. This can be usefull if you just want to log ibus messages passend on the bus. In order to run the daemon as simple logger execute it as

openbm-gateway -l 4 -f ibus.log

Which will protocol ibus actions to the ibus.log file. The log file will look like this:

...
2010-Jul-20 10:07:00.767817: C0 04 68 32 11 8F
2010-Jul-20 10:07:00.891897: C0 04 68 32 11 8F
2010-Jul-20 10:07:00.928066: C0 04 68 32 10 8E
2010-Jul-20 10:07:00.943753: C0 04 68 32 10 8E
2010-Jul-20 10:07:01.116929: C0 03 68 01 AA
2010-Jul-20 10:07:01.140001: 68 04 BF 02 00 D1
...

Note there is currently no analysis going on, just a simple logging.

D-Bus connection

Per default the daemon creates a connection "openbm.ibus.BMW" on the D-Bus. In the current version there is only support for simple raw message passing with slightly format change. So on every received message over the IBus the daemon send a signal message to the D-Bus:

signal sender=xxx -> dest=(null destination) serial=xxx path=/openbm/ibus/BMW; interface=openbm.ibus; member=RawMessage
   byte 192
   byte 104
   uint32 2
   array [
      byte 50
      byte 16
   ]

Here the first byte of the signal indicates the source node of the IBus, here 192=0xC0=MID, and the second byte indicates the destination node, here 104=0x68=RADIO. The third component of the message is always an unsigned integer indicating the amount of data passed with the message, in this example 2 bytes. And lastly an array containing the data bytes is submitted, in this case {50=0x32, 16=0x10}.

Signals in this form received over the D-Bus are accepted by OpenBM-Gateway and translated into IBus message frames. Finally they are sent over the wire. There is collision/retransmit logic implemented in the software, so the probability that message will be not delivered is very low.

FAQ

  1. When starting openbm-gateway I see following error message:
    error: D-Bus Connection Error (Did not receive a reply. Possible causes include: the remote application did not send a reply, 
    the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.)
    

This error is typically caused by missing rights to connect to the D-Bus or when executed by the root. Correct the user rights to allow connections to the D-Bus.


Pay methods