From 0fbe579dfe7a7f51eb3aeb44570e36b318252a88 Mon Sep 17 00:00:00 2001 From: nzkarit Date: Fri, 8 Sep 2017 21:33:46 +1200 Subject: [PATCH] Nothing appears to use these parity functions --- parity.py | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 parity.py diff --git a/parity.py b/parity.py deleted file mode 100644 index b7d1112..0000000 --- a/parity.py +++ /dev/null @@ -1,49 +0,0 @@ -''' - Copyright 2015 Wolfgang Nagele - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -''' -def bin2dec(buf): - if 0 == len(buf): # Crap input - return -1 - return int(buf, 2) - -# Ported from: http://www.radarspotters.eu/forum/index.php?topic=5617.msg41293#msg41293 -def get_parity(msg, extended): - msg_length = len(msg) - payload = msg[:msg_length - 24] - parity = msg[msg_length - 24:] - - data = bin2dec(payload[0:32]) - if extended: - data1 = bin2dec(payload[32:64]) - data2 = bin2dec(payload[64:]) << 8 - - hex_id = bin2dec(parity) << 8 - - for i in range(0, len(payload)): - if ((data & 0x80000000) != 0): - data ^= 0xFFFA0480 - data <<= 1 - - if extended: - if ((data1 & 0x80000000) != 0): - data |= 1 - data1 <<= 1 - - if ((data2 & 0x80000000) != 0): - data1 = data1 | 1 - data2 <<= 1 - - return data - #return (data ^ hex_id) >> 8