As explained in the project readme, the purpose of the daemon is to allow multiple client programs to open an OBDIISocket
to the same (interface, transfer ID, receive ID)
tuple simultaneously. Clients send a request to the daemon to open a socket on their behalf, and then the daemon sends back the socket's file descriptor, which a client can use directly. Importantly, clients must obtain exclusive access to the socket before performing any reads and writes via a call to flock
. This is done automatically by the OBDIIPerformQuery
API.
Clients communicate with the daemon using a Unix domain datagram socket, sending requests to /tmp/obdiid.sock
. See the protocol section for the request/response format.
In the sequence diagram above, after the daemon sends a successful response to the client, it then passes the socket's file descriptor to the client using sendmsg
. The client accepts the file descriptor using a call to recvmsg
. This effectively dups the file descriptor across the processes.
All multi-byte fields are in little endian order.
A request has the following format:
Currently, the only supported value for API version
is 1
.
Supported request types:
Name | Value |
---|---|
Open Socket | 0 |
Close Socket | 1 |
For both the Open Socket
and Close Socket
request types, the parameters are as follows:
The CAN interface index
parameter is the interface's index number as returned by a call to if_nametoindex
.
The response is a two-byte unsigned integer, representing a response code. Possible values are listed below.
Code | Name | Description |
---|---|---|
0 | Success | The request succeeded |
1 | No Such Socket | A request was sent to close a socket, but no socket with the given parameters was open |
2 | Open Socket Error | Opening the socket failed (possible if the interface does not exist) |