add script to parse VLC atmolight fnordlight output

This commit is contained in:
King Kévin 2015-07-14 15:39:02 +02:00
parent fff9e17f1b
commit ba848539f1
1 changed files with 21 additions and 0 deletions

21
parse_vlc_dump.rb Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# encoding: utf-8
# ruby: 1.9
raise "provide dump file as argument" unless ARGV.size==1
raise "#{ARGV[0]} is not a file" unless File.file? ARGV[0]
dump = IO.read(ARGV[0]) # read data
dump.gsub!(/[^[[:xdigit:]]]/,"") # remove non hex (e.g. newline)
dump.gsub!(/(1b){15,}00/,"sync\n") # replace sync
dump.gsub!(/([[:xdigit:]]{30})/,"\\1\n") # format lines
dump.each_line do |line|
line.chomp!
if (line[2,2]=="01") then # only look for set coloe lines
channel = line[0,2].to_i(16)
puts "color for LED #{channel.to_s.rjust(2,'0')}: #{line[8,6]}"
else
puts line
end
end