From 5d0f656e3d609a4004093c1856309f776740d610 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Fri, 30 Sep 2016 14:16:53 -0500 Subject: [PATCH] Initial Upload --- const.py | 8 ++++++++ crc.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 const.py create mode 100755 crc.py diff --git a/const.py b/const.py new file mode 100644 index 0000000..8079392 --- /dev/null +++ b/const.py @@ -0,0 +1,8 @@ +BS_VOICE_SYNC = '\x75\x5F\xD7\xDF\x75\xF7' +BS_DATA_SYNC = '\xDF\xF5\x7D\x75\xDF\x5D' + +''' +EMB: CC(4b), PI(1b), LCSS(2b), EMB Parity(9b - QR 16,7,5) +Slot Type: CC(4b), DataType(4), Slot Type Parity(12b - ) + +''' \ No newline at end of file diff --git a/crc.py b/crc.py new file mode 100755 index 0000000..18e0d05 --- /dev/null +++ b/crc.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# +# This work is licensed under the Creative Attribution-NonCommercial-ShareAlike +# 3.0 Unported License.To view a copy of this license, visit +# http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to +# Creative Commons, 444 Castro Street, Suite 900, Mountain View, +# California, 94041, USA. + +from __future__ import print_function +from bitarray import bitarray + +# Does anybody read this stuff? There's a PEP somewhere that says I should do this. +__author__ = 'Cortney T. Buffington, N0MJS' +__copyright__ = 'Copyright (c) 2016 Cortney T. Buffington, N0MJS and the K0USY Group' +__credits__ = 'Jonathan Naylor, G4KLX' +__license__ = 'Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported' +__maintainer__ = 'Cort Buffington, N0MJS' +__email__ = 'n0mjs@me.com' + + +def csum5(_data): + _data = bytearray(_data) + accum = 0 + assert len(_data) == 9, 'csum5 expected 9 bytes of data and got something else' + for i in xrange(9): + accum += _data[i] + accum = chr(accum % 31) + csum = bitarray() + csum.frombytes(accum) + del csum[0:3] + return csum + + + + +if __name__ == '__main__': + from binascii import b2a_hex as h + + message = '\x00\x10\x20\x00\x0c\x30\x2f\x9b\xe5' + + result = csum5(message) + print(result, type(result)) \ No newline at end of file