Skip to content

Instantly share code, notes, and snippets.

Avatar

Brent Picasso brentpicasso

View GitHub Profile
@brentpicasso
brentpicasso / manual_OBDII.lua
Last active Apr 19, 2018
Manual OBDII query
View manual_OBDII.lua
--Implements a simple OBDII engine in lua scripting, with a configurable delay between PIDs.
-- IMPORTANT: Ensure built-in OBDII is turned off in Setup
--
--500K baud. set your baud rate here.
initCAN(0, 500000)
--standard 11 bit PID request 0x7DF
--extended 29 bit PID request 0x18DB33F1
--standard 11 bit PID response 0x7E8
--extended 29 bit PID response 0x18DAF110
@brentpicasso
brentpicasso / RT_serial_integration.lua
Last active Apr 5, 2018
RaceTechnology DL1 serial integration
View RT_serial_integration.lua
-----------------------------------------------------------------
--Race Technology Serial Data stream interface for PodiumConnect
--Customize your analog and rpm channels in setup()
--GPS position, altitude, speed, and accelerometer channels
--are built-in
--https://www.race-technology.com/wiki/index.php/General/SerialDataFormat
-----------------------------------------------------------------
--set to true for metric speed and altitude units
metric = false
@brentpicasso
brentpicasso / SmartyCAM_GPS_mapping.lua
Last active Jul 26, 2018
SmartyCAM GPS CAN mapping research
View SmartyCAM_GPS_mapping.lua
--SmartyCAM GPS channels research
--Latitude / Longitude are confirmed
--GPS Satellite and GPS DOP (dilution of precision) are somewhat confident
--Need GPS lock status
--Need UTC / Timestamp
latId = addChannel('SC_GPSLat', 10, 6, -180, 180)
lonId = addChannel('SC_GPSLon', 10, 6, -180, 180)
gsat1Id = addChannel('SC_GPSSats', 10, 0, 0, 20)
gpsdopId = addChannel('SC_GPSDOP', 10, 0, 0, 10)
@brentpicasso
brentpicasso / RaceCapture_GPS_IMU_CAN_broadcast.lua
Created Nov 15, 2017
Broadcast GPS and IMU data over CAN bus
View RaceCapture_GPS_IMU_CAN_broadcast.lua
--This script broadcasts current GPS and IMU channels over CAN
setTickRate(20)
function sendCAN(can, id, data)
local res = txCAN(can, id, 0, data,100)
if res == 0 then println('send CAN res ' ..res) end
end
function split32(val)
return bit.band(val, 0xFF), bit.band(bit.rshift(val,8), 0xFF), bit.band(bit.rshift(val,16),0xFF),bit.band(bit.rshift(val,24),0xFF)
@brentpicasso
brentpicasso / lap_simulator.lua
Created Oct 6, 2017
Lap simulator script. generates laps based on elapsed distance - useful in a non-circuit environment
View lap_simulator.lua
--Lap simulator script
--Ensure GPS Distance channel is disabled
--Ensure Race Timing is disabled
--Requires a GPS lock for proper operation
--sets the length of the lap desired, in miles.
lapLength = 1
setTickRate(10)
@brentpicasso
brentpicasso / 29_bit_obdii.lua
Created Jun 30, 2017
29 bit OBDII simulator
View 29_bit_obdii.lua
--500K baud. set your baud rate here.
initCAN(0, 500000)
--standard 11 bit PID request 0x7DF
--extended 29 bit PID request 0x18DB33F1
--standard 11 bit PID response 0x7E8
--extended 29 bit PID response 0x18DAF110
standard = false
--this function drains all pending CAN messages
View shiftx2_obdii_stepped_shift_light.lua
shiftx_can = 1
shiftx_id = 0xE3700
function shiftx_tx(offset, data)
txCAN(shiftx_can, shiftx_id + offset, 1, data)
sleep(10)
end
function splitWord(value)
return bit.band(value, 0xFF), bit.rshift(bit.band(value, 0xFF00),8)
end
@brentpicasso
brentpicasso / OBDII_PID_query.lua
Created May 26, 2017
OBDII PID simulator in Lua, supports 29 bit mode and 11 bit mode
View OBDII_PID_query.lua
--500K baud. set your baud rate here.
initCAN(0, 500000)
--standard 11 bit PID request 0x7DF
--extended 29 bit PID request 0x18DB33F1
--standard 11 bit PID response 0x7E8
--extended 29 bit PID response 0x18DAF110
standard = false
--this function drains all pending CAN messages
@brentpicasso
brentpicasso / shiftx2_color_sweep.lua
Last active Jun 22, 2017
Cycles ShiftX2 through all colors
View shiftx2_color_sweep.lua
sxCan = 0
sxId=0
tickRate=30
sxBright=0
r = 0
g = 0
b = 0
step = 10
View shiftx2_random_colors.lua
sxCan = 0
sxId=0
tickRate=30
sxBright=0
function rndc()
return math.random(0,255)
end
function sxOnUpdate()
You can’t perform that action at this time.