I seem to have disabled all channels

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
zandr
Posts: 3
Joined: Tue Feb 24, 2015 10:22 pm

I seem to have disabled all channels

Post by zandr »

In the course of writing some Lua to map CAN data to virtual channels, I seem to have disabled all data. I don't even see battery voltage in the dashboard now. I'm sure this is something simple that I've done, but I don't see it.

Here's the code:

Code: Select all

&#65279;setTickRate&#40;30&#41;

function c2f &#40;c&#41;
  return &#40;c*1.8&#41;+32
end

function k2m &#40;k&#41;
  return &#40;k*0.62137&#41;
end

initCAN&#40;0,500000&#41;

coolantId = addChannel&#40;"Coolant", 10&#41;
oilId = addChannel&#40;"OilTemp", 10&#41;
throttleId = addChannel&#40;"TPS", 10&#41; 
brakeId = addChannel&#40;"Brake", 10&#41; 
wheelId = addChannel&#40;"Wheel", 10&#41;
wheel1Id = addChannel&#40;"Wheel1", 10&#41;
wheel2Id = addChannel&#40;"Wheel2", 10&#41;
wheel3Id = addChannel&#40;"Wheel3", 10&#41;
wheel4Id = addChannel&#40;"Wheel4", 10&#41;
rpmId = addChannel&#40;"RPM", 10&#41;
clutchId = addChannel&#40;"Clutch", 10&#41;
fuelId = addChannel&#40;"FuelLevel", 10&#41;
steerId = addChannel&#40;"Steering", 10&#41;


CANIds = &#123;
  &#91;339&#93; = function &#40;data&#41;
    vss = &#40;&#40;&#40;data&#91;3&#93;&#41;*256&#41;+&#40;data&#91;2&#93;%16&#41;&#41;/8
    mph = k2m&#40;vss&#41;
    setChannel&#40;wheelId, mph&#41;
  end,    
  &#91;496&#93; = function &#40;data&#41; end,
  &#91;499&#93; = function &#40;data&#41; end,
  &#91;501&#93; = function &#40;data&#41; 
    if data&#91;2&#93; > 127 then
      steer = -1*&#40;&#40;&#40;data&#91;2&#93;-128&#41;*256&#41;+data&#91;1&#93;&#41;
    else
      steer = &#40;data&#91;2&#93;*256&#41;+data&#91;1&#93;
    end
    setChannel&#40;steerId, steer&#41;
  end,
  &#91;790&#93; = function &#40;data&#41;
    rpm = &#40;data&#91;4&#93;*256&#41;+data&#91;3&#93;
    setChannel&#40;rpmId, rpm&#41;
  end,
  &#91;809&#93; = function &#40;data&#41;
    tempC = &#40;data&#91;2&#93; * 0.75&#41; - 48
    tempF = c2f&#40;tempC&#41;
    setChannel&#40;coolantId, tempF&#41;

    throttle = data&#91;6&#93;/256
    setChannel&#40;throttleId, throttle&#41;

    clutch = data&#91;4&#93;
    setChannel&#40;clutchId, clutch&#41;

    brake = data&#91;7&#93;
    setChannel&#40;brakeId, brake&#41;
  end,
  &#91;1349&#93; = function &#40;data&#41;
    tempC = data&#91;5&#93; - 48
    tempF = c2f&#40;tempC&#41;
    setChannel&#40;oilId, tempF&#41;
  end,
  &#91;1552&#93; = function &#40;data&#41; end,
  &#91;1555&#93; = function &#40;data&#41;
    fuel = &#40;data&#91;3&#93;%128&#41;/58
    setChannel&#40;fuelId, fuel&#41;
  end,
  &#91;1557&#93; = function &#40;data&#41; end
&#125;

function onTick&#40;&#41;
  repeat
    id, ext, data = rxCAN&#40;0&#41;
    CANIds&#91;id&#93;&#40;data&#41;
  until id == nil
end

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

Post by brentp »

Thanks -

Basic troubleshooting: I would recommend removing the script to prove basic functionality is restored, then re-incorporate your script gradually until you see something not work.

I'd help more if I had that CAN datastream to work with too. :)
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply