Page 1 of 1
Getting CAN mapping value in lua script
Posted: Sun Jul 02, 2017 5:22 am
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?
Posted: Tue Jul 04, 2017 2:09 am
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?
Posted: Tue Jul 04, 2017 4:03 am
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.
Posted: Wed Jul 05, 2017 8:20 pm
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?
Posted: Wed Jul 05, 2017 9:56 pm
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.
Posted: Wed Jul 05, 2017 10:26 pm
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