diff --git a/parse_vlc_dump.rb b/parse_vlc_dump.rb new file mode 100755 index 0000000..5ad056b --- /dev/null +++ b/parse_vlc_dump.rb @@ -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