From d781355c05c5265943f0f593b46c1c0303558214 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 8 Jan 2022 14:27:30 +0000 Subject: [PATCH] switch back to 16 bit crc --- bridge_master.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bridge_master.py b/bridge_master.py index 74e3033..9330742 100644 --- a/bridge_master.py +++ b/bridge_master.py @@ -39,7 +39,7 @@ import importlib.util import re import copy from setproctitle import setproctitle -from crccheck.crc import Crc32 +from crccheck.crc import Crc16 # Twisted is pretty important, so I keep it separate from twisted.internet.protocol import Factory, Protocol @@ -1464,7 +1464,7 @@ class routerOBP(OPENBRIDGE): pkt_time = time() dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(_data[4:53]) + _pkt_crc = Crc16.calc(_data[4:53]) # Match UNIT data, SMS/GPS, and send it to the dst_id if it is in SUB_MAP if _call_type == 'unit' and (_dtype_vseq == 6 or _dtype_vseq == 7 or _dtype_vseq == 8 or ((_stream_id not in self.STATUS) and _dtype_vseq == 3)): @@ -1711,9 +1711,9 @@ class routerOBP(OPENBRIDGE): if _seq and _seq == self.STATUS[_stream_id]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if self.STATUS[_stream_id]['packets'] > 1 and _pkt_crc in self.STATUS[_stream_id]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s: SEQ:%s packets: %s %s ",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id),_seq, self.STATUS[_stream_id]['packets'],self.STATUS[_stream_id]['crcs']) return #Inbound out-of-order packets if _seq and self.STATUS[_stream_id]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_stream_id]['lastSeq']): @@ -2059,7 +2059,7 @@ class routerHBP(HBSYSTEM): dmrpkt = _data[20:53] _bits = _data[15] - _pkt_crc = Crc32.calc(dmrpkt) + _pkt_crc = Crc16.calc(dmrpkt) _nine = bytes_3(9) @@ -2430,9 +2430,9 @@ class routerHBP(HBSYSTEM): if _seq and _seq == self.STATUS[_slot]['lastSeq']: logger.warning("(%s) *PacketControl* Duplicate sequence number %s, disgarding. Stream ID:, %s TGID: %s",self._system,_seq,int_id(_stream_id),int_id(_dst_id)) return - #Duplicate DMR payload to previuos packet (by Crc32) + #Duplicate DMR payload to previuos packet (by Crc16) if _pkt_crc in self.STATUS[_slot]['crcs']: - logger.warning("(%s) *PacketControl* DMR packet payload with Crc32: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) + logger.warning("(%s) *PacketControl* DMR packet payload with Crc16: %s seen before in this stream, disgarding. Stream ID:, %s TGID: %s",self._system,_pkt_crc,int_id(_stream_id),int_id(_dst_id)) return #Inbound out-of-order packets if _seq and self.STATUS[_slot]['lastSeq'] and (_seq != 1) and (_seq < self.STATUS[_slot]['lastSeq']):