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?
Getting CAN mapping value in lua script
-
- Posts: 27
- Joined: Thu Apr 09, 2015 8:18 pm
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?
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?
-
- Posts: 27
- Joined: Thu Apr 09, 2015 8:18 pm
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
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