Getting CAN mapping value in lua script

Discussions on CAN mapping for ECUs, sensors, PDMs, and more.
Post Reply
rwdsubi
Posts: 3
Joined: Sun Jul 02, 2017 5:16 am

Getting CAN mapping value in lua script

Post by rwdsubi »

I have most of my my channels mapped via the CAN Mapping feature with my Racecapture/Pro Mk2. I am trying to get some of those values within my scripting to act on. When I try to use getChannel(), I get a "Virtual Channel not found" error. I am using the name setup in the CAN mapping screen. I realize the documentation says that its to get channels added with the addChannel() function but I can't find any other way to get the values in script.

Is there anyway to get the values of channels defined in the CAN Mapping feature within the Lua script?

Mustangkev
Posts: 27
Joined: Thu Apr 09, 2015 8:18 pm

Post by Mustangkev »

I'm having the same issue too. I have the E46 channels mapped and I can't get the math channels to work I. Lua for any channel that uses a can mapped parameter.

Have you been able to make this work yet?

rwdsubi
Posts: 3
Joined: Sun Jul 02, 2017 5:16 am

Post by rwdsubi »

i havent. if i cant get it working, im just going to revert to parsing the CAN messages in lua script like i did before the can mapping was added.

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

Post by brentp »

Hi,

Currently there is not a function to get the current value of a direct CAN mapping channel. I can see it as something that would be useful. Out of curiosity, are you needing the value so you can perform some additional computations, or is it because the built-in formula editor isn't flexible enough to extract the correct value?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Mustangkev
Posts: 27
Joined: Thu Apr 09, 2015 8:18 pm

Post by Mustangkev »

I was using it for math channels. I.e using rpm and speed to calculate gear.
I thought the can mapping function would clear up space in the Lua script to be able to have more math channels.

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

Post by brentp »

Got it, thanks.

Indeed, that is the primary intention, to free up space.

So right now it's pretty convenient to get the current OBDII channel value in Lua by requesting it by PID ID, which is a unique ID for each OBDII channel.

We'll need to think how to do it with CAN channels. There's no convenient unique ID, since you can extract multiple values from the same CAN message.

Some ideas:

* We can do it based on CAN mapping index, but that's pretty fragile and will break the script if the ordering of the CAN mapping changes.
* We can key it off of the combination of CAN ID / offset / length since those are typically unique, but that would be a bit cumbersome.
* We can query based on the actual channel name, which would make it work for any channel, but that would be a pretty big addition to the firmware.

Tracking issue here for implementation: https://github.com/autosportlabs/RaceCa ... issues/939
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply