CAN bus recorded on the server into ASAM MDF4: can-recorder (Rust, can-recorder/) reads every interface's SocketCAN frames with the kernel's timestamp and writes a finished .mf4 every 5 min (data/can_rec/<UTC start>.mf4, .part then renamed: a power cut loses at most the last segment), its own minimal MDF 4.10 writer in the CANedge CAN_DataFrame layout (mdf4-rs's lacks the bus-event flags and components: asammdf couldn't DBC-decode it) — checked in asammdf 8.8.35 against candump, every frame, < 0.002 ms, DBC decoding works; lib/maptool/can_recorder.rb starts and stops it, GET/POST/DELETE /api/can/recording, the files by GET /api/can/recordings/<name>; /trace.html's 'Recording on the server (MF4)'; built in its own Dockerfile stage (rust:1.100-slim-trixie)
This commit is contained in:
1 parent
712c6bf7ad
commit
60d7c825fc
13 files changed
+980
No files matched your search
@@ -1,5 +1,6 @@
|
||||
require_relative "test_helper"
|
||||
require "maptool/can"
|
||||
require "maptool/can_recorder"
|
||||
require "timeout"
|
||||
|
||||
class CanTest < Minitest::Test
|
||||
@@ -101,4 +102,21 @@ class CanTest < Minitest::Test
|
||||
reader&.kill
|
||||
sender&.close
|
||||
end
|
||||
|
||||
def test_the_recorder_runs_its_binary_until_stopped
|
||||
Dir.mktmpdir do |dir|
|
||||
binary = File.join(dir, "fake-recorder")
|
||||
File.write(binary, "#!/bin/sh\necho \"$@\" > \"$3/args\"\ntrap 'exit 0' TERM\nwhile :; do sleep 0.1; done\n")
|
||||
File.chmod(0o755, binary)
|
||||
recorder = Maptool::Can::Recorder.new(File.join(dir, "rec"), %w[can0 vcan0], binary: binary, segment: 60)
|
||||
recorder.start
|
||||
assert recorder.running?
|
||||
sleep 0.05 until File.exist?(File.join(dir, "rec", "args"))
|
||||
recorder.stop
|
||||
refute recorder.running?
|
||||
assert_nil recorder.error
|
||||
assert_equal "--segment 60 #{dir}/rec can0 vcan0\n", File.read(File.join(dir, "rec", "args"))
|
||||
assert_raises(Errno::ENOENT) { Maptool::Can::Recorder.new(dir, [], binary: "/nonexistent").start }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user