From 6ca62453eef34613cb18e4003e74136bb08ad93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 28 Aug 2021 13:03:10 +0200 Subject: [PATCH] sdr/decode: improve decoding thanks to aaronsp777 --- sdr/decode.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdr/decode.rb b/sdr/decode.rb index 09723f7..0ea54eb 100755 --- a/sdr/decode.rb +++ b/sdr/decode.rb @@ -137,8 +137,10 @@ puts "# values: #{values.size}" unless values.empty? then puts "values: " values.each do |value| - data_bits = (value & 0x07) - system_code = ((value & 0x7fffff) >> 3) - puts "- value: #{value} (0x#{value.to_s(16).rjust(6,'0')}), system code: #{system_code} (0x#{system_code.to_s(16)}), databits: #{data_bits} (0x#{data_bits.to_s(16)})" + button = value & 7 + code = (value >> 3) & 65535 + facility = (value >> 19) & 15 + printf("- value: 0X%06x, code: %05d, facility: %d, button: %d\n", value, code, facility, button) + end end end