Initial Upload

This commit is contained in:
Cort Buffington 2016-09-30 14:16:53 -05:00
parent 86c434c00c
commit 5d0f656e3d
2 changed files with 50 additions and 0 deletions

8
const.py Normal file
View File

@ -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 - )
'''

42
crc.py Executable file
View File

@ -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))