#!/usr/bin/env python3
#
# Software License Agreement (MIT License)
# Author: Duke Fong <d@d-l.io>

import cgi, sys, os, json, time, filelock, shutil
from datetime import datetime
from hashlib import sha1

# pip3 install pythoncrc
from PyCRC.CRC16 import CRC16

def modbus_crc(frame):
    return CRC16(modbus_flag=True).calculate(frame)

with open('bb1_v1.0-1-g663f5b3.bin', mode='rb') as file:
    bin_dat = file.read()

crc_val = modbus_crc(bin_dat)

print(f'crc_val {crc_val:04x}, len: {len(bin_dat)}')


