This is hopefully a reasonably short post about the software framework I’ve developed to help read sensor data from the MBE 9A4 ECU.
The idea behind mbe.py is to “abstract” the setup and processing of requests and responses to an MBE 9A4 ECU and to provide a “human readable” set of results. The code implements the MBE-ISOTP protocol and can create multiple compound CAN bus requests and process multiple compound CAN bus responses.
The code is implemented as a Python class with a few member functions to initialise the class and then send and process messages to the ECU.
There’s an example test program here.
The Programming Interface (API) to the code is as follows:
Creates an mbe class object with no parameters
set_options(vars_file, request_id, response_id, interface)
Sets the mbe options.
- vars_file: A JSON encoded representation of the Easimap EC2 file. This is used to define all the variables the ECU can process. It also sets offset and scaling configurations for each of the variables. This file is created using ec2parse.py and the latest version of the JSON vars_file can be found at 9A4be52a.ec2.utf8.json.
- request_id: This is the CAN bus ID needed to tell mbe.py what ID to use when making requests to the ECU. This parameter may be ignored and mbe.py will use the default 0x0cbe1101.
- response_id: This is the CAN bus ID needed to tell mbe.py what ID to look for when receiving responses for the ECU. This parameter may be ignored and mbe.py will use the default 0x0cbe0111.
- interface: defaults to can0
- RETURN: Returns False is there was a problem setting these options
Adds a list of variables to the mbe class to be processed later.
- list: an array of strings defining which ECU variables to request and process with process_all_pages()
- RETURN: False if there is problem with the list, otherwise returns True
Opens and binds mbe.py to can-isotp kernel module.
- RETURN: True
Processes all variables.
- results: A dictionary indexed by the variable name string and supplying results, units, and human readable string for each variable.
- RETURN: a dictionary of results, otherwise returns False if there’s a problem.
A simple example might be as follows:
ecu = mbe.mbe()
ecu.set_options("9A4be52a.ec2.utf8.json", 0x0cbe1101, 0x0cbe0111, "can0")