Creating a Script to read CAN data - Brazil

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
FHB-PERFORMANCE
Posts: 24
Joined: Sun Mar 20, 2016 7:13 am
Location: Melbourne-Australia / Sao Paulo-Brazil

Creating a Script to read CAN data - Brazil

Post by FHB-PERFORMANCE »

Hi guys,

I am just starting my business here in Brazil, which one of my services is to test cars for magazines using RCP Pro2 to record acceleration, speed and CAN data. For that, I need to be able to read the CAN data from the vehicles.

It would be very easy if Brazil had chosen OBD2 language for CAN output data. But Brazil created its own "addresses", called OBD-BR2. I have some of the OBD-BR2 addresses and Ryan, from Autosportlabs, helped me to write them in the RCP script. However, it did not work :(

Now, what I am doing is reading the data that came out from the CAN logger. At least I could read a lot of data from a Suzuki Grand Vitara 2013. But, I don´t have any idea on how to convert these numbers into LUA language and start reading RPM and Pedal Position, at least. I have done this before using other softwares, so I have some idea that I need to check difference that could indicate RPM or Pedal Position "shape". The problem is that I am very fresh and new on RCP and LUA scripting and for this reason I am feeling quite lost on how to create a script file based on the data that I recorded.

Would someone be able to help me with that? The data read is attached.

Thank you guys for your support!
Attachments
Can-Logger-Info-500k.txt
Can-Logger-INFO-500k
(9.99 KiB) Downloaded 92 times

brentp
Site Admin
Posts: 6274
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi,

Are you doing a type of OBDII 'request / reply' in your Lua script, and this data is the ECU's reply to the requests?

or, is this a capture of data that is streaming automatically from the ECU?

To support a custom OBDII style protocol you could re-create the request / reply behavior in Lua scripting, and turn off the built-in OBDII feature in the firmware. With virtual channels you would be able to get the same effect as the built-in OBDII.

This will require some custom Lua scripting work to code in the behavior. It will be some work, but completely do-able.

Lua scripting reference: https://wiki.autosportlabs.com/RaceCapt ... _Scripting

General information about how standard OBDII works: https://en.wikipedia.org/wiki/OBD-II_PIDs

Hope this helps!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

FHB-PERFORMANCE
Posts: 24
Joined: Sun Mar 20, 2016 7:13 am
Location: Melbourne-Australia / Sao Paulo-Brazil

Post by FHB-PERFORMANCE »

Hi Brent,

Actually, this file is the streaming from the OBD using the "CAN Bus Logger" script:
https://wiki.autosportlabs.com/CAN_Bus_logger

I do have the OBD-BR2 addresses as file attached. I shared it with Ryan (see below)and he sent me a script to read it, but it did not worked.

From Ryan´s email:
"Here is what the line of code would look like for that:

tempId = addChannel("EngineTemp", 1, 0, -40, 210, 'C')
CAN_map = {
[62469] = function(data) map_chan(tempId, data, 0, 1, 1, -40) end
}

The function map_chan takes the channel id, CAN data, offset, length, multiplier and adder. You can see in the example the CAN_map hash has the CAN id of 62469 and passes the tempId, CAN data, offset, multiplier and adder to map_chan. "


So, my question, or difficulty, is on how to use all this information to create a script that I could read the OBD-BR2 data. I have read several times the page suggested (https://wiki.autosportlabs.com/RaceCapt ... _Scripting) but my limited brain is not able to create the script that I need from that as well.

Could you help me with that?

Thank you again for your support and great product!

Kind regards,
Attachments
OBD-BR2.png
OBD-BR2.png (65.76 KiB) Viewed 1106 times
Felipe

brentp
Site Admin
Posts: 6274
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi,

Your best bet is to find someone local with some programming skills, like a university student that can help you write the script, once you understand the format of the streaming data. We can support you with RaceCapture specific questions and ensure it is operating as advertised (fixing bugs).

Our main guide on reverse-engineering CAN data and mapping virtual channels:
https://wiki.autosportlabs.com/CAN_Bus_Integration

You can model your mapping script on one of the existing integrations.
https://wiki.autosportlabs.com/BMW_E46_CAN

Good luck, and keep us posted on progress!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply