wiki:Software/Gateway

Version 8 (modified by art, 14 years ago) (diff)

--

IBus Gateway

OpenBM-Gateway is a linux daemon running in the background and acting as a gateway between BMW's IBus and local clients connected over a network TCP stack. 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.

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

Features

  • low CPU and memory usage (one thread per client + 3 server threads)
  • forward IBus messages to connected clients over TCP/IPv4 and vice versa
  • retransmit messages on collision
  • completely asynchronous (receive and send messages over IBus and TCP/IP without blocking or intercepting)
  • can 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.

TCP/IP protocol

In order to be able to connect to the gateway server we have to make sure that server and client speaks the same language. The low-level protocol used for communication between the server (OpenBM-Gateway) and any client is TCP. On top of this a simple, really simple protocol is used to understand sent messages. Here is a small overview over the protocol:

Header:

  Ident:
src dst len x priority x x
1 2 3 4 5 6 7 8
  Byte:

Data:

  Ident:
data
1 ... len
  Byte:

Every message sent over the network and to/from the server must have this form. Here x indicates reserved/non-used bytes. src and dst are the IBus-Device ids for source and destination respectively. len indicates the amount of bytes passed in the data field. Data field can be send in another TCP frame or together with the header. priority sets the priority of a message to be sent over IBus.

There are also exists special messages sent between server and the client. This special messages are required for establishing communication and checking if client is still alive for example. Every message in which header len is set to 0, is a special message. There are currently existing following special message types:

  • Ping: src=0xAA, dst=0xAA - is sent by a client every 3 seconds to indicate that the client is still alive
  • Hello: src='h' , dst='i' - is sent by a client to the server before any other message. Server response to this message with a Connect message and creates a socket connection on a reserved port.
  • Connect: src='c' , dst='t' - is sent by a server to client to indicate that connection is established. The priority field of the header contains the port number to which client's socket has to connect to.
  • Disconnect: src=0, dst=0 - is sent by a client to the server, to indicate that client is disconnecting. Server will free resources and mark the used port as free again.

Server

...in work...

Client

...in work...

FAQ

...in work...


Pay methods