code: def __create_checksum(self, p):
          
          l = len(p)
          checksum = 0
          while l > 1:
              checksum += unpack('H', pack('BB', p[0], p[1]))[0]
              p = p[2:]
              if checksum > const.USHRT_MAX:
                  checksum -= const.USHRT_MAX
              l -= 2
          if l:
              checksum = checksum + p[-1]
  
          while checksum > const.USHRT_MAX:
              checksum -= const.USHRT_MAX
  
          checksum = ~checksum
  
          while checksum < 0:
              checksum += const.USHRT_MAX
  
          return pack('H', checksum)
docs: Calculates the checksum of the packet to be sent to the time clock
          Copied from zkemsdk.c