CAN Bus logger: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
The following script will output all CAN bus messages to the RaceCapture/Pro logfile.  
The following script will output all CAN bus messages received on CAN channel 1 to the RaceCapture/Pro log window.


After writing the script, you can observe the output in the log monitor window in the RaceCapture app.
After writing the script, you can observe the output in the log monitor window in the RaceCapture app.
Line 8: Line 8:




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


  --onTick() will be called at 10Hz.
setTickRate(30) --onTick() will be called at 30Hz.
--may need to raise if CAN messages are being missed.
 
setTickRate(10)
--this function drains all pending CAN messages
--and outputs messages to the log
--500K baud. set your baud rate here.
function outputCAN()
initCAN(0, 500000)
repeat  
id, ext, data = rxCAN(0, 100)
--this function drains all pending CAN messages
if id ~= nil then
--and outputs messages to the log
print(id ..', ')
function outputCAN()
for i = 1,#data do
repeat  
print(data[i] ..', ')
id, ext, data = rxCAN(0, 100)
end
if id ~= nil then
println('')
print(id ..': ')
end
for i = 1,#data do
until id == nil
print(data[i] ..' ')
end
end
println('')
end
until id == nil
end
   
   
function onTick()
function onTick()
outputCAN()
outputCAN()
end
end
</pre>

Revision as of 17:56, 28 February 2015

The following script will output all CAN bus messages received on CAN channel 1 to the RaceCapture/Pro log window.

After writing the script, you can observe the output in the log monitor window in the RaceCapture app.

However, to gather large amounts of data, we recommend connecting directly to RaceCapture/Pro's serial console using a terminal program like Hyperterminal, RealTerm, minicom or similar.

  • You can view the log by issuing the command 'viewLog' at the serial console.


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

setTickRate(30)  --onTick() will be called at 30Hz.

--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