GENIVI / rvi_core

Specify, design, plan and build a reference implementation of the open source infrastructure that drives next generation's connected vehicle services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BT connection manager does not split up multi-command packages.

mfeuer opened this issue · comments

components/dlink_bt/src/bt_connection.erl:handle_info(..., {data, Data}) does not split up multiple JSON-RPC commands bundled into a single RFCOMM transmit and invokes dlink_bt_rpc:handle_socket() separately for each command.

This problem has been fixed in components/dlink_tcp/connection.erl, where a receive buffer is kept in the process state and complete commands are extracted and forwarded to dlink_tcp_rpc:handle_socket(), with residual data being returned to state to be prepended to the next received network packet.

The TCP solution should be copied to the BT connection code.

This bug fix must be back ported to release-0.4.0, creating release-0.4.1

A question: In the Erlang world, it's more commonplace to use e.g. {packet, 4}, adding some size bytes at the beginning of the message. This allows the receiver to know exactly how much to fetch, and eliminates the need for parsing to determine whether a complete message has arrived (which also opens some possibilities, e.g. when sending binary data which doesn't fit nicely inside JSON).

In Erlang, the size header processing is built in, so the user code only needs to pass the option when opening the socket. The socket logic then takes care of stripping the size header and delivering whole packets.

http://www.erlang.org/doc/man/inet.html#setopts-2