From bdd255a940a786314ebd151cd650b64fde679b3c Mon Sep 17 00:00:00 2001 From: Horst Beham Date: Thu, 23 Sep 2021 15:24:21 +0200 Subject: [PATCH] Panasonic: fixed byte-order detection for symbol rate and satellite orbital position --- source/ChanSort.Loader.Panasonic/DbChannel.cs | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/source/ChanSort.Loader.Panasonic/DbChannel.cs b/source/ChanSort.Loader.Panasonic/DbChannel.cs index 9f0b329..f1b6c9e 100644 --- a/source/ChanSort.Loader.Panasonic/DbChannel.cs +++ b/source/ChanSort.Loader.Panasonic/DbChannel.cs @@ -98,23 +98,33 @@ namespace ChanSort.Loader.Panasonic this.FreqInMhz = freq/10; // ReSharper restore PossibleLossOfFraction - if (deliveryLength == 17) // files of this version also include an additional "cicam_identifier" column + if (deliveryLength >= 12) { - // 50 94 14 01 90 99 21 00 22 31 92 01 00 00 00 00 00 - this.SymbolRate = (delivery[6] >> 4) * 10000 + (delivery[6] & 0x0F) * 1000 + - (delivery[5] >> 4) * 100 + (delivery[5] & 0x0F) * 10; - this.SatPosition = ((decimal)((delivery[11] >> 4) * 1000 + (delivery[11] & 0x0F) * 100 + - (delivery[10] >> 4) * 10 + (delivery[10] & 0x0F)) / 10).ToString("n1"); // 92 01 => 19.2 - this.Satellite = this.SatPosition; - } - else if (deliveryLength == 15) - { - // 01 14 92 99 00 21 99 90 02 31 01 92 00 00 00 - this.SymbolRate = (delivery[5] >> 4) * 10000 + (delivery[5] & 0x0F) * 1000 + - (delivery[6] >> 4) * 100 + (delivery[6] & 0x0F) * 10; - this.SatPosition = ((decimal)((delivery[10] >> 4) * 1000 + (delivery[10] & 0x0F) * 100 + (delivery[11] >> 4) * 10 + - (delivery[11] & 0x0F)) / 10).ToString("n1"); // 01 92 => 19.2 - this.Satellite = this.SatPosition; + // byte 5 and 6 contain hex-encoded decimal digits for symbol rate divided by 10. bytes 10 and 11 are the sat orbital position + // however there are some files that swap the bytes with no clear indication what format is used by the TV. + // we use a heuristic approach whether byte 0 or byte 3 is 0x01 + + if (delivery[3] == 0x01) + { + // 50 94 14 01 90 99 21 00 22 31 92 01 00 00 00 00 00 + // 04 54 10 01 10 50 27 00 04 09 30 01 00 00 00 + + this.SymbolRate = (delivery[6] >> 4) * 10000 + (delivery[6] & 0x0F) * 1000 + + (delivery[5] >> 4) * 100 + (delivery[5] & 0x0F) * 10; + this.SatPosition = ((decimal)((delivery[11] >> 4) * 1000 + (delivery[11] & 0x0F) * 100 + // 99 21 => 21990, 50 27 => 27500 + (delivery[10] >> 4) * 10 + (delivery[10] & 0x0F)) / 10).ToString("n1"); // 92 01 => 19.2 + this.Satellite = this.SatPosition; + } + else + { + // 01 14 92 99 00 21 99 90 02 31 01 92 00 00 00 + + this.SymbolRate = (delivery[5] >> 4) * 10000 + (delivery[5] & 0x0F) * 1000 + // 21 99 => 21990 + (delivery[6] >> 4) * 100 + (delivery[6] & 0x0F) * 10; + this.SatPosition = ((decimal)((delivery[10] >> 4) * 1000 + (delivery[10] & 0x0F) * 100 + (delivery[11] >> 4) * 10 + + (delivery[11] & 0x0F)) / 10).ToString("n1"); // 01 92 => 19.2 + this.Satellite = this.SatPosition; + } } else {