Jump to: navigation, search

CAN Bus logger

Revision as of 17:52, 8 January 2015 by Brentp (Talk | contribs) (Created page with "The following script will output all CAN bus messages to the RaceCapture/Pro logfile. After writing the script, you can see the output in the log monitor window, or you can con...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The following script will output all CAN bus messages to the RaceCapture/Pro logfile.

After writing the script, you can see the output in the log monitor window, or you can connect to the serial console directly using a terminal program like Hyperterminal, RealTerm, minicom or similar.


--onTick() will be called at 10Hz.
--may need to raise if CAN messages are being missed.
setTickRate(10)

--500K baud. set your baud rate here.
initCAN(0, 500000) 

--this function drains all pending CAN messages
--and outputs messages to the log
function outputCAN()
	repeat 
		id, ext, data = rxCAN(0, 100)
		if id ~= nil then
			print(id ..': ')
			for i = 1,#data do
				print(data[i] ..' ')
			end
			println()
		end
	until id == nil
end

function onTick()
	outputCAN()
end